From 30ad4b516c76eda8e8ba353db431d169bc1083fa Mon Sep 17 00:00:00 2001 From: "zhiyong.ning" <354350178@qq.com> Date: Mon, 22 Mar 2021 15:27:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msdw/tms/api/StudentControllerApi.java | 3 ++ .../msdw/tms/api/UserInfoControllerApi.java | 3 ++ .../java/com/msdw/tms/config/SendSMS.java | 3 +- .../tms/controller/StudentController.java | 47 ++++++++++++++++++- .../tms/controller/UserInfoController.java | 47 +++++++++++++++++-- .../com/msdw/tms/entity/vo/StudentVo.java | 1 + .../com/msdw/tms/service/UserInfoService.java | 2 +- .../tms/service/impl/UserInfoServiceImpl.java | 4 +- 8 files changed, 100 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/msdw/tms/api/StudentControllerApi.java b/src/main/java/com/msdw/tms/api/StudentControllerApi.java index d4bd3da..db1438a 100644 --- a/src/main/java/com/msdw/tms/api/StudentControllerApi.java +++ b/src/main/java/com/msdw/tms/api/StudentControllerApi.java @@ -18,6 +18,9 @@ public interface StudentControllerApi { @ApiOperation(value = "新增学生",notes = "新增学生") public R addStudent(@RequestBody StudentVo studentVo); + @ApiOperation(value = "新增学生",notes = "新增学生") + public R zzAddStudent(@RequestBody StudentVo studentVo); + @ApiOperation(value = "学生列表信息",notes = "学生列表信息") public R queryStudent(Integer schoolId, String seachContent, Integer page, Integer size); diff --git a/src/main/java/com/msdw/tms/api/UserInfoControllerApi.java b/src/main/java/com/msdw/tms/api/UserInfoControllerApi.java index 037f505..7f84ee6 100644 --- a/src/main/java/com/msdw/tms/api/UserInfoControllerApi.java +++ b/src/main/java/com/msdw/tms/api/UserInfoControllerApi.java @@ -26,6 +26,9 @@ public interface UserInfoControllerApi { @ApiOperation(value = "注册",notes = "注册") R save(UserInfoEntity entity,@ApiParam(value = "学号",required = true)String workNumber); + @ApiOperation(value = "注册",notes = "注册") + R zzAdd(UserInfoEntity entity,@ApiParam(value = "学号",required = true)String workNumber); + @ApiOperation(value = "个人中心信息展示",notes = "个人中心信息展示") R userInfo(Integer id); diff --git a/src/main/java/com/msdw/tms/config/SendSMS.java b/src/main/java/com/msdw/tms/config/SendSMS.java index f34eb41..aaf7a23 100644 --- a/src/main/java/com/msdw/tms/config/SendSMS.java +++ b/src/main/java/com/msdw/tms/config/SendSMS.java @@ -16,7 +16,7 @@ public class SendSMS { private static final String PHONSMSTEMPLATE = "SMS_204155294"; public static void main(String[] args){ - String mobile="17722612183";//需要接受短信验证码的手机号 + String mobile="12345678910";//需要接受短信验证码的手机号 // String sendTemplate="SMS_204155294";//短信模板ID,需要去阿里云平台申请,审核通过后方能使用,通常是以"SMS_"开头字符串 String code = (int)((Math.random() * 9 + 1) * 100000)+ "";//要发送给用户的短信验证码,行业通常使用六位纯数字 @@ -26,7 +26,6 @@ public class SendSMS { }else{ System.out.println("短信发送失败"); } - } /** * 通过阿里云平台发送短信,如果发送成功,返回"OK" ;否则返回的是错误信息 diff --git a/src/main/java/com/msdw/tms/controller/StudentController.java b/src/main/java/com/msdw/tms/controller/StudentController.java index 614c4b9..5f82491 100644 --- a/src/main/java/com/msdw/tms/controller/StudentController.java +++ b/src/main/java/com/msdw/tms/controller/StudentController.java @@ -40,13 +40,13 @@ public class StudentController implements StudentControllerApi{ private UserInfoService userInfoService; /** - * 新增学生 + * 职站新增学生 * @param studentVo * @return */ @Transactional @Override - @PostMapping("/addStudent") + @PostMapping("/zzAddStudent") public R addStudent(@RequestBody @Valid StudentVo studentVo){ studentVo.setSchoolId(ConstantUtils.Keda_schoolId); String account = studentVo.getAccount(); @@ -83,6 +83,49 @@ public class StudentController implements StudentControllerApi{ } } + /** + * 科大新增学生 + * @param studentVo + * @return + */ + @Transactional + @Override + @PostMapping("/addStudent") + public R zzAddStudent(@RequestBody @Valid StudentVo studentVo){ + String account = studentVo.getAccount(); + String phone = studentVo.getPhone(); + Integer schoolId = studentVo.getSchoolId(); + Integer result = studentService.queryStudentIdNumber(studentVo.getWorkNumber(),schoolId); + Integer res = userInfoService.queryStudentAccount(account,schoolId); + if (phone!=null&&phone!=""){ + Integer outcome = userInfoService.queryStudentPhone(phone); + if(outcome==1){ + return R.error("手机号不能重复,只能绑定一个用户"); + } + } + String email = studentVo.getEmail(); + if (result==1){ + return R.error("学号不能重复"); + }else if (res==1){ + return R.error("账号不能重复"); + } + else{ + UserInfoEntity userInfoList = new UserInfoEntity(); + + userInfoList.setAccount(account) + .setPhone(phone) + .setEmail(studentVo.getEmail()) + .setSchoolId(studentVo.getSchoolAppellationId()) + .setUserName(studentVo.getUserName()) + .setToken(new ConstantUtils().token); + userInfoService.saveUserInfo(userInfoList); + + studentVo.setUserId(userInfoList.getUserId()).setPlatformId(ConstantUtils.PLATFORMID);//暂时写死平台id(PlatformId) + boolean saveStudent = studentService.saveStudent(studentVo); + return saveStudent ? R.ok() : R.error(); + } + } + /** * 学生列表 * @param schoolId diff --git a/src/main/java/com/msdw/tms/controller/UserInfoController.java b/src/main/java/com/msdw/tms/controller/UserInfoController.java index b859d1a..3e1578d 100644 --- a/src/main/java/com/msdw/tms/controller/UserInfoController.java +++ b/src/main/java/com/msdw/tms/controller/UserInfoController.java @@ -62,7 +62,6 @@ public class UserInfoController implements UserInfoControllerApi { 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()); @@ -96,6 +95,48 @@ public class UserInfoController implements UserInfoControllerApi { return studentService.addStudentInfo(studentVo); } + /** + * 职站注册 + */ + @Override + @Transactional + @PostMapping("/zzAdd") + public R zzAdd(@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.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,"该手机号已被绑定"); + } + if (num == 1){ + return R.error(400,"该学号重复!"); + } + int userId = userInfoService.add(userInfoEntity); + if (userId==0){ + return R.error(400,"添加用户信息失败"); + } +// userInfoEntity.setUserId(userId); + studentVo.setUserId(userInfoEntity.getUserId()); + return studentService.addStudentInfo(studentVo); + } + /** * 修改 */ @@ -222,7 +263,7 @@ public class UserInfoController implements UserInfoControllerApi { @Override @GetMapping("/getUserId") public R getUserId(@RequestParam String token){ - Integer userId = userInfoService.getUserId(token); - return R.ok().put("userId", userId); + R result = userInfoService.getUserId(token); + return result; } } diff --git a/src/main/java/com/msdw/tms/entity/vo/StudentVo.java b/src/main/java/com/msdw/tms/entity/vo/StudentVo.java index e1daa44..1617a47 100644 --- a/src/main/java/com/msdw/tms/entity/vo/StudentVo.java +++ b/src/main/java/com/msdw/tms/entity/vo/StudentVo.java @@ -5,6 +5,7 @@ import com.msdw.tms.entity.UserInfoEntity; import lombok.Data; import lombok.experimental.Accessors; +import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import java.util.List; diff --git a/src/main/java/com/msdw/tms/service/UserInfoService.java b/src/main/java/com/msdw/tms/service/UserInfoService.java index b6b52dd..2948e42 100644 --- a/src/main/java/com/msdw/tms/service/UserInfoService.java +++ b/src/main/java/com/msdw/tms/service/UserInfoService.java @@ -48,6 +48,6 @@ public interface UserInfoService extends IService { R queryAccount(); - Integer getUserId(String token); + R getUserId(String token); } diff --git a/src/main/java/com/msdw/tms/service/impl/UserInfoServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/UserInfoServiceImpl.java index 392b2aa..a852738 100644 --- a/src/main/java/com/msdw/tms/service/impl/UserInfoServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/UserInfoServiceImpl.java @@ -223,8 +223,8 @@ public class UserInfoServiceImpl extends ServiceImpl