Config.php 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace app\admin\controller\index;
  3. use app\admin\controller\BaseController;
  4. use app\admin\server\index\ConfigServer;
  5. class Config extends BaseController
  6. {
  7. /**
  8. * Notes:获取设置分类列表
  9. * @return \support\Response
  10. * User: yym
  11. * Date: 2022/10/10
  12. */
  13. public function getClassify()
  14. {
  15. return json_success(ConfigServer::getClassify(), '获取成功');
  16. }
  17. /**
  18. * Notes:设置分类添加
  19. * @return \support\Response
  20. * User: yym
  21. * Date: 2022/10/10
  22. */
  23. public function insertClassify()
  24. {
  25. $classify_pid = $this->request->post('classify_pid', 0);//父级ID
  26. $classify_name = $this->request->post('classify_name');//分类名称
  27. $classify_key = $this->request->post('classify_key');//分类键名
  28. $classify_info = $this->request->post('classify_info', '');//配置分类说明
  29. $classify_sort = $this->request->post('classify_sort', 0);//排序
  30. $classify_status = $this->request->post('classify_status', 1);//状态 0禁用 1启用
  31. $admin_id = $this->request->admin_id;
  32. $this->validateCheck('index\ConfigValidate', ['classify_name' => $classify_name, 'classify_key' => $classify_key], 'add');
  33. ConfigServer::insertClassify($classify_pid, $classify_name, $classify_key, $classify_info, $classify_sort, $classify_status, $admin_id);
  34. return json_success([], '操作成功');
  35. }
  36. /**
  37. * Notes:系统设置分类编辑
  38. * @return \support\Response
  39. * @throws \Exception
  40. * User: yym
  41. * Date: 2022/10/10
  42. */
  43. public function updateClassify()
  44. {
  45. $classify_id = $this->request->post('classify_id');//分类编号
  46. $classify_pid = $this->request->post('classify_pid', 0);//父级ID
  47. $classify_name = $this->request->post('classify_name');//分类名称
  48. $classify_key = $this->request->post('classify_key');//分类键名
  49. $classify_info = $this->request->post('classify_info', '');//配置分类说明
  50. $classify_sort = $this->request->post('classify_sort', 0);//排序
  51. $classify_status = $this->request->post('classify_status', 1);//状态 0禁用 1启用
  52. $admin_id = $this->request->admin_id;
  53. $this->validateCheck('index\ConfigValidate', ['classify_id' => $classify_id, 'classify_name' => $classify_name, 'classify_key' => $classify_key], 'up');
  54. ConfigServer::updateClassify($classify_id, $classify_pid, $classify_name, $classify_key, $classify_info, $classify_sort, $classify_status, $admin_id);
  55. return json_success([], '操作成功');
  56. }
  57. /**
  58. * Notes:配置分类删除或编辑状态
  59. * @return \support\Response
  60. * @throws \Exception
  61. * User: yym
  62. * Date: 2022/10/10
  63. */
  64. public function delUpClassify()
  65. {
  66. $type = $this->request->post('type', 0);//类型 0删除 1修改状态
  67. $classify_id = $this->request->post('classify_id');//分类编号
  68. $status = $this->request->post('status', 0);//状态 0禁用 1启用
  69. $admin_id = $this->request->admin_id;
  70. $this->validateCheck('index\ConfigValidate', ['classify_id' => $classify_id], 'del_up');
  71. ConfigServer::delUpClassify($classify_id, $type, $status, $admin_id);
  72. return json_success([], '操作成功');
  73. }
  74. /**
  75. * Notes:获取单个配置信息
  76. * @return \support\Response
  77. * User: yym
  78. * Date: 2022/10/10
  79. */
  80. public function getClassifyInfo()
  81. {
  82. $classify_id = $this->request->get('classify_id');//分类编号
  83. $this->validateCheck('index\ConfigValidate', ['classify_id' => $classify_id], 'del_up');
  84. return json_success(ConfigServer::getClassifyInfo($classify_id), '获取成功');
  85. }
  86. }