|
@@ -4,6 +4,8 @@ import com.caimei365.user.model.ResponseJson;
|
|
import com.caimei365.user.model.vo.UserLoginVo;
|
|
import com.caimei365.user.model.vo.UserLoginVo;
|
|
import com.caimei365.user.service.LoginService;
|
|
import com.caimei365.user.service.LoginService;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import io.swagger.annotations.ApiParam;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -33,8 +35,12 @@ public class LoginApi {
|
|
* @param password 密码
|
|
* @param password 密码
|
|
* @return BaseUser
|
|
* @return BaseUser
|
|
*/
|
|
*/
|
|
|
|
+ @ApiOperation("登录(用户名,密码)")
|
|
@PostMapping("/password")
|
|
@PostMapping("/password")
|
|
- public ResponseJson<UserLoginVo> passwordLogin(String mobileOrEmail, String password) {
|
|
|
|
|
|
+ public ResponseJson<UserLoginVo> passwordLogin(
|
|
|
|
+ @ApiParam(required = true, value = "手机号或邮箱") @RequestParam("mobileOrEmail") String mobileOrEmail,
|
|
|
|
+ @ApiParam(required = true, value = "密码") @RequestParam("password") String password
|
|
|
|
+ ) {
|
|
return loginService.passwordLogin(mobileOrEmail, password);
|
|
return loginService.passwordLogin(mobileOrEmail, password);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -47,8 +53,14 @@ public class LoginApi {
|
|
* @param encryptedData 微信加密数据
|
|
* @param encryptedData 微信加密数据
|
|
* @param iv 加密算法的初始向量
|
|
* @param iv 加密算法的初始向量
|
|
*/
|
|
*/
|
|
|
|
+ @ApiOperation("微信授权登录(小程序)")
|
|
@PostMapping("/auth/applets")
|
|
@PostMapping("/auth/applets")
|
|
- public ResponseJson<UserLoginVo> appletsAuthorization(String code, String encryptedData, String iv, @RequestHeader HttpHeaders headers) {
|
|
|
|
|
|
+ public ResponseJson<UserLoginVo> appletsAuthorization(
|
|
|
|
+ @ApiParam("微信授权code") @RequestParam("code") String code,
|
|
|
|
+ @ApiParam("微信加密数据") @RequestParam("encryptedData") String encryptedData,
|
|
|
|
+ @ApiParam("加密算法的初始向量") @RequestParam("iv") String iv,
|
|
|
|
+ @RequestHeader HttpHeaders headers
|
|
|
|
+ ) {
|
|
return loginService.appletsAuthorization(code, encryptedData, iv, headers);
|
|
return loginService.appletsAuthorization(code, encryptedData, iv, headers);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -60,8 +72,12 @@ public class LoginApi {
|
|
* @param redirectUri 用于微信授权的中间页面
|
|
* @param redirectUri 用于微信授权的中间页面
|
|
* @param mode 授权方式:1静默授权,其他手动同意授权
|
|
* @param mode 授权方式:1静默授权,其他手动同意授权
|
|
*/
|
|
*/
|
|
|
|
+ @ApiOperation("微信公众号授权链接(www)")
|
|
@GetMapping("/auth/link")
|
|
@GetMapping("/auth/link")
|
|
- public ResponseJson<String> getAuthorizationLink(String redirectUri, Integer mode) {
|
|
|
|
|
|
+ public ResponseJson<String> getAuthorizationLink(
|
|
|
|
+ @ApiParam("用于微信授权的中间页面") @RequestParam("redirectUri") String redirectUri,
|
|
|
|
+ @ApiParam("授权方式:1静默授权,其他手动同意授权") @RequestParam("mode") Integer mode
|
|
|
|
+ ) {
|
|
return loginService.getAuthorizationLink(redirectUri, mode);
|
|
return loginService.getAuthorizationLink(redirectUri, mode);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -74,8 +90,14 @@ public class LoginApi {
|
|
* @param state 安全认证
|
|
* @param state 安全认证
|
|
* @param mode 1:静默授权,2:用户手动授权
|
|
* @param mode 1:静默授权,2:用户手动授权
|
|
*/
|
|
*/
|
|
|
|
+ @ApiOperation("微信公众号授权登录(www)")
|
|
@GetMapping("/auth/website")
|
|
@GetMapping("/auth/website")
|
|
- public ResponseJson<UserLoginVo> websiteAuthorization(String code, String state, Integer mode, @RequestHeader HttpHeaders headers) {
|
|
|
|
|
|
+ public ResponseJson<UserLoginVo> websiteAuthorization(
|
|
|
|
+ @ApiParam("微信授权code") @RequestParam("code") String code,
|
|
|
|
+ @ApiParam("安全认证") @RequestParam("state") String state,
|
|
|
|
+ @ApiParam("1:静默授权,2:用户手动授权") @RequestParam("mode") Integer mode,
|
|
|
|
+ @RequestHeader HttpHeaders headers
|
|
|
|
+ ) {
|
|
return loginService.websiteAuthorization(code, state, mode, headers);
|
|
return loginService.websiteAuthorization(code, state, mode, headers);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -96,6 +118,7 @@ public class LoginApi {
|
|
*
|
|
*
|
|
* @return Map(appId,redirectUri,state)
|
|
* @return Map(appId,redirectUri,state)
|
|
*/
|
|
*/
|
|
|
|
+ @ApiOperation("获取生成微信二维码的参数")
|
|
@GetMapping("/auth/parameters")
|
|
@GetMapping("/auth/parameters")
|
|
public ResponseJson<Map<String, String>> getAuthParameters(){
|
|
public ResponseJson<Map<String, String>> getAuthParameters(){
|
|
return loginService.getAuthParameters();
|
|
return loginService.getAuthParameters();
|
|
@@ -109,8 +132,12 @@ public class LoginApi {
|
|
* @param code 微信code
|
|
* @param code 微信code
|
|
* @param state 安全认证key(第一步获取参数时自定义生成的uuid)
|
|
* @param state 安全认证key(第一步获取参数时自定义生成的uuid)
|
|
*/
|
|
*/
|
|
|
|
+ @ApiOperation("扫码后微信服务器回调")
|
|
@GetMapping("/auth/callback")
|
|
@GetMapping("/auth/callback")
|
|
- public void qrCodeAuthScan(String code, String state) {
|
|
|
|
|
|
+ public void qrCodeAuthScan(
|
|
|
|
+ @ApiParam("微信授权code") @RequestParam("code") String code,
|
|
|
|
+ @ApiParam("安全认证") @RequestParam("state") String state
|
|
|
|
+ ) {
|
|
loginService.qrCodeAuthScan(code, state);
|
|
loginService.qrCodeAuthScan(code, state);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -122,8 +149,11 @@ public class LoginApi {
|
|
* @param state 安全认证key(第一步获取参数时自定义生成的uuid)
|
|
* @param state 安全认证key(第一步获取参数时自定义生成的uuid)
|
|
* @return UserLoginVo
|
|
* @return UserLoginVo
|
|
*/
|
|
*/
|
|
|
|
+ @ApiOperation("校验扫码登录结果")
|
|
@GetMapping("/auth/scan/result")
|
|
@GetMapping("/auth/scan/result")
|
|
- public ResponseJson<UserLoginVo> qrCodeAuthScanResult(String state){
|
|
|
|
|
|
+ public ResponseJson<UserLoginVo> qrCodeAuthScanResult(
|
|
|
|
+ @ApiParam("安全认证") @RequestParam("state") String state
|
|
|
|
+ ){
|
|
return loginService.qrCodeAuthScanResult(state);
|
|
return loginService.qrCodeAuthScanResult(state);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -138,8 +168,14 @@ public class LoginApi {
|
|
* @param unionId 微信unionId
|
|
* @param unionId 微信unionId
|
|
* @return UserLoginVo
|
|
* @return UserLoginVo
|
|
*/
|
|
*/
|
|
|
|
+ @ApiOperation("运营人员邀请码授权登录")
|
|
@PostMapping("/auth/invitation")
|
|
@PostMapping("/auth/invitation")
|
|
- public ResponseJson<UserLoginVo> invitationCodeLogin(String invitationCode, String nickName, String avatarUrl, String unionId) {
|
|
|
|
|
|
+ public ResponseJson<UserLoginVo> invitationCodeLogin(
|
|
|
|
+ @ApiParam("邀请码") @RequestParam("invitationCode") String invitationCode,
|
|
|
|
+ @ApiParam("微信昵称") @RequestParam("nickName") String nickName,
|
|
|
|
+ @ApiParam("微信头像(headimgurl)") @RequestParam("avatarUrl") String avatarUrl,
|
|
|
|
+ @ApiParam("微信unionId") @RequestParam("unionId") String unionId
|
|
|
|
+ ) {
|
|
return loginService.invitationCodeLogin(invitationCode, nickName, avatarUrl, unionId);
|
|
return loginService.invitationCodeLogin(invitationCode, nickName, avatarUrl, unionId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -154,8 +190,14 @@ public class LoginApi {
|
|
* @param smsCode 微信unionId
|
|
* @param smsCode 微信unionId
|
|
* @return OperationPo
|
|
* @return OperationPo
|
|
*/
|
|
*/
|
|
|
|
+ @ApiOperation("运营人员绑定微信")
|
|
@PostMapping("/auth/wechat/bind")
|
|
@PostMapping("/auth/wechat/bind")
|
|
- public ResponseJson<UserLoginVo> operationBindWeChat(Integer userId, String mobile, String smsCode, String unionId) {
|
|
|
|
|
|
+ public ResponseJson<UserLoginVo> operationBindWeChat(
|
|
|
|
+ @ApiParam("要绑定的用户Id") @RequestParam("userId") Integer userId,
|
|
|
|
+ @ApiParam("手机号") @RequestParam("mobile") String mobile,
|
|
|
|
+ @ApiParam("手机验证码(verificationCode)") @RequestParam("smsCode") String smsCode,
|
|
|
|
+ @ApiParam("微信unionId") @RequestParam("unionId") String unionId
|
|
|
|
+ ) {
|
|
return loginService.operationBindWeChat(userId, mobile, smsCode, unionId);
|
|
return loginService.operationBindWeChat(userId, mobile, smsCode, unionId);
|
|
}
|
|
}
|
|
|
|
|