123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <?php
- namespace App\Admin\Controllers;
- use App\Services\SettingValueService;
- use Slowlyo\OwlAdmin\Controllers\AdminController;
- /**
- * @group 后台
- *
- * 设置值管理
- *
- * @property SettingValueService $service
- */
- class SettingValueController extends AdminController
- {
- protected string $serviceName = SettingValueService::class;
- public function list()
- {
- $crud = $this->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)
- );
- }
- }
|