diff --git a/src/main/java/com/msdw/tms/api/UserInfoControllerApi.java b/src/main/java/com/msdw/tms/api/UserInfoControllerApi.java index 51edcf5..037f505 100644 --- a/src/main/java/com/msdw/tms/api/UserInfoControllerApi.java +++ b/src/main/java/com/msdw/tms/api/UserInfoControllerApi.java @@ -24,7 +24,7 @@ public interface UserInfoControllerApi { R getUserId(String token); @ApiOperation(value = "注册",notes = "注册") - R save(UserInfoEntity entity); + R save(UserInfoEntity entity,@ApiParam(value = "学号",required = true)String workNumber); @ApiOperation(value = "个人中心信息展示",notes = "个人中心信息展示") R userInfo(Integer id); diff --git a/src/main/java/com/msdw/tms/controller/UserInfoController.java b/src/main/java/com/msdw/tms/controller/UserInfoController.java index 5f9586a..f5bac50 100644 --- a/src/main/java/com/msdw/tms/controller/UserInfoController.java +++ b/src/main/java/com/msdw/tms/controller/UserInfoController.java @@ -8,6 +8,7 @@ import com.msdw.tms.entity.UserEntity; import com.msdw.tms.entity.UserInfoEntity; import com.msdw.tms.entity.UserPersonalFileEntity; import com.msdw.tms.entity.vo.CheckVo; +import com.msdw.tms.entity.vo.StudentVo; import com.msdw.tms.entity.vo.UserEntityVo; import com.msdw.tms.entity.vo.UserProsonalEntityVo; import com.msdw.tms.service.StudentService; @@ -58,27 +59,41 @@ public class UserInfoController implements UserInfoControllerApi { @Override @Transactional @PostMapping("/add") - public R save(@RequestBody UserInfoEntity userInfoEntity){ + public R save(@RequestBody UserInfoEntity userInfoEntity,@RequestParam String workNumber){ String token ="UT_"+ UUID.randomUUID().toString().replace("-", ""); userInfoEntity.setToken(token); userInfoEntity.setSchoolId(2105); Integer schoolId = userInfoEntity.getSchoolId(); Integer integer = userInfoService.queryStudentAccount(userInfoEntity.getAccount(),schoolId); Integer integer1 = userInfoService.queryStudentPhone(userInfoEntity.getPhone()); + + //新增学生 + StudentVo studentVo = new StudentVo(); + studentVo.setUserId(userInfoEntity.getUserId()); + studentVo.setRoleId(Integer.valueOf(userInfoEntity.getRoleId())); + studentVo.setSchoolId(schoolId); + studentVo.setIsdel(0); + studentVo.setWorkNumber(workNumber); + studentVo.setPlatformId(1); + //为1 学号有重复 + int num = studentService.queryStudentByWorkNumber(studentVo); + if (integer==1){ return R.error(400,"账号已存在"); } if (integer1==1){ - return R.error(400,"改手机号已被绑定"); + return R.error(400,"该手机号已被绑定"); + } + if (num == 1){ + return R.error(400,"该学号重复!"); } int userId = userInfoService.add(userInfoEntity); if (userId==0){ return R.error(400,"添加用户信息失败"); } // userInfoEntity.setUserId(userId); - studentService.addStudentInfo(userInfoEntity); - return R.ok(); + return studentService.addStudentInfo(studentVo); } /** diff --git a/src/main/java/com/msdw/tms/dao/StudentDao.java b/src/main/java/com/msdw/tms/dao/StudentDao.java index b426e78..1dff280 100644 --- a/src/main/java/com/msdw/tms/dao/StudentDao.java +++ b/src/main/java/com/msdw/tms/dao/StudentDao.java @@ -28,7 +28,7 @@ public interface StudentDao extends BaseMapper { void updateWorkNumber(String workNumber,Integer studentId); - boolean addStudentInfo(UserInfoEntity userInfoEntity); + boolean addStudentInfo(StudentVo studentVo); List querySchoolName(String schoolAppellationName); @@ -37,4 +37,6 @@ public interface StudentDao extends BaseMapper { int querySchoolAppellationName(String schoolAppellationName); List queryAccount(String account,Integer schoolId); + + int queryStudentByWorkNumber(StudentVo studentVo); } diff --git a/src/main/java/com/msdw/tms/service/StudentService.java b/src/main/java/com/msdw/tms/service/StudentService.java index 05d99e9..efc4e0e 100644 --- a/src/main/java/com/msdw/tms/service/StudentService.java +++ b/src/main/java/com/msdw/tms/service/StudentService.java @@ -30,7 +30,7 @@ public interface StudentService extends IService{ void updateWorkNumber(Integer studentId); - R addStudentInfo(UserInfoEntity userInfoEntity); + R addStudentInfo(StudentVo studentVo); void downloadFiles(HttpServletResponse response) throws IOException; @@ -40,4 +40,5 @@ public interface StudentService extends IService{ R queryAccount(String account,Integer schoolId); + int queryStudentByWorkNumber(StudentVo studentVo); } diff --git a/src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java index cca9696..e3a099d 100644 --- a/src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java @@ -122,18 +122,15 @@ public class StudentServiceImpl extends ServiceImpl im } @Override - public R addStudentInfo(UserInfoEntity userInfoEntity) { + public R addStudentInfo(StudentVo studentVo) { R r = new R(); - boolean result = studentDao.addStudentInfo(userInfoEntity); + boolean result = studentDao.addStudentInfo(studentVo); if (result==false){ - r.put("code",300); - r.put("errmessage","注册失败!"); - return r; + throw new RuntimeException();//添加失败,抛出运行时异常让外层事务回滚 }else{ - r.put("code",200); - r.put("errmessage","注册成功!"); - return r; + return R.ok("注册成功!"); } + } @Override @@ -310,4 +307,9 @@ public class StudentServiceImpl extends ServiceImpl im } + @Override + public int queryStudentByWorkNumber(StudentVo studentVo) { + return studentDao.queryStudentByWorkNumber(studentVo); + } + } diff --git a/src/main/resources/mapper/tms/AchievementManagementDao.xml b/src/main/resources/mapper/tms/AchievementManagementDao.xml index e408af8..621e937 100644 --- a/src/main/resources/mapper/tms/AchievementManagementDao.xml +++ b/src/main/resources/mapper/tms/AchievementManagementDao.xml @@ -498,11 +498,10 @@ et.creation_time AS creationTime, et.is_del FROM - tms_experimental_teaching et, - hr_project_management pm + tms_experimental_teaching et inner join + hr_project_management pm on et.project_id = pm.projectId WHERE user_id = #{userId} - AND et.project_id = pm.projectId AND pm.isdel = 0 and et.experimental_class_name like concat('%',#{searchContant},'%') or et.experimental_name like concat('%',#{searchContant},'%') or diff --git a/src/main/resources/mapper/tms/StudentDao.xml b/src/main/resources/mapper/tms/StudentDao.xml index e421705..6a11653 100644 --- a/src/main/resources/mapper/tms/StudentDao.xml +++ b/src/main/resources/mapper/tms/StudentDao.xml @@ -94,9 +94,9 @@ WHERE ) - INSERT INTO student(schoolId,userId,roleId,isdel,platformId) + INSERT INTO student(schoolId,userId,roleId,isdel,platformId,workNumber) VALUES - ( #{schoolId},#{userId},4,0,1 + ( #{schoolId},#{userId},#{roleId},#{isdel},#{platformId},#{workNumber} ) @@ -146,4 +146,8 @@ WHERE update student set workNumber = #{workNumber} where studentId = #{studentId} + + \ No newline at end of file diff --git a/src/main/resources/mapper/tms/UserDao.xml b/src/main/resources/mapper/tms/UserDao.xml index ba71046..f7508ac 100644 --- a/src/main/resources/mapper/tms/UserDao.xml +++ b/src/main/resources/mapper/tms/UserDao.xml @@ -19,6 +19,7 @@ u.IDNumber, u.documentType, u.educationDegree, + u.userAvatars, pro.provinceId, pro.provinceName, s.schoolId,