diff --git a/app/api/controller/Api.php b/app/api/controller/Api.php new file mode 100644 index 0000000..d990d53 --- /dev/null +++ b/app/api/controller/Api.php @@ -0,0 +1,60 @@ +isPost()) { + if (isset($param['end_time'])) { + $param['end_time'] = strtotime(urldecode($param['end_time'])); + } + + try { + validate(TaskCheck::class)->scene('add')->check($param); + } catch (ValidateException $e) { + // 验证失败 输出错误信息 + return to_assign(1, $e->getError()); + } + $param['create_time'] = time(); + $param['admin_id'] = 1; + if (!empty($param['md5']) && strlen($param['md5']) > 2) { + $id = TaskList::where('md5', $param['md5'])->value('id'); + if ($id) { + return to_assign(1, '已存在'); + } + } + $sid = TaskList::strict(false)->field(true)->insertGetId($param); + if ($sid) { + add_log('add', $sid, $param); + $log_data = array( + 'module' => 'task', + 'task_id' => $sid, + 'new_content' => $param['title'], + 'field' => 'new', + 'action' => 'add', + 'admin_id' => 1, + 'create_time' => time(), + ); + Db::name('ProjectLog')->strict(false)->field(true)->insert($log_data); + //发消息 + //$users = $param['director_uid']; + //sendMessage($users, 21, ['title' => $param['title'],'from_uid' => $this->uid, 'create_time'=>date('Y-m-d H:i:s',time()), 'action_id' => $sid]); + } + return to_assign(); + } + } +} \ No newline at end of file diff --git a/app/home/controller/Api.php b/app/home/controller/Api.php index 8e8b6d8..d74013a 100644 --- a/app/home/controller/Api.php +++ b/app/home/controller/Api.php @@ -12,9 +12,7 @@ namespace app\home\controller; use app\api\BaseController; use think\facade\Db; -use app\project\model\ProjectTask as TaskList; -use app\project\validate\TaskCheck; -use think\exception\ValidateException; + class api extends BaseController { @@ -192,47 +190,4 @@ class api extends BaseController return to_assign(0, '', ['data_logs' => $data_logs]); } - //添加 - public function task_add() - { - $param = get_params(); - if (request()->isPost()) { - if (isset($param['end_time'])) { - $param['end_time'] = strtotime(urldecode($param['end_time'])); - } - - try { - validate(TaskCheck::class)->scene('add')->check($param); - } catch (ValidateException $e) { - // 验证失败 输出错误信息 - return to_assign(1, $e->getError()); - } - $param['create_time'] = time(); - $param['admin_id'] = 1; - if (!empty($param['md5']) && strlen($param['md5']) > 2) { - $id = TaskList::where('md5', $param['md5'])->value('id'); - if ($id) { - return to_assign(1, '已存在'); - } - } - $sid = TaskList::strict(false)->field(true)->insertGetId($param); - if ($sid) { - add_log('add', $sid, $param); - $log_data = array( - 'module' => 'task', - 'task_id' => $sid, - 'new_content' => $param['title'], - 'field' => 'new', - 'action' => 'add', - 'admin_id' => 1, - 'create_time' => time(), - ); - Db::name('ProjectLog')->strict(false)->field(true)->insert($log_data); - //发消息 - //$users = $param['director_uid']; - //sendMessage($users, 21, ['title' => $param['title'],'from_uid' => $this->uid, 'create_time'=>date('Y-m-d H:i:s',time()), 'action_id' => $sid]); - } - return to_assign(); - } - } }