Commit b3f11d9379d5d3042c54c9edc236b1ae4e8ddc95

Authored by zhangdaiscott
1 parent 743ba7d9

重构system模块代码规范,JeecgBoot 3.2.0 版本发布

jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/controller/SystemAPIController.java deleted
1 -package org.jeecg.modules.api.controller;  
2 -  
3 -import com.alibaba.fastjson.JSONObject;  
4 -import lombok.extern.slf4j.Slf4j;  
5 -import org.jeecg.common.api.dto.OnlineAuthDTO;  
6 -import org.jeecg.common.api.dto.message.*;  
7 -import org.jeecg.common.system.vo.*;  
8 -import org.jeecg.modules.system.service.ISysUserService;  
9 -import org.jeecg.modules.system.service.impl.SysBaseApiImpl;  
10 -import org.springframework.beans.factory.annotation.Autowired;  
11 -import org.springframework.web.bind.annotation.*;  
12 -  
13 -import java.util.List;  
14 -import java.util.Map;  
15 -import java.util.Set;  
16 -  
17 -  
18 -/**  
19 - * 服务化 system模块 对外接口请求类  
20 - * @author: jeecg-boot  
21 - */  
22 -@Slf4j  
23 -@RestController  
24 -@RequestMapping("/sys/api")  
25 -public class SystemAPIController {  
26 -  
27 - @Autowired  
28 - private SysBaseApiImpl sysBaseApi;  
29 - @Autowired  
30 - private ISysUserService sysUserService;  
31 -  
32 -  
33 - /**  
34 - * 发送系统消息  
35 - * @param message 使用构造器赋值参数 如果不设置category(消息类型)则默认为2 发送系统消息  
36 - */  
37 - @PostMapping("/sendSysAnnouncement")  
38 - public void sendSysAnnouncement(@RequestBody MessageDTO message){  
39 - sysBaseApi.sendSysAnnouncement(message);  
40 - }  
41 -  
42 - /**  
43 - * 发送消息 附带业务参数  
44 - * @param message 使用构造器赋值参数  
45 - */  
46 - @PostMapping("/sendBusAnnouncement")  
47 - public void sendBusAnnouncement(@RequestBody BusMessageDTO message){  
48 - sysBaseApi.sendBusAnnouncement(message);  
49 - }  
50 -  
51 - /**  
52 - * 通过模板发送消息  
53 - * @param message 使用构造器赋值参数  
54 - */  
55 - @PostMapping("/sendTemplateAnnouncement")  
56 - public void sendTemplateAnnouncement(@RequestBody TemplateMessageDTO message){  
57 - sysBaseApi.sendTemplateAnnouncement(message);  
58 - }  
59 -  
60 - /**  
61 - * 通过模板发送消息 附带业务参数  
62 - * @param message 使用构造器赋值参数  
63 - */  
64 - @PostMapping("/sendBusTemplateAnnouncement")  
65 - public void sendBusTemplateAnnouncement(@RequestBody BusTemplateMessageDTO message){  
66 - sysBaseApi.sendBusTemplateAnnouncement(message);  
67 - }  
68 -  
69 - /**  
70 - * 通过消息中心模板,生成推送内容  
71 - * @param templateDTO 使用构造器赋值参数  
72 - * @return  
73 - */  
74 - @PostMapping("/parseTemplateByCode")  
75 - public String parseTemplateByCode(@RequestBody TemplateDTO templateDTO){  
76 - return sysBaseApi.parseTemplateByCode(templateDTO);  
77 - }  
78 -  
79 - /**  
80 - * 根据业务类型busType及业务busId修改消息已读  
81 - */  
82 - @GetMapping("/updateSysAnnounReadFlag")  
83 - public void updateSysAnnounReadFlag(@RequestParam("busType") String busType, @RequestParam("busId")String busId){  
84 - sysBaseApi.updateSysAnnounReadFlag(busType, busId);  
85 - }  
86 -  
87 - /**  
88 - * 根据用户账号查询用户信息  
89 - * @param username  
90 - * @return  
91 - */  
92 - @GetMapping("/getUserByName")  
93 - public LoginUser getUserByName(@RequestParam("username") String username){  
94 - return sysBaseApi.getUserByName(username);  
95 - }  
96 -  
97 - /**  
98 - * 根据用户id查询用户信息  
99 - * @param id  
100 - * @return  
101 - */  
102 - @GetMapping("/getUserById")  
103 - LoginUser getUserById(@RequestParam("id") String id){  
104 - return sysBaseApi.getUserById(id);  
105 - }  
106 -  
107 - /**  
108 - * 通过用户账号查询角色集合  
109 - * @param username  
110 - * @return  
111 - */  
112 - @GetMapping("/getRolesByUsername")  
113 - List<String> getRolesByUsername(@RequestParam("username") String username){  
114 - return sysBaseApi.getRolesByUsername(username);  
115 - }  
116 -  
117 - /**  
118 - * 通过用户账号查询部门集合  
119 - * @param username  
120 - * @return 部门 id  
121 - */  
122 - @GetMapping("/getDepartIdsByUsername")  
123 - List<String> getDepartIdsByUsername(@RequestParam("username") String username){  
124 - return sysBaseApi.getDepartIdsByUsername(username);  
125 - }  
126 -  
127 - /**  
128 - * 通过用户账号查询部门 name  
129 - * @param username  
130 - * @return 部门 name  
131 - */  
132 - @GetMapping("/getDepartNamesByUsername")  
133 - List<String> getDepartNamesByUsername(@RequestParam("username") String username){  
134 - return sysBaseApi.getDepartNamesByUsername(username);  
135 - }  
136 -  
137 -  
138 - /**  
139 - * 获取数据字典  
140 - * @param code  
141 - * @return  
142 - */  
143 - @GetMapping("/queryDictItemsByCode")  
144 - List<DictModel> queryDictItemsByCode(@RequestParam("code") String code){  
145 - return sysBaseApi.queryDictItemsByCode(code);  
146 - }  
147 -  
148 - /**  
149 - * 获取有效的数据字典  
150 - * @param code  
151 - * @return  
152 - */  
153 - @GetMapping("/queryEnableDictItemsByCode")  
154 - List<DictModel> queryEnableDictItemsByCode(@RequestParam("code") String code){  
155 - return sysBaseApi.queryEnableDictItemsByCode(code);  
156 - }  
157 -  
158 -  
159 - /** 查询所有的父级字典,按照create_time排序 */  
160 - @GetMapping("/queryAllDict")  
161 - List<DictModel> queryAllDict(){  
162 -// try{  
163 -// //睡10秒,gateway网关5秒超时,会触发熔断降级操作  
164 -// Thread.sleep(10000);  
165 -// }catch (Exception e){  
166 -// e.printStackTrace();  
167 -// }  
168 -  
169 - log.info("--我是jeecg-system服务节点,微服务接口queryAllDict被调用--");  
170 - return sysBaseApi.queryAllDict();  
171 - }  
172 -  
173 - /**  
174 - * 查询所有分类字典  
175 - * @return  
176 - */  
177 - @GetMapping("/queryAllSysCategory")  
178 - List<SysCategoryModel> queryAllSysCategory(){  
179 - return sysBaseApi.queryAllSysCategory();  
180 - }  
181 -  
182 -  
183 - /**  
184 - * 查询所有部门 作为字典信息 id -->value,departName -->text  
185 - * @return  
186 - */  
187 - @GetMapping("/queryAllDepartBackDictModel")  
188 - List<DictModel> queryAllDepartBackDictModel(){  
189 - return sysBaseApi.queryAllDepartBackDictModel();  
190 - }  
191 -  
192 - /**  
193 - * 获取所有角色 带参  
194 - * roleIds 默认选中角色  
195 - * @return  
196 - */  
197 - @GetMapping("/queryAllRole")  
198 - public List<ComboModel> queryAllRole(@RequestParam(name = "roleIds",required = false)String[] roleIds){  
199 - if(roleIds==null || roleIds.length==0){  
200 - return sysBaseApi.queryAllRole();  
201 - }else{  
202 - return sysBaseApi.queryAllRole(roleIds);  
203 - }  
204 - }  
205 -  
206 - /**  
207 - * 通过用户账号查询角色Id集合  
208 - * @param username  
209 - * @return  
210 - */  
211 - @GetMapping("/getRoleIdsByUsername")  
212 - public List<String> getRoleIdsByUsername(@RequestParam("username")String username){  
213 - return sysBaseApi.getRoleIdsByUsername(username);  
214 - }  
215 -  
216 - /**  
217 - * 通过部门编号查询部门id  
218 - * @param orgCode  
219 - * @return  
220 - */  
221 - @GetMapping("/getDepartIdsByOrgCode")  
222 - public String getDepartIdsByOrgCode(@RequestParam("orgCode")String orgCode){  
223 - return sysBaseApi.getDepartIdsByOrgCode(orgCode);  
224 - }  
225 -  
226 - /**  
227 - * 查询所有部门  
228 - * @return  
229 - */  
230 - @GetMapping("/getAllSysDepart")  
231 - public List<SysDepartModel> getAllSysDepart(){  
232 - return sysBaseApi.getAllSysDepart();  
233 - }  
234 -  
235 - /**  
236 - * 根据 id 查询数据库中存储的 DynamicDataSourceModel  
237 - *  
238 - * @param dbSourceId  
239 - * @return  
240 - */  
241 - @GetMapping("/getDynamicDbSourceById")  
242 - DynamicDataSourceModel getDynamicDbSourceById(@RequestParam("dbSourceId")String dbSourceId){  
243 - return sysBaseApi.getDynamicDbSourceById(dbSourceId);  
244 - }  
245 -  
246 -  
247 -  
248 - /**  
249 - * 根据部门Id获取部门负责人  
250 - * @param deptId  
251 - * @return  
252 - */  
253 - @GetMapping("/getDeptHeadByDepId")  
254 - public List<String> getDeptHeadByDepId(@RequestParam("deptId") String deptId){  
255 - return sysBaseApi.getDeptHeadByDepId(deptId);  
256 - }  
257 -  
258 - /**  
259 - * 查找父级部门  
260 - * @param departId  
261 - * @return  
262 - */  
263 - @GetMapping("/getParentDepartId")  
264 - public DictModel getParentDepartId(@RequestParam("departId")String departId){  
265 - return sysBaseApi.getParentDepartId(departId);  
266 - }  
267 -  
268 - /**  
269 - * 根据 code 查询数据库中存储的 DynamicDataSourceModel  
270 - *  
271 - * @param dbSourceCode  
272 - * @return  
273 - */  
274 - @GetMapping("/getDynamicDbSourceByCode")  
275 - public DynamicDataSourceModel getDynamicDbSourceByCode(@RequestParam("dbSourceCode") String dbSourceCode){  
276 - return sysBaseApi.getDynamicDbSourceByCode(dbSourceCode);  
277 - }  
278 -  
279 - /**  
280 - * 给指定用户发消息  
281 - * @param userIds  
282 - * @param cmd  
283 - */  
284 - @GetMapping("/sendWebSocketMsg")  
285 - public void sendWebSocketMsg(String[] userIds, String cmd){  
286 - sysBaseApi.sendWebSocketMsg(userIds, cmd);  
287 - }  
288 -  
289 -  
290 - /**  
291 - * 根据id获取所有参与用户  
292 - * userIds  
293 - * @return  
294 - */  
295 - @GetMapping("/queryAllUserByIds")  
296 - public List<LoginUser> queryAllUserByIds(@RequestParam("userIds") String[] userIds){  
297 - return sysBaseApi.queryAllUserByIds(userIds);  
298 - }  
299 -  
300 - /**  
301 - * 查询所有用户 返回ComboModel  
302 - * @return  
303 - */  
304 - @GetMapping("/queryAllUserBackCombo")  
305 - public List<ComboModel> queryAllUserBackCombo(){  
306 - return sysBaseApi.queryAllUserBackCombo();  
307 - }  
308 -  
309 - /**  
310 - * 分页查询用户 返回JSONObject  
311 - * @return  
312 - */  
313 - @GetMapping("/queryAllUser")  
314 - public JSONObject queryAllUser(@RequestParam(name="userIds",required=false)String userIds, @RequestParam(name="pageNo",required=false) Integer pageNo,@RequestParam(name="pageSize",required=false) int pageSize){  
315 - return sysBaseApi.queryAllUser(userIds, pageNo, pageSize);  
316 - }  
317 -  
318 -  
319 -  
320 - /**  
321 - * 将会议签到信息推动到预览  
322 - * userIds  
323 - * @return  
324 - * @param userId  
325 - */  
326 - @GetMapping("/meetingSignWebsocket")  
327 - public void meetingSignWebsocket(@RequestParam("userId")String userId){  
328 - sysBaseApi.meetingSignWebsocket(userId);  
329 - }  
330 -  
331 - /**  
332 - * 根据name获取所有参与用户  
333 - * userNames  
334 - * @return  
335 - */  
336 - @GetMapping("/queryUserByNames")  
337 - public List<LoginUser> queryUserByNames(@RequestParam("userNames")String[] userNames){  
338 - return sysBaseApi.queryUserByNames(userNames);  
339 - }  
340 -  
341 - /**  
342 - * 获取用户的角色集合  
343 - * @param username  
344 - * @return  
345 - */  
346 - @GetMapping("/getUserRoleSet")  
347 - public Set<String> getUserRoleSet(@RequestParam("username")String username){  
348 - return sysBaseApi.getUserRoleSet(username);  
349 - }  
350 -  
351 - /**  
352 - * 获取用户的权限集合  
353 - * @param username  
354 - * @return  
355 - */  
356 - @GetMapping("/getUserPermissionSet")  
357 - public Set<String> getUserPermissionSet(@RequestParam("username") String username){  
358 - return sysBaseApi.getUserPermissionSet(username);  
359 - }  
360 -  
361 - //-----  
362 -  
363 - /**  
364 - * 判断是否有online访问的权限  
365 - * @param onlineAuthDTO  
366 - * @return  
367 - */  
368 - @PostMapping("/hasOnlineAuth")  
369 - public boolean hasOnlineAuth(@RequestBody OnlineAuthDTO onlineAuthDTO){  
370 - return sysBaseApi.hasOnlineAuth(onlineAuthDTO);  
371 - }  
372 -  
373 - /**  
374 - * 查询用户角色信息  
375 - * @param username  
376 - * @return  
377 - */  
378 - @GetMapping("/queryUserRoles")  
379 - public Set<String> queryUserRoles(@RequestParam("username") String username){  
380 - return sysUserService.getUserRolesSet(username);  
381 - }  
382 -  
383 -  
384 - /**  
385 - * 查询用户权限信息  
386 - * @param username  
387 - * @return  
388 - */  
389 - @GetMapping("/queryUserAuths")  
390 - public Set<String> queryUserAuths(@RequestParam("username") String username){  
391 - return sysUserService.getUserPermissionsSet(username);  
392 - }  
393 -  
394 - /**  
395 - * 通过部门id获取部门全部信息  
396 - */  
397 - @GetMapping("/selectAllById")  
398 - public SysDepartModel selectAllById(@RequestParam("id") String id){  
399 - return sysBaseApi.selectAllById(id);  
400 - }  
401 -  
402 - /**  
403 - * 根据用户id查询用户所属公司下所有用户ids  
404 - * @param userId  
405 - * @return  
406 - */  
407 - @GetMapping("/queryDeptUsersByUserId")  
408 - public List<String> queryDeptUsersByUserId(@RequestParam("userId") String userId){  
409 - return sysBaseApi.queryDeptUsersByUserId(userId);  
410 - }  
411 -  
412 -  
413 - /**  
414 - * 查询数据权限  
415 - * @return  
416 - */  
417 - @GetMapping("/queryPermissionDataRule")  
418 - public List<SysPermissionDataRuleModel> queryPermissionDataRule(@RequestParam("component") String component, @RequestParam("requestPath")String requestPath, @RequestParam("username") String username){  
419 - return sysBaseApi.queryPermissionDataRule(component, requestPath, username);  
420 - }  
421 -  
422 - /**  
423 - * 查询用户信息  
424 - * @param username  
425 - * @return  
426 - */  
427 - @GetMapping("/getCacheUser")  
428 - public SysUserCacheInfo getCacheUser(@RequestParam("username") String username){  
429 - return sysBaseApi.getCacheUser(username);  
430 - }  
431 -  
432 - /**  
433 - * 普通字典的翻译  
434 - * @param code  
435 - * @param key  
436 - * @return  
437 - */  
438 - @GetMapping("/translateDict")  
439 - public String translateDict(@RequestParam("code") String code, @RequestParam("key") String key){  
440 - return sysBaseApi.translateDict(code, key);  
441 - }  
442 -  
443 -  
444 - /**  
445 - * 36根据多个用户账号(逗号分隔),查询返回多个用户信息  
446 - * @param usernames  
447 - * @return  
448 - */  
449 - @RequestMapping("/queryUsersByUsernames")  
450 - List<JSONObject> queryUsersByUsernames(@RequestParam("usernames") String usernames){  
451 - return this.sysBaseApi.queryUsersByUsernames(usernames);  
452 - }  
453 -  
454 - /**  
455 - * 37根据多个用户id(逗号分隔),查询返回多个用户信息  
456 - * @param ids  
457 - * @return  
458 - */  
459 - @RequestMapping("/queryUsersByIds")  
460 - List<JSONObject> queryUsersByIds(@RequestParam("ids") String ids){  
461 - return this.sysBaseApi.queryUsersByIds(ids);  
462 - }  
463 -  
464 - /**  
465 - * 38根据多个部门编码(逗号分隔),查询返回多个部门信息  
466 - * @param orgCodes  
467 - * @return  
468 - */  
469 - @GetMapping("/queryDepartsByOrgcodes")  
470 - List<JSONObject> queryDepartsByOrgcodes(@RequestParam("orgCodes") String orgCodes){  
471 - return this.sysBaseApi.queryDepartsByOrgcodes(orgCodes);  
472 - }  
473 -  
474 - /**  
475 - * 39根据多个部门ID(逗号分隔),查询返回多个部门信息  
476 - * @param ids  
477 - * @return  
478 - */  
479 - @GetMapping("/queryDepartsByIds")  
480 - List<JSONObject> queryDepartsByIds(@RequestParam("ids") String ids){  
481 - return this.sysBaseApi.queryDepartsByIds(ids);  
482 - }  
483 -  
484 - /**  
485 - * 40发送邮件消息  
486 - * @param email  
487 - * @param title  
488 - * @param content  
489 - */  
490 - @GetMapping("/sendEmailMsg")  
491 - public void sendEmailMsg(@RequestParam("email")String email,@RequestParam("title")String title,@RequestParam("content")String content){  
492 - this.sysBaseApi.sendEmailMsg(email,title,content);  
493 - };  
494 - /**  
495 - * 41 获取公司下级部门和公司下所有用户信息  
496 - * @param orgCode  
497 - */  
498 - @GetMapping("/getDeptUserByOrgCode")  
499 - List<Map> getDeptUserByOrgCode(@RequestParam("orgCode")String orgCode){  
500 - return this.sysBaseApi.getDeptUserByOrgCode(orgCode);  
501 - }  
502 -  
503 - /**  
504 - * 查询分类字典翻译  
505 - *  
506 - * @param ids 分类字典表id  
507 - * @return  
508 - */  
509 - @GetMapping("/loadCategoryDictItem")  
510 - public List<String> loadCategoryDictItem(@RequestParam("ids") String ids) {  
511 - return sysBaseApi.loadCategoryDictItem(ids);  
512 - }  
513 -  
514 - /**  
515 - * 根据字典code加载字典text  
516 - *  
517 - * @param dictCode 顺序:tableName,text,code  
518 - * @param keys 要查询的key  
519 - * @return  
520 - */  
521 - @GetMapping("/loadDictItem")  
522 - public List<String> loadDictItem(@RequestParam("dictCode") String dictCode, @RequestParam("keys") String keys) {  
523 - return sysBaseApi.loadDictItem(dictCode, keys);  
524 - }  
525 -  
526 - /**  
527 - * 根据字典code查询字典项  
528 - *  
529 - * @param dictCode 顺序:tableName,text,code  
530 - * @param dictCode 要查询的key  
531 - * @return  
532 - */  
533 - @GetMapping("/getDictItems")  
534 - public List<DictModel> getDictItems(@RequestParam("dictCode") String dictCode) {  
535 - return sysBaseApi.getDictItems(dictCode);  
536 - }  
537 -  
538 - /**  
539 - * 根据多个字典code查询多个字典项  
540 - *  
541 - * @param dictCodeList  
542 - * @return key = dictCode ; value=对应的字典项  
543 - */  
544 - @RequestMapping("/getManyDictItems")  
545 - public Map<String, List<DictModel>> getManyDictItems(@RequestParam("dictCodeList") List<String> dictCodeList) {  
546 - return sysBaseApi.getManyDictItems(dictCodeList);  
547 - }  
548 -  
549 - /**  
550 - * 【下拉搜索】  
551 - * 大数据量的字典表 走异步加载,即前端输入内容过滤数据  
552 - *  
553 - * @param dictCode 字典code格式:table,text,code  
554 - * @param keyword 过滤关键字  
555 - * @return  
556 - */  
557 - @GetMapping("/loadDictItemByKeyword")  
558 - public List<DictModel> loadDictItemByKeyword(@RequestParam("dictCode") String dictCode, @RequestParam("keyword") String keyword, @RequestParam(value = "pageSize", required = false) Integer pageSize) {  
559 - return sysBaseApi.loadDictItemByKeyword(dictCode, keyword, pageSize);  
560 - }  
561 -  
562 - /**  
563 - * 48 普通字典的翻译,根据多个dictCode和多条数据,多个以逗号分割  
564 - * @param dictCodes  
565 - * @param keys  
566 - * @return  
567 - */  
568 - @GetMapping("/translateManyDict")  
569 - public Map<String, List<DictModel>> translateManyDict(@RequestParam("dictCodes") String dictCodes, @RequestParam("keys") String keys){  
570 - return this.sysBaseApi.translateManyDict(dictCodes, keys);  
571 - }  
572 -  
573 -  
574 - /**  
575 - * 获取表数据字典 【接口签名验证】  
576 - * @param table  
577 - * @param text  
578 - * @param code  
579 - * @return  
580 - */  
581 - @GetMapping("/queryTableDictItemsByCode")  
582 - List<DictModel> queryTableDictItemsByCode(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code){  
583 - return sysBaseApi.queryTableDictItemsByCode(table, text, code);  
584 - }  
585 -  
586 - /**  
587 - * 查询表字典 支持过滤数据 【接口签名验证】  
588 - * @param table  
589 - * @param text  
590 - * @param code  
591 - * @param filterSql  
592 - * @return  
593 - */  
594 - @GetMapping("/queryFilterTableDictInfo")  
595 - List<DictModel> queryFilterTableDictInfo(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("filterSql") String filterSql){  
596 - return sysBaseApi.queryFilterTableDictInfo(table, text, code, filterSql);  
597 - }  
598 -  
599 - /**  
600 - * 【接口签名验证】  
601 - * 查询指定table的 text code 获取字典,包含text和value  
602 - * @param table  
603 - * @param text  
604 - * @param code  
605 - * @param keyArray  
606 - * @return  
607 - */  
608 - @Deprecated  
609 - @GetMapping("/queryTableDictByKeys")  
610 - public List<String> queryTableDictByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keyArray") String[] keyArray){  
611 - return sysBaseApi.queryTableDictByKeys(table, text, code, keyArray);  
612 - }  
613 -  
614 -  
615 - /**  
616 - * 字典表的 翻译【接口签名验证】  
617 - * @param table  
618 - * @param text  
619 - * @param code  
620 - * @param key  
621 - * @return  
622 - */  
623 - @GetMapping("/translateDictFromTable")  
624 - public String translateDictFromTable(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("key") String key){  
625 - return sysBaseApi.translateDictFromTable(table, text, code, key);  
626 - }  
627 -  
628 -  
629 - /**  
630 - * 【接口签名验证】  
631 - * 49 字典表的 翻译,可批量  
632 - *  
633 - * @param table  
634 - * @param text  
635 - * @param code  
636 - * @param keys 多个用逗号分割  
637 - * @return  
638 - */  
639 - @GetMapping("/translateDictFromTableByKeys")  
640 - public List<DictModel> translateDictFromTableByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keys") String keys) {  
641 - return this.sysBaseApi.translateDictFromTableByKeys(table, text, code, keys);  
642 - }  
643 -  
644 -}  
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/cas/util/CASServiceUtil.java deleted
1 -package org.jeecg.modules.cas.util;  
2 -  
3 -import java.io.BufferedReader;  
4 -import java.io.IOException;  
5 -import java.io.InputStreamReader;  
6 -import java.security.cert.X509Certificate;  
7 -  
8 -import javax.net.ssl.SSLContext;  
9 -import javax.net.ssl.TrustManager;  
10 -import javax.net.ssl.X509TrustManager;  
11 -  
12 -import org.apache.http.HttpResponse;  
13 -import org.apache.http.client.methods.HttpGet;  
14 -import org.apache.http.conn.socket.LayeredConnectionSocketFactory;  
15 -import org.apache.http.conn.ssl.SSLConnectionSocketFactory;  
16 -import org.apache.http.impl.client.CloseableHttpClient;  
17 -import org.apache.http.impl.client.HttpClients;  
18 -  
19 -/**  
20 - * @Description: CASServiceUtil  
21 - * @author: jeecg-boot  
22 - */  
23 -public class CASServiceUtil {  
24 -  
25 - public static void main(String[] args) {  
26 - String serviceUrl = "https://cas.8f8.com.cn:8443/cas/p3/serviceValidate";  
27 - String service = "http://localhost:3003/user/login";  
28 - String ticket = "ST-5-1g-9cNES6KXNRwq-GuRET103sm0-DESKTOP-VKLS8B3";  
29 - String res = getSTValidate(serviceUrl,ticket, service);  
30 -  
31 - System.out.println("---------res-----"+res);  
32 - }  
33 -  
34 -  
35 - /**  
36 - * 验证ST  
37 - */  
38 - public static String getSTValidate(String url,String st, String service){  
39 - try {  
40 - url = url+"?service="+service+"&ticket="+st;  
41 - CloseableHttpClient httpclient = createHttpClientWithNoSsl();  
42 - HttpGet httpget = new HttpGet(url);  
43 - HttpResponse response = httpclient.execute(httpget);  
44 - String res = readResponse(response);  
45 - return res == null ? null : (res == "" ? null : res);  
46 - } catch (Exception e) {  
47 - e.printStackTrace();  
48 - }  
49 - return "";  
50 - }  
51 -  
52 -  
53 - /**  
54 - * 读取 response body 内容为字符串  
55 - *  
56 - * @param response  
57 - * @return  
58 - * @throws IOException  
59 - */  
60 - private static String readResponse(HttpResponse response) throws IOException {  
61 - BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));  
62 - String result = new String();  
63 - String line;  
64 - while ((line = in.readLine()) != null) {  
65 - result += line;  
66 - }  
67 - return result;  
68 - }  
69 -  
70 -  
71 - /**  
72 - * 创建模拟客户端(针对 https 客户端禁用 SSL 验证)  
73 - *  
74 - * @param cookieStore 缓存的 Cookies 信息  
75 - * @return  
76 - * @throws Exception  
77 - */  
78 - private static CloseableHttpClient createHttpClientWithNoSsl() throws Exception {  
79 - // Create a trust manager that does not validate certificate chains  
80 - TrustManager[] trustAllCerts = new TrustManager[]{  
81 - new X509TrustManager() {  
82 - @Override  
83 - public X509Certificate[] getAcceptedIssuers() {  
84 - return null;  
85 - }  
86 -  
87 - @Override  
88 - public void checkClientTrusted(X509Certificate[] certs, String authType) {  
89 - // don't check  
90 - }  
91 -  
92 - @Override  
93 - public void checkServerTrusted(X509Certificate[] certs, String authType) {  
94 - // don't check  
95 - }  
96 - }  
97 - };  
98 -  
99 - SSLContext ctx = SSLContext.getInstance("TLS");  
100 - ctx.init(null, trustAllCerts, null);  
101 - LayeredConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(ctx);  
102 - return HttpClients.custom()  
103 - .setSSLSocketFactory(sslSocketFactory)  
104 - .build();  
105 - }  
106 -  
107 -}  
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oss/controller/OSSFileController.java deleted
1 -package org.jeecg.modules.oss.controller;  
2 -  
3 -import javax.servlet.http.HttpServletRequest;  
4 -  
5 -import org.apache.shiro.authz.annotation.RequiresRoles;  
6 -import org.jeecg.common.api.vo.Result;  
7 -import org.jeecg.common.system.query.QueryGenerator;  
8 -import org.jeecg.modules.oss.entity.OSSFile;  
9 -import org.jeecg.modules.oss.service.IOSSFileService;  
10 -import org.springframework.beans.factory.annotation.Autowired;  
11 -import org.springframework.stereotype.Controller;  
12 -import org.springframework.web.bind.annotation.*;  
13 -import org.springframework.web.multipart.MultipartFile;  
14 -  
15 -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;  
16 -import com.baomidou.mybatisplus.core.metadata.IPage;  
17 -import com.baomidou.mybatisplus.extension.plugins.pagination.Page;  
18 -  
19 -import lombok.extern.slf4j.Slf4j;  
20 -  
21 -/**  
22 - * 云存储示例 DEMO  
23 - * @author: jeecg-boot  
24 - */  
25 -@Slf4j  
26 -@Controller  
27 -@RequestMapping("/sys/oss/file")  
28 -public class OSSFileController {  
29 -  
30 - @Autowired  
31 - private IOSSFileService ossFileService;  
32 -  
33 - @ResponseBody  
34 - @GetMapping("/list")  
35 - public Result<IPage<OSSFile>> queryPageList(OSSFile file,  
36 - @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,  
37 - @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {  
38 - Result<IPage<OSSFile>> result = new Result<>();  
39 - QueryWrapper<OSSFile> queryWrapper = QueryGenerator.initQueryWrapper(file, req.getParameterMap());  
40 - Page<OSSFile> page = new Page<>(pageNo, pageSize);  
41 - IPage<OSSFile> pageList = ossFileService.page(page, queryWrapper);  
42 - result.setSuccess(true);  
43 - result.setResult(pageList);  
44 - return result;  
45 - }  
46 -  
47 - @ResponseBody  
48 - @PostMapping("/upload")  
49 - //@RequiresRoles("admin")  
50 - public Result upload(@RequestParam("file") MultipartFile multipartFile) {  
51 - Result result = new Result();  
52 - try {  
53 - ossFileService.upload(multipartFile);  
54 - result.success("上传成功!");  
55 - }  
56 - catch (Exception ex) {  
57 - log.info(ex.getMessage(), ex);  
58 - result.error500("上传失败");  
59 - }  
60 - return result;  
61 - }  
62 -  
63 - @ResponseBody  
64 - @DeleteMapping("/delete")  
65 - public Result delete(@RequestParam(name = "id") String id) {  
66 - Result result = new Result();  
67 - OSSFile file = ossFileService.getById(id);  
68 - if (file == null) {  
69 - result.error500("未找到对应实体");  
70 - }  
71 - else {  
72 - boolean ok = ossFileService.delete(file);  
73 - if (ok) {  
74 - result.success("删除成功!");  
75 - }  
76 - }  
77 - return result;  
78 - }  
79 -  
80 - /**  
81 - * 通过id查询.  
82 - */  
83 - @ResponseBody  
84 - @GetMapping("/queryById")  
85 - public Result<OSSFile> queryById(@RequestParam(name = "id") String id) {  
86 - Result<OSSFile> result = new Result<>();  
87 - OSSFile file = ossFileService.getById(id);  
88 - if (file == null) {  
89 - result.error500("未找到对应实体");  
90 - }  
91 - else {  
92 - result.setResult(file);  
93 - result.setSuccess(true);  
94 - }  
95 - return result;  
96 - }  
97 -  
98 -}  
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oss/entity/OSSFile.java deleted
1 -package org.jeecg.modules.oss.entity;  
2 -  
3 -import com.baomidou.mybatisplus.annotation.TableName;  
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.experimental.Accessors;  
7 -import org.jeecg.common.system.base.entity.JeecgEntity;  
8 -import org.jeecgframework.poi.excel.annotation.Excel;  
9 -  
10 -/**  
11 - * @Description: oss云存储实体类  
12 - * @author: jeecg-boot  
13 - */  
14 -@Data  
15 -@TableName("oss_file")  
16 -@EqualsAndHashCode(callSuper = false)  
17 -@Accessors(chain = true)  
18 -public class OSSFile extends JeecgEntity {  
19 -  
20 - private static final long serialVersionUID = 1L;  
21 -  
22 - @Excel(name = "文件名称")  
23 - private String fileName;  
24 -  
25 - @Excel(name = "文件地址")  
26 - private String url;  
27 -  
28 -}  
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oss/mapper/OSSFileMapper.java deleted
1 -package org.jeecg.modules.oss.mapper;  
2 -  
3 -import com.baomidou.mybatisplus.core.mapper.BaseMapper;  
4 -import org.jeecg.modules.oss.entity.OSSFile;  
5 -  
6 -/**  
7 - * @Description: oss云存储Mapper  
8 - * @author: jeecg-boot  
9 - */  
10 -public interface OSSFileMapper extends BaseMapper<OSSFile> {  
11 -  
12 -}  
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oss/service/IOSSFileService.java deleted
1 -package org.jeecg.modules.oss.service;  
2 -  
3 -import java.io.IOException;  
4 -  
5 -import com.baomidou.mybatisplus.extension.service.IService;  
6 -import org.jeecg.modules.oss.entity.OSSFile;  
7 -import org.springframework.web.multipart.MultipartFile;  
8 -  
9 -/**  
10 - * @Description: OOS云存储service接口  
11 - * @author: jeecg-boot  
12 - */  
13 -public interface IOSSFileService extends IService<OSSFile> {  
14 -  
15 - /**  
16 - * oss文件上传  
17 - * @param multipartFile  
18 - * @throws IOException  
19 - */  
20 - void upload(MultipartFile multipartFile) throws IOException;  
21 -  
22 - /**  
23 - * oss文件删除  
24 - * @param ossFile OSSFile对象  
25 - * @return  
26 - */  
27 - boolean delete(OSSFile ossFile);  
28 -  
29 -}  
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/oss/service/impl/OSSFileServiceImpl.java deleted
1 -package org.jeecg.modules.oss.service.impl;  
2 -  
3 -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;  
4 -import org.jeecg.common.util.CommonUtils;  
5 -import org.jeecg.common.util.oss.OssBootUtil;  
6 -import org.jeecg.modules.oss.entity.OSSFile;  
7 -import org.jeecg.modules.oss.mapper.OSSFileMapper;  
8 -import org.jeecg.modules.oss.service.IOSSFileService;  
9 -import org.springframework.stereotype.Service;  
10 -import org.springframework.web.multipart.MultipartFile;  
11 -  
12 -import java.io.IOException;  
13 -  
14 -/**  
15 - * @Description: OSS云存储实现类  
16 - * @author: jeecg-boot  
17 - */  
18 -@Service("ossFileService")  
19 -public class OSSFileServiceImpl extends ServiceImpl<OSSFileMapper, OSSFile> implements IOSSFileService {  
20 -  
21 - @Override  
22 - public void upload(MultipartFile multipartFile) throws IOException {  
23 - String fileName = multipartFile.getOriginalFilename();  
24 - fileName = CommonUtils.getFileName(fileName);  
25 - OSSFile ossFile = new OSSFile();  
26 - ossFile.setFileName(fileName);  
27 - String url = OssBootUtil.upload(multipartFile,"upload/test");  
28 - //update-begin--Author:scott Date:20201227 for:JT-361【文件预览】阿里云原生域名可以文件预览,自己映射域名kkfileview提示文件下载失败-------------------  
29 - // 返回阿里云原生域名前缀URL  
30 - ossFile.setUrl(OssBootUtil.getOriginalUrl(url));  
31 - //update-end--Author:scott Date:20201227 for:JT-361【文件预览】阿里云原生域名可以文件预览,自己映射域名kkfileview提示文件下载失败-------------------  
32 - this.save(ossFile);  
33 - }  
34 -  
35 - @Override  
36 - public boolean delete(OSSFile ossFile) {  
37 - try {  
38 - this.removeById(ossFile.getId());  
39 - OssBootUtil.deleteUrl(ossFile.getUrl());  
40 - }  
41 - catch (Exception ex) {  
42 - return false;  
43 - }  
44 - return true;  
45 - }  
46 -  
47 -}  
jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/util/XSSUtils.java deleted
1 -package org.jeecg.modules.system.util;  
2 -  
3 -import org.springframework.web.util.HtmlUtils;  
4 -  
5 -import java.util.regex.Pattern;  
6 -  
7 -/**  
8 - * @Description: 工具类XSSUtils,现在的做法是替换成空字符,CSDN的是进行转义,比如文字开头的"<"转成&lt;  
9 - * @author: lsq  
10 - * @date: 2021年07月26日 19:13  
11 - */  
12 -public class XSSUtils {  
13 - public static String striptXSS(String value) {  
14 - if (value != null) {  
15 - value = value.replaceAll(" ", "");  
16 - Pattern scriptPattern = Pattern.compile("<script>(.*?)</script>", Pattern.CASE_INSENSITIVE);  
17 - value = scriptPattern.matcher(value).replaceAll("");  
18 - scriptPattern = Pattern.compile("src[\r\n]*=[\r\n]*\\\'(.*?)\\\'", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);  
19 - value = scriptPattern.matcher(value).replaceAll("");  
20 - scriptPattern = Pattern.compile("src[\r\n]*=[\r\n]*\\\"(.*?)\\\"", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);  
21 - value = scriptPattern.matcher(value).replaceAll("");  
22 - scriptPattern = Pattern.compile("</script>", Pattern.CASE_INSENSITIVE);  
23 - value = scriptPattern.matcher(value).replaceAll("");  
24 - scriptPattern = Pattern.compile("<script(.*?)>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);  
25 - value = scriptPattern.matcher(value).replaceAll("");  
26 - scriptPattern = Pattern.compile("eval\\((.*?)\\)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);  
27 - value = scriptPattern.matcher(value).replaceAll("");  
28 - scriptPattern = Pattern.compile("e­xpression\\((.*?)\\)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);  
29 - value = scriptPattern.matcher(value).replaceAll("");  
30 - scriptPattern = Pattern.compile("javascript:", Pattern.CASE_INSENSITIVE);  
31 - value = scriptPattern.matcher(value).replaceAll("");  
32 - scriptPattern = Pattern.compile("vbscript:", Pattern.CASE_INSENSITIVE);  
33 - value = scriptPattern.matcher(value).replaceAll("");  
34 - scriptPattern = Pattern.compile("onload(.*?)=", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);  
35 - value = scriptPattern.matcher(value).replaceAll("");  
36 - }  
37 - return HtmlUtils.htmlEscape(value);  
38 - }  
39 -  
40 - public static void main(String[] args) {  
41 - String s = striptXSS("<img src=x onload=alert(111).*?><script></script>javascript:eval()\\\\.");  
42 - System.err.println("s======>" + s);  
43 - }  
44 -}