ConfigSet.php 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Description: 应用状态
  4. // +----------------------------------------------------------------------
  5. // | Author: Michael_xu | gengxiaoxu@5kcrm.com
  6. // +----------------------------------------------------------------------
  7. namespace app\admin\controller;
  8. use think\Hook;
  9. use think\Request;
  10. class ConfigSet extends ApiCommon
  11. {
  12. /**
  13. * 用于判断权限
  14. * @permission 无限制
  15. * @allow 登录用户可访问
  16. * @other 其他根据系统设置
  17. **/
  18. public function _initialize()
  19. {
  20. $action = [
  21. 'permission'=>[''],
  22. 'allow'=>['']
  23. ];
  24. Hook::listen('check_auth',$action);
  25. $request = Request::instance();
  26. $a = strtolower($request->action());
  27. if (!in_array($a, $action['permission'])) {
  28. parent::_initialize();
  29. }
  30. }
  31. /**
  32. * 应用状态列表
  33. * @author Michael_xu
  34. * @return
  35. */
  36. public function index()
  37. {
  38. $configModel = model('Config');
  39. $data = $configModel->getDataList();
  40. return resultArray(['data' => $data]);
  41. }
  42. /**
  43. * 状态编辑
  44. * @author Michael_xu
  45. * @return
  46. */
  47. public function update()
  48. {
  49. $configModel = model('Config');
  50. $param = $this->param;
  51. if (!$param['id']) {
  52. return resultArray(['error' => '参数错误']);
  53. }
  54. if ($configModel->updateDataById($param, $param['id'])) {
  55. return resultArray(['data' => '编辑成功']);
  56. }
  57. return resultArray(['error' => $configModel->getError()]);
  58. }
  59. }