修改位置

This commit is contained in:
mkm 2024-03-26 11:42:52 +08:00
parent 80b5e1724d
commit ac19ad40b4
2 changed files with 49 additions and 57 deletions

View File

@ -13,7 +13,9 @@ use Firebase\JWT\JWT;
use Firebase\JWT\Key;
use think\facade\Db;
use think\facade\Request;
use app\project\model\ProjectTask as TaskList;
use app\project\validate\TaskCheck;
use think\exception\ValidateException;
class Demo extends BaseController
{
/**
@ -21,7 +23,7 @@ class Demo extends BaseController
* @var array
*/
protected $middleware = [
Auth::class => ['except' => ['index','login'] ]
Auth::class => ['except' => ['index','login','task_add'] ]
];
/**
@ -128,4 +130,48 @@ class Demo extends BaseController
$userInfo = Db::name('Admin')->where(['id' => $uid])->find();
$this->apiSuccess('请求成功', ['user' => $userInfo]);
}
//添加
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();
}
}
}

View File

@ -10,22 +10,12 @@ declare(strict_types=1);
namespace app\api\controller;
use app\project\model\ProjectTask as TaskList;
use app\api\BaseController;
use think\facade\Db;
use app\project\validate\TaskCheck;
use think\exception\ValidateException;
use app\api\middleware\Auth;
class Index extends BaseController
{
/**
* 控制器中间件 [登录、注册 不需要鉴权]
* @var array
*/
protected $middleware = [
Auth::class => ['except' => ['task_add'] ]
];
//上传文件
public function upload()
{
@ -663,48 +653,4 @@ class Index extends BaseController
$cate = get_work_cate();
return to_assign(0, '', $cate);
}
//添加
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();
}
}
}