123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <?php
- namespace App\Admin\Controllers;
- use App\Services\SettingPermissionService;
- use Slowlyo\OwlAdmin\Controllers\AdminController;
- /**
- * @group 后台
- *
- * 设置权限管理
- *
- * @property SettingPermissionService $service
- */
- class SettingPermissionController extends AdminController
- {
- protected string $serviceName = SettingPermissionService::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('can_edit', '是否可编辑'),
- amis()->TableColumn('min_value', '最小值限制'),
- amis()->TableColumn('max_value', '最大值限制'),
- amis()->TableColumn('options', '可选值限制'),
- 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('can_edit', '是否可编辑'),
- amis()->TextControl('min_value', '最小值限制'),
- amis()->TextControl('max_value', '最大值限制'),
- amis()->TextControl('options', '可选值限制'),
- ]);
- }
- 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('can_edit', '是否可编辑')->static(),
- amis()->TextControl('min_value', '最小值限制')->static(),
- amis()->TextControl('max_value', '最大值限制')->static(),
- amis()->TextControl('options', '可选值限制')->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 perPage 每页数量
- *
- * @response {
- * "data": [
- * {
- * "id": 1,
- * "item_id": 1,
- * "object_type": "PLATFORM",
- * "can_edit": 1,
- * "min_value": 0,
- * "max_value": 100,
- * "options": null,
- * "created_at": "2023-01-01 00:00:00",
- * "updated_at": "2023-01-01 00:00:00"
- * }
- * ]
- * }
- */
- public function getPermissionList()
- {
- 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 can_edit 是否可编辑
- * @param float min_value 最小值限制
- * @param float max_value 最大值限制
- * @param json options 可选值限制
- *
- * @response {
- * "item_id": 1,
- * "object_type": "PLATFORM",
- * "can_edit": 1,
- * "min_value": 0,
- * "max_value": 100,
- * "options": null
- * }
- */
- public function createPermission()
- {
- 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 can_edit 是否可编辑
- * @param float min_value 最小值限制
- * @param float max_value 最大值限制
- * @param json options 可选值限制
- *
- * @response true
- */
- public function updatePermission($id)
- {
- return $this->response()->success(
- $this->service->update($id, request()->all())
- );
- }
- /**
- * [权限]删除设置权限
- *
- * @description 删除指定ID的设置权限
- *
- * @param int id 权限ID
- *
- * @response true
- */
- public function deletePermission($id)
- {
- return $this->response()->success(
- $this->service->destroy($id)
- );
- }
- /**
- * [权限]获取设置权限详情
- *
- * @description 获取指定ID的设置权限详情
- *
- * @param int id 权限ID
- *
- * @response {
- * "id": 1,
- * "item_id": 1,
- * "object_type": "PLATFORM",
- * "can_edit": 1,
- * "min_value": 0,
- * "max_value": 100,
- * "options": null,
- * "created_at": "2023-01-01 00:00:00",
- * "updated_at": "2023-01-01 00:00:00"
- * }
- */
- public function getPermissionDetail($id)
- {
- return $this->response()->success(
- $this->service->detail($id)
- );
- }
- }
|