baseCRUD() ->filterTogglable(false) ->headerToolbar([ $this->createButton('dialog'), ...$this->baseHeaderToolBar() ]) ->columns([ amis()->TableColumn('id', 'ID')->sortable(), amis()->TableColumn('item_id', '设置项ID'), amis()->TableColumn('object_type', '业务对象类型:PLATFORM,AGENT,SHOP,COACH'), amis()->TableColumn('object_id', '业务对象ID'), amis()->TableColumn('value', '设置值'), amis()->TableColumn('created_at', admin_trans('admin.created_at'))->type('datetime')->sortable(), amis()->TableColumn('updated_at', admin_trans('admin.updated_at'))->type('datetime')->sortable(), $this->rowActions('dialog') ]); return $this->baseList($crud); } public function form($isEdit = false) { return $this->baseForm()->body([ amis()->TextControl('item_id', '设置项ID'), amis()->TextControl('object_type', '业务对象类型:PLATFORM,AGENT,SHOP,COACH'), amis()->TextControl('object_id', '业务对象ID'), amis()->TextControl('value', '设置值'), ]); } public function detail() { return $this->baseDetail()->body([ amis()->TextControl('id', 'ID')->static(), amis()->TextControl('item_id', '设置项ID')->static(), amis()->TextControl('object_type', '业务对象类型:PLATFORM,AGENT,SHOP,COACH')->static(), amis()->TextControl('object_id', '业务对象ID')->static(), amis()->TextControl('value', '设置值')->static(), amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(), amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(), ]); } /** * [值]获取设置值列表 * * @description 获取所有设置值列表 * * @param int item_id 设置项ID * @param string object_type 业务对象类型 * @param int object_id 业务对象ID * @param int perPage 每页数量 * * @response { * "data": [ * { * "id": 1, * "item_id": 1, * "object_type": "PLATFORM", * "object_id": 1, * "value": "示例值", * "created_at": "2023-01-01 00:00:00", * "updated_at": "2023-01-01 00:00:00" * } * ] * } */ public function getValueList() { return $this->response()->success( $this->service->list(request()->all()) ); } /** * [值]创建设置值 * * @description 创建新的设置值 * * @param int item_id 设置项ID * @param string object_type 业务对象类型:PLATFORM,AGENT,SHOP,COACH * @param int object_id 业务对象ID * @param string value 设置值 * * @response { * "item_id": 1, * "object_type": "PLATFORM", * "object_id": 1, * "value": "示例值" * } */ public function createValue() { return $this->response()->success( $this->service->store(request()->all()) ); } /** * [值]更新设置值 * * @description 更新指定ID的设置值 * * @param int id 设置值ID * @param int item_id 设置项ID * @param string object_type 业务对象类型:PLATFORM,AGENT,SHOP,COACH * @param int object_id 业务对象ID * @param string value 设置值 * * @response true */ public function updateValue($id) { return $this->response()->success( $this->service->update($id, request()->all()) ); } /** * [值]删除设置值 * * @description 删除指定ID的设置值 * * @param int id 设置值ID * * @response true */ public function deleteValue($id) { return $this->response()->success( $this->service->destroy($id) ); } /** * [值]获取设置值详情 * * @description 获取指定ID的设置值详情 * * @param int id 设置值ID * * @response { * "id": 1, * "item_id": 1, * "object_type": "PLATFORM", * "object_id": 1, * "value": "示例值", * "created_at": "2023-01-01 00:00:00", * "updated_at": "2023-01-01 00:00:00" * } */ public function getValueDetail($id) { return $this->response()->success( $this->service->detail($id) ); } }