fix:作品类型列表接口修改

This commit is contained in:
xjh 2023-04-19 16:33:59 +08:00
parent 6dab590f4c
commit bf4f98acd8

View File

@ -27,14 +27,19 @@ class WorksType extends BaseController
* @author xjh * @author xjh
* @since 1.0.0 * @since 1.0.0
*/ */
public function getWorksTypeList(Request $request): array public function getWorksTypeList(Request $request):array
{ {
$con = Tool::getOptionalQuery( $con = Tool::getOptionalQuery(['works_type_name', 'LIKE']);
['b.works_type_delete_time', 'NULL'], $con[] = ['works_type_parent_guid', '=', "0"];
['a.works_type_name', 'LIKE'] $works_type_guids = self::pageWrapper(ModelWorksType::where($con))
); ->order('works_type_order')
->column('works_type_guid');
$works_type = ModelWorksType::where($con) $works_type = ModelWorksType::whereOr([
[["a.works_type_guid", 'in', $works_type_guids]],
[["a.works_type_ancestors_guid", 'REGEXP', implode('|', $works_type_guids)]],
])
->where([['b.works_type_delete_time', 'NULL', null]])
->field([ ->field([
'a.works_type_id', 'a.works_type_id',
'a.works_type_guid', 'a.works_type_guid',
@ -43,8 +48,7 @@ class WorksType extends BaseController
'a.works_type_parent_guid', 'a.works_type_parent_guid',
'a.works_type_ancestors_guid', 'a.works_type_ancestors_guid',
'b.works_type_name' => "works_type_parent_name", 'b.works_type_name' => "works_type_parent_name",
]) ])->alias('a')
->alias('a')
->leftjoin('works_type b', 'a.works_type_parent_guid = b.works_type_guid') ->leftjoin('works_type b', 'a.works_type_parent_guid = b.works_type_guid')
->order('works_type_order') ->order('works_type_order')
->select() ->select()
@ -62,7 +66,10 @@ class WorksType extends BaseController
]; ];
}); });
return msg("获取作品类型列表成功!", $works_type_tree); return msg(0, "获取作品类型列表成功!", [
'data' => $works_type_tree,
'count' => ModelWorksType::where('works_type_parent_guid', '0')->count()
]);
} }
/** /**
@ -179,7 +186,7 @@ class WorksType extends BaseController
* @author xjh * @author xjh
* @since 1.0.0 * @since 1.0.0
*/ */
public function exportExcel(Request $request):void public function exportExcel(Request $request): void
{ {
$params = $request->param(); $params = $request->param();
$con = []; $con = [];