woody 1 год назад
Родитель
Сommit
2bc65e588c

+ 27 - 11
src/main/java/com/chelvc/cloud/maintain/controller/AuthorizeController.java

@@ -6,12 +6,15 @@ import com.chelvc.cloud.maintain.param.MobileParam;
 import com.chelvc.cloud.uc.api.AuthorizeClient;
 import com.chelvc.cloud.uc.api.model.Authorization;
 import com.chelvc.cloud.uc.api.param.AuthorizeParam;
+import com.chelvc.cloud.uc.api.service.UserService;
 import com.chelvc.framework.base.annotation.ResponseWrapping;
 import com.chelvc.framework.oauth.annotation.Authorize;
 import com.chelvc.framework.sms.CaptchaSmsHandler;
 import com.chelvc.framework.sms.SmsSession;
 import lombok.RequiredArgsConstructor;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
@@ -24,22 +27,13 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 @ResponseWrapping
-@Authorize(enabled = false)
 @RequiredArgsConstructor(onConstructor = @__(@Autowired))
 public class AuthorizeController {
     private final AuthorizeClient authorizeClient;
     private final CaptchaSmsHandler captchaSmsHandler;
 
-    /**
-     * 发送验证码短信
-     *
-     * @param param 手机号参数
-     * @return 短信会话信息
-     */
-    @PostMapping("/sms/captcha")
-    public SmsSession sendCaptcha(@RequestBody @Valid MobileParam param) {
-        return this.captchaSmsHandler.send(param.getMobile());
-    }
+    @DubboReference
+    private UserService userService;
 
     /**
      * 短信登陆
@@ -47,17 +41,31 @@ public class AuthorizeController {
      * @param param 登陆参数
      * @return 认证信息
      */
+    @Authorize(enabled = false)
     @PostMapping("/login/sms")
     public Authorization loginWithSms(@RequestBody @Valid AuthorizeParam.Sms param) {
         return this.authorizeClient.authorize(param);
     }
 
+    /**
+     * 发送短信登陆验证码
+     *
+     * @param param 手机号参数
+     * @return 短信会话信息
+     */
+    @Authorize(enabled = false)
+    @PostMapping("/login/sms/captcha")
+    public SmsSession sendCaptcha(@RequestBody @Valid MobileParam param) {
+        return this.captchaSmsHandler.send(param.getMobile());
+    }
+
     /**
      * 微信登陆
      *
      * @param param 登陆参数
      * @return 认证信息
      */
+    @Authorize(enabled = false)
     @PostMapping("/login/wechat")
     public Authorization loginWithWechat(@RequestBody @Valid AuthorizeParam.Wechat param) {
         return this.authorizeClient.authorize(param);
@@ -83,4 +91,12 @@ public class AuthorizeController {
     public void logout(@RequestBody @Valid AuthorizeParam param) {
         this.authorizeClient.logout(param);
     }
+
+    /**
+     * 用户注销
+     */
+    @DeleteMapping("/unregister")
+    public void unregister() {
+        this.userService.unregister();
+    }
 }

+ 0 - 9
src/main/java/com/chelvc/cloud/maintain/controller/UserController.java

@@ -9,7 +9,6 @@ import com.chelvc.cloud.uc.api.service.UserService;
 import com.chelvc.framework.base.annotation.ResponseWrapping;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -47,12 +46,4 @@ public class UserController {
     public void updatePersonal(@RequestBody @Valid PersonalModifyParam param) {
         this.userService.updatePersonal(param);
     }
-
-    /**
-     * 用户注销
-     */
-    @DeleteMapping("/user/unregister")
-    public void unregister() {
-        this.userService.unregister();
-    }
 }

+ 7 - 0
src/main/resources/application-dev.yml

@@ -18,6 +18,13 @@ nacos:
 
 oauth:
   secret: oauth.token.secret@chelvc!@#2023
+  clients:
+    - id: chelvc_client
+      secret: chelvc@secret#2023!
+      scopes: ADMIN,CUSTOMER,MERCHANT
+      grants: sms,wechat,password,refresh_token
+      access-token-timeout: 3600
+      refresh-token-timeout: 86400
 
 upload:
   clients:

+ 7 - 0
src/main/resources/application-pre.yml

@@ -18,6 +18,13 @@ nacos:
 
 oauth:
   secret: oauth.token.secret@chelvc!@#2023
+  clients:
+    - id: chelvc_client
+      secret: chelvc@secret#2023!
+      scopes: ADMIN,CUSTOMER,MERCHANT
+      grants: sms,wechat,password,refresh_token
+      access-token-timeout: 3600
+      refresh-token-timeout: 86400
 
 upload:
   clients:

+ 7 - 0
src/main/resources/application-prod.yml

@@ -18,6 +18,13 @@ nacos:
 
 oauth:
   secret: oauth.token.secret@chelvc!@#2023
+  clients:
+    - id: chelvc_client
+      secret: chelvc@secret#2023!
+      scopes: ADMIN,CUSTOMER,MERCHANT
+      grants: sms,wechat,password,refresh_token
+      access-token-timeout: 3600
+      refresh-token-timeout: 86400
 
 upload:
   clients:

+ 7 - 0
src/main/resources/application-test.yml

@@ -18,6 +18,13 @@ nacos:
 
 oauth:
   secret: oauth.token.secret@chelvc!@#2023
+  clients:
+    - id: chelvc_client
+      secret: chelvc@secret#2023!
+      scopes: ADMIN,CUSTOMER,MERCHANT
+      grants: sms,wechat,password,refresh_token
+      access-token-timeout: 3600
+      refresh-token-timeout: 86400
 
 upload:
   clients:

+ 1 - 5
src/main/resources/application.yml

@@ -40,8 +40,4 @@ dubbo:
     group: ${spring.profiles.active}
     check: false
     timeout: 10000
-    retries: 0
-
-oauth:
-  resource:
-    permit: "/**/sms/**,/**/index,/**/configuration,/**/categories"
+    retries: 0