注册添加必须要带学号,验证学号唯一

hehai
jiakun.lin 4 years ago
parent 3d94009027
commit 0d2ba8feb2
  1. 2
      src/main/java/com/msdw/tms/api/UserInfoControllerApi.java
  2. 23
      src/main/java/com/msdw/tms/controller/UserInfoController.java
  3. 4
      src/main/java/com/msdw/tms/dao/StudentDao.java
  4. 3
      src/main/java/com/msdw/tms/service/StudentService.java
  5. 18
      src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java
  6. 8
      src/main/resources/mapper/tms/StudentDao.xml

@ -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);

@ -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);
}
/**

@ -28,7 +28,7 @@ public interface StudentDao extends BaseMapper<StudentEntity> {
void updateWorkNumber(String workNumber,Integer studentId);
boolean addStudentInfo(UserInfoEntity userInfoEntity);
boolean addStudentInfo(StudentVo studentVo);
List<Integer> querySchoolName(String schoolAppellationName);
@ -37,4 +37,6 @@ public interface StudentDao extends BaseMapper<StudentEntity> {
int querySchoolAppellationName(String schoolAppellationName);
List<StudentVo> queryAccount(String account,Integer schoolId);
int queryStudentByWorkNumber(StudentVo studentVo);
}

@ -30,7 +30,7 @@ public interface StudentService extends IService<StudentEntity>{
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<StudentEntity>{
R queryAccount(String account,Integer schoolId);
int queryStudentByWorkNumber(StudentVo studentVo);
}

@ -122,18 +122,15 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> 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<StudentDao,StudentEntity> im
}
@Override
public int queryStudentByWorkNumber(StudentVo studentVo) {
return studentDao.queryStudentByWorkNumber(studentVo);
}
}

@ -94,9 +94,9 @@ WHERE
)
</insert>
<insert id="addStudentInfo">
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}
)
</insert>
<insert id="bacthAddStudents">
@ -146,4 +146,8 @@ WHERE
update student set workNumber = #{workNumber} where studentId = #{studentId}
</update>
<select id="queryStudentByWorkNumber" resultType="java.lang.Integer">
SELECT count(*) FROM student WHERE workNumber = #{workNumber} AND schoolId = #{schoolId} AND isdel = 0
</select>
</mapper>
Loading…
Cancel
Save