ConfigSet.php 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. $userInfo=$this->userInfo;
  52. $param['user_id']=$userInfo['id'];
  53. if (!$param['id']) {
  54. return resultArray(['error' => '参数错误']);
  55. }
  56. if ($configModel->updateDataById($param, $param['id'])) {
  57. return resultArray(['data' => '编辑成功']);
  58. }
  59. return resultArray(['error' => $configModel->getError()]);
  60. }
  61. }