From fd9a20a4002774f42ee91e0ce6fd045eda830d99 Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Thu, 11 Mar 2021 10:41:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=88=A0=E9=99=A4=E6=8E=89?= =?UTF-8?q?=E7=9A=84=E8=80=83=E6=A0=B8=E4=BE=9D=E6=97=A7=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E5=B7=B2=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExperimentalTeachingController.java | 55 ++++++++++--------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/msdw/tms/controller/ExperimentalTeachingController.java b/src/main/java/com/msdw/tms/controller/ExperimentalTeachingController.java index 9b0d5ac..cf9cccf 100644 --- a/src/main/java/com/msdw/tms/controller/ExperimentalTeachingController.java +++ b/src/main/java/com/msdw/tms/controller/ExperimentalTeachingController.java @@ -28,12 +28,13 @@ public class ExperimentalTeachingController implements ExperimentalTeachingContr /** * 根据id查询实验班级详情 */ - @Override - @GetMapping("/getById/{id}") - public R getById(@PathVariable("id") Integer id){ - ExperimentalTeachingEntity et = experimentalTeachingService.getById(id); + @Override + @GetMapping("/getById/{id}") + public R getById(@PathVariable("id") Integer id) { + ExperimentalTeachingEntity et = experimentalTeachingService.getById(id); return R.ok().put("ExperimentalTeaching", et); - } + } + /** * 根据邀请码查询 */ @@ -44,39 +45,40 @@ public class ExperimentalTeachingController implements ExperimentalTeachingContr .eq("is_del", Constant.IsDel.NOT_DEL)); return R.ok().put("InvitationCode", one); } + /** * 查询 */ @Override @GetMapping("/list") public R list(@RequestParam Integer page, @RequestParam Integer size, - Integer month, Integer type, Integer status,Integer systemId, String startTime, - String stopTime, String searchContent,@RequestParam Integer schoolId){ + Integer month, Integer type, Integer status, Integer systemId, String startTime, + String stopTime, String searchContent, @RequestParam Integer schoolId) { ExperimentalTeachingVO vo = new ExperimentalTeachingVO(); vo.setSchoolId(schoolId); - if (month!=null){ + if (month != null) { vo.setMonth(month); } - if (systemId!=null){ + if (systemId != null) { vo.setSystemId(systemId); } - if (type!=null){ + if (type != null) { vo.setType(type); } - if (status!=null){ + if (status != null) { vo.setStatus(status); } - if (startTime!=null&&startTime!=""){ + if (startTime != null && startTime != "") { vo.setStartTime(startTime); } - if (stopTime!=null&&startTime!=""){ - vo.setStopTime(stopTime); + if (stopTime != null && startTime != "") { + vo.setStopTime(stopTime); } - if (searchContent!=null&&searchContent!=""){ + if (searchContent != null && searchContent != "") { vo.setSearchContent(searchContent); } - PageUtils list = experimentalTeachingService.queryExperimentalTeaching(page,size,vo); - return R.ok().put("list",list); + PageUtils list = experimentalTeachingService.queryExperimentalTeaching(page, size, vo); + return R.ok().put("list", list); } /** @@ -84,7 +86,7 @@ public class ExperimentalTeachingController implements ExperimentalTeachingContr */ @Override @PostMapping("/save") - public R save(@RequestBody ExperimentalTeachingEntity experimentalTeachingEntity){ + public R save(@RequestBody ExperimentalTeachingEntity experimentalTeachingEntity) { experimentalTeachingService.save(experimentalTeachingEntity); return R.ok(); } @@ -97,7 +99,7 @@ public class ExperimentalTeachingController implements ExperimentalTeachingContr public R update(@RequestBody ExperimentalTeachingEntity experimentalTeachingEntity) throws ParseException { //添加实验结束时间 ExperimentalTeachingEntity byId = experimentalTeachingService.getById(experimentalTeachingEntity.getId()); - if (byId.getType()==1){ + if (byId.getType() == 1) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String time = byId.getExperimentDuration(); int d = time.indexOf("d"); @@ -106,11 +108,11 @@ public class ExperimentalTeachingController implements ExperimentalTeachingContr int dd = Integer.parseInt(time.substring(0, d)); int hh = Integer.parseInt(time.substring(d + 1, h)); int mm = Integer.parseInt(time.substring(h + 1, m)); - int newTime = dd*24*60 + hh*60 + mm; + int newTime = dd * 24 * 60 + hh * 60 + mm; Calendar nowTime = Calendar.getInstance(); Date date = new Date(); nowTime.setTime(date); - nowTime.add(Calendar.MINUTE,newTime); + nowTime.add(Calendar.MINUTE, newTime); experimentalTeachingEntity.setStopTime(sdf.format(nowTime.getTime())); } experimentalTeachingService.updateById(experimentalTeachingEntity); @@ -123,7 +125,7 @@ public class ExperimentalTeachingController implements ExperimentalTeachingContr */ @Override @PostMapping("/delete") - public R delete(@RequestBody Integer[] ids){ + public R delete(@RequestBody Integer[] ids) { //改为假删除tms_experimental_teaching experimentalTeachingService.deleteTeachByIds(Arrays.asList(ids)); @@ -132,10 +134,13 @@ public class ExperimentalTeachingController implements ExperimentalTeachingContr @Override @GetMapping("/check") - public R checkExperimentalName(@RequestParam String experimentalName){ + public R checkExperimentalName(@RequestParam String experimentalName) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("experimental_name",experimentalName); - if (experimentalTeachingService.count(queryWrapper)>0){return R.error(200,"实验名称不能重复");} + queryWrapper.eq("experimental_name", experimentalName); + queryWrapper.eq("is_del", 0); + if (experimentalTeachingService.count(queryWrapper) > 0) { + return R.error(200, "实验名称不能重复"); + } return R.ok(); } // /**