diff --git a/src/main/java/cn/com/tenlion/service/teacher/impl/TeacherServiceImpl.java b/src/main/java/cn/com/tenlion/service/teacher/impl/TeacherServiceImpl.java index 35a9ce4..bf97c7a 100644 --- a/src/main/java/cn/com/tenlion/service/teacher/impl/TeacherServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/teacher/impl/TeacherServiceImpl.java @@ -91,16 +91,25 @@ public class TeacherServiceImpl extends DefaultBaseService implements ITeacherSe @Override public SuccessResultData save(String token, TeacherVO teacherVO) throws Exception { - // 同机构下讲师不可重复 String idCardNumber = teacherVO.getIdCardNumber(); if(idCardNumber == null || "".equals(idCardNumber)){ throw new SaveException("讲师证件号码不允许为空值"); } + if(teacherVO.getWorkerCategoryId() == null || "".equals(teacherVO.getWorkerCategoryId())){ + throw new SaveException("讲师授课工种不能为空值"); + } Map queryMap = getHashMap(8); + // 同工种下讲师不可重复,跨工种可以重复 + String WorkerCategoryIds[] = teacherVO.getWorkerCategoryId().split(","); queryMap.put("idCardNumber",idCardNumber); - TeacherDTO teacherDTO = teacherDao.get(queryMap); - if(teacherDTO != null && !"".equals(teacherDTO.getTeacherId())){ - throw new SaveException("您不能添加证件号码相同的讲师"); + for(int i = 0; i < WorkerCategoryIds.length;i++){ + queryMap.put("workerCategoryId",WorkerCategoryIds[i]); + TeacherDTO teacherDTO = teacherDao.get(queryMap); + if(teacherDTO != null && !"".equals(teacherDTO.getTeacherId())){ + throw new SaveException("该证件号码已在 【" + + teacherDTO.getWorkerCategoryName().split(",")[i] + + "】 工种中注册讲师"); + } } String teacherId = UUIDUtil.getUUID(); Map params = HashMapUtil.beanToMap(teacherVO); diff --git a/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml b/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml index 9df318d..0ca6bb2 100644 --- a/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml +++ b/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml @@ -162,6 +162,9 @@ AND t1.org_id = #{orgId} + + AND FIND_IN_SET( #{workerCategoryId},t1.worker_category_id) + AND t1.id_card_number = #{idCardNumber}