解决删除掉的考核依旧提示名称已存在

hehai
rong.liu 4 years ago
parent 63c5aac00b
commit fd9a20a400
  1. 55
      src/main/java/com/msdw/tms/controller/ExperimentalTeachingController.java

@ -28,12 +28,13 @@ public class ExperimentalTeachingController implements ExperimentalTeachingContr
/** /**
* 根据id查询实验班级详情 * 根据id查询实验班级详情
*/ */
@Override @Override
@GetMapping("/getById/{id}") @GetMapping("/getById/{id}")
public R getById(@PathVariable("id") Integer id){ public R getById(@PathVariable("id") Integer id) {
ExperimentalTeachingEntity et = experimentalTeachingService.getById(id); ExperimentalTeachingEntity et = experimentalTeachingService.getById(id);
return R.ok().put("ExperimentalTeaching", et); return R.ok().put("ExperimentalTeaching", et);
} }
/** /**
* 根据邀请码查询 * 根据邀请码查询
*/ */
@ -44,39 +45,40 @@ public class ExperimentalTeachingController implements ExperimentalTeachingContr
.eq("is_del", Constant.IsDel.NOT_DEL)); .eq("is_del", Constant.IsDel.NOT_DEL));
return R.ok().put("InvitationCode", one); return R.ok().put("InvitationCode", one);
} }
/** /**
* 查询 * 查询
*/ */
@Override @Override
@GetMapping("/list") @GetMapping("/list")
public R list(@RequestParam Integer page, @RequestParam Integer size, public R list(@RequestParam Integer page, @RequestParam Integer size,
Integer month, Integer type, Integer status,Integer systemId, String startTime, Integer month, Integer type, Integer status, Integer systemId, String startTime,
String stopTime, String searchContent,@RequestParam Integer schoolId){ String stopTime, String searchContent, @RequestParam Integer schoolId) {
ExperimentalTeachingVO vo = new ExperimentalTeachingVO(); ExperimentalTeachingVO vo = new ExperimentalTeachingVO();
vo.setSchoolId(schoolId); vo.setSchoolId(schoolId);
if (month!=null){ if (month != null) {
vo.setMonth(month); vo.setMonth(month);
} }
if (systemId!=null){ if (systemId != null) {
vo.setSystemId(systemId); vo.setSystemId(systemId);
} }
if (type!=null){ if (type != null) {
vo.setType(type); vo.setType(type);
} }
if (status!=null){ if (status != null) {
vo.setStatus(status); vo.setStatus(status);
} }
if (startTime!=null&&startTime!=""){ if (startTime != null && startTime != "") {
vo.setStartTime(startTime); vo.setStartTime(startTime);
} }
if (stopTime!=null&&startTime!=""){ if (stopTime != null && startTime != "") {
vo.setStopTime(stopTime); vo.setStopTime(stopTime);
} }
if (searchContent!=null&&searchContent!=""){ if (searchContent != null && searchContent != "") {
vo.setSearchContent(searchContent); vo.setSearchContent(searchContent);
} }
PageUtils list = experimentalTeachingService.queryExperimentalTeaching(page,size,vo); PageUtils list = experimentalTeachingService.queryExperimentalTeaching(page, size, vo);
return R.ok().put("list",list); return R.ok().put("list", list);
} }
/** /**
@ -84,7 +86,7 @@ public class ExperimentalTeachingController implements ExperimentalTeachingContr
*/ */
@Override @Override
@PostMapping("/save") @PostMapping("/save")
public R save(@RequestBody ExperimentalTeachingEntity experimentalTeachingEntity){ public R save(@RequestBody ExperimentalTeachingEntity experimentalTeachingEntity) {
experimentalTeachingService.save(experimentalTeachingEntity); experimentalTeachingService.save(experimentalTeachingEntity);
return R.ok(); return R.ok();
} }
@ -97,7 +99,7 @@ public class ExperimentalTeachingController implements ExperimentalTeachingContr
public R update(@RequestBody ExperimentalTeachingEntity experimentalTeachingEntity) throws ParseException { public R update(@RequestBody ExperimentalTeachingEntity experimentalTeachingEntity) throws ParseException {
//添加实验结束时间 //添加实验结束时间
ExperimentalTeachingEntity byId = experimentalTeachingService.getById(experimentalTeachingEntity.getId()); ExperimentalTeachingEntity byId = experimentalTeachingService.getById(experimentalTeachingEntity.getId());
if (byId.getType()==1){ if (byId.getType() == 1) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = byId.getExperimentDuration(); String time = byId.getExperimentDuration();
int d = time.indexOf("d"); int d = time.indexOf("d");
@ -106,11 +108,11 @@ public class ExperimentalTeachingController implements ExperimentalTeachingContr
int dd = Integer.parseInt(time.substring(0, d)); int dd = Integer.parseInt(time.substring(0, d));
int hh = Integer.parseInt(time.substring(d + 1, h)); int hh = Integer.parseInt(time.substring(d + 1, h));
int mm = Integer.parseInt(time.substring(h + 1, m)); 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(); Calendar nowTime = Calendar.getInstance();
Date date = new Date(); Date date = new Date();
nowTime.setTime(date); nowTime.setTime(date);
nowTime.add(Calendar.MINUTE,newTime); nowTime.add(Calendar.MINUTE, newTime);
experimentalTeachingEntity.setStopTime(sdf.format(nowTime.getTime())); experimentalTeachingEntity.setStopTime(sdf.format(nowTime.getTime()));
} }
experimentalTeachingService.updateById(experimentalTeachingEntity); experimentalTeachingService.updateById(experimentalTeachingEntity);
@ -123,7 +125,7 @@ public class ExperimentalTeachingController implements ExperimentalTeachingContr
*/ */
@Override @Override
@PostMapping("/delete") @PostMapping("/delete")
public R delete(@RequestBody Integer[] ids){ public R delete(@RequestBody Integer[] ids) {
//改为假删除tms_experimental_teaching //改为假删除tms_experimental_teaching
experimentalTeachingService.deleteTeachByIds(Arrays.asList(ids)); experimentalTeachingService.deleteTeachByIds(Arrays.asList(ids));
@ -132,10 +134,13 @@ public class ExperimentalTeachingController implements ExperimentalTeachingContr
@Override @Override
@GetMapping("/check") @GetMapping("/check")
public R checkExperimentalName(@RequestParam String experimentalName){ public R checkExperimentalName(@RequestParam String experimentalName) {
QueryWrapper<ExperimentalTeachingEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<ExperimentalTeachingEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("experimental_name",experimentalName); queryWrapper.eq("experimental_name", experimentalName);
if (experimentalTeachingService.count(queryWrapper)>0){return R.error(200,"实验名称不能重复");} queryWrapper.eq("is_del", 0);
if (experimentalTeachingService.count(queryWrapper) > 0) {
return R.error(200, "实验名称不能重复");
}
return R.ok(); return R.ok();
} }
// /** // /**

Loading…
Cancel
Save