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