From 69c7102b59b1ec7f52b119ccb5cfd59013721c3f Mon Sep 17 00:00:00 2001 From: wans <747101512@qq.com> Date: Fri, 4 Jun 2021 17:10:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=8C=E5=B7=A5=E7=A7=8D?= =?UTF-8?q?=E4=B8=8B=E4=B8=8D=E5=8F=AF=E4=BB=A5=E5=AD=98=E5=9C=A8=E7=9B=B8?= =?UTF-8?q?=E5=90=8C=E8=BA=AB=E4=BB=BD=E8=AF=81=E5=8F=B7=E7=9A=84=E8=AE=B2?= =?UTF-8?q?=E5=B8=88=E7=9A=84=E6=A0=A1=E9=AA=8C=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teacher/impl/TeacherServiceImpl.java | 17 +++++++++++++---- .../mybatis/mapper/teacher/teacher-mapper.xml | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) 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}