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

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查询实验班级详情
*/
@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<ExperimentalTeachingEntity> 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();
}
// /**

Loading…
Cancel
Save