SettingValueController.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Services\SettingValueService;
  4. use Slowlyo\OwlAdmin\Controllers\AdminController;
  5. /**
  6. * @group 后台
  7. *
  8. * 设置值管理
  9. *
  10. * @property SettingValueService $service
  11. */
  12. class SettingValueController extends AdminController
  13. {
  14. protected string $serviceName = SettingValueService::class;
  15. public function list()
  16. {
  17. $crud = $this->baseCRUD()
  18. ->filterTogglable(false)
  19. ->headerToolbar([
  20. $this->createButton('dialog'),
  21. ...$this->baseHeaderToolBar()
  22. ])
  23. ->columns([
  24. amis()->TableColumn('id', 'ID')->sortable(),
  25. amis()->TableColumn('item_id', '设置项ID'),
  26. amis()->TableColumn('object_type', '业务对象类型:PLATFORM,AGENT,SHOP,COACH'),
  27. amis()->TableColumn('object_id', '业务对象ID'),
  28. amis()->TableColumn('value', '设置值'),
  29. amis()->TableColumn('created_at', admin_trans('admin.created_at'))->type('datetime')->sortable(),
  30. amis()->TableColumn('updated_at', admin_trans('admin.updated_at'))->type('datetime')->sortable(),
  31. $this->rowActions('dialog')
  32. ]);
  33. return $this->baseList($crud);
  34. }
  35. public function form($isEdit = false)
  36. {
  37. return $this->baseForm()->body([
  38. amis()->TextControl('item_id', '设置项ID'),
  39. amis()->TextControl('object_type', '业务对象类型:PLATFORM,AGENT,SHOP,COACH'),
  40. amis()->TextControl('object_id', '业务对象ID'),
  41. amis()->TextControl('value', '设置值'),
  42. ]);
  43. }
  44. public function detail()
  45. {
  46. return $this->baseDetail()->body([
  47. amis()->TextControl('id', 'ID')->static(),
  48. amis()->TextControl('item_id', '设置项ID')->static(),
  49. amis()->TextControl('object_type', '业务对象类型:PLATFORM,AGENT,SHOP,COACH')->static(),
  50. amis()->TextControl('object_id', '业务对象ID')->static(),
  51. amis()->TextControl('value', '设置值')->static(),
  52. amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(),
  53. amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
  54. ]);
  55. }
  56. /**
  57. * [值]获取设置值列表
  58. *
  59. * @description 获取所有设置值列表
  60. *
  61. * @param int item_id 设置项ID
  62. * @param string object_type 业务对象类型
  63. * @param int object_id 业务对象ID
  64. * @param int perPage 每页数量
  65. *
  66. * @response {
  67. * "data": [
  68. * {
  69. * "id": 1,
  70. * "item_id": 1,
  71. * "object_type": "PLATFORM",
  72. * "object_id": 1,
  73. * "value": "示例值",
  74. * "created_at": "2023-01-01 00:00:00",
  75. * "updated_at": "2023-01-01 00:00:00"
  76. * }
  77. * ]
  78. * }
  79. */
  80. public function getValueList()
  81. {
  82. return $this->response()->success(
  83. $this->service->list(request()->all())
  84. );
  85. }
  86. /**
  87. * [值]创建设置值
  88. *
  89. * @description 创建新的设置值
  90. *
  91. * @param int item_id 设置项ID
  92. * @param string object_type 业务对象类型:PLATFORM,AGENT,SHOP,COACH
  93. * @param int object_id 业务对象ID
  94. * @param string value 设置值
  95. *
  96. * @response {
  97. * "item_id": 1,
  98. * "object_type": "PLATFORM",
  99. * "object_id": 1,
  100. * "value": "示例值"
  101. * }
  102. */
  103. public function createValue()
  104. {
  105. return $this->response()->success(
  106. $this->service->store(request()->all())
  107. );
  108. }
  109. /**
  110. * [值]更新设置值
  111. *
  112. * @description 更新指定ID的设置值
  113. *
  114. * @param int id 设置值ID
  115. * @param int item_id 设置项ID
  116. * @param string object_type 业务对象类型:PLATFORM,AGENT,SHOP,COACH
  117. * @param int object_id 业务对象ID
  118. * @param string value 设置值
  119. *
  120. * @response true
  121. */
  122. public function updateValue($id)
  123. {
  124. return $this->response()->success(
  125. $this->service->update($id, request()->all())
  126. );
  127. }
  128. /**
  129. * [值]删除设置值
  130. *
  131. * @description 删除指定ID的设置值
  132. *
  133. * @param int id 设置值ID
  134. *
  135. * @response true
  136. */
  137. public function deleteValue($id)
  138. {
  139. return $this->response()->success(
  140. $this->service->destroy($id)
  141. );
  142. }
  143. /**
  144. * [值]获取设置值详情
  145. *
  146. * @description 获取指定ID的设置值详情
  147. *
  148. * @param int id 设置值ID
  149. *
  150. * @response {
  151. * "id": 1,
  152. * "item_id": 1,
  153. * "object_type": "PLATFORM",
  154. * "object_id": 1,
  155. * "value": "示例值",
  156. * "created_at": "2023-01-01 00:00:00",
  157. * "updated_at": "2023-01-01 00:00:00"
  158. * }
  159. */
  160. public function getValueDetail($id)
  161. {
  162. return $this->response()->success(
  163. $this->service->detail($id)
  164. );
  165. }
  166. }