Преглед изворни кода

家长绑定学生,增加手机号字段

dzx пре 1 година
родитељ
комит
429db12ad6

+ 4 - 1
src/main/java/com/xjrsoft/module/organization/controller/UserController.java

@@ -723,7 +723,10 @@ public class UserController {
     public R bindStudent(@Valid @RequestBody UserStudentBindDto dto) {
         User user = userService.getOne(Wrappers.<User>query().lambda()
                 .eq(User::getName, dto.getName())
-                .eq(User::getCredentialNumber, dto.getIdCard()));
+                .eq(User::getCredentialNumber, dto.getIdCard())
+                .eq(User::getMobile, dto.getMobile())
+        );
+
         UserStudentAddDto userStudentAddDto = new UserStudentAddDto();
         if (user == null) {
             return R.error("学生不存在!");

+ 1 - 0
src/main/java/com/xjrsoft/module/organization/dto/UserStudentBindDto.java

@@ -7,4 +7,5 @@ public class UserStudentBindDto {
     private Long userId;
     private String name;
     private String idCard;
+    private String mobile;
 }

+ 4 - 2
src/main/java/com/xjrsoft/module/organization/service/impl/UserStudentServiceImpl.java

@@ -6,6 +6,7 @@ import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.xjrsoft.common.exception.MyException;
 import com.xjrsoft.module.organization.dto.UserStudentAddDto;
 import com.xjrsoft.module.organization.dto.UserStudentDeleteDto;
+import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.organization.entity.UserStudent;
 import com.xjrsoft.module.organization.mapper.UserStudentMapper;
 import com.xjrsoft.module.organization.service.IUserStudentService;
@@ -23,9 +24,10 @@ public class UserStudentServiceImpl extends MPJBaseServiceImpl<UserStudentMapper
     public boolean add(UserStudentAddDto dto) {
         long count = count(Wrappers.<UserStudent>query().lambda()
                 .eq(UserStudent::getUserId, dto.getUserId())
-                .eq(UserStudent::getStudentId, dto.getStudentId()));
+                .eq(UserStudent::getStudentId, dto.getStudentId())
+        );
         if (count > 0) {
-            throw new MyException("已经绑定了学生,不能出重复绑定");
+            throw new MyException("已经绑定了学生,不能出重复绑定");
         }
         UserStudent userStudent = BeanUtil.toBean(dto, UserStudent.class);
         userStudentMapper.insert(userStudent);