|
|
@ -55,6 +55,50 @@ public class WxSvcLoginApi { |
|
|
|
|
|
|
|
private SysUserService sysUserService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 小程序登陆(暂测试) |
|
|
|
* @param wxLoginUser |
|
|
|
* @param request |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@SysLog(title = "小程序登录",biz = BizType.LOGIN,inter = InterType.API) |
|
|
|
@PostMapping("/ma") |
|
|
|
public R<?> loginMicroApp(@RequestBody @Valid WxLoginUser wxLoginUser, HttpServletRequest request){ |
|
|
|
Map<String,Object> objectMap = new HashMap<>(); |
|
|
|
WxUser wxUser = null; |
|
|
|
try { |
|
|
|
//TODO wxUser = wxUserService.login(wxLoginUser);
|
|
|
|
} catch (Exception e) { |
|
|
|
log.warn(e.getMessage()); |
|
|
|
} |
|
|
|
if(wxUser==null){ |
|
|
|
Assert.throwEx(HttpCode.WX_ERR); |
|
|
|
} |
|
|
|
String token = IdUtil.fastSimpleUUID(); |
|
|
|
LoginUser loginUser = new LoginUser(wxUser.getId(),wxUser.getEmpName(),"", |
|
|
|
ServletUtils.getIp(request), LoginUserType.APP_USER,new ArrayList<>(),null,AuthContextUtils.getTenant()); |
|
|
|
objectMap.put("token",token); |
|
|
|
//微信登录ID
|
|
|
|
String wxUserKey = StringUtils.format(RedisCacheKeys.WX_KEY_USER,token); |
|
|
|
redisService.set(wxUserKey,wxUser.getId()); |
|
|
|
//后台管理员信息
|
|
|
|
Map<String,Object> tokenMap = new HashMap<>(10); |
|
|
|
String client = "wx_app"; |
|
|
|
String redisKey = StringUtils.format(RedisCacheKeys.LOGIN_KEY_APP,client,wxUser.getSysUserId()); |
|
|
|
String pctoken = JwtUtils.generateToken(wxUser.getSysUserId(),loginUser.getTypeFlag(),client); |
|
|
|
redisService.set(redisKey,pctoken); |
|
|
|
tokenMap.put("token", pctoken); |
|
|
|
tokenMap.put("userId", wxUser.getSysUserId()); |
|
|
|
tokenMap.put("IP", loginUser.getLoginIp()); |
|
|
|
tokenMap.put("tenant", sysTenantMapper.selectById(loginUser.getTenant())); |
|
|
|
tokenMap.put("loginType",client); |
|
|
|
tokenMap.put("client",client); |
|
|
|
//关联
|
|
|
|
objectMap.put("adminTokenInfo",tokenMap); |
|
|
|
return R.ok(objectMap); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 公众号登录 |
|
|
|
* @param wxLoginUser |
|
|
|