1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-29 05:41:37 +08:00

整理categoryId相关

This commit is contained in:
xiaochong0302 2025-02-20 19:20:48 +08:00
parent e22f3b4bdc
commit 5854d86875
9 changed files with 45 additions and 30 deletions

View File

@ -199,9 +199,8 @@ class Article extends Service
$data['published'] = $validator->checkPublishStatus($post['published']);
}
if (isset($post['category_id']) && !empty($post['category_id'])) {
$category = $validator->checkCategory($post['category_id']);
$data['category_id'] = $category->id;
if (isset($post['category_id'])) {
$data['category_id'] = $validator->checkCategoryId($post['category_id']);
}
if (isset($post['xm_tag_ids'])) {

View File

@ -63,12 +63,10 @@ class Help extends Service
$data = [];
$category = $validator->checkCategory($post['category_id']);
$data['title'] = $validator->checkTitle($post['title']);
$data['content'] = $validator->checkContent($post['content']);
$data['priority'] = $validator->checkPriority($post['priority']);
$data['category_id'] = $category->id;
$data['category_id'] = $validator->checkCategoryId($post['category_id']);
$help = new HelpModel();
@ -88,8 +86,7 @@ class Help extends Service
$data = [];
if (isset($post['category_id'])) {
$category = $validator->checkCategory($post['category_id']);
$data['category_id'] = $category->id;
$data['category_id'] = $validator->checkCategoryId($post['category_id']);
}
if (isset($post['title'])) {

View File

@ -186,9 +186,8 @@ class Question extends Service
$data['published'] = $validator->checkPublishStatus($post['published']);
}
if (isset($post['category_id']) && !empty($post['category_id'])) {
$category = $validator->checkCategory($post['category_id']);
$data['category_id'] = $category->id;
if (isset($post['category_id'])) {
$data['category_id'] = $validator->checkCategoryId($post['category_id']);
}
if (isset($post['xm_tag_ids'])) {

View File

@ -34,8 +34,7 @@ trait ArticleDataTrait
$data['content'] = $validator->checkContent($post['content']);
if (isset($post['category_id'])) {
$category = $validator->checkCategory($post['category_id']);
$data['category_id'] = $category->id;
$data['category_id'] = $validator->checkCategoryId($post['category_id']);
}
if (isset($post['source_type'])) {

View File

@ -33,8 +33,7 @@ trait QuestionDataTrait
$data['content'] = $validator->checkContent($post['content']);
if (isset($post['category_id'])) {
$category = $validator->checkCategory($post['category_id']);
$data['category_id'] = $category->id;
$data['category_id'] = $validator->checkCategoryId($post['category_id']);
}
if (isset($post['closed'])) {

View File

@ -66,11 +66,17 @@ class Article extends Validator
}
}
public function checkCategory($id)
public function checkCategoryId($id)
{
$validator = new Category();
$result = 0;
return $validator->checkCategory($id);
if ($id > 0) {
$validator = new Category();
$category = $validator->checkCategory($id);
$result = $category->id;
}
return $result;
}
public function checkTitle($title)

View File

@ -68,24 +68,28 @@ class Course extends Validator
public function checkCategoryId($id)
{
$result = 0;
if ($id > 0) {
$validator = new Category();
$category = $validator->checkCategory($id);
return $category->id;
} else {
return 0;
$result = $category->id;
}
return $result;
}
public function checkTeacherId($id)
{
$result = 0;
if ($id > 0) {
$validator = new User();
$user = $validator->checkTeacher($id);
return $user->id;
} else {
return 0;
$result = $user->id;
}
return $result;
}
public function checkModel($model)

View File

@ -27,11 +27,17 @@ class Help extends Validator
return $help;
}
public function checkCategory($id)
public function checkCategoryId($id)
{
$validator = new Category();
$result = 0;
return $validator->checkCategory($id);
if ($id > 0) {
$validator = new Category();
$category = $validator->checkCategory($id);
$result = $category->id;
}
return $result;
}
public function checkTitle($title)

View File

@ -65,11 +65,17 @@ class Question extends Validator
}
}
public function checkCategory($id)
public function checkCategoryId($id)
{
$validator = new Category();
$result = 0;
return $validator->checkCategory($id);
if ($id > 0) {
$validator = new Category();
$category = $validator->checkCategory($id);
$result = $category->id;
}
return $result;
}
public function checkTitle($title)