fix:代码块类目模块后台逻辑优化
This commit is contained in:
parent
a2f352ac6f
commit
55c74b0f6f
@ -16,6 +16,7 @@ use think\facade\Db;
|
|||||||
use think\facade\Env;
|
use think\facade\Env;
|
||||||
use app\admin\logic\Code\CodeModuleCategory as LogicCodeModuleCategory;
|
use app\admin\logic\Code\CodeModuleCategory as LogicCodeModuleCategory;
|
||||||
use app\admin\logic\Code\CodeModuleCategoryAudit as LogicCodeModuleCategoryAudit;
|
use app\admin\logic\Code\CodeModuleCategoryAudit as LogicCodeModuleCategoryAudit;
|
||||||
|
use app\common\logic\Code\CodeModuleCategory as CommonLogicCodeModuleCategory;
|
||||||
|
|
||||||
class CodeModuleCategory extends BaseController
|
class CodeModuleCategory extends BaseController
|
||||||
{
|
{
|
||||||
@ -106,6 +107,7 @@ class CodeModuleCategory extends BaseController
|
|||||||
'code_module_category_audit',
|
'code_module_category_audit',
|
||||||
'code_module_category_update_user_guid'
|
'code_module_category_update_user_guid'
|
||||||
])->save($params);
|
])->save($params);
|
||||||
|
CommonLogicCodeModuleCategory::hanldCommonInfoFieldsDataSync($params['code_module_category_guid']);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return msg('编辑成功!');
|
return msg('编辑成功!');
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
|
@ -89,6 +89,7 @@ class CodeModuleCategoryAudit
|
|||||||
if ($count == 0) {
|
if ($count == 0) {
|
||||||
$son_category_audits = ModelCodeModuleCategory::scope('auditPass')->where('code_module_category_parent_guid', $module_category_parent_guid)
|
$son_category_audits = ModelCodeModuleCategory::scope('auditPass')->where('code_module_category_parent_guid', $module_category_parent_guid)
|
||||||
->column('code_module_category_audit');
|
->column('code_module_category_audit');
|
||||||
|
//是否全部子类目审核都不通过
|
||||||
$is_all_not_failed = true;
|
$is_all_not_failed = true;
|
||||||
foreach ($son_category_audits as $son_category_audit) {
|
foreach ($son_category_audits as $son_category_audit) {
|
||||||
if ($son_category_audit != ModelCodeModuleCategory::AUDIT_FAILED) {
|
if ($son_category_audit != ModelCodeModuleCategory::AUDIT_FAILED) {
|
||||||
@ -96,17 +97,10 @@ class CodeModuleCategoryAudit
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($is_all_not_failed) {
|
ModelCodeModuleCategory::update([
|
||||||
ModelCodeModuleCategory::update([
|
'code_module_category_guid' => $module_category_parent_guid,
|
||||||
'code_module_category_guid' => $module_category_parent_guid,
|
'code_module_category_audit' => $is_all_not_failed ? ModelCodeModuleCategory::AUDIT_FAILED : ModelCodeModuleCategory::AUDIT_PASS,
|
||||||
'code_module_category_audit' => ModelCodeModuleCategory::AUDIT_FAILED,
|
]);
|
||||||
]);
|
|
||||||
} else {
|
|
||||||
ModelCodeModuleCategory::update([
|
|
||||||
'code_module_category_guid' => $module_category_parent_guid,
|
|
||||||
'code_module_category_audit' => ModelCodeModuleCategory::AUDIT_PASS,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,24 +9,28 @@ use app\common\model\Token as ModelToken;
|
|||||||
class CodeModuleCategory
|
class CodeModuleCategory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 编辑后父子数据共用信息处理
|
* 父子数据共用信息数据同步处理
|
||||||
*
|
*
|
||||||
* @param ModelCodeModuleCategory &$model
|
* @param string $code_module_category_guid 类目guid
|
||||||
* @return void
|
* @return void
|
||||||
* @date 2023-07-07
|
* @date 2023-07-07
|
||||||
* @author xjh
|
* @author xjh
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public static function onAfterUpdateCommonInfoFields(ModelCodeModuleCategory &$model): void
|
public static function hanldCommonInfoFieldsDataSync(string $code_module_category_guid): void
|
||||||
{
|
{
|
||||||
|
$category = ModelCodeModuleCategory::find($code_module_category_guid);
|
||||||
|
if (!$category) {
|
||||||
|
throwErrorMsg('该类目不存在!');
|
||||||
|
}
|
||||||
//为主级类目时才执行
|
//为主级类目时才执行
|
||||||
//该方法目的是保持父子类目的共用信息一致
|
//该方法目的是保持父子类目的共用信息一致
|
||||||
if ($model->code_module_category_parent_guid == ModelCodeModuleCategory::MASTER_DEFAULT) {
|
if ($category->code_module_category_parent_guid == ModelCodeModuleCategory::MASTER_DEFAULT) {
|
||||||
$update_data = [];
|
$update_data = [];
|
||||||
foreach (ModelCodeModuleCategory::COMMON_INFO_FIELDS as $field) {
|
foreach (ModelCodeModuleCategory::COMMON_INFO_FIELDS as $field) {
|
||||||
$update_data[$field] = $model->$field;
|
$update_data[$field] = $category->$field;
|
||||||
}
|
}
|
||||||
ModelCodeModuleCategory::where('code_module_category_parent_guid', $model->code_module_category_guid)->select()->update($update_data);
|
ModelCodeModuleCategory::where('code_module_category_parent_guid', $code_module_category_guid)->select()->update($update_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,15 +107,6 @@ class CodeModuleCategory extends BaseModel
|
|||||||
$model->completeUpdateField();
|
$model->completeUpdateField();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新后
|
|
||||||
*/
|
|
||||||
public static function onAfterUpdate(self $model): void
|
|
||||||
{
|
|
||||||
CommonLogicCodeModuleCategory::onAfterUpdateCommonInfoFields($model);
|
|
||||||
$model->completeUpdateField();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除前
|
* 删除前
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user