1
This commit is contained in:
parent
0d1904a5c5
commit
451079ffda
@ -122,7 +122,7 @@ public class BaseConfigController extends BaseController
|
|||||||
if(list.isEmpty()){
|
if(list.isEmpty()){
|
||||||
error("未查询到相关配置!");
|
error("未查询到相关配置!");
|
||||||
}
|
}
|
||||||
return success(list.get(0));
|
return AjaxResult.ok(list.get(0).getJsonStr());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,19 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
|
import java.security.InvalidKeyException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.spec.AlgorithmParameterSpec;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.ruoyi.common.config.WxAppConfig;
|
||||||
|
import com.ruoyi.common.core.domain.model.WxLoginBody;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
@ -18,6 +30,14 @@ import com.ruoyi.framework.web.service.SysLoginService;
|
|||||||
import com.ruoyi.framework.web.service.SysPermissionService;
|
import com.ruoyi.framework.web.service.SysPermissionService;
|
||||||
import com.ruoyi.framework.web.service.TokenService;
|
import com.ruoyi.framework.web.service.TokenService;
|
||||||
import com.ruoyi.system.service.ISysMenuService;
|
import com.ruoyi.system.service.ISysMenuService;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import javax.crypto.BadPaddingException;
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import javax.crypto.IllegalBlockSizeException;
|
||||||
|
import javax.crypto.NoSuchPaddingException;
|
||||||
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录验证
|
* 登录验证
|
||||||
@ -27,6 +47,11 @@ import com.ruoyi.system.service.ISysMenuService;
|
|||||||
@RestController
|
@RestController
|
||||||
public class SysLoginController
|
public class SysLoginController
|
||||||
{
|
{
|
||||||
|
@Autowired
|
||||||
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WxAppConfig wxAppConfig;
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysLoginService loginService;
|
private SysLoginService loginService;
|
||||||
|
|
||||||
@ -38,6 +63,45 @@ public class SysLoginController
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TokenService tokenService;
|
private TokenService tokenService;
|
||||||
|
@PostMapping("/wxLogin")
|
||||||
|
public AjaxResult wxLogin(@RequestBody WxLoginBody wxLoginBody)
|
||||||
|
{
|
||||||
|
//获取登录凭证 只能用一次
|
||||||
|
String code = wxLoginBody.getCode();
|
||||||
|
//秘钥
|
||||||
|
String encryptedIv = wxLoginBody.getEncryptedIv();
|
||||||
|
//加密数据
|
||||||
|
String encryptedData = wxLoginBody.getEncryptedData();
|
||||||
|
|
||||||
|
//想微信服务器发送请求获取用户信息
|
||||||
|
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxAppConfig.getAppId() + "&secret=" + wxAppConfig.getAppSecret() + "&js_code=" + code + "&grant_type=authorization_code";
|
||||||
|
String res = restTemplate.getForObject(url, String.class);
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
||||||
|
|
||||||
|
//获取session_key和openid
|
||||||
|
String sessionKey = jsonObject.getString("session_key");
|
||||||
|
String openid = jsonObject.getString("openid");
|
||||||
|
|
||||||
|
//解密
|
||||||
|
String decryptResult = "";
|
||||||
|
try {
|
||||||
|
//如果没有绑定微信开放平台,解析结果是没有unionid的。
|
||||||
|
decryptResult = decrypt(sessionKey,encryptedIv,encryptedData);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return AjaxResult.error("微信登录失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.hasText(decryptResult)){
|
||||||
|
//如果解析成功,获取token
|
||||||
|
String token = loginService.wxLogin(openid,decryptResult);
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
ajax.put(Constants.TOKEN, token);
|
||||||
|
return ajax;
|
||||||
|
}else{
|
||||||
|
return AjaxResult.error("微信登录失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录方法
|
* 登录方法
|
||||||
@ -70,7 +134,7 @@ public class SysLoginController
|
|||||||
Set<String> roles = permissionService.getRolePermission(user);
|
Set<String> roles = permissionService.getRolePermission(user);
|
||||||
// 权限集合
|
// 权限集合
|
||||||
Set<String> permissions = permissionService.getMenuPermission(user);
|
Set<String> permissions = permissionService.getMenuPermission(user);
|
||||||
if (!loginUser.getPermissions().equals(permissions))
|
if (null!=loginUser.getPermissions() && !loginUser.getPermissions().equals(permissions))
|
||||||
{
|
{
|
||||||
loginUser.setPermissions(permissions);
|
loginUser.setPermissions(permissions);
|
||||||
tokenService.refreshToken(loginUser);
|
tokenService.refreshToken(loginUser);
|
||||||
@ -94,4 +158,50 @@ public class SysLoginController
|
|||||||
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||||
return AjaxResult.success(menuService.buildMenus(menus));
|
return AjaxResult.success(menuService.buildMenus(menus));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* AES解密
|
||||||
|
* @param sessionKey
|
||||||
|
* @param encryptedIv
|
||||||
|
* @param encryptedData
|
||||||
|
*/
|
||||||
|
public String decrypt(String sessionKey,String encryptedIv,String encryptedData) throws Exception{
|
||||||
|
// 转化为字节数组
|
||||||
|
byte[] key = com.sun.org.apache.xerces.internal.impl.dv.util.Base64.decode(sessionKey);
|
||||||
|
byte[] iv = com.sun.org.apache.xerces.internal.impl.dv.util.Base64.decode(encryptedIv);
|
||||||
|
byte[] encData = Base64.decode(encryptedData);
|
||||||
|
// 如果密钥不足16位,那么就补足
|
||||||
|
int base =16;
|
||||||
|
if (key.length % base !=0) {
|
||||||
|
int groups = key.length / base +(key.length % base != 0 ? 1 : 0);
|
||||||
|
byte[] temp = new byte[groups * base];
|
||||||
|
Arrays.fill(temp,(byte) 0);
|
||||||
|
System.arraycopy(key,0,temp,0,key.length);
|
||||||
|
key = temp;
|
||||||
|
}
|
||||||
|
// 如果初始向量不足16位,也补足
|
||||||
|
if (iv.length % base !=0) {
|
||||||
|
int groups = iv.length / base +(iv.length % base != 0 ? 1 : 0);
|
||||||
|
byte[] temp = new byte[groups * base];
|
||||||
|
Arrays.fill(temp,(byte) 0);
|
||||||
|
System.arraycopy(iv,0,temp,0,iv.length);
|
||||||
|
iv = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
AlgorithmParameterSpec ivSpec = new IvParameterSpec(iv);
|
||||||
|
String resultStr = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||||
|
SecretKeySpec keySpec = new SecretKeySpec(key,"AES");
|
||||||
|
cipher.init(Cipher.DECRYPT_MODE,keySpec,ivSpec);
|
||||||
|
resultStr = new String(cipher.doFinal(encData),"UTF-8");
|
||||||
|
} catch (Exception e){
|
||||||
|
// logger.info("解析错误");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 解析加密后的字符串
|
||||||
|
return resultStr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,3 +146,7 @@ xss:
|
|||||||
excludes: /system/notice
|
excludes: /system/notice
|
||||||
# 匹配链接
|
# 匹配链接
|
||||||
urlPatterns: /system/*,/monitor/*,/tool/*
|
urlPatterns: /system/*,/monitor/*,/tool/*
|
||||||
|
# 微信小程序配置
|
||||||
|
wx-app:
|
||||||
|
appId: wxd8ef44a8268672e4
|
||||||
|
appSecret: 30c18855ceb0ab0f9801407c998199c2
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.ruoyi.common.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@ConfigurationProperties(prefix = "wx-app")
|
||||||
|
@Data
|
||||||
|
public class WxAppConfig {
|
||||||
|
/** AppId */
|
||||||
|
private String appId;
|
||||||
|
|
||||||
|
/** AppSecret */
|
||||||
|
private String appSecret;
|
||||||
|
}
|
@ -113,7 +113,6 @@ public class BaseController
|
|||||||
{
|
{
|
||||||
return AjaxResult.success(message);
|
return AjaxResult.success(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功消息
|
* 返回成功消息
|
||||||
*/
|
*/
|
||||||
|
@ -79,6 +79,16 @@ public class AjaxResult extends HashMap<String, Object>
|
|||||||
return AjaxResult.success("操作成功", data);
|
return AjaxResult.success("操作成功", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功数据
|
||||||
|
*
|
||||||
|
* @return 成功消息
|
||||||
|
*/
|
||||||
|
public static AjaxResult ok(Object data)
|
||||||
|
{
|
||||||
|
return AjaxResult.success("操作成功", data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功消息
|
* 返回成功消息
|
||||||
*
|
*
|
||||||
|
@ -70,6 +70,9 @@ public class SysUser extends BaseEntity
|
|||||||
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
|
||||||
private Date loginDate;
|
private Date loginDate;
|
||||||
|
|
||||||
|
/** openId */
|
||||||
|
private String openId;
|
||||||
|
|
||||||
/** 部门对象 */
|
/** 部门对象 */
|
||||||
@Excels({
|
@Excels({
|
||||||
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
|
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
|
||||||
@ -297,6 +300,13 @@ public class SysUser extends BaseEntity
|
|||||||
this.roleId = roleId;
|
this.roleId = roleId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getOpenId() {
|
||||||
|
return openId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpenId(String openId) {
|
||||||
|
this.openId = openId;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
@ -71,6 +71,9 @@ public class LoginUser implements UserDetails
|
|||||||
*/
|
*/
|
||||||
private SysUser user;
|
private SysUser user;
|
||||||
|
|
||||||
|
/** openId */
|
||||||
|
private String openId;
|
||||||
|
|
||||||
public LoginUser()
|
public LoginUser()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -119,6 +122,14 @@ public class LoginUser implements UserDetails
|
|||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getOpenId() {
|
||||||
|
return openId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOpenId(String openId) {
|
||||||
|
this.openId = openId;
|
||||||
|
}
|
||||||
|
|
||||||
@JSONField(serialize = false)
|
@JSONField(serialize = false)
|
||||||
@Override
|
@Override
|
||||||
public String getPassword()
|
public String getPassword()
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.ruoyi.common.core.domain.model;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class WxLoginBody {
|
||||||
|
/** 临时登录凭证 code 只能使用一次 */
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/** 偏移量 */
|
||||||
|
private String encryptedIv;
|
||||||
|
|
||||||
|
/** 加密数据 */
|
||||||
|
private String encryptedData;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "WxLoginBody{" +
|
||||||
|
"code='" + code + '\'' +
|
||||||
|
", encryptedIv='" + encryptedIv + '\'' +
|
||||||
|
", encryptedData='" + encryptedData + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilde
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 程序注解配置
|
* 程序注解配置
|
||||||
@ -27,4 +28,13 @@ public class ApplicationConfig
|
|||||||
{
|
{
|
||||||
return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault());
|
return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault());
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 远程调用
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public RestTemplate restTemplate()
|
||||||
|
{
|
||||||
|
return new RestTemplate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,12 +111,14 @@ public class SecurityConfig
|
|||||||
.authorizeHttpRequests((requests) -> {
|
.authorizeHttpRequests((requests) -> {
|
||||||
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
|
permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
|
||||||
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
// 对于登录login 注册register 验证码captchaImage 允许匿名访问
|
||||||
requests.antMatchers("/login", "/register", "/captchaImage").permitAll()
|
requests.antMatchers("/login","/wxLogin", "/register", "/captchaImage").permitAll()
|
||||||
// 静态资源,可匿名访问
|
//相关配置参数可匿名访问
|
||||||
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
.antMatchers("/base/config/getConfigByCode").permitAll()
|
||||||
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
// 静态资源,可匿名访问
|
||||||
// 除上面外的所有请求全部需要鉴权认证
|
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
|
||||||
.anyRequest().authenticated();
|
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
|
||||||
|
// 除上面外的所有请求全部需要鉴权认证
|
||||||
|
.anyRequest().authenticated();
|
||||||
})
|
})
|
||||||
// 添加Logout filter
|
// 添加Logout filter
|
||||||
.logout(logout -> logout.logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler))
|
.logout(logout -> logout.logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler))
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package com.ruoyi.framework.web.service;
|
package com.ruoyi.framework.web.service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||||
|
import com.ruoyi.system.mapper.SysUserMapper;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.authentication.BadCredentialsException;
|
import org.springframework.security.authentication.BadCredentialsException;
|
||||||
@ -48,6 +52,8 @@ public class SysLoginService
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
|
@Autowired
|
||||||
|
private SysUserMapper userMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysConfigService configService;
|
private ISysConfigService configService;
|
||||||
@ -100,6 +106,62 @@ public class SysLoginService
|
|||||||
return tokenService.createToken(loginUser);
|
return tokenService.createToken(loginUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信登录
|
||||||
|
*
|
||||||
|
* @param decryptResult 登录凭证 只能用一次
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String wxLogin(String openid,String decryptResult){
|
||||||
|
//字符串转json
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(decryptResult);
|
||||||
|
//手机号
|
||||||
|
String phone = jsonObject.getString("phoneNumber");
|
||||||
|
//根据openid判断数据库中是否有该用户
|
||||||
|
//根据openid查询用户信息
|
||||||
|
SysUser wxUser = userMapper.selectWxUserByOpenIdOrPhone(openid,null);
|
||||||
|
if(null==wxUser){
|
||||||
|
//根据openId没查到,再根据手机号查
|
||||||
|
wxUser = userMapper.selectWxUserByOpenIdOrPhone(null,phone);
|
||||||
|
}
|
||||||
|
//如果查不到,则新增,查到了,则更新
|
||||||
|
SysUser user = new SysUser();
|
||||||
|
if (wxUser == null) {
|
||||||
|
// 新增
|
||||||
|
// 设置姓名 ,默认使用昵称+随机数,防止重复姓名的发生 数据库中把username的长度修改的长一点
|
||||||
|
user.setUserName(phone);
|
||||||
|
user.setNickName("微信用户");
|
||||||
|
user.setOpenId(openid);
|
||||||
|
user.setPhonenumber(phone);
|
||||||
|
user.setSex("2");
|
||||||
|
user.setCreateTime(DateUtils.getNowDate());
|
||||||
|
//新增 用户
|
||||||
|
userMapper.insertUser(user);
|
||||||
|
}else {
|
||||||
|
//,查到了
|
||||||
|
if(!"0".equals(wxUser.getStatus())){
|
||||||
|
//非正常状态,无法登录
|
||||||
|
throw new ServiceException("账号状态异常");
|
||||||
|
}
|
||||||
|
// 更新
|
||||||
|
user = wxUser;
|
||||||
|
if(!openid.equals(user.getOpenId())){
|
||||||
|
user.setOpenId(openid);
|
||||||
|
user.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
userMapper.updateUser(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//组装token信息
|
||||||
|
LoginUser loginUser = new LoginUser();
|
||||||
|
loginUser.setOpenId(openid);
|
||||||
|
loginUser.setUser(user);
|
||||||
|
loginUser.setUserId(user.getUserId());
|
||||||
|
|
||||||
|
// 生成token
|
||||||
|
return tokenService.createToken(loginUser);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验验证码
|
* 校验验证码
|
||||||
*
|
*
|
||||||
|
@ -151,7 +151,9 @@ public class TokenService
|
|||||||
loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
|
loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
|
||||||
// 根据uuid将loginUser缓存
|
// 根据uuid将loginUser缓存
|
||||||
String userKey = getTokenKey(loginUser.getToken());
|
String userKey = getTokenKey(loginUser.getToken());
|
||||||
redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
|
// redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
|
||||||
|
/* vinjor 永不过期,适配小程序*/
|
||||||
|
redisCache.setCacheObject(userKey, loginUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,4 +124,12 @@ public interface SysUserMapper
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public SysUser checkEmailUnique(String email);
|
public SysUser checkEmailUnique(String email);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据openId或手机号查询用户信息
|
||||||
|
* @param openId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SysUser selectWxUserByOpenIdOrPhone(@Param("openId") String openId,@Param("phone") String phone);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="avatar" column="avatar" />
|
<result property="avatar" column="avatar" />
|
||||||
<result property="password" column="password" />
|
<result property="password" column="password" />
|
||||||
<result property="status" column="status" />
|
<result property="status" column="status" />
|
||||||
|
<result property="openId" column="open_id" />
|
||||||
<result property="delFlag" column="del_flag" />
|
<result property="delFlag" column="del_flag" />
|
||||||
<result property="loginIp" column="login_ip" />
|
<result property="loginIp" column="login_ip" />
|
||||||
<result property="loginDate" column="login_date" />
|
<result property="loginDate" column="login_date" />
|
||||||
@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectUserVo">
|
<sql id="selectUserVo">
|
||||||
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status,u.open_id, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
||||||
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
||||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
|
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
|
||||||
from sys_user u
|
from sys_user u
|
||||||
@ -57,7 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
|
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,u.open_id, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
where u.del_flag = '0'
|
where u.del_flag = '0'
|
||||||
<if test="userId != null and userId != 0">
|
<if test="userId != null and userId != 0">
|
||||||
@ -86,7 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status,u.open_id, u.create_time
|
||||||
from sys_user u
|
from sys_user u
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
left join sys_user_role ur on u.user_id = ur.user_id
|
left join sys_user_role ur on u.user_id = ur.user_id
|
||||||
@ -103,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status,u.open_id, u.create_time
|
||||||
from sys_user u
|
from sys_user u
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
left join sys_user_role ur on u.user_id = ur.user_id
|
left join sys_user_role ur on u.user_id = ur.user_id
|
||||||
@ -154,6 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="sex != null and sex != ''">sex,</if>
|
<if test="sex != null and sex != ''">sex,</if>
|
||||||
<if test="password != null and password != ''">password,</if>
|
<if test="password != null and password != ''">password,</if>
|
||||||
<if test="status != null and status != ''">status,</if>
|
<if test="status != null and status != ''">status,</if>
|
||||||
|
<if test="openId != null and openId != ''">open_id,</if>
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
create_time
|
create_time
|
||||||
@ -168,6 +170,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="sex != null and sex != ''">#{sex},</if>
|
<if test="sex != null and sex != ''">#{sex},</if>
|
||||||
<if test="password != null and password != ''">#{password},</if>
|
<if test="password != null and password != ''">#{password},</if>
|
||||||
<if test="status != null and status != ''">#{status},</if>
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
|
<if test="openId != null and openId != ''">#{openId},</if>
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
sysdate()
|
sysdate()
|
||||||
@ -185,6 +188,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
||||||
<if test="password != null and password != ''">password = #{password},</if>
|
<if test="password != null and password != ''">password = #{password},</if>
|
||||||
<if test="status != null and status != ''">status = #{status},</if>
|
<if test="status != null and status != ''">status = #{status},</if>
|
||||||
|
<if test="openId != null and openId != ''">open_id = #{openId},</if>
|
||||||
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
||||||
<if test="loginDate != null">login_date = #{loginDate},</if>
|
<if test="loginDate != null">login_date = #{loginDate},</if>
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
@ -216,5 +220,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
#{userId}
|
#{userId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
|
<select id="selectWxUserByOpenIdOrPhone" parameterType="String" resultMap="SysUserResult">
|
||||||
</mapper>
|
<include refid="selectUserVo"/>
|
||||||
|
where u.del_flag = '0'
|
||||||
|
<if test="openId!=null and openId!=''">
|
||||||
|
and u.open_id = #{openId}
|
||||||
|
</if>
|
||||||
|
<if test="phone!=null and phone!=''">
|
||||||
|
and u.user_name = #{phone}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue
Block a user