diff --git a/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java b/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java index 3c613fb..e89e3b0 100644 --- a/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java +++ b/src/main/java/com/yipin/liuwanr/controller/AssesmentController.java @@ -5,13 +5,7 @@ import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.yipin.liuwanr.entity.Assesment; import com.yipin.liuwanr.entity.Response; @@ -491,5 +485,45 @@ public class AssesmentController { } return resp; } + + @DeleteMapping("/deleteAssesment") + Response deleteAssesment(@RequestParam Integer assesmentId){ + Response resp = new Response(); + if(StringUtils.isEmpty(assesmentId)){ + resp.setStatus(300); + resp.setErrmessage("考核信息为空"); + }else{ + HashMap ret = service.deleteAssesment(assesmentId); + int status = (int) ret.get("retcode"); + if (200 == status) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + } + return resp; + } + + @GetMapping("/isNameExistis") + Response isNameExistis(@RequestParam String assesmentName){ + Response resp = new Response(); + if(StringUtils.isEmpty(assesmentName)){ + resp.setStatus(300); + resp.setErrmessage("考核信息为空"); + }else{ + HashMap ret = service.isNameExistis(assesmentName); + int status = (int) ret.get("retcode"); + if (200 == status) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + } + return resp; + } } diff --git a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java index ce567eb..4f9a82a 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java @@ -88,6 +88,10 @@ public interface AssesmentMapper { void insertAssesment(Assesment assesment); + @Delete("delete from assessment where id=#{id}") + boolean deleteAssesment(Integer assesmentId); + + /** * 修改考核 * @@ -151,10 +155,12 @@ public interface AssesmentMapper { * @param assesmentId * @param students */ - @Delete({""}) void deleteRecord(@Param("assesmentId") Integer assesmentId, @Param("students") List students); diff --git a/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java b/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java index 1526013..9c63ea0 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java @@ -215,7 +215,8 @@ public interface CourseMapper { * @param schoolId * @return */ - @Select("select c.courseId,courseName from course c left join hr_course_permissions cp on (c.courseId=cp.courseId) left join orders o on (cp.orderId=o.orderId) left join customer cu on(o.customerId=cu.customerId) where c.isdel=0 and c.isShelves=0 and cu.schoolId=#{schoolId} GROUP BY c.courseId") + @Select("select c.courseId,courseName from course c left join hr_course_permissions cp on (c.courseId=cp.courseId) left join orders o " + + " on (cp.orderId=o.orderId) left join customer cu on(o.customerId=cu.customerId) where c.isdel=0 and c.isShelves=0 and cu.schoolId=#{schoolId} GROUP BY c.courseId") List getBySchool(Integer schoolId); diff --git a/src/main/java/com/yipin/liuwanr/service/AssesmentService.java b/src/main/java/com/yipin/liuwanr/service/AssesmentService.java index e670df0..2884a07 100644 --- a/src/main/java/com/yipin/liuwanr/service/AssesmentService.java +++ b/src/main/java/com/yipin/liuwanr/service/AssesmentService.java @@ -627,4 +627,38 @@ public class AssesmentService { } + public HashMap deleteAssesment(Integer assesmentId) { + HashMap resp = new HashMap(); + try { + boolean relus=mapper.deleteAssesment(assesmentId); + if(relus){ + mapper.deleteRecord(assesmentId,null); + } + resp.put("retcode", 200); + }catch (RuntimeException e){ + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "DELETE Failed"); + return resp; + } + return resp; + } + + public HashMap isNameExistis(String assesmentName) { + HashMap resp = new HashMap(); + try { + Integer count=mapper.getByAssesmentName(assesmentName); + if(count!=null && count>1){ + resp.put("retvalue", "考核名称已存在"); + resp.put("retcode", 300); + } + resp.put("retcode", 200); + }catch (RuntimeException e){ + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "DELETE Failed"); + return resp; + } + return resp; + } }