12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * crm模块下的通用功能控制器
  4. *
  5. * @author qifan
  6. * @date 2020-12-11
  7. */
  8. namespace app\crm\controller;
  9. use app\admin\controller\ApiCommon;
  10. use app\crm\logic\CommonLogic;
  11. use think\Hook;
  12. use think\Request;
  13. class Common extends ApiCommon
  14. {
  15. /**
  16. * 用于判断权限
  17. * @permission 无限制
  18. * @allow 登录用户可访问
  19. * @other 其他根据系统设置
  20. **/
  21. public function _initialize()
  22. {
  23. $action = [
  24. 'permission' => [''],
  25. 'allow' => ['quickedit']
  26. ];
  27. Hook::listen('check_auth',$action);
  28. $request = Request::instance();
  29. $a = strtolower($request->action());
  30. if (!in_array($a, $action['permission'])) {
  31. parent::_initialize();
  32. }
  33. }
  34. /**
  35. * 快捷编辑
  36. *
  37. * @param CommonLogic $commonLogic
  38. * @return \think\response\Json
  39. * @throws \think\Exception
  40. * @throws \think\db\exception\DataNotFoundException
  41. * @throws \think\db\exception\ModelNotFoundException
  42. * @throws \think\exception\DbException
  43. * @throws \think\exception\PDOException
  44. */
  45. public function quickEdit(CommonLogic $commonLogic)
  46. {
  47. if (empty($this->param['types'])) return resultArray(['error' => '缺少模块类型!']);
  48. if (empty($this->param['action_id'])) return resultArray(['error' => '缺少数据ID!']);
  49. if ($commonLogic->quickEdit($this->param) === false) return resultArray(['error' => $commonLogic->error]);
  50. return resultArray(['data' => '操作成功!']);
  51. }
  52. }