AiRemoveController.php
2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace App\Http\Controllers\Aside\AiRemove;
use App\Enums\Common\Code;
use App\Http\Controllers\Aside\BaseController;
use App\Jobs\WordAi;
use App\Models\AiRemove\AiRemove;
use App\Models\Manage\Manage;
class AiRemoveController extends BaseController
{
/**
* 获取去AI痕迹任务列表
* @author Akun
* @date 2025/11/20 11:35
*/
public function getTaskLists()
{
$model = new AiRemove();
$lists = $model->lists($this->map, $this->page, $this->row, 'id', ['id', 'user_id', 'status', 'error_msg', 'created_at', 'updated_at']);
if (!empty($lists)) {
$manage_model = new Manage();
foreach ($lists['list'] as $k => $v) {
$lists['list'][$k]['operator_name'] = $manage_model->getName($v['user_id']);
}
}
$this->response('success', Code::SUCCESS, $lists);
}
/**
* 获取去AI任务详情
* @author Akun
* @date 2025/11/20 11:47
*/
public function taskInfo()
{
$this->request->validate([
'id' => 'required'
], [
'id.required' => 'ID不能为空'
]);
$model = new AiRemove();
$info = $model->read(['id' => $this->param['id']]);
$this->response('success', Code::SUCCESS, $info);
}
/**
* 提交去AI痕迹任务
* @throws \App\Exceptions\AsideGlobalException
* @author Akun
* @date 2025/11/20 11:41
*/
public function saveTask()
{
$this->request->validate([
'origin_text' => 'required',
], [
'origin_text.required' => '需要去痕迹的内容不能为空'
]);
$data = [
'user_id' => $this->uid,
'origin_text' => $this->param['origin_text'],
'status' => ['<', AiRemove::STATUS_FAL]
];
$model = new AiRemove();
$task_info = $model->read($data);
if ($task_info) {
$this->fail('已提交过相同任务,请勿重复提交');
}
$data['status'] = AiRemove::STATUS_UN;
$id = $model->addReturnId($data);
WordAi::dispatch(['id' => $id]);
$this->response('success');
}
}