【fix sonar】 SysAnnouncementSendController.java SysCategoryController.java 文件
This commit is contained in:
+5
-4
@@ -10,6 +10,7 @@ import com.jero.common.constant.CommonConstant;
|
||||
import com.jero.common.constant.CommonSendStatus;
|
||||
import com.jero.common.constant.WebsocketConst;
|
||||
import com.jero.common.system.api.ISysBaseAPI;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import com.jero.common.system.util.JwtUtil;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.RedisUtil;
|
||||
@@ -299,7 +300,7 @@ public class SysAnnouncementController {
|
||||
querySaWrapper.notInSql(SysAnnouncement::getId,"select annt_id from sys_announcement_send where user_id='"+userId+"'");
|
||||
//update-begin--Author:liusq Date:20210108 for: [JT-424] 【开源issue】bug处理--------------------
|
||||
List<SysAnnouncement> announcements = sysAnnouncementService.list(querySaWrapper);
|
||||
if(announcements.isEmpty()) {
|
||||
if(!announcements.isEmpty()) {
|
||||
for(int i=0;i<announcements.size();i++) {
|
||||
//update-begin--Author:wangshuai Date:20200803 for: 通知公告消息重复LOWCOD-759--------------------
|
||||
//因为websocket没有判断是否存在这个用户,要是判断会出现问题,故在此判断逻辑
|
||||
@@ -347,10 +348,10 @@ public class SysAnnouncementController {
|
||||
queryWrapper.eq(SysAnnouncement::getDelFlag,CommonConstant.DEL_FLAG_0);
|
||||
List<SysAnnouncement> pageList = sysAnnouncementService.list(queryWrapper);
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "系统通告列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysAnnouncement.class);
|
||||
mv.addObject(JeroController.FILE_NAME, "系统通告列表");
|
||||
mv.addObject(JeroController.CLASS, SysAnnouncement.class);
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("系统通告列表数据", "导出人:"+user.getRealname(), "导出信息"));
|
||||
mv.addObject(JeroController.PARAMS, new ExportParams("系统通告列表数据", "导出人:"+user.getRealname(), "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
|
||||
+53
-45
@@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
@@ -46,7 +48,8 @@ import java.util.stream.Collectors;
|
||||
public class SysCategoryController {
|
||||
@Autowired
|
||||
private ISysCategoryService sysCategoryService;
|
||||
|
||||
private String ERROE_MSG = "未找到对应实体";
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
* @param sysCategory
|
||||
@@ -63,15 +66,14 @@ public class SysCategoryController {
|
||||
if(oConvertUtils.isEmpty(sysCategory.getPid())){
|
||||
sysCategory.setPid("0");
|
||||
}
|
||||
Result<IPage<SysCategory>> result = new Result<IPage<SysCategory>>();
|
||||
|
||||
Result<IPage<SysCategory>> result = new Result<>();
|
||||
|
||||
//--author:os_chengtgen---date:20190804 -----for: 分类字典页面显示错误,issues:377--------start
|
||||
//QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, req.getParameterMap());
|
||||
QueryWrapper<SysCategory> queryWrapper = new QueryWrapper<SysCategory>();
|
||||
QueryWrapper<SysCategory> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("pid", sysCategory.getPid());
|
||||
//--author:os_chengtgen---date:20190804 -----for: 分类字典页面显示错误,issues:377--------end
|
||||
|
||||
Page<SysCategory> page = new Page<SysCategory>(pageNo, pageSize);
|
||||
Page<SysCategory> page = new Page<>(pageNo, pageSize);
|
||||
IPage<SysCategory> pageList = sysCategoryService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
@@ -80,15 +82,15 @@ public class SysCategoryController {
|
||||
|
||||
@GetMapping(value = "/childList")
|
||||
public Result<List<SysCategory>> queryPageList(SysCategory sysCategory,HttpServletRequest req) {
|
||||
Result<List<SysCategory>> result = new Result<List<SysCategory>>();
|
||||
Result<List<SysCategory>> result = new Result<>();
|
||||
QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, req.getParameterMap());
|
||||
List<SysCategory> list = sysCategoryService.list(queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(list);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param sysCategory
|
||||
@@ -105,7 +107,7 @@ public class SysCategoryController {
|
||||
return Result.error("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param sysCategory
|
||||
@@ -116,13 +118,13 @@ public class SysCategoryController {
|
||||
public Result<Object> edit(@RequestBody SysCategory sysCategory) {
|
||||
SysCategory sysCategoryEntity = sysCategoryService.getById(sysCategory.getId());
|
||||
if(sysCategoryEntity==null) {
|
||||
return Result.error("未找到对应实体");
|
||||
return Result.error(ERROE_MSG);
|
||||
}else {
|
||||
sysCategoryService.updateSysCategory(sysCategory);
|
||||
return Result.OK("操作成功!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
* @param id
|
||||
@@ -133,13 +135,13 @@ public class SysCategoryController {
|
||||
public Result<Object> delete(@RequestParam(name="id",required=true) String id) {
|
||||
SysCategory sysCategory = sysCategoryService.getById(id);
|
||||
if(sysCategory==null) {
|
||||
return Result.error("未找到对应实体");
|
||||
return Result.error(ERROE_MSG);
|
||||
}else {
|
||||
this.sysCategoryService.deleteSysCategory(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param ids
|
||||
@@ -155,7 +157,7 @@ public class SysCategoryController {
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
* @param id
|
||||
@@ -166,7 +168,7 @@ public class SysCategoryController {
|
||||
public Result<SysCategory> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
SysCategory sysCategory = sysCategoryService.getById(id);
|
||||
if(sysCategory==null) {
|
||||
return Result.error("未找到对应实体");
|
||||
return Result.error(ERROE_MSG);
|
||||
}else {
|
||||
return Result.OK(sysCategory);
|
||||
}
|
||||
@@ -195,10 +197,10 @@ public class SysCategoryController {
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
|
||||
}
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "分类字典列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysCategory.class);
|
||||
mv.addObject(JeroController.FILE_NAME, "分类字典列表");
|
||||
mv.addObject(JeroController.CLASS, SysCategory.class);
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("分类字典列表数据", "导出人:"+user.getRealname(), "导出信息"));
|
||||
mv.addObject(JeroController.PARAMS, new ExportParams("分类字典列表数据", "导出人:"+user.getRealname(), "导出信息"));
|
||||
return mv;
|
||||
}
|
||||
|
||||
@@ -210,8 +212,9 @@ public class SysCategoryController {
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("sys:category:import")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
// @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
@PostMapping("/importExcel")
|
||||
public Result<T> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
@@ -254,20 +257,21 @@ public class SysCategoryController {
|
||||
}
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 加载单个数据 用于回显
|
||||
*/
|
||||
@RequestMapping(value = "/loadOne", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/loadOne", method = RequestMethod.GET)
|
||||
@GetMapping("/loadOne")
|
||||
public Result<SysCategory> loadOne(@RequestParam(name="field") String field,@RequestParam(name="val") String val) {
|
||||
try {
|
||||
|
||||
QueryWrapper<SysCategory> query = new QueryWrapper<SysCategory>();
|
||||
|
||||
QueryWrapper<SysCategory> query = new QueryWrapper<>();
|
||||
query.eq(field, val);
|
||||
List<SysCategory> ls = this.sysCategoryService.list(query);
|
||||
if(ls==null || ls.size()==0) {
|
||||
if(ls==null || ls.isEmpty()) {
|
||||
return Result.error("查询无果");
|
||||
}else if(ls.size()>1) {
|
||||
return Result.error("查询数据异常,["+field+"]存在多个值:"+val);
|
||||
@@ -279,13 +283,13 @@ public class SysCategoryController {
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 加载节点的子数据
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET)
|
||||
@GetMapping("/loadTreeChildren")
|
||||
public Result<List<TreeSelectModel>> loadTreeChildren(@RequestParam(name="pid") String pid) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
Result<List<TreeSelectModel>> result = new Result<>();
|
||||
try {
|
||||
List<TreeSelectModel> ls = this.sysCategoryService.queryListByPid(pid);
|
||||
result.setResult(ls);
|
||||
@@ -297,13 +301,14 @@ public class SysCategoryController {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 加载一级节点/如果是同步 则所有数据
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET)
|
||||
@GetMapping("/loadTreeRoot")
|
||||
public Result<List<TreeSelectModel>> loadTreeRoot(@RequestParam(name="async") Boolean async,@RequestParam(name="pcode") String pcode) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
Result<List<TreeSelectModel>> result = new Result<>();
|
||||
try {
|
||||
List<TreeSelectModel> ls = this.sysCategoryService.queryListByCode(pcode);
|
||||
if(!async) {
|
||||
@@ -318,12 +323,12 @@ public class SysCategoryController {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void loadAllCategoryChildren(List<TreeSelectModel> ls) {
|
||||
for (TreeSelectModel tsm : ls) {
|
||||
List<TreeSelectModel> temp = this.sysCategoryService.queryListByPid(tsm.getKey());
|
||||
if(temp!=null && temp.size()>0) {
|
||||
if(temp!=null && !temp.isEmpty()) {
|
||||
tsm.setChildren(temp);
|
||||
loadAllCategoryChildren(temp);
|
||||
}
|
||||
@@ -337,7 +342,7 @@ public class SysCategoryController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/checkCode")
|
||||
public Result<?> checkCode(@RequestParam(name="pid",required = false) String pid,@RequestParam(name="code",required = false) String code) {
|
||||
public Result<T> checkCode(@RequestParam(name="pid",required = false) String pid,@RequestParam(name="code",required = false) String code) {
|
||||
if(oConvertUtils.isEmpty(code)){
|
||||
return Result.error("错误,类型编码为空!");
|
||||
}
|
||||
@@ -361,9 +366,10 @@ public class SysCategoryController {
|
||||
* @param condition
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeData", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/loadTreeData", method = RequestMethod.GET)
|
||||
@GetMapping("/loadTreeData")
|
||||
public Result<List<TreeSelectModel>> loadDict(@RequestParam(name="pid",required = false) String pid,@RequestParam(name="pcode",required = false) String pcode, @RequestParam(name="condition",required = false) String condition) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
Result<List<TreeSelectModel>> result = new Result<>();
|
||||
//pid如果传值了 就忽略pcode的作用
|
||||
if(oConvertUtils.isEmpty(pid)){
|
||||
if(oConvertUtils.isEmpty(pcode)){
|
||||
@@ -400,7 +406,8 @@ public class SysCategoryController {
|
||||
* @param delNotExist 是否移除不存在的项,默认为true,设为false如果某个key不存在数据库中,则直接返回key本身
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadDictItem", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/loadDictItem", method = RequestMethod.GET)
|
||||
@GetMapping("/loadDictItem")
|
||||
public Result<List<String>> loadDictItem(@RequestParam(name = "ids") String ids, @RequestParam(name = "delNotExist", required = false, defaultValue = "true") boolean delNotExist) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
// 非空判断
|
||||
@@ -421,20 +428,21 @@ public class SysCategoryController {
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadAllData", method = RequestMethod.GET)
|
||||
// @RequestMapping(value = "/loadAllData", method = RequestMethod.GET)
|
||||
@GetMapping("/loadAllData")
|
||||
public Result<List<DictModel>> loadAllData(@RequestParam(name="code",required = true) String code) {
|
||||
Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<SysCategory>();
|
||||
Result<List<DictModel>> result = new Result<>();
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<>();
|
||||
if(oConvertUtils.isNotEmpty(code) && !"0".equals(code)){
|
||||
query.likeRight(SysCategory::getCode,code);
|
||||
}
|
||||
List<SysCategory> list = this.sysCategoryService.list(query);
|
||||
if(list==null || list.size()==0) {
|
||||
if(list==null || list.isEmpty()) {
|
||||
result.setMessage("无数据,参数有误.[code]");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
List<DictModel> rdList = new ArrayList<DictModel>();
|
||||
List<DictModel> rdList = new ArrayList<>();
|
||||
for (SysCategory c : list) {
|
||||
rdList.add(new DictModel(c.getId(),c.getName()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user