release: getLoginQr后端不再生成二维码,前端主动生成

release-2024-08-08
huangyw 4 months ago
parent fe44007049
commit 3504afe58c

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

Loading…
Cancel
Save