From 110729d9ab14cbca2dd46a2467b99370fa060a09 Mon Sep 17 00:00:00 2001 From: wans <747101512@qq.com> Date: Wed, 19 May 2021 10:59:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=8C=E6=9C=BA=E6=9E=84?= =?UTF-8?q?=E8=AE=B2=E5=B8=88=E4=BF=A1=E6=81=AF=E9=87=8D=E5=A4=8D=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tenlion/dao/teacher/ITeacherDao.java | 14 ++++---- .../teacher/impl/TeacherServiceImpl.java | 29 ++++++++++++++--- .../mybatis/mapper/teacher/teacher-mapper.xml | 32 +++++++++++++++++++ 3 files changed, 64 insertions(+), 11 deletions(-) diff --git a/src/main/java/cn/com/tenlion/dao/teacher/ITeacherDao.java b/src/main/java/cn/com/tenlion/dao/teacher/ITeacherDao.java index 2a3847b..1b7e24d 100644 --- a/src/main/java/cn/com/tenlion/dao/teacher/ITeacherDao.java +++ b/src/main/java/cn/com/tenlion/dao/teacher/ITeacherDao.java @@ -62,13 +62,6 @@ public interface ITeacherDao { */ Map count(Map params); - /** - * 根据身份证查询讲师授课列表 - * @param idCardNumber - * @return - */ - List> listTeacherLessonsTime(String idCardNumber); - /** * 保存讲师授课记录 * @param params @@ -81,4 +74,11 @@ public interface ITeacherDao { * @return */ List listTeacherLessonsTimeDTO(Map params); + + /** + * 查询将是信息 + * @param params + * @return + */ + TeacherDTO get(Map params); } 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 75313d6..26c1a73 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 @@ -18,6 +18,7 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import ink.wgink.common.base.DefaultBaseService; import ink.wgink.exceptions.RemoveException; +import ink.wgink.exceptions.SaveException; import ink.wgink.exceptions.SearchException; import ink.wgink.module.dictionary.pojo.dtos.DataDTO; import ink.wgink.module.dictionary.service.IDataService; @@ -68,11 +69,15 @@ public class TeacherServiceImpl extends DefaultBaseService implements ITeacherSe List dtos = teacherDao.list(page.getParams()); for (TeacherDTO item : dtos){ //处理性别 - DataDTO gender = dataService.get(item.getGender()); - item.setGenderName(gender.getDataName()); + if(item.getGender() != null && !"".equals(item.getGender())){ + DataDTO gender = dataService.get(item.getGender()); + item.setGenderName(gender.getDataName()); + } //处理学历 - DataDTO education = dataService.get(item.getEducation()); - item.setEducationName(education.getDataName()); + if(item.getEducation() != null && !"".equals(item.getEducation())){ + DataDTO education = dataService.get(item.getEducation()); + item.setEducationName(education.getDataName()); + } } PageInfo pageInfo = new PageInfo<>(dtos); return new SuccessResultList<>(dtos, pageInfo.getPageNum(), pageInfo.getTotal()); @@ -86,6 +91,22 @@ public class TeacherServiceImpl extends DefaultBaseService implements ITeacherSe @Override public SuccessResultData save(String token, TeacherVO teacherVO) throws Exception { + // 同机构下讲师不可重复 + String orgId = teacherVO.getOrgId(); + String idCardNumber = teacherVO.getIdCardNumber(); + if(orgId == null || "".equals(orgId)){ + throw new SaveException("机构ID缺失无法关联到所属机构"); + } + if(idCardNumber == null || "".equals(idCardNumber)){ + throw new SaveException("讲师证件号码不允许为空值"); + } + Map queryMap = getHashMap(8); + queryMap.put("orgId",orgId); + queryMap.put("idCardNumber",idCardNumber); + TeacherDTO teacherDTO = teacherDao.get(queryMap); + if(teacherDTO != null && !"".equals(teacherDTO.getTeacherId())){ + throw new SaveException("您不能添加证件号码相同的讲师"); + } String teacherId = UUIDUtil.getUUID(); Map params = HashMapUtil.beanToMap(teacherVO); params.put("teacherId", teacherId); diff --git a/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml b/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml index 92a1bce..1e09255 100644 --- a/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml +++ b/src/main/resources/mybatis/mapper/teacher/teacher-mapper.xml @@ -129,6 +129,38 @@ + + UPDATE e_teacher