【fix sonar】 JobCodeController.java文件

This commit is contained in:
tianwenbo
2023-03-10 13:44:58 +08:00
parent dae47b7a95
commit b5e60923aa
@@ -24,7 +24,7 @@ import java.util.List;
@Controller @Controller
@RequestMapping("/jobcode") @RequestMapping("/jobcode")
public class JobCodeController { public class JobCodeController {
@Resource @Resource
private XxlJobInfoDao xxlJobInfoDao; private XxlJobInfoDao xxlJobInfoDao;
@Resource @Resource
@@ -52,34 +52,34 @@ public class JobCodeController {
model.addAttribute("jobLogGlues", jobLogGlues); model.addAttribute("jobLogGlues", jobLogGlues);
return "jobcode/jobcode.index"; return "jobcode/jobcode.index";
} }
@RequestMapping("/save") @RequestMapping("/save")
@ResponseBody @ResponseBody
public ReturnT<String> save(Model model, int id, String glueSource, String glueRemark) { public ReturnT<String> save(Model model, int id, String glueSource, String glueRemark) {
// valid // valid
if (glueRemark==null) { if (glueRemark==null) {
return new ReturnT<String>(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_glue_remark")) ); return new ReturnT<>(500, (I18nUtil.getString("system_please_input") + I18nUtil.getString("jobinfo_glue_remark")) );
} }
if (glueRemark.length()<4 || glueRemark.length()>100) { if (glueRemark.length()<4 || glueRemark.length()>100) {
return new ReturnT<String>(500, I18nUtil.getString("jobinfo_glue_remark_limit")); return new ReturnT<>(500, I18nUtil.getString("jobinfo_glue_remark_limit"));
} }
XxlJobInfo exists_jobInfo = xxlJobInfoDao.loadById(id); XxlJobInfo existsJobInfo = xxlJobInfoDao.loadById(id);
if (exists_jobInfo == null) { if (existsJobInfo == null) {
return new ReturnT<String>(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid")); return new ReturnT<>(500, I18nUtil.getString("jobinfo_glue_jobid_unvalid"));
} }
// update new code
exists_jobInfo.setGlueSource(glueSource);
exists_jobInfo.setGlueRemark(glueRemark);
exists_jobInfo.setGlueUpdatetime(new Date());
exists_jobInfo.setUpdateTime(new Date()); // update new code
xxlJobInfoDao.update(exists_jobInfo); existsJobInfo.setGlueSource(glueSource);
existsJobInfo.setGlueRemark(glueRemark);
existsJobInfo.setGlueUpdatetime(new Date());
existsJobInfo.setUpdateTime(new Date());
xxlJobInfoDao.update(existsJobInfo);
// log old code // log old code
XxlJobLogGlue xxlJobLogGlue = new XxlJobLogGlue(); XxlJobLogGlue xxlJobLogGlue = new XxlJobLogGlue();
xxlJobLogGlue.setJobId(exists_jobInfo.getId()); xxlJobLogGlue.setJobId(existsJobInfo.getId());
xxlJobLogGlue.setGlueType(exists_jobInfo.getGlueType()); xxlJobLogGlue.setGlueType(existsJobInfo.getGlueType());
xxlJobLogGlue.setGlueSource(glueSource); xxlJobLogGlue.setGlueSource(glueSource);
xxlJobLogGlue.setGlueRemark(glueRemark); xxlJobLogGlue.setGlueRemark(glueRemark);
@@ -88,9 +88,9 @@ public class JobCodeController {
xxlJobLogGlueDao.save(xxlJobLogGlue); xxlJobLogGlueDao.save(xxlJobLogGlue);
// remove code backup more than 30 // remove code backup more than 30
xxlJobLogGlueDao.removeOld(exists_jobInfo.getId(), 30); xxlJobLogGlueDao.removeOld(existsJobInfo.getId(), 30);
return ReturnT.SUCCESS; return ReturnT.SUCCESS;
} }
} }