You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wkcrm/application/admin/controller/DailyRule.php

163 lines
5.3 KiB

4 years ago
<?php
/**
* 日志规则控制器
*
* @author qifan
* @date 2020-12-03
*/
namespace app\admin\controller;
use app\admin\logic\DailyRuleLogic;
use think\Hook;
use think\Request;
class DailyRule extends ApiCommon
{
/**
* 用于判断权限
* @permission 无限制
* @allow 登录用户可访问
* @other 其他根据系统设置
**/
public function _initialize()
{
$action = [
'permission'=>[''],
4 years ago
'allow'=>['welcome', 'setwelcome', 'worklogrule', 'setworklogrule','schedulelist','addschedule','setschedule','delschedule']
4 years ago
];
Hook::listen('check_auth',$action);
$request = Request::instance();
$a = strtolower($request->action());
if (!in_array($a, $action['permission'])) {
parent::_initialize();
}
}
/**
* 获取欢迎语
*
* @param DailyRuleLogic $dailyRuleLogic
* @return \think\response\Json
*/
public function welcome(DailyRuleLogic $dailyRuleLogic)
{
$data = $dailyRuleLogic->welcome();
return resultArray(['data' => $data]);
}
/**
* 添加欢迎语
*
* @param DailyRuleLogic $dailyRuleLogic
* @return \think\response\Json
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function setWelcome(DailyRuleLogic $dailyRuleLogic)
{
$mark = $this->param['welcome'];
4 years ago
$userInfo=$this->userInfo;
4 years ago
if (empty($mark)) return resultArray(['error' => '缺少日志欢迎语!']);
if (!$dailyRuleLogic->setWelcome($mark)) return resultArray(['error' => '添加失败!']);
4 years ago
# 系统操作日志
SystemActionLog($userInfo['id'], 'admin_oalog_rule','work_task','1','update','日志欢迎语' , '', '','设置了日志欢迎语');
4 years ago
return resultArray(['data' => '添加成功!']);
}
/**
* 获取日志规则
*
* @param DailyRuleLogic $dailyRuleLogic
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function workLogRule(DailyRuleLogic $dailyRuleLogic)
{
$data = $dailyRuleLogic->workLogRule();
return resultArray(['data' => $data]);
}
/**
* 设置日志规则
*
* @param DailyRuleLogic $dailyRuleLogic
* @return \think\response\Json
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function setWorkLogRule(DailyRuleLogic $dailyRuleLogic)
{
if (empty($this->param['rule'])) return resultArray(['error' => '缺少规则参数!']);
4 years ago
$userInfo=$this->userInfo;
4 years ago
$dailyRuleLogic->setWorkLogRule($this->param['rule']);
4 years ago
# 系统操作日志
SystemActionLog($userInfo['id'], 'admin_oalog_rule','work_task', 1, 'update','日志规则' , '', '','设置了日志规则');
4 years ago
return resultArray(['data' => '设置成功!']);
}
/**
* 获取日程规则
* @param DailyRuleLogic $dailyRuleLogic
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function scheduleList(DailyRuleLogic $dailyRuleLogic){
$data = $dailyRuleLogic->schedule();
return resultArray(['data' => $data]);
}
/**
* 设置日程自定义规则
* @param DailyRuleLogic $dailyRuleLogic
* @return \think\response\Json
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function setSchedule(DailyRuleLogic $dailyRuleLogic){
4 years ago
$userInfo=$this->userInfo;
4 years ago
if(empty($this->param['id'])) return resultArray(['error'=>'缺少参数']);
$dailyRuleLogic->setSchedule($this->param);
4 years ago
# 系统操作日志
SystemActionLog($userInfo['id'], 'admin_oalog_rule','work_task', 1, 'update','日程类型' , '', '','设置了日程类型');
4 years ago
return resultArray(['data' => '设置成功!']);
}
/**
* 添加日程自定义规则
* @param DailyRuleLogic $dailyRuleLogic
* @return \think\response\Json
*/
public function addSchedule(DailyRuleLogic $dailyRuleLogic){
4 years ago
$userInfo=$this->userInfo;
4 years ago
if(empty($this->param['name'])) return resultArray(['error'=>'缺少参数']);
$dailyRuleLogic->addSchedule($this->param);
4 years ago
# 系统操作日志
SystemActionLog($userInfo['id'], 'admin_oalog_rule','work_task', 1, 'save','日程类型' , '', '','新增了日程类型');
4 years ago
return resultArray(['data' => '添加成功!']);
}
/**
* 删除日程自定义规则
* @param DailyRuleLogic $dailyRuleLogic
* @return \think\response\Json
*/
public function delSchedule(DailyRuleLogic $dailyRuleLogic){
4 years ago
$userInfo=$this->userInfo;
4 years ago
if(empty($this->param['id'])) return resultArray(['error'=>'缺少参数']);
$dailyRuleLogic->delSchedule($this->param['id']);
4 years ago
# 系统操作日志
SystemActionLog($userInfo['id'], 'admin_oalog_rule','work_task', 1, 'update','日程类型' , '', '','删除了日程类型');
4 years ago
return resultArray(['data' => '删除成功!']);
}
}