param(); $this->validate($params, [ 'code_module_category_parent_guid|上级类目guid' => 'require', 'code_module_category_name|类目名' => 'require', 'code_module_category_sort|排序' => 'require', ]); LogicCodeModuleCategory::handleAddEditCodeModuleCategory($params, 'add'); $category_create = ModelCodeModuleCategory::create($params, [ 'code_module_category_name', 'code_module_category_parent_guid', 'code_module_category_sort', 'code_module_category_global_mode', 'code_module_category_library_type', 'customer_guid', 'code_module_category_audit', 'code_module_category_ps', 'code_module_category_guid', 'code_module_category_create_user_guid', 'code_module_category_update_user_guid' ]); //公共类目提交则走发送审核消息流程 if ($category_create->code_module_category_library_type == ModelCodeModuleCategory::LIBRARY_COMMON) { CustomerMessageAuditCodeModuleCategory::unaudited($category_create->code_module_category_guid); } Db::commit(); return msg('添加类目成功!'); } catch (\Throwable $th) { Db::rollback(); throw $th; } } /** * 编辑代码类目接口 * * @param Request $request * @return array * @date 2023-07-12 * @author xjh * @since 1.0.0 */ public function editCodeModuleCategory(Request $request): array { Db::startTrans(); BaseModel::setUserGuid(false); try { $params = $request->param(); $this->validate($params, [ 'code_module_category_parent_guid|上级类目guid' => 'require', 'code_module_category_guid|类目' => 'require', 'code_module_category_name|类目名' => 'require', 'code_module_category_sort|排序' => 'require', ]); $model = ModelCodeModuleCategory::where('code_module_category_guid', $params['code_module_category_guid'])->find(); if (!$model) { throwErrorMsg("该代码块类目不存在", 1); } LogicCodeModuleCategory::handleAddEditCodeModuleCategory($params, 'edit'); $model->allowField([ 'code_module_category_name', 'code_module_category_parent_guid', 'code_module_category_sort', 'code_module_category_global_mode', 'code_module_category_library_type', 'customer_guid', 'code_module_category_audit', 'code_module_category_ps', 'code_module_category_update_user_guid' ])->save($params); CommonLogicCodeModuleCategory::hanldCommonInfoFieldsDataSync($params['code_module_category_guid']); //公共类目提交则走发送审核消息流程 if ($params['code_module_category_library_type'] == ModelCodeModuleCategory::LIBRARY_COMMON) { CustomerMessageAuditCodeModuleCategory::unaudited($params['code_module_category_guid']); } Db::commit(); return msg('编辑类目成功!'); } catch (\Throwable $th) { Db::rollback(); throw $th; } } /** * 删除代码类目接口 * * @param Request $request * @return array * @date 2023-07-20 * @author xjh * @since 1.0.0 */ public function deleteCodeModuleCategory(Request $request): array { Db::startTrans(); BaseModel::setUserGuid(false); try { $params = $request->param(); $this->validate($params, ['code_module_category_guid|类目guid' => 'require',]); foreach (explode(',', $params['code_module_category_guid']) as $code_module_category_guid) { LogicCodeModuleCategory::validateDeleteCodeModuleCategory($code_module_category_guid); ModelCodeModuleCategory::find($code_module_category_guid)->delete(); } Db::commit(); return msg('删除代码类目成功!'); } catch (\Throwable $th) { Db::rollback(); throw $th; } } /** * 上传公共类目接口 * * @param Request $request * @return array * @date 2023-07-20 * @author xjh * @since 1.0.0 */ public function uploadCommonCodeModuleCategory(Request $request): array { Db::startTrans(); BaseModel::setUserGuid(false); try { $params = $request->param(); $this->validate($params, [ 'code_module_category_guid|主级类目guid' => 'require', ]); LogicCodeModuleCategory::handleUploadCommonCodeModuleCategory($params['code_module_category_guid']); Db::commit(); return msg('上传公共类目成功!请耐心等待审核...'); } catch (\Throwable $th) { Db::rollback(); throw $th; } } }