mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-27 21:10:24 +08:00
精简判断
This commit is contained in:
parent
6614cdc8d2
commit
3a6d295aa1
@ -48,8 +48,8 @@ Tips: 请用手机注册一个新账号,用户中心 -> 关注订阅,扫码
|
|||||||
|
|
||||||
### 项目组件
|
### 项目组件
|
||||||
|
|
||||||
- 后台框架:[phalcon 3.4.5](https://phalcon.io)
|
- 后台框架:[phalcon 3.4](https://phalcon.io)
|
||||||
- 前端框架:[layui 2.9.10](https://layui.dev)
|
- 前端框架:[layui 2.9.20](https://layui.dev)
|
||||||
- 全文检索:[xunsearch 1.4.17](http://www.xunsearch.com)
|
- 全文检索:[xunsearch 1.4.17](http://www.xunsearch.com)
|
||||||
- 基础依赖:[php7.3](https://php.net), [mysql5.7](https://mysql.com), [redis5.0](https://redis.io)
|
- 基础依赖:[php7.3](https://php.net), [mysql5.7](https://mysql.com), [redis5.0](https://redis.io)
|
||||||
|
|
||||||
|
@ -168,12 +168,12 @@ class Course extends Service
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($post['category_id']) && !empty($post['category_id'])) {
|
if (!empty($post['category_id'])) {
|
||||||
$category = $validator->checkCategory($post['category_id']);
|
$category = $validator->checkCategory($post['category_id']);
|
||||||
$data['category_id'] = $category->id;
|
$data['category_id'] = $category->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($post['teacher_id']) && !empty($post['teacher_id'])) {
|
if (!empty($post['teacher_id'])) {
|
||||||
$teacher = $validator->checkTeacher($post['teacher_id']);
|
$teacher = $validator->checkTeacher($post['teacher_id']);
|
||||||
$data['teacher_id'] = $teacher->id;
|
$data['teacher_id'] = $teacher->id;
|
||||||
}
|
}
|
||||||
|
@ -59,9 +59,8 @@ class Package extends Service
|
|||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
$price = $item->market_price > 0 ? sprintf("¥%0.2f", $item->market_price) : '免费';
|
|
||||||
$result[] = [
|
$result[] = [
|
||||||
'name' => sprintf('%s - %s(¥%0.2f)', $item->id, $item->title, $price),
|
'name' => sprintf('%s - %s(¥%0.2f)', $item->id, $item->title, $item->market_price),
|
||||||
'value' => $item->id,
|
'value' => $item->id,
|
||||||
'selected' => in_array($item->id, $courseIds),
|
'selected' => in_array($item->id, $courseIds),
|
||||||
];
|
];
|
||||||
@ -152,7 +151,7 @@ class Package extends Service
|
|||||||
$package->update($data);
|
$package->update($data);
|
||||||
|
|
||||||
$this->handlePackagedCourses($package->id);
|
$this->handlePackagedCourses($package->id);
|
||||||
$this->updatePackageCourseCount($package->id);
|
$this->recountPackageCourses($package->id);
|
||||||
$this->rebuildPackageCache($package->id);
|
$this->rebuildPackageCache($package->id);
|
||||||
|
|
||||||
return $package;
|
return $package;
|
||||||
@ -217,7 +216,7 @@ class Package extends Service
|
|||||||
'course_id' => $courseId,
|
'course_id' => $courseId,
|
||||||
'package_id' => $package->id,
|
'package_id' => $package->id,
|
||||||
]);
|
]);
|
||||||
$this->updateCoursePackageCount($courseId);
|
$this->recountCoursePackages($courseId);
|
||||||
$this->rebuildCoursePackageCache($courseId);
|
$this->rebuildCoursePackageCache($courseId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,7 +228,7 @@ class Package extends Service
|
|||||||
foreach ($deletedCourseIds as $courseId) {
|
foreach ($deletedCourseIds as $courseId) {
|
||||||
$coursePackage = $coursePackageRepo->findCoursePackage($courseId, $package->id);
|
$coursePackage = $coursePackageRepo->findCoursePackage($courseId, $package->id);
|
||||||
$coursePackage->delete();
|
$coursePackage->delete();
|
||||||
$this->updateCoursePackageCount($courseId);
|
$this->recountCoursePackages($courseId);
|
||||||
$this->rebuildCoursePackageCache($courseId);
|
$this->rebuildCoursePackageCache($courseId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,7 +248,7 @@ class Package extends Service
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function updatePackageCourseCount($packageId)
|
protected function recountPackageCourses($packageId)
|
||||||
{
|
{
|
||||||
$packageRepo = new PackageRepo();
|
$packageRepo = new PackageRepo();
|
||||||
|
|
||||||
@ -262,7 +261,7 @@ class Package extends Service
|
|||||||
$package->update();
|
$package->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function updateCoursePackageCount($courseId)
|
protected function recountCoursePackages($courseId)
|
||||||
{
|
{
|
||||||
$courseRepo = new CourseRepo();
|
$courseRepo = new CourseRepo();
|
||||||
|
|
||||||
@ -293,15 +292,4 @@ class Package extends Service
|
|||||||
$cache->rebuild($courseId);
|
$cache->rebuild($courseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function recountCoursePackages($courseId)
|
|
||||||
{
|
|
||||||
$courseRepo = new CourseRepo();
|
|
||||||
|
|
||||||
$course = $courseRepo->findById($courseId);
|
|
||||||
|
|
||||||
$course->package_count = $courseRepo->countPackages($courseId);
|
|
||||||
|
|
||||||
$course->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ class Article extends Model
|
|||||||
$this->cover = self::getCoverPath($this->cover);
|
$this->cover = self::getCoverPath($this->cover);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($this->tags) || is_object($this->tags)) {
|
if (is_array($this->tags)) {
|
||||||
$this->tags = kg_json_encode($this->tags);
|
$this->tags = kg_json_encode($this->tags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ class Chapter extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($this->attrs) || is_object($this->attrs)) {
|
if (is_array($this->attrs)) {
|
||||||
$this->attrs = kg_json_encode($this->attrs);
|
$this->attrs = kg_json_encode($this->attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ class Chapter extends Model
|
|||||||
|
|
||||||
public function beforeUpdate()
|
public function beforeUpdate()
|
||||||
{
|
{
|
||||||
if (is_array($this->attrs) || is_object($this->attrs)) {
|
if (is_array($this->attrs)) {
|
||||||
$this->attrs = kg_json_encode($this->attrs);
|
$this->attrs = kg_json_encode($this->attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,11 +75,11 @@ class ChapterVod extends Model
|
|||||||
|
|
||||||
public function beforeCreate()
|
public function beforeCreate()
|
||||||
{
|
{
|
||||||
if (is_array($this->file_transcode) || is_object($this->file_transcode)) {
|
if (is_array($this->file_transcode)) {
|
||||||
$this->file_transcode = kg_json_encode($this->file_transcode);
|
$this->file_transcode = kg_json_encode($this->file_transcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($this->file_remote) || is_object($this->file_remote)) {
|
if (is_array($this->file_remote)) {
|
||||||
$this->file_remote = kg_json_encode($this->file_remote);
|
$this->file_remote = kg_json_encode($this->file_remote);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,11 +88,11 @@ class ChapterVod extends Model
|
|||||||
|
|
||||||
public function beforeUpdate()
|
public function beforeUpdate()
|
||||||
{
|
{
|
||||||
if (is_array($this->file_transcode) || is_object($this->file_transcode)) {
|
if (is_array($this->file_transcode)) {
|
||||||
$this->file_transcode = kg_json_encode($this->file_transcode);
|
$this->file_transcode = kg_json_encode($this->file_transcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($this->file_remote) || is_object($this->file_remote)) {
|
if (is_array($this->file_remote)) {
|
||||||
$this->file_remote = kg_json_encode($this->file_remote);
|
$this->file_remote = kg_json_encode($this->file_remote);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ class Course extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($this->attrs) || is_object($this->attrs)) {
|
if (is_array($this->attrs)) {
|
||||||
$this->attrs = kg_json_encode($this->attrs);
|
$this->attrs = kg_json_encode($this->attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,7 +338,7 @@ class Course extends Model
|
|||||||
$sync->addItem($this->id);
|
$sync->addItem($this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($this->attrs) || is_object($this->attrs)) {
|
if (is_array($this->attrs)) {
|
||||||
$this->attrs = kg_json_encode($this->attrs);
|
$this->attrs = kg_json_encode($this->attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,17 +355,13 @@ class Course extends Model
|
|||||||
$this->cover = self::getCoverPath($this->cover);
|
$this->cover = self::getCoverPath($this->cover);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($this->tags) || is_object($this->tags)) {
|
if (is_array($this->tags)) {
|
||||||
$this->tags = kg_json_encode($this->tags);
|
$this->tags = kg_json_encode($this->tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->summary)) {
|
if (empty($this->summary)) {
|
||||||
$this->summary = kg_parse_summary($this->details);
|
$this->summary = kg_parse_summary($this->details);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->origin_price)) {
|
|
||||||
$this->origin_price = 1.5 * $this->market_price;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function afterCreate()
|
public function afterCreate()
|
||||||
|
@ -186,7 +186,7 @@ class Notification extends Model
|
|||||||
|
|
||||||
public function beforeSave()
|
public function beforeSave()
|
||||||
{
|
{
|
||||||
if (is_array($this->event_info) || is_object($this->event_info)) {
|
if (is_array($this->event_info)) {
|
||||||
$this->event_info = kg_json_encode($this->event_info);
|
$this->event_info = kg_json_encode($this->event_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ class Order extends Model
|
|||||||
|
|
||||||
public function beforeSave()
|
public function beforeSave()
|
||||||
{
|
{
|
||||||
if (is_array($this->item_info) || is_object($this->item_info)) {
|
if (is_array($this->item_info)) {
|
||||||
$this->item_info = kg_json_encode($this->item_info);
|
$this->item_info = kg_json_encode($this->item_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ class PointGift extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($this->attrs) || is_object($this->attrs)) {
|
if (is_array($this->attrs)) {
|
||||||
$this->attrs = kg_json_encode($this->attrs);
|
$this->attrs = kg_json_encode($this->attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ class PointGift extends Model
|
|||||||
|
|
||||||
public function beforeUpdate()
|
public function beforeUpdate()
|
||||||
{
|
{
|
||||||
if (is_array($this->attrs) || is_object($this->attrs)) {
|
if (is_array($this->attrs)) {
|
||||||
$this->attrs = kg_json_encode($this->attrs);
|
$this->attrs = kg_json_encode($this->attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ class PointHistory extends Model
|
|||||||
|
|
||||||
public function beforeSave()
|
public function beforeSave()
|
||||||
{
|
{
|
||||||
if (is_array($this->event_info) || is_object($this->event_info)) {
|
if (is_array($this->event_info)) {
|
||||||
$this->event_info = kg_json_encode($this->event_info);
|
$this->event_info = kg_json_encode($this->event_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ class Question extends Model
|
|||||||
$this->cover = self::getCoverPath($this->cover);
|
$this->cover = self::getCoverPath($this->cover);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($this->tags) || is_object($this->tags)) {
|
if (is_array($this->tags)) {
|
||||||
$this->tags = kg_json_encode($this->tags);
|
$this->tags = kg_json_encode($this->tags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,6 +295,9 @@ class Question extends Model
|
|||||||
|
|
||||||
public function afterFetch()
|
public function afterFetch()
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* 问题封面非必要,有则处理,无则略过
|
||||||
|
*/
|
||||||
if (!empty($this->cover) && !Text::startsWith($this->cover, 'http')) {
|
if (!empty($this->cover) && !Text::startsWith($this->cover, 'http')) {
|
||||||
$this->cover = kg_cos_article_cover_url($this->cover);
|
$this->cover = kg_cos_article_cover_url($this->cover);
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ class Role extends Model
|
|||||||
|
|
||||||
public function beforeSave()
|
public function beforeSave()
|
||||||
{
|
{
|
||||||
if (is_array($this->routes) || is_object($this->routes)) {
|
if (is_array($this->routes)) {
|
||||||
$this->routes = kg_json_encode($this->routes);
|
$this->routes = kg_json_encode($this->routes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ class Slide extends Model
|
|||||||
$this->cover = self::getCoverPath($this->cover);
|
$this->cover = self::getCoverPath($this->cover);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($this->target_attrs) || is_object($this->target_attrs)) {
|
if (is_array($this->target_attrs)) {
|
||||||
$this->target_attrs = kg_json_encode($this->target_attrs);
|
$this->target_attrs = kg_json_encode($this->target_attrs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ class Tag extends Model
|
|||||||
$this->icon = self::getIconPath($this->icon);
|
$this->icon = self::getIconPath($this->icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($this->scopes) || is_object($this->scopes)) {
|
if (is_array($this->scopes)) {
|
||||||
$this->scopes = kg_json_encode($this->scopes);
|
$this->scopes = kg_json_encode($this->scopes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ class Task extends Model
|
|||||||
|
|
||||||
public function beforeSave()
|
public function beforeSave()
|
||||||
{
|
{
|
||||||
if (is_array($this->item_info) || is_object($this->item_info)) {
|
if (is_array($this->item_info)) {
|
||||||
$this->item_info = kg_json_encode($this->item_info);
|
$this->item_info = kg_json_encode($this->item_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,22 +95,21 @@ class Vip extends Model
|
|||||||
|
|
||||||
public function beforeCreate()
|
public function beforeCreate()
|
||||||
{
|
{
|
||||||
if (empty($this->cover)) {
|
|
||||||
$this->cover = kg_default_vip_cover_path();
|
|
||||||
} elseif (Text::startsWith($this->cover, 'http')) {
|
|
||||||
$this->cover = self::getCoverPath($this->cover);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->create_time = time();
|
$this->create_time = time();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function beforeUpdate()
|
public function beforeUpdate()
|
||||||
{
|
{
|
||||||
if (Text::startsWith($this->cover, 'http')) {
|
$this->update_time = time();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function beforeSave()
|
||||||
|
{
|
||||||
|
if (empty($this->cover)) {
|
||||||
|
$this->cover = kg_default_vip_cover_path();
|
||||||
|
} elseif (Text::startsWith($this->cover, 'http')) {
|
||||||
$this->cover = self::getCoverPath($this->cover);
|
$this->cover = self::getCoverPath($this->cover);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->update_time = time();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function afterFetch()
|
public function afterFetch()
|
||||||
|
@ -41,7 +41,7 @@ class ArticleDocument extends Injectable
|
|||||||
*/
|
*/
|
||||||
public function formatDocument(ArticleModel $article)
|
public function formatDocument(ArticleModel $article)
|
||||||
{
|
{
|
||||||
if (is_array($article->tags) || is_object($article->tags)) {
|
if (is_array($article->tags)) {
|
||||||
$article->tags = kg_json_encode($article->tags);
|
$article->tags = kg_json_encode($article->tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,11 +41,11 @@ class CourseDocument extends Injectable
|
|||||||
*/
|
*/
|
||||||
public function formatDocument(CourseModel $course)
|
public function formatDocument(CourseModel $course)
|
||||||
{
|
{
|
||||||
if (is_array($course->attrs) || is_object($course->attrs)) {
|
if (is_array($course->attrs)) {
|
||||||
$course->attrs = kg_json_encode($course->attrs);
|
$course->attrs = kg_json_encode($course->attrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($course->tags) || is_object($course->tags)) {
|
if (is_array($course->tags)) {
|
||||||
$course->tags = kg_json_encode($course->tags);
|
$course->tags = kg_json_encode($course->tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class QuestionDocument extends Injectable
|
|||||||
*/
|
*/
|
||||||
public function formatDocument(QuestionModel $question)
|
public function formatDocument(QuestionModel $question)
|
||||||
{
|
{
|
||||||
if (is_array($question->tags) || is_object($question->tags)) {
|
if (is_array($question->tags)) {
|
||||||
$question->tags = kg_json_encode($question->tags);
|
$question->tags = kg_json_encode($question->tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user