DailyRule.php 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <?php
  2. /**
  3. * 日志规则控制器
  4. *
  5. * @author qifan
  6. * @date 2020-12-03
  7. */
  8. namespace app\admin\controller;
  9. use app\admin\logic\DailyRuleLogic;
  10. use think\Hook;
  11. use think\Request;
  12. class DailyRule extends ApiCommon
  13. {
  14. /**
  15. * 用于判断权限
  16. * @permission 无限制
  17. * @allow 登录用户可访问
  18. * @other 其他根据系统设置
  19. **/
  20. public function _initialize()
  21. {
  22. $action = [
  23. 'permission'=>[''],
  24. 'allow'=>['welcome', 'setwelcome', 'worklogrule', 'setworklogrule','schedulelist','addschedule','setschedule','delschedule']
  25. ];
  26. Hook::listen('check_auth',$action);
  27. $request = Request::instance();
  28. $a = strtolower($request->action());
  29. if (!in_array($a, $action['permission'])) {
  30. parent::_initialize();
  31. }
  32. }
  33. /**
  34. * 获取欢迎语
  35. *
  36. * @param DailyRuleLogic $dailyRuleLogic
  37. * @return \think\response\Json
  38. */
  39. public function welcome(DailyRuleLogic $dailyRuleLogic)
  40. {
  41. $data = $dailyRuleLogic->welcome();
  42. return resultArray(['data' => $data]);
  43. }
  44. /**
  45. * 添加欢迎语
  46. *
  47. * @param DailyRuleLogic $dailyRuleLogic
  48. * @return \think\response\Json
  49. * @throws \think\Exception
  50. * @throws \think\exception\PDOException
  51. */
  52. public function setWelcome(DailyRuleLogic $dailyRuleLogic)
  53. {
  54. $mark = $this->param['welcome'];
  55. $userInfo=$this->userInfo;
  56. if (empty($mark)) return resultArray(['error' => '缺少日志欢迎语!']);
  57. if (!$dailyRuleLogic->setWelcome($mark)) return resultArray(['error' => '添加失败!']);
  58. # 系统操作日志
  59. SystemActionLog($userInfo['id'], 'admin_oalog_rule','work_task','1','update','日志欢迎语' , '', '','设置了日志欢迎语');
  60. return resultArray(['data' => '添加成功!']);
  61. }
  62. /**
  63. * 获取日志规则
  64. *
  65. * @param DailyRuleLogic $dailyRuleLogic
  66. * @return \think\response\Json
  67. * @throws \think\db\exception\DataNotFoundException
  68. * @throws \think\db\exception\ModelNotFoundException
  69. * @throws \think\exception\DbException
  70. */
  71. public function workLogRule(DailyRuleLogic $dailyRuleLogic)
  72. {
  73. $data = $dailyRuleLogic->workLogRule();
  74. return resultArray(['data' => $data]);
  75. }
  76. /**
  77. * 设置日志规则
  78. *
  79. * @param DailyRuleLogic $dailyRuleLogic
  80. * @return \think\response\Json
  81. * @throws \think\Exception
  82. * @throws \think\exception\PDOException
  83. */
  84. public function setWorkLogRule(DailyRuleLogic $dailyRuleLogic)
  85. {
  86. if (empty($this->param['rule'])) return resultArray(['error' => '缺少规则参数!']);
  87. $userInfo=$this->userInfo;
  88. $dailyRuleLogic->setWorkLogRule($this->param['rule']);
  89. # 系统操作日志
  90. SystemActionLog($userInfo['id'], 'admin_oalog_rule','work_task', 1, 'update','日志规则' , '', '','设置了日志规则');
  91. return resultArray(['data' => '设置成功!']);
  92. }
  93. /**
  94. * 获取日程规则
  95. * @param DailyRuleLogic $dailyRuleLogic
  96. * @return \think\response\Json
  97. * @throws \think\db\exception\DataNotFoundException
  98. * @throws \think\db\exception\ModelNotFoundException
  99. * @throws \think\exception\DbException
  100. */
  101. public function scheduleList(DailyRuleLogic $dailyRuleLogic){
  102. $data = $dailyRuleLogic->schedule();
  103. return resultArray(['data' => $data]);
  104. }
  105. /**
  106. * 设置日程自定义规则
  107. * @param DailyRuleLogic $dailyRuleLogic
  108. * @return \think\response\Json
  109. * @throws \think\Exception
  110. * @throws \think\exception\PDOException
  111. */
  112. public function setSchedule(DailyRuleLogic $dailyRuleLogic){
  113. $userInfo=$this->userInfo;
  114. if(empty($this->param['id'])) return resultArray(['error'=>'缺少参数']);
  115. $dailyRuleLogic->setSchedule($this->param);
  116. # 系统操作日志
  117. SystemActionLog($userInfo['id'], 'admin_oalog_rule','work_task', 1, 'update','日程类型' , '', '','设置了日程类型');
  118. return resultArray(['data' => '设置成功!']);
  119. }
  120. /**
  121. * 添加日程自定义规则
  122. * @param DailyRuleLogic $dailyRuleLogic
  123. * @return \think\response\Json
  124. */
  125. public function addSchedule(DailyRuleLogic $dailyRuleLogic){
  126. $userInfo=$this->userInfo;
  127. if(empty($this->param['name'])) return resultArray(['error'=>'缺少参数']);
  128. $dailyRuleLogic->addSchedule($this->param);
  129. # 系统操作日志
  130. SystemActionLog($userInfo['id'], 'admin_oalog_rule','work_task', 1, 'save','日程类型' , '', '','新增了日程类型');
  131. return resultArray(['data' => '添加成功!']);
  132. }
  133. /**
  134. * 删除日程自定义规则
  135. * @param DailyRuleLogic $dailyRuleLogic
  136. * @return \think\response\Json
  137. */
  138. public function delSchedule(DailyRuleLogic $dailyRuleLogic){
  139. $userInfo=$this->userInfo;
  140. if(empty($this->param['id'])) return resultArray(['error'=>'缺少参数']);
  141. $dailyRuleLogic->delSchedule($this->param['id']);
  142. # 系统操作日志
  143. SystemActionLog($userInfo['id'], 'admin_oalog_rule','work_task', 1, 'update','日程类型' , '', '','删除了日程类型');
  144. return resultArray(['data' => '删除成功!']);
  145. }
  146. }