fix:代码块、代码块类目模块前台接口优化

This commit is contained in:
xjh 2023-07-01 22:24:11 +08:00
parent aea1dc4e40
commit ee17c4d7eb
4 changed files with 54 additions and 15 deletions

View File

@ -51,6 +51,7 @@ class CodeModule extends BaseController
'code_module_category.code_module_category_guid',
])->leftJoin('code_module_category', 'code_module_category.code_module_category_guid = code_module.code_module_category_guid')
->where('code_module.code_module_category_guid', $code_module_category_guid)
->scope('audit_pass')
->order('code_module.code_module_sort')->select();
$data[] = $code_module_list;
}

View File

@ -23,9 +23,6 @@ class CodeModuleCategory extends BaseController
*/
public function getCodeModuleFirstCategoryList(Request $request)
{
$params = $request->param();
$con[] = ['a.code_module_category_audit', '=', '2'];
$query = ModelCodeModuleCategory::alias('a')->field([
'a.code_module_category_guid' => 'guid',
'a.code_module_category_name' => 'name',
@ -39,11 +36,11 @@ class CodeModuleCategory extends BaseController
->append(['langHit', 'libraryType'])
->hidden(['code_module_category_global_mode', 'code_module_category_library_type'])
->leftjoin('customer c', 'a.customer_guid = c.customer_guid')
->where($con)
->scope('audit_pass')
->where('a.code_module_category_parent_guid', 0)->select();
return msg(0, "获取一级类目列表成功!", [
'count' => $query->count(),
'count' => $query->count(),
'data' => $query,
]);
}
@ -57,7 +54,6 @@ class CodeModuleCategory extends BaseController
$this->validate($params, ['code_module_category_guid|当前类目guid' => 'require']);
$con[] = ['a.code_module_category_audit', '=', '2'];
$query = ModelCodeModuleCategory::alias('a')->field([
'a.code_module_category_guid' => 'guid',
'a.code_module_category_name' => 'name',
@ -71,12 +67,13 @@ class CodeModuleCategory extends BaseController
->append(['langHit', 'libraryType'])
->hidden(['code_module_category_global_mode', 'code_module_category_library_type'])
->leftjoin('customer c', 'a.customer_guid = c.customer_guid')
->where($con)->where('code_module_category_parent_guid', $params['code_module_category_guid'])
->scope('audit_pass')
->where('code_module_category_parent_guid', $params['code_module_category_guid'])
->select();
return msg(0, "获取当前一级类目的二级类目列表成功!", [
'count' => $query->count(),
'count' => $query->count(),
'data' => $query,
]);
}
}
}

View File

@ -61,6 +61,20 @@ class CodeModule extends BaseModel
'code_module_script' => 'script内容',
'code_module_sort' => '排序',
];
// 字典
public static $dictionaryMap = [
'code_module_category_audit' => [
self::AUDIT_UNAUDITED => '未审核',
self::AUDIT_PASS => '审核通过',
self::AUDIT_FAILED => '审核未通过'
],
];
// 审核状态 未审核
const AUDIT_UNAUDITED = 1;
// 审核状态 审核通过
const AUDIT_PASS = 2;
// 审核状态 审核未通过
const AUDIT_FAILED = 3;
/**
* 新增前
@ -89,6 +103,20 @@ class CodeModule extends BaseModel
$model->completeDeleteField();
}
/**
* 查询范围-过审代码块
*
* @param $query
* @return void
* @date 2023-07-01
* @author xjh
* @since 1.0.0
*/
public function scopeAuditPass($query): void
{
$query->where('code_module.code_module_audit', self::AUDIT_PASS);
}
/**
* 导出Excel

View File

@ -162,7 +162,7 @@ class CodeModuleCategory extends BaseModel
*
* @param $query
* @return void
* @date 2023-06-29
* @date 2023-07-01
* @author xjh
* @since 1.0.0
*/
@ -171,9 +171,22 @@ class CodeModuleCategory extends BaseModel
$query->where('code_module_category.code_module_category_parent_guid', '!=', self::MASTER_DEFAULT);
}
/**
* 查询范围-过审代码块类目
*
* @param $query
* @return void
* @date 2023-07-01
* @author xjh
* @since 1.0.0
*/
public function scopeAuditPass($query): void
{
$query->where('code_module_category.code_module_category_audit', self::AUDIT_PASS);
}
/**
* 获取命中模型模式名称
* 获取全局模式名称
*
* @param string $value
* @return array
@ -189,7 +202,7 @@ class CodeModuleCategory extends BaseModel
foreach ($mode_arr as $key => $value) {
$global_mode = ModelDictionary::getDictionaryData('global_mode');
$mode_name_arr[] = ModelDictionary::getDataDictionaryName($global_mode, $value);
$mode_name_arr[] = ModelDictionary::getDataDictionaryName($global_mode, $value);
}
return $mode_name_arr;
}
@ -203,7 +216,7 @@ class CodeModuleCategory extends BaseModel
* @author lwh
* @since 1.0.0
*/
public function getLibraryTypeAttr($value,$data)
public function getLibraryTypeAttr($value, $data)
{
$library = $data['code_module_category_library_type'];
$library_arr = explode(',', $library);
@ -211,8 +224,8 @@ class CodeModuleCategory extends BaseModel
foreach ($library_arr as $key => $value) {
$library_type = ModelDictionary::getDictionaryData('library_type');
$library_name_arr[] = ModelDictionary::getDataDictionaryName($library_type, $value);
$library_name_arr[] = ModelDictionary::getDataDictionaryName($library_type, $value);
}
return $library_name_arr;
}
}
}