fix: 修改作品接口

This commit is contained in:
lwh 2023-05-04 23:36:30 +08:00
parent a2bd1d16ee
commit 9a6fd702a1

View File

@ -27,13 +27,25 @@ class Works extends BaseController
* @author xjh
* @since 1.0.0
*/
public function getWorksList(Request $request): array
public function getWorksList(Request $request)
{
$params = $request->param();
$this->validate($params, [
'works_type_id|作品类型id' => 'require',
'idx|索引值' => 'require',
]);
$work_type = ModelWorksType::field(['works_type_name' => 'name', 'works_type_id'])
->where('works_type_parent_guid', "0")
->order('works_type_order')
->select();
$params['works_type_id'] = null;
foreach ($work_type as $key => $value) {
if ($key == $params['idx']) {
$params['works_type_id'] = $value['works_type_id'];
}
}
$works_type = ModelWorksType::where('works_type_id', $params['works_type_id'])->find();
if (!$works_type) throwErrorMsg('该作品类型不存在!');