优化企业微信登录
This commit is contained in:
parent
f6e16a6cb1
commit
d18dc2c515
|
|
@ -2,6 +2,7 @@ package com.ruoyi.test.conrtroller;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.utils.ShiroUtils;
|
||||
import com.ruoyi.system.service.IWechatApiService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
|
@ -46,9 +47,13 @@ public class WechatApiController extends BaseController {
|
|||
@ResponseBody
|
||||
public Map<String, String> SendTextMessageToWechatUser() {
|
||||
List<String> userIdList = new ArrayList<>();
|
||||
userIdList.add("2342343243");
|
||||
userIdList.add("erqrqwe");
|
||||
userIdList.add("2342343243");//错误userId示例
|
||||
userIdList.add("erqrqwe");//错误userId示例
|
||||
userIdList.add(""); //空UserId示例
|
||||
userIdList.add("359");
|
||||
if(!ShiroUtils.getUserId().equals("359")){
|
||||
userIdList.add(String.valueOf(ShiroUtils.getUserId()));
|
||||
}
|
||||
Map<String, String> resultMap = wechatApiService.SendTextMessageToWechatUser(userIdList,"<a href=\"www.baidu.com\">哈哈哈!</a>");
|
||||
return resultMap;
|
||||
}
|
||||
|
|
@ -57,11 +62,15 @@ public class WechatApiController extends BaseController {
|
|||
@ResponseBody
|
||||
public Map<String, String> SendTextCardMessageToWechatUser() {
|
||||
List<String> userIdList = new ArrayList<>();
|
||||
userIdList.add("23456667");
|
||||
userIdList.add("355354354");
|
||||
userIdList.add("23456667"); //错误userId示例
|
||||
userIdList.add("355354354"); //错误userId示例
|
||||
userIdList.add(""); //空UserId示例
|
||||
userIdList.add("359");
|
||||
userIdList.add("454");
|
||||
userIdList.add("408");
|
||||
//userIdList.add("454");
|
||||
//userIdList.add("408");
|
||||
if(!ShiroUtils.getUserId().equals("359")){
|
||||
userIdList.add(String.valueOf(ShiroUtils.getUserId()));
|
||||
}
|
||||
String title="号外:特大优惠!限时抢购";
|
||||
String description="今年仅此一次,苹果手机1000元起!欢迎前来购买!走过路过,不要错过!";
|
||||
String dtailUrl="https://item.jd.com/100008348530.html";
|
||||
|
|
|
|||
|
|
@ -38,17 +38,15 @@ public class SysLoginController extends BaseController
|
|||
String code= request.getParameter("code");
|
||||
//String state = request.getParameter("state");
|
||||
String username=wechatApiService.GetLoginNameWithWechatCode(code);
|
||||
//如果没有获取到用户名,说明验证失败,跳转登录页
|
||||
//如果没有获取到登录名,说明验证失败,跳转登录页
|
||||
if(StringUtils.isEmpty(username)){
|
||||
return "login";
|
||||
}
|
||||
|
||||
String password="";
|
||||
Boolean rememberMe=true;
|
||||
map.put("loginType","wechat");
|
||||
map.put("username",username);
|
||||
map.put("password",password);
|
||||
|
||||
return "loginwechat";
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
var loginType = [[${loginType}]];
|
||||
var username = [[${username}]];
|
||||
var password = [[${password}]];
|
||||
var rememberMe = "true";
|
||||
var rememberMe = true;
|
||||
|
||||
$(function () {
|
||||
if (loginType == 'wechat') {
|
||||
|
|
|
|||
|
|
@ -112,12 +112,19 @@ public class WechatApiServiceImpl implements IWechatApiService {
|
|||
@Override
|
||||
public String GetLoginNameWithWechatCode(String code)
|
||||
{
|
||||
if(StringUtils.isEmpty(code)){
|
||||
return "";
|
||||
}
|
||||
//获取访问用户身份ID
|
||||
String userId= GetUseridByWechatLogin(code);
|
||||
|
||||
if(StringUtils.isEmpty(userId)){
|
||||
return "";
|
||||
}
|
||||
//获取用户邮箱与姓名
|
||||
WechatUserInfo wechatUserInfo = GetWechatUserInfoDetailByUserId(userId);
|
||||
|
||||
if (null==wechatUserInfo || null==wechatUserInfo.getName()){
|
||||
return "";
|
||||
}
|
||||
//根据用户id+邮箱名+用户名匹配本地用户对应的userId+邮箱名与用户名
|
||||
SysUser sysUserWechat=new SysUser();
|
||||
sysUserWechat.setUserId(Long.parseLong(wechatUserInfo.getUserid()));
|
||||
|
|
@ -131,7 +138,7 @@ public class WechatApiServiceImpl implements IWechatApiService {
|
|||
return ""; //系统里没有用户,没有从OA同步? 处理逻辑待定
|
||||
}
|
||||
if(count > 1){
|
||||
return ""; //本地数据库存在多个姓名与邮箱相同的记录,如何处理??
|
||||
return ""; //本地数据库存在多个姓名与邮箱相同的记录,如何处理??--加上了sysUserWechat.setUserId(Long.parseLong(wechatUserInfo.getUserid()));,不存在这种情况了。
|
||||
}
|
||||
String loginName= userList.get(0).getLoginName();
|
||||
return loginName;
|
||||
|
|
|
|||
Loading…
Reference in New Issue