IndexController.php
7.7 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<?php
namespace App\Http\Controllers\Aside\Com;
use App\Enums\Common\Code;
use App\Enums\Common\Common;
use App\Helper\Translate;
use App\Http\Controllers\Aside\BaseController;
use App\Http\Logic\Aside\Manage\MenuLogic;
use App\Http\Logic\Bside\User\UserLoginLogic;
use App\Models\Inquiry\InquiryData;
use App\Models\Manage\Manage;
use App\Models\User\User;
use App\Models\WebSetting\WebLanguage;
use App\Services\HumanizeAiTextService;
use App\Services\WordAiService;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Http;
/**
* Class IndexController
* @package App\Http\Controllers\Aside
* @author zbj
* @date 2023/4/19
*/
class IndexController extends BaseController
{
/**
* 用户菜单
* @param MenuLogic $logic
* @return \Illuminate\Http\JsonResponse
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @author zbj
* @date 2023/6/21
*/
public function get_menu(MenuLogic $logic)
{
if($this->manage['gid'] == 0){ //超级管理员
$menus = $logic->getAllMenu();
}else{
$menus = $logic->getMenuByGroupId($this->manage['gid']);
}
$this->response('success',Code::SUCCESS,$menus);
}
/**
* @remark :修改密码
* @name :editPassword
* @author :lyh
* @method :post
* @time :2023/9/11 9:10
*/
public function editPassword(){
$this->request->validate([
// 'oldPassword'=>'required',
'password' => 'required',
'confirm'=>'required',
], [
// 'oldPassword.required' => '请输入原密码',
'password.required' => '请输入新密码',
'confirm.required' => '请再次输入新密码',
]);
//查询员密码是否正确
$managerModel = new Manage();
$info = $managerModel->read(['id'=>$this->manage['id']]);
// if(!Hash::check($this->param['oldPassword'], $info['password'])){
// $this->response('原密码错误',Code::USER_REGISTER_ERROE);
// }
if($this->param['password'] != $this->param['confirm']){
$this->response('两次密码不一致');
}
$rs = $managerModel->edit(['password'=>Hash::make($this->param['password'])],['id'=>$this->manage['id']]);
if($rs === false){
$this->response('系统错误',Code::SYSTEM_ERROR);
}
Cache::pull(Common::MANAGE_TOKEN . $info['token']);
$this->response('success');
}
/**
* @remark :同步询盘记录
* @name :sync_inquiry
* @author :lyh
* @method :post
* @time :2023/11/16 9:51
*/
public function sync_inquiry(){
$this->request->validate([
'data' => 'required|array',
'identifying'=>'required',
], [
'data.required' => '自定义询盘数据不为空',
'data.array' => '必须为数组',
'identifying.required' => '唯一标识不为空',
]);
$inquiryModel = new InquiryData();
$rs = $inquiryModel->add($this->param);
if($rs === false){
$this->response('error',Code::SYSTEM_ERROR);
}
$this->response('success');
}
/**
* 生成嵌套AICC企微的token
* @author zbj
* @date 2024/2/29
*/
public function generateAiCCToken(){
$data = [
'id' => $this->manage['id'],
'name' => $this->manage['name'],
'timestamp' => time(), // 接收到字符串解密出来以后需要 验证时间不超过30秒 超过时间视为无效授权
];
$common = new \App\Helper\Common();
$str = $common->encrypt($data);
$this->response('success',Code::SUCCESS,['str'=>$str]);
}
/**
* @remark :模拟登录返回token
* @name :getToken
* @author :lyh
* @method :post
* @time :2024/3/29 16:19
*/
public function getAutoToken(){
$this->request->validate([
'project_id' => 'required',
], [
'project_id.required' => '项目id不能为空',
]);
//获取当前用户的管理员
$userModel = new User();
$userInfo = $userModel->read(['project_id'=>$this->param['project_id'],'role_id'=>0]);
$userLoginLogicModel = new UserLoginLogic();
$info = $userLoginLogicModel->autoAssembleParam($userInfo);
//生成新token
$token = md5(uniqid().'auto'.$info['id']);
//存储缓存
$info['token'] = $token;
Cache::add($token,$info,12 * 3600);
$languageModel = new WebLanguage();
$languageInfo = $languageModel->read(['id'=>$info['main_lang_id']],['short','english','chinese']);
$data = ['token'=>$token,'main_lang_id'=>$info['main_lang_id'],'language_info'=>$languageInfo,'project_seo_type'=>$info['project_seo_type']];
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取动态密码
* @name :getDynamicPassword
* @author :lyh
* @method :post
* @time :2024/9/14 16:58
*/
public function getDynamicPassword(){
$dynamic_password = Cache::get('dynamic_password');
if(empty($dynamic_password)){
$dynamic_password = generateRandomString(16);
Cache::put('dynamic_password',$dynamic_password,5 * 3600);
}
$this->response('success',Code::SUCCESS,['dynamic_password'=>$dynamic_password]);
}
/**
* @remark :去ai痕迹
* @name :notAiHumanizer
* @author :lyh
* @method :post
* @time :2025/5/21 9:08
*/
public function notAiHumanizer(){
$this->request->validate([
'text'=>'required',
'lang'=>'required'
],[
'text.required' => '文本text不能为空',
'lang.required' => '语种不能为空',
]);
if($this->param['lang'] == 0){
$lang = Translate::translateSl($this->param['text']);
$this->param['lang'] = $lang['texts']['sl'] ?? '';
}
if(empty($this->param['lang'])){
$this->fail('未获取到语种');
}
$service = new HumanizeAiTextService();
$data = $service->humanizer($this->param['text'],$this->param['lang']);
$this->response('success', Code::SUCCESS, $data);
}
/**
* @remark :去Ai痕迹
* @name :notWordAi
* @author :lyh
* @method :post
* @time :2025/11/19 17:57
*/
public function notWordAiHumanizer()
{
$this->request->validate([
'text'=>'required',
],[
'text.required' => '文本text不能为空',
]);
$wordAiService = new WordAiService();
$data = $wordAiService->setApiAvoid($this->param['text']);
$this->response('success', Code::SUCCESS, $data);
}
/**
* @remark :翻译
* @name :stringTranslation
* @author :lyh
* @method :post
* @time :2025/5/21 9:31
*/
public function stringTranslation(){
$data = Translate::translateSl($this->param['text']);
$this->response('success', Code::SUCCESS, $data);
}
/**
* @remark :pr报告下载
* @name :prInfoDownload
* @author :lyh
* @method :post
* @time :2025/11/18 15:00
*/
public function prInfoDownload()
{
$url = 'http://crawl.scraper.waimaoq.com/export/issuewire?token=MT0CM7y4tdFTFTm';
$response = Http::get($url,['page'=>$this->param['page'],'page_size'=>$this->param['row']]);
if ($response->successful()) {
$result = $response->json();
}
$this->response('success', Code::SUCCESS, ['url'=>$url,'list'=>$result ?? []]);
}
}