DictConfigController.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeadmin快速开发前后端分离管理后台(PHP版)
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
  8. // | github下载:https://github.com/likeshop-github/likeadmin
  9. // | 访问官网:https://www.likeadmin.cn
  10. // | likeadmin团队 版权所有 拥有最终解释权
  11. // +----------------------------------------------------------------------
  12. // | author: likeadminTeam
  13. // +----------------------------------------------------------------------
  14. namespace app\adminapi\controller\setting\dict;
  15. use app\adminapi\controller\BaseAdminController;
  16. use app\adminapi\lists\setting\dict\DictConfigLists;
  17. use app\adminapi\logic\setting\dict\DictConfigLogic;
  18. use app\adminapi\validate\dict\DictConfigValidate;
  19. /**
  20. * 字典数据
  21. * Class DictConfigController
  22. * @package app\adminapi\controller\dictionary
  23. */
  24. class DictConfigController extends BaseAdminController
  25. {
  26. /**
  27. * @notes 获取字典数据列表
  28. * @return \think\response\Json
  29. */
  30. public function lists()
  31. {
  32. return $this->dataLists(new DictConfigLists());
  33. }
  34. /**
  35. * @notes 添加字典数据
  36. * @return \think\response\Json
  37. */
  38. public function add()
  39. {
  40. $params = (new DictConfigValidate())->post()->goCheck('add');
  41. $result = DictConfigLogic::save($params);
  42. if (false === $result) {
  43. return $this->fail(DictConfigLogic::getError());
  44. }
  45. return $this->success('添加成功', [], 1, 1);
  46. }
  47. /**
  48. * @notes 编辑字典数据
  49. * @return \think\response\Json
  50. */
  51. public function edit()
  52. {
  53. $params = (new DictConfigValidate())->post()->goCheck('edit');
  54. $result = DictConfigLogic::save($params);
  55. if (false === $result) {
  56. return $this->fail(DictConfigLogic::getError());
  57. }
  58. return $this->success('编辑成功', [], 1, 1);
  59. }
  60. /**
  61. * @notes 删除字典数据
  62. * @return \think\response\Json
  63. */
  64. public function delete()
  65. {
  66. $params = (new DictConfigValidate())->post()->goCheck('id');
  67. DictConfigLogic::delete($params);
  68. return $this->success('删除成功', [], 1, 1);
  69. }
  70. /**
  71. * @notes 获取字典详情
  72. * @return \think\response\Json
  73. */
  74. public function detail()
  75. {
  76. $params = (new DictConfigValidate())->goCheck('id');
  77. $result = DictConfigLogic::detail($params);
  78. return $this->data($result);
  79. }
  80. }