Index.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Description: 工作台及基础
  4. // +----------------------------------------------------------------------
  5. // | Author: yykun
  6. // +----------------------------------------------------------------------
  7. namespace app\work\controller;
  8. use think\Request;
  9. use think\Session;
  10. use think\Hook;
  11. use think\Db;
  12. use app\admin\controller\ApiCommon;
  13. use app\admin\model\Comment as Comment;
  14. use app\work\model\WorkModel as WorkModel;
  15. class Index extends ApiCommon
  16. {
  17. /**
  18. * 用于判断权限
  19. * @permission 无限制
  20. * @allow 登录用户可访问
  21. * @other 其他根据系统设置
  22. **/
  23. public function _initialize()
  24. {
  25. $action = [
  26. 'permission'=>[''], //不登录可访问
  27. 'allow'=>['worklist','fields','index','fieldrecord'] //需要登录才能访问
  28. ];
  29. Hook::listen('check_auth',$action);
  30. $request = Request::instance();
  31. $a = strtolower($request->action());
  32. if (!in_array($a, $action['permission'])) {
  33. parent::_initialize();
  34. }
  35. }
  36. /**
  37. * 左侧导航栏项目展示
  38. * @author Michael_xu
  39. * @return
  40. */
  41. public function workList()
  42. {
  43. $userInfo = $this->userInfo;
  44. $WorkModel = model('Work');
  45. $param['user_id'] = $userInfo['id'];
  46. //权限
  47. $map = $WorkModel->getWorkWhere($param);
  48. $list = Db::name('Work')->where(['status' => 1])->where($map)->select();
  49. return resultArray(['data' => $list]);
  50. }
  51. /**
  52. * 看板试图
  53. * @author Michael_xu
  54. * @return
  55. */
  56. public function index()
  57. {
  58. $commentModel = new Comment();
  59. $param['task_id'] =2;
  60. $list = $commentModel->read($param);
  61. if ($list) {
  62. return resultArray(['data' => $list ]);
  63. } else {
  64. return resultArray(['error'=> $commentModel->getError()]);
  65. }
  66. }
  67. }