|
|
@ -4,6 +4,7 @@ import annotation.GlobalInterceptor;
|
|
|
|
import annotation.VerifyParam;
|
|
|
|
import annotation.VerifyParam;
|
|
|
|
import api.Result;
|
|
|
|
import api.Result;
|
|
|
|
import api.StatusCode;
|
|
|
|
import api.StatusCode;
|
|
|
|
|
|
|
|
import cn.hutool.extra.qrcode.QrCodeUtil;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.luoo.user.dto.UserNameLoginDto;
|
|
|
|
import com.luoo.user.dto.UserNameLoginDto;
|
|
|
|
import com.luoo.user.dto.request.*;
|
|
|
|
import com.luoo.user.dto.request.*;
|
|
|
@ -365,7 +366,7 @@ public class LoginController extends BaseController {
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return 登录结果
|
|
|
|
* @return 登录结果
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ApiOperation(value = "通过用户名/密码登录")
|
|
|
|
@ApiOperation(value = "7.通过用户名/密码登录")
|
|
|
|
@PostMapping("/login/username")
|
|
|
|
@PostMapping("/login/username")
|
|
|
|
public Result loginByUserName(@Validated @RequestBody UserNameLoginDto userNameLoginDto) {
|
|
|
|
public Result loginByUserName(@Validated @RequestBody UserNameLoginDto userNameLoginDto) {
|
|
|
|
String userName = userNameLoginDto.getUserName();
|
|
|
|
String userName = userNameLoginDto.getUserName();
|
|
|
@ -388,11 +389,55 @@ public class LoginController extends BaseController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "修改密码")
|
|
|
|
@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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "9.1.获取UUID", notes = "获取UUID")
|
|
|
|
|
|
|
|
@GetMapping(value = "/uuid")
|
|
|
|
|
|
|
|
public Result<String> getUuid() {
|
|
|
|
|
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
|
|
|
|
|
return Result.success(uuid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "9.2.校验uuid对应的请求认证状态", notes = "0是未完成,其余是已完成状态的token")
|
|
|
|
|
|
|
|
@GetMapping(value = "/check/qr")
|
|
|
|
|
|
|
|
public Result<String> getCountryCode(String uuid) {
|
|
|
|
|
|
|
|
return Result.success(redisTemplate.opsForValue().get(uuid).toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
response.setHeader("uuid", uuid);
|
|
|
|
|
|
|
|
// 这里是开源工具类 hutool里的QrCodeUtil
|
|
|
|
|
|
|
|
// 网址:http://hutool.mydoc.io/
|
|
|
|
|
|
|
|
QrCodeUtil.generate(uuid, 300, 300, "jpg",response.getOutputStream());
|
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(uuid, 0, 60, TimeUnit.SECONDS);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "9.4.确认身份接口:确定身份以及判断是否二维码过期等", notes = "确认身份接口:确定身份以及判断是否二维码过期等")
|
|
|
|
|
|
|
|
@PostMapping(value = "/bindUserIdAndToken")
|
|
|
|
|
|
|
|
public Result<String> bindUserIdAndToken(@RequestParam("token") String token ,
|
|
|
|
|
|
|
|
@RequestParam("userId") String userId){
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
return Result.success(userInfoService.bindUserIdAndToken(userId,token));
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|