|
@@ -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();
|
|
|
+ }
|
|
|
}
|