更新
This commit is contained in:
parent
5ddd12c3f4
commit
f684e31e2e
60
app/api/controller/Api.php
Normal file
60
app/api/controller/Api.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 勾股工作室
|
||||
* @license https://opensource.org/licenses/Apache-2.0
|
||||
* @link https://www.gougucms.com
|
||||
*/
|
||||
declare (strict_types = 1);
|
||||
namespace app\api\controller;
|
||||
|
||||
use think\facade\Db;
|
||||
use app\project\model\ProjectTask as TaskList;
|
||||
use app\project\validate\TaskCheck;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
class Api
|
||||
{
|
||||
//添加
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user