Browse Source

注册业务

zhoutg 6 years ago
parent
commit
b02ef46165

+ 2 - 1
user-service/src/main/java/com/diagbot/exception/ServiceErrorCode.java

@@ -16,7 +16,8 @@ public enum ServiceErrorCode implements ErrorCode {
     SMS_SEND_ERROR("10020004", "短信发送错误!"),
     USER_BIND_ERROR("10020005", "用户手机号已经绑定无需再次验证!"),
     USER_UN_BIND_ERROR("10020006", "用户手机号未绑定无需解绑!"),
-    VERIFYCODE_ERROR("10020007", "图片验证码生成错误!");
+    VERIFYCODE_ERROR("10020007", "图片验证码生成错误!"),
+    USER_EXIST("10020008", "该手机已注册!");
 
     private String code;
     private String msg;

+ 4 - 0
user-service/src/main/java/com/diagbot/facade/UserFacade.java

@@ -32,6 +32,10 @@ public class UserFacade extends UserServiceImpl {
     AuthServiceClient authServiceClient;
 
     public User createUser(User user){
+        User bean = findByName(user.getUsername());
+        if(bean != null) {
+            throw new CommonException(ServiceErrorCode.USER_EXIST);
+        }
         PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
         String entryPassword= passwordEncoder.encode(user.getPassword());
         user.setPassword(entryPassword);