SystemConfigTab.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\v1\setting;
  12. use app\adminapi\controller\AuthController;
  13. use app\services\system\config\SystemConfigServices;
  14. use app\services\system\config\SystemConfigTabServices;
  15. use think\facade\App;
  16. /**
  17. * 配置分类
  18. * Class SystemConfigTab
  19. * @package app\adminapi\controller\v1\setting
  20. */
  21. class SystemConfigTab extends AuthController
  22. {
  23. /**
  24. * g构造方法
  25. * SystemConfigTab constructor.
  26. * @param App $app
  27. * @param SystemConfigTabServices $services
  28. */
  29. public function __construct(App $app, SystemConfigTabServices $services)
  30. {
  31. parent::__construct($app);
  32. $this->services = $services;
  33. }
  34. /**
  35. * 显示资源列表
  36. *
  37. * @return \think\Response
  38. */
  39. public function index()
  40. {
  41. $where = $this->request->getMore([
  42. ['status', ''],
  43. ['title', '']
  44. ]);
  45. return app('json')->success($this->services->getConfgTabList($where));
  46. }
  47. /**
  48. * 显示创建资源表单页.
  49. *
  50. * @return \think\Response
  51. */
  52. public function create()
  53. {
  54. return app('json')->success($this->services->createForm());
  55. }
  56. /**
  57. * 保存新建的资源
  58. *
  59. * @return \think\Response
  60. */
  61. public function save()
  62. {
  63. $data = $this->request->postMore([
  64. 'eng_title',
  65. 'status',
  66. 'title',
  67. 'icon',
  68. ['type', 0],
  69. ['sort', 0],
  70. ['pid', 0],
  71. ]);
  72. if (!$data['title']) return app('json')->fail(400291);
  73. $this->services->save($data);
  74. return app('json')->success(400292);
  75. }
  76. /**
  77. * 显示指定的资源
  78. *
  79. * @param int $id
  80. * @return \think\Response
  81. */
  82. public function read($id)
  83. {
  84. //
  85. }
  86. /**
  87. * 显示编辑资源表单页.
  88. *
  89. * @param int $id
  90. * @return \think\Response
  91. */
  92. public function edit($id)
  93. {
  94. return app('json')->success($this->services->updateForm((int)$id));
  95. }
  96. /**
  97. * 保存更新的资源
  98. *
  99. * @param int $id
  100. * @return \think\Response
  101. */
  102. public function update($id)
  103. {
  104. $data = $this->request->postMore([
  105. 'title',
  106. 'status',
  107. 'eng_title',
  108. 'icon',
  109. ['type', 0],
  110. ['sort', 0],
  111. ['pid', 0],
  112. ]);
  113. if (!$data['title']) return app('json')->fail(400291);
  114. if (!$data['eng_title']) return app('json')->fail(400275);
  115. $this->services->update($id, $data);
  116. return app('json')->success(100001);
  117. }
  118. /**
  119. * 删除指定资源
  120. *
  121. * @param int $id
  122. * @return \think\Response
  123. */
  124. public function delete(SystemConfigServices $services, $id)
  125. {
  126. if ($services->count(['tab_id' => $id])) {
  127. return app('json')->fail(400293);
  128. }
  129. if (!$this->services->delete($id))
  130. return app('json')->fail(100008);
  131. else
  132. return app('json')->success(100002);
  133. }
  134. /**
  135. * 修改状态
  136. * @param $id
  137. * @param $status
  138. * @return mixed
  139. */
  140. public function set_status($id, $status)
  141. {
  142. if ($status == '' || $id == 0) {
  143. return app('json')->fail(100100);
  144. }
  145. $this->services->update($id, ['status' => $status]);
  146. return app('json')->success(100014);
  147. }
  148. }