Parcourir la source

注册BUG修复

anderx il y a 7 ans
Parent
commit
e8e70d2904

+ 13 - 0
src/main/java/com/goafanti/user/bo/InputUser.java

@@ -1,5 +1,7 @@
 package com.goafanti.user.bo;
 
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
 import javax.validation.constraints.Size;
 
 import com.goafanti.common.constant.ErrorConstants;
@@ -17,7 +19,18 @@ public class InputUser {
 
 	@Size(min = 0, max = 32, message = "{" + ErrorConstants.PARAM_SIZE_ERROR + "}")
 	private String	username;
+	@Max(value = 2, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	@Min(value = 0, message = "{" + ErrorConstants.PARAM_ERROR + "}")
+	private Integer	type;
 	
+	public Integer getType() {
+		return type;
+	}
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
 	public String getMobile() {
 		return mobile;
 	}

+ 4 - 7
src/main/java/com/goafanti/user/controller/UserRegisterController.java

@@ -65,7 +65,7 @@ public class UserRegisterController extends BaseController {
 					UserFields.getFieldDesc(bindingResult.getFieldError().getField())));
 			return res;
 		}
-		User u = userService.selectByNameAndType(user.getUsername().trim(), null);
+		User u = userService.selectByMobieAndType(user.getMobile().trim(),user.getType());
 		if (null != u) {
 			res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "用户已存在"));
 		}
@@ -81,7 +81,6 @@ public class UserRegisterController extends BaseController {
 		if (res.getError().isEmpty()) {
 			User us = new User();
 			us.setId(UUID.randomUUID().toString());
-			us.setUsername(user.getUsername().trim());
 			us.setMobile(user.getMobile().trim());
 			us.setPassword(user.getPassword());
 			Calendar now = Calendar.getInstance();
@@ -89,8 +88,7 @@ public class UserRegisterController extends BaseController {
 			us.setCreateTime(now.getTime());
 			us.setUpdateTime(now.getTime());
 			us.setPassword(passwordUtil.getEncryptPwd(us));
-			us.setLvl(0);
-			us.setNickname(user.getUsername());
+			us.setNickname(user.getUnitName());
 			us.setSource(AFTConstants.USER_SOURCE_REGISTER);
 			us.setStatus(AFTConstants.USER_STATUS_NORMAL);
 			us.setShareType(AFTConstants.USER_SHARE_PUBLIC);
@@ -119,7 +117,7 @@ public class UserRegisterController extends BaseController {
 					UserFields.getFieldDesc(bindingResult.getFieldError().getField())));
 			return res;
 		}
-		User u = userService.selectByNameAndType(user.getUsername().trim(), null);
+		User u = userService.selectByMobieAndType(user.getMobile().trim(),user.getType());
 		if (null != u) {
 			res.getError().add(buildError(ErrorConstants.USER_ALREADY_EXIST, "用户已存在"));
 		}
@@ -143,8 +141,7 @@ public class UserRegisterController extends BaseController {
 			us.setCreateTime(now.getTime());
 			us.setUpdateTime(now.getTime());
 			us.setPassword(passwordUtil.getEncryptPwd(us));
-			us.setLvl(0);
-			us.setNickname(user.getUsername());
+			us.setNickname(user.getUnitName());
 			us.setSource(AFTConstants.USER_SOURCE_REGISTER);
 			us.setStatus(AFTConstants.USER_STATUS_NORMAL);
 			us.setShareType(AFTConstants.USER_SHARE_PUBLIC);