|
@@ -1,5 +1,6 @@
|
|
|
package com.zhongzheng.controller.wx;
|
|
|
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
|
|
import com.zhongzheng.common.constant.Constants;
|
|
|
import com.zhongzheng.common.core.domain.AjaxResult;
|
|
@@ -7,6 +8,7 @@ import com.zhongzheng.common.core.domain.entity.SysMenu;
|
|
|
import com.zhongzheng.common.core.domain.entity.SysUser;
|
|
|
import com.zhongzheng.common.core.domain.model.LoginBody;
|
|
|
import com.zhongzheng.common.core.domain.model.LoginUser;
|
|
|
+import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
import com.zhongzheng.framework.web.service.*;
|
|
|
import com.zhongzheng.modules.system.service.ISysMenuService;
|
|
@@ -23,6 +25,7 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@Api(tags ="微信登录用户操作管理")
|
|
|
@ApiSupport(order = 2)
|
|
@@ -37,6 +40,8 @@ public class WxLoginController
|
|
|
|
|
|
@Autowired
|
|
|
private IUserService iUserService;
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
|
|
|
/**
|
|
|
* 登录方法
|
|
@@ -75,6 +80,22 @@ public class WxLoginController
|
|
|
return AjaxResult.success(openId);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation("小程序校验PC登录二维码")
|
|
|
+ @PostMapping("/scan_login_check")
|
|
|
+ public AjaxResult scan_login_check(@RequestParam("scanCode") String scanCode)
|
|
|
+ {
|
|
|
+ ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ String key = "SCAN_LOGIN_"+scanCode;
|
|
|
+ Long userId = redisCache.getCacheObject(key);
|
|
|
+ if(Validator.isNotEmpty(userId)){
|
|
|
+ redisCache.setCacheObject(key, loginUser.getUser().getUserId(),30, TimeUnit.SECONDS);//30秒锁定
|
|
|
+ return AjaxResult.success();
|
|
|
+ }else{
|
|
|
+ return AjaxResult.error("校验码不存在或已过期 ");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 公众号登录方法
|
|
|
*
|