|
|
@ -24,9 +24,11 @@ import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.apache.commons.lang.ObjectUtils;
|
|
|
|
import org.apache.commons.lang.ObjectUtils;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@ -47,9 +49,11 @@ import java.util.concurrent.TimeUnit;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@CrossOrigin
|
|
|
|
@CrossOrigin
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
@RequestMapping("/user")
|
|
|
|
@RequestMapping("/user")
|
|
|
|
@Api(tags = "LoginController")
|
|
|
|
@Api(tags = "LoginController")
|
|
|
|
public class LoginController extends BaseController {
|
|
|
|
public class LoginController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
private static final List<CountryCodeDTO> DEFAULT_SUPPORTED_COUNTRY_CODES = Arrays
|
|
|
|
private static final List<CountryCodeDTO> DEFAULT_SUPPORTED_COUNTRY_CODES = Arrays
|
|
|
|
.asList(new CountryCodeDTO("中国", "+86"));
|
|
|
|
.asList(new CountryCodeDTO("中国", "+86"));
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
@ -64,6 +68,9 @@ public class LoginController extends BaseController {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private JwtUtil jwtUtil;
|
|
|
|
private JwtUtil jwtUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${download.url}")
|
|
|
|
|
|
|
|
private String downloadUrl;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 更新好友粉丝数和用户关注数
|
|
|
|
* 更新好友粉丝数和用户关注数
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -71,7 +78,8 @@ public class LoginController extends BaseController {
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PutMapping("/{userid}/{friendid}/{x}")
|
|
|
|
@PutMapping("/{userid}/{friendid}/{x}")
|
|
|
|
public void updatefanscountandfollowcount(@PathVariable String userid, @PathVariable String friendid,
|
|
|
|
public void updatefanscountandfollowcount(@PathVariable String userid,
|
|
|
|
|
|
|
|
@PathVariable String friendid,
|
|
|
|
@PathVariable int x) {
|
|
|
|
@PathVariable int x) {
|
|
|
|
userInfoService.updatefanscountandfollowcount(x, userid, friendid);
|
|
|
|
userInfoService.updatefanscountandfollowcount(x, userid, friendid);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -91,7 +99,8 @@ public class LoginController extends BaseController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!StringTools.isEmpty(sendSmsReq.getImageCheckCode())) {
|
|
|
|
if (!StringTools.isEmpty(sendSmsReq.getImageCheckCode())) {
|
|
|
|
// 得到缓存中的验证码
|
|
|
|
// 得到缓存中的验证码
|
|
|
|
String redisImageCheckCodeKey = Constants.REDIS_KEY_IMAGE_CHECK_CODE + sendSmsReq.getDeviceId();
|
|
|
|
String redisImageCheckCodeKey =
|
|
|
|
|
|
|
|
Constants.REDIS_KEY_IMAGE_CHECK_CODE + sendSmsReq.getDeviceId();
|
|
|
|
String redisImageCheckCode = (String) redisTemplate.opsForValue().get(redisImageCheckCodeKey);
|
|
|
|
String redisImageCheckCode = (String) redisTemplate.opsForValue().get(redisImageCheckCodeKey);
|
|
|
|
if (StringTools.isEmpty(redisImageCheckCode)) {
|
|
|
|
if (StringTools.isEmpty(redisImageCheckCode)) {
|
|
|
|
return Result.failed(StatusCode.USER_IMAGE_VERIFICATION_CODE_EXPIRED);
|
|
|
|
return Result.failed(StatusCode.USER_IMAGE_VERIFICATION_CODE_EXPIRED);
|
|
|
@ -141,8 +150,8 @@ public class LoginController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "2.1 appleId登录/注册", notes = "成功后返回authorization")
|
|
|
|
@ApiOperation(value = "2.1 appleId登录/注册", notes = "成功后返回authorization")
|
|
|
|
@PostMapping("/appleIdLogin")
|
|
|
|
@PostMapping("/appleIdLogin")
|
|
|
|
public Result<String> appleIdLogin(HttpServletRequest request, @VerifyParam AppleLoginReq appleLoginReq) {
|
|
|
|
public Result<String> appleIdLogin(HttpServletRequest request,
|
|
|
|
|
|
|
|
@VerifyParam AppleLoginReq appleLoginReq) {
|
|
|
|
|
|
|
|
|
|
|
|
// 无手机号和验证码
|
|
|
|
// 无手机号和验证码
|
|
|
|
String identityToken = appleLoginReq.getIdentityToken();
|
|
|
|
String identityToken = appleLoginReq.getIdentityToken();
|
|
|
@ -169,7 +178,6 @@ public class LoginController extends BaseController {
|
|
|
|
loginUserInfo.setLastUseDeviceBrand(appleLoginReq.getDeviceBrand());
|
|
|
|
loginUserInfo.setLastUseDeviceBrand(appleLoginReq.getDeviceBrand());
|
|
|
|
String token = userInfoService.appleLoginOrRegister(loginUserInfo);
|
|
|
|
String token = userInfoService.appleLoginOrRegister(loginUserInfo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Result.success(token);
|
|
|
|
return Result.success(token);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -177,13 +185,16 @@ public class LoginController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "2.2 微信wxId登录/注册", notes = "成功后返回authorization")
|
|
|
|
@ApiOperation(value = "2.2 微信wxId登录/注册", notes = "成功后返回authorization")
|
|
|
|
@PostMapping("/wxIdLogin")
|
|
|
|
@PostMapping("/wxIdLogin")
|
|
|
|
public Result<String> wxIdLogin(HttpServletRequest request, @VerifyParam WeChatLoginReq weChatLoginReq) {
|
|
|
|
public Result<String> wxIdLogin(HttpServletRequest request,
|
|
|
|
|
|
|
|
@VerifyParam WeChatLoginReq weChatLoginReq) {
|
|
|
|
|
|
|
|
|
|
|
|
// 如果有手机号,是首次微信登录时绑定流程
|
|
|
|
// 如果有手机号,是首次微信登录时绑定流程
|
|
|
|
if (StringUtils.isNotEmpty(weChatLoginReq.getMobile())) {
|
|
|
|
if (StringUtils.isNotEmpty(weChatLoginReq.getMobile())) {
|
|
|
|
//得到缓存中的验证码
|
|
|
|
//得到缓存中的验证码
|
|
|
|
String redisMobileCheckCodeKey = Constants.REDIS_KEY_MOBILE_CHECK_CODE + weChatLoginReq.getDeviceId();
|
|
|
|
String redisMobileCheckCodeKey =
|
|
|
|
String redisMobileCheckCode = (String) redisTemplate.opsForValue().get(redisMobileCheckCodeKey);
|
|
|
|
Constants.REDIS_KEY_MOBILE_CHECK_CODE + weChatLoginReq.getDeviceId();
|
|
|
|
|
|
|
|
String redisMobileCheckCode = (String) redisTemplate.opsForValue()
|
|
|
|
|
|
|
|
.get(redisMobileCheckCodeKey);
|
|
|
|
if (StringTools.isEmpty(redisMobileCheckCode)) {
|
|
|
|
if (StringTools.isEmpty(redisMobileCheckCode)) {
|
|
|
|
return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_EXPIRED);
|
|
|
|
return Result.failed(StatusCode.USER_MOBILE_VERIFICATION_CODE_EXPIRED);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -294,7 +305,8 @@ public class LoginController extends BaseController {
|
|
|
|
public Result<String> autoLogin(HttpServletRequest request,
|
|
|
|
public Result<String> autoLogin(HttpServletRequest request,
|
|
|
|
@RequestHeader(value = "Authorization", required = false) String authorization,
|
|
|
|
@RequestHeader(value = "Authorization", required = false) String authorization,
|
|
|
|
@VerifyParam TokenRefreshReq tokenRefreshReq) {
|
|
|
|
@VerifyParam TokenRefreshReq tokenRefreshReq) {
|
|
|
|
return Result.success(userInfoService.autoLogin(authorization, tokenRefreshReq.getDeviceId(), tokenRefreshReq.getDeviceBrand(), getIpAddr(request)));
|
|
|
|
return Result.success(userInfoService.autoLogin(authorization, tokenRefreshReq.getDeviceId(),
|
|
|
|
|
|
|
|
tokenRefreshReq.getDeviceBrand(), getIpAddr(request)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -359,7 +371,8 @@ public class LoginController extends BaseController {
|
|
|
|
@ApiOperation(value = "6.退出登录")
|
|
|
|
@ApiOperation(value = "6.退出登录")
|
|
|
|
@PostMapping("/logout")
|
|
|
|
@PostMapping("/logout")
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
@GlobalInterceptor(checkAppUserLogin = true)
|
|
|
|
public Result<Void> logout(@RequestHeader(value = "Authorization", required = true) String authorization) {
|
|
|
|
public Result<Void> logout(
|
|
|
|
|
|
|
|
@RequestHeader(value = "Authorization", required = true) String authorization) {
|
|
|
|
return Result.success();
|
|
|
|
return Result.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -394,7 +407,8 @@ public class LoginController extends BaseController {
|
|
|
|
@ApiOperation(value = "8.修改密码")
|
|
|
|
@ApiOperation(value = "8.修改密码")
|
|
|
|
@PostMapping("/changePassword")
|
|
|
|
@PostMapping("/changePassword")
|
|
|
|
public Result<Void> changePassword(@Validated @RequestBody UserNameLoginDto changePasswordDto) {
|
|
|
|
public Result<Void> changePassword(@Validated @RequestBody UserNameLoginDto changePasswordDto) {
|
|
|
|
userInfoService.changePassword(changePasswordDto.getUserName(), changePasswordDto.getPassword());
|
|
|
|
userInfoService.changePassword(changePasswordDto.getUserName(),
|
|
|
|
|
|
|
|
changePasswordDto.getPassword());
|
|
|
|
return Result.success();
|
|
|
|
return Result.success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -414,12 +428,8 @@ public class LoginController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "9.3.获取登录二维码、放入Token", notes = "前端获取二维码")
|
|
|
|
@ApiOperation(value = "9.3.获取登录二维码、放入Token", notes = "前端获取二维码")
|
|
|
|
@GetMapping(value = "/getLoginQr")
|
|
|
|
@GetMapping(value = "/getLoginQr")
|
|
|
|
public void createCodeImg(HttpServletRequest request, HttpServletResponse response, String uuid) {
|
|
|
|
public Result<String> createCodeImg(HttpServletRequest request, HttpServletResponse response,
|
|
|
|
response.setHeader("Pragma", "No-cache");
|
|
|
|
String uuid) {
|
|
|
|
response.setHeader("Cache-Control", "no-cache");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
response.setDateHeader("Expires", 0);
|
|
|
|
|
|
|
|
response.setContentType("image/jpeg");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
@ -431,14 +441,12 @@ public class LoginController extends BaseController {
|
|
|
|
throw new BizException("登录认证已完成");
|
|
|
|
throw new BizException("登录认证已完成");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
response.setHeader("uuid", uuid);
|
|
|
|
|
|
|
|
// 这里是开源工具类 hutool里的QrCodeUtil
|
|
|
|
|
|
|
|
// 网址:http://hutool.mydoc.io/
|
|
|
|
|
|
|
|
QrCodeUtil.generate(uuid, 300, 300, "jpg", response.getOutputStream());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info(downloadUrl);
|
|
|
|
|
|
|
|
return Result.success(uuid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "9.4.确认身份接口:确定身份以及判断是否二维码过期等", notes = "确认身份接口:确定身份以及判断是否二维码过期等")
|
|
|
|
@ApiOperation(value = "9.4.确认身份接口:确定身份以及判断是否二维码过期等", notes = "确认身份接口:确定身份以及判断是否二维码过期等")
|
|
|
|