forked from ruoyi/RuoYi-Vue
优化代码,支持防盗链功能
This commit is contained in:
@@ -127,6 +127,13 @@ springdoc:
|
|||||||
paths-to-match: '/**'
|
paths-to-match: '/**'
|
||||||
packages-to-scan: com.devttl.web.controller.tool
|
packages-to-scan: com.devttl.web.controller.tool
|
||||||
|
|
||||||
|
# 防盗链配置
|
||||||
|
referer:
|
||||||
|
# 防盗链开关
|
||||||
|
enabled: false
|
||||||
|
# 允许的域名列表
|
||||||
|
allowed-domains: localhost,127.0.0.1,devttl.com,www.devttl.com
|
||||||
|
|
||||||
# 防止XSS攻击
|
# 防止XSS攻击
|
||||||
xss:
|
xss:
|
||||||
# 过滤开关
|
# 过滤开关
|
||||||
|
@@ -0,0 +1,63 @@
|
|||||||
|
package com.devttl.common.filter;
|
||||||
|
|
||||||
|
import jakarta.servlet.*;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 防盗链过滤器
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
*/
|
||||||
|
public class RefererFilter implements Filter {
|
||||||
|
/**
|
||||||
|
* 允许的域名列表
|
||||||
|
*/
|
||||||
|
public List<String> allowedDomains;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(FilterConfig filterConfig) throws ServletException {
|
||||||
|
String domains = filterConfig.getInitParameter("allowedDomains");
|
||||||
|
this.allowedDomains = Arrays.asList(domains.split(","));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||||
|
throws IOException, ServletException {
|
||||||
|
HttpServletRequest req = (HttpServletRequest) request;
|
||||||
|
HttpServletResponse resp = (HttpServletResponse) response;
|
||||||
|
|
||||||
|
String referer = req.getHeader("Referer");
|
||||||
|
|
||||||
|
// 如果Referer为空,拒绝访问
|
||||||
|
if (referer == null || referer.isEmpty()) {
|
||||||
|
resp.sendError(HttpServletResponse.SC_FORBIDDEN, "Access denied: Referer header is required");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查Referer是否在允许的域名列表中
|
||||||
|
boolean allowed = false;
|
||||||
|
for (String domain : allowedDomains) {
|
||||||
|
if (referer.contains(domain)) {
|
||||||
|
allowed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据检查结果决定是否放行
|
||||||
|
if (allowed) {
|
||||||
|
chain.doFilter(request, response);
|
||||||
|
} else {
|
||||||
|
resp.sendError(HttpServletResponse.SC_FORBIDDEN, "Access denied: Referer '" + referer + "' is not allowed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -1,16 +1,19 @@
|
|||||||
package com.devttl.framework.config;
|
package com.devttl.framework.config;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import com.devttl.common.constant.Constants;
|
||||||
import java.util.Map;
|
import com.devttl.common.filter.RefererFilter;
|
||||||
|
import com.devttl.common.filter.RepeatableFilter;
|
||||||
|
import com.devttl.common.filter.XssFilter;
|
||||||
|
import com.devttl.common.utils.StringUtils;
|
||||||
import jakarta.servlet.DispatcherType;
|
import jakarta.servlet.DispatcherType;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||||
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 com.devttl.common.filter.RepeatableFilter;
|
|
||||||
import com.devttl.common.filter.XssFilter;
|
import java.util.HashMap;
|
||||||
import com.devttl.common.utils.StringUtils;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter配置
|
* Filter配置
|
||||||
@@ -18,19 +21,20 @@ import com.devttl.common.utils.StringUtils;
|
|||||||
* @author devttl
|
* @author devttl
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class FilterConfig
|
public class FilterConfig {
|
||||||
{
|
|
||||||
@Value("${xss.excludes}")
|
@Value("${xss.excludes}")
|
||||||
private String excludes;
|
private String excludes;
|
||||||
|
|
||||||
@Value("${xss.urlPatterns}")
|
@Value("${xss.urlPatterns}")
|
||||||
private String urlPatterns;
|
private String urlPatterns;
|
||||||
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@Value("${referer.allowed-domains}")
|
||||||
|
private String allowedDomains;
|
||||||
|
|
||||||
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(value = "xss.enabled", havingValue = "true")
|
@ConditionalOnProperty(value = "xss.enabled", havingValue = "true")
|
||||||
public FilterRegistrationBean xssFilterRegistration()
|
public FilterRegistrationBean xssFilterRegistration() {
|
||||||
{
|
|
||||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||||
registration.setDispatcherTypes(DispatcherType.REQUEST);
|
registration.setDispatcherTypes(DispatcherType.REQUEST);
|
||||||
registration.setFilter(new XssFilter());
|
registration.setFilter(new XssFilter());
|
||||||
@@ -43,10 +47,25 @@ public class FilterConfig
|
|||||||
return registration;
|
return registration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
@Bean
|
@Bean
|
||||||
public FilterRegistrationBean someFilterRegistration()
|
@ConditionalOnProperty(value = "referer.enabled", havingValue = "true")
|
||||||
{
|
public FilterRegistrationBean refererFilterRegistration() {
|
||||||
|
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||||
|
registration.setDispatcherTypes(DispatcherType.REQUEST);
|
||||||
|
registration.setFilter(new RefererFilter());
|
||||||
|
registration.addUrlPatterns(Constants.RESOURCE_PREFIX + "/*");
|
||||||
|
registration.setName("refererFilter");
|
||||||
|
registration.setOrder(FilterRegistrationBean.HIGHEST_PRECEDENCE);
|
||||||
|
Map<String, String> initParameters = new HashMap<String, String>();
|
||||||
|
initParameters.put("allowedDomains", allowedDomains);
|
||||||
|
registration.setInitParameters(initParameters);
|
||||||
|
return registration;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
|
@Bean
|
||||||
|
public FilterRegistrationBean someFilterRegistration() {
|
||||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||||
registration.setFilter(new RepeatableFilter());
|
registration.setFilter(new RepeatableFilter());
|
||||||
registration.addUrlPatterns("/*");
|
registration.addUrlPatterns("/*");
|
||||||
|
@@ -1,24 +1,12 @@
|
|||||||
package com.devttl.framework.web.service;
|
package com.devttl.framework.web.service;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.authentication.AuthenticationManager;
|
|
||||||
import org.springframework.security.authentication.BadCredentialsException;
|
|
||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import com.devttl.common.constant.CacheConstants;
|
import com.devttl.common.constant.CacheConstants;
|
||||||
import com.devttl.common.constant.Constants;
|
import com.devttl.common.constant.Constants;
|
||||||
import com.devttl.common.constant.UserConstants;
|
import com.devttl.common.constant.UserConstants;
|
||||||
import com.devttl.common.core.domain.entity.SysUser;
|
|
||||||
import com.devttl.common.core.domain.model.LoginUser;
|
import com.devttl.common.core.domain.model.LoginUser;
|
||||||
import com.devttl.common.core.redis.RedisCache;
|
import com.devttl.common.core.redis.RedisCache;
|
||||||
import com.devttl.common.exception.ServiceException;
|
import com.devttl.common.exception.ServiceException;
|
||||||
import com.devttl.common.exception.user.BlackListException;
|
import com.devttl.common.exception.user.*;
|
||||||
import com.devttl.common.exception.user.CaptchaException;
|
|
||||||
import com.devttl.common.exception.user.CaptchaExpireException;
|
|
||||||
import com.devttl.common.exception.user.UserNotExistsException;
|
|
||||||
import com.devttl.common.exception.user.UserPasswordNotMatchException;
|
|
||||||
import com.devttl.common.utils.DateUtils;
|
import com.devttl.common.utils.DateUtils;
|
||||||
import com.devttl.common.utils.MessageUtils;
|
import com.devttl.common.utils.MessageUtils;
|
||||||
import com.devttl.common.utils.StringUtils;
|
import com.devttl.common.utils.StringUtils;
|
||||||
@@ -28,15 +16,22 @@ import com.devttl.framework.manager.factory.AsyncFactory;
|
|||||||
import com.devttl.framework.security.context.AuthenticationContextHolder;
|
import com.devttl.framework.security.context.AuthenticationContextHolder;
|
||||||
import com.devttl.system.service.ISysConfigService;
|
import com.devttl.system.service.ISysConfigService;
|
||||||
import com.devttl.system.service.ISysUserService;
|
import com.devttl.system.service.ISysUserService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
|
import org.springframework.security.authentication.BadCredentialsException;
|
||||||
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录校验方法
|
* 登录校验方法
|
||||||
*
|
*
|
||||||
* @author devttl
|
* @author devttl
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class SysLoginService
|
public class SysLoginService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TokenService tokenService;
|
private TokenService tokenService;
|
||||||
|
|
||||||
@@ -45,7 +40,7 @@ public class SysLoginService
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService userService;
|
private ISysUserService userService;
|
||||||
|
|
||||||
@@ -54,43 +49,34 @@ public class SysLoginService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录验证
|
* 登录验证
|
||||||
*
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param password 密码
|
* @param password 密码
|
||||||
* @param code 验证码
|
* @param code 验证码
|
||||||
* @param uuid 唯一标识
|
* @param uuid 唯一标识
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public String login(String username, String password, String code, String uuid)
|
public String login(String username, String password, String code, String uuid) {
|
||||||
{
|
|
||||||
// 验证码校验
|
// 验证码校验
|
||||||
validateCaptcha(username, code, uuid);
|
validateCaptcha(username, code, uuid);
|
||||||
// 登录前置校验
|
// 登录前置校验
|
||||||
loginPreCheck(username, password);
|
loginPreCheck(username, password);
|
||||||
// 用户验证
|
// 用户验证
|
||||||
Authentication authentication = null;
|
Authentication authentication = null;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
|
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
|
||||||
AuthenticationContextHolder.setContext(authenticationToken);
|
AuthenticationContextHolder.setContext(authenticationToken);
|
||||||
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
||||||
authentication = authenticationManager.authenticate(authenticationToken);
|
authentication = authenticationManager.authenticate(authenticationToken);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
if (e instanceof BadCredentialsException) {
|
||||||
{
|
|
||||||
if (e instanceof BadCredentialsException)
|
|
||||||
{
|
|
||||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
|
||||||
throw new UserPasswordNotMatchException();
|
throw new UserPasswordNotMatchException();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
|
||||||
throw new ServiceException(e.getMessage());
|
throw new ServiceException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
} finally {
|
||||||
finally
|
|
||||||
{
|
|
||||||
AuthenticationContextHolder.clearContext();
|
AuthenticationContextHolder.clearContext();
|
||||||
}
|
}
|
||||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
||||||
@@ -102,27 +88,23 @@ public class SysLoginService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验验证码
|
* 校验验证码
|
||||||
*
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param code 验证码
|
* @param code 验证码
|
||||||
* @param uuid 唯一标识
|
* @param uuid 唯一标识
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public void validateCaptcha(String username, String code, String uuid)
|
public void validateCaptcha(String username, String code, String uuid) {
|
||||||
{
|
|
||||||
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
boolean captchaEnabled = configService.selectCaptchaEnabled();
|
||||||
if (captchaEnabled)
|
if (captchaEnabled) {
|
||||||
{
|
|
||||||
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
|
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
|
||||||
String captcha = redisCache.getCacheObject(verifyKey);
|
String captcha = redisCache.getCacheObject(verifyKey);
|
||||||
if (captcha == null)
|
if (captcha == null) {
|
||||||
{
|
|
||||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
|
||||||
throw new CaptchaExpireException();
|
throw new CaptchaExpireException();
|
||||||
}
|
}
|
||||||
redisCache.deleteObject(verifyKey);
|
redisCache.deleteObject(verifyKey);
|
||||||
if (!code.equalsIgnoreCase(captcha))
|
if (!code.equalsIgnoreCase(captcha)) {
|
||||||
{
|
|
||||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
|
||||||
throw new CaptchaException();
|
throw new CaptchaException();
|
||||||
}
|
}
|
||||||
@@ -131,35 +113,31 @@ public class SysLoginService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录前置校验
|
* 登录前置校验
|
||||||
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @param password 用户密码
|
* @param password 用户密码
|
||||||
*/
|
*/
|
||||||
public void loginPreCheck(String username, String password)
|
public void loginPreCheck(String username, String password) {
|
||||||
{
|
|
||||||
// 用户名或密码为空 错误
|
// 用户名或密码为空 错误
|
||||||
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password))
|
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
|
||||||
{
|
|
||||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("not.null")));
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("not.null")));
|
||||||
throw new UserNotExistsException();
|
throw new UserNotExistsException();
|
||||||
}
|
}
|
||||||
// 密码如果不在指定范围内 错误
|
// 密码如果不在指定范围内 错误
|
||||||
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
|
||||||
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH)
|
|| password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
|
||||||
{
|
|
||||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
|
||||||
throw new UserPasswordNotMatchException();
|
throw new UserPasswordNotMatchException();
|
||||||
}
|
}
|
||||||
// 用户名不在指定范围内 错误
|
// 用户名不在指定范围内 错误
|
||||||
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
if (username.length() < UserConstants.USERNAME_MIN_LENGTH
|
||||||
|| username.length() > UserConstants.USERNAME_MAX_LENGTH)
|
|| username.length() > UserConstants.USERNAME_MAX_LENGTH) {
|
||||||
{
|
|
||||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
|
||||||
throw new UserPasswordNotMatchException();
|
throw new UserPasswordNotMatchException();
|
||||||
}
|
}
|
||||||
// IP黑名单校验
|
// IP黑名单校验
|
||||||
String blackStr = configService.selectConfigByKey("sys.login.blackIPList");
|
String blackStr = configService.selectConfigByKey("sys.login.blackIPList");
|
||||||
if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr()))
|
if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) {
|
||||||
{
|
|
||||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("login.blocked")));
|
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("login.blocked")));
|
||||||
throw new BlackListException();
|
throw new BlackListException();
|
||||||
}
|
}
|
||||||
@@ -170,12 +148,7 @@ public class SysLoginService
|
|||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
*/
|
*/
|
||||||
public void recordLoginInfo(Long userId)
|
public void recordLoginInfo(Long userId) {
|
||||||
{
|
userService.updateLoginInfo(userId, IpUtils.getIpAddr(), DateUtils.getNowDate());
|
||||||
SysUser sysUser = new SysUser();
|
|
||||||
sysUser.setUserId(userId);
|
|
||||||
sysUser.setLoginIp(IpUtils.getIpAddr());
|
|
||||||
sysUser.setLoginDate(DateUtils.getNowDate());
|
|
||||||
userService.updateUserProfile(sysUser);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,19 +1,20 @@
|
|||||||
package com.devttl.system.mapper;
|
package com.devttl.system.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import com.devttl.common.core.domain.entity.SysUser;
|
import com.devttl.common.core.domain.entity.SysUser;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户表 数据层
|
* 用户表 数据层
|
||||||
*
|
*
|
||||||
* @author devttl
|
* @author devttl
|
||||||
*/
|
*/
|
||||||
public interface SysUserMapper
|
public interface SysUserMapper {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询用户列表
|
* 根据条件分页查询用户列表
|
||||||
*
|
*
|
||||||
* @param sysUser 用户信息
|
* @param sysUser 用户信息
|
||||||
* @return 用户信息集合信息
|
* @return 用户信息集合信息
|
||||||
*/
|
*/
|
||||||
@@ -21,7 +22,7 @@ public interface SysUserMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询已配用户角色列表
|
* 根据条件分页查询已配用户角色列表
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 用户信息集合信息
|
* @return 用户信息集合信息
|
||||||
*/
|
*/
|
||||||
@@ -29,7 +30,7 @@ public interface SysUserMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询未分配用户角色列表
|
* 根据条件分页查询未分配用户角色列表
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 用户信息集合信息
|
* @return 用户信息集合信息
|
||||||
*/
|
*/
|
||||||
@@ -37,7 +38,7 @@ public interface SysUserMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户名查询用户
|
* 通过用户名查询用户
|
||||||
*
|
*
|
||||||
* @param userName 用户名
|
* @param userName 用户名
|
||||||
* @return 用户对象信息
|
* @return 用户对象信息
|
||||||
*/
|
*/
|
||||||
@@ -45,7 +46,7 @@ public interface SysUserMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID查询用户
|
* 通过用户ID查询用户
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @return 用户对象信息
|
* @return 用户对象信息
|
||||||
*/
|
*/
|
||||||
@@ -53,7 +54,7 @@ public interface SysUserMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户信息
|
* 新增用户信息
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -61,7 +62,7 @@ public interface SysUserMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户信息
|
* 修改用户信息
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -69,17 +70,27 @@ public interface SysUserMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户头像
|
* 修改用户头像
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param avatar 头像地址
|
* @param avatar 头像地址
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int updateUserAvatar(@Param("userId") Long userId, @Param("avatar") String avatar);
|
public int updateUserAvatar(@Param("userId") Long userId, @Param("avatar") String avatar);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户登录信息(IP和登录时间)
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param loginIp 登录IP地址
|
||||||
|
* @param loginDate 登录时间
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateLoginInfo(@Param("userId") Long userId, @Param("loginIp") String loginIp, @Param("loginDate") Date loginDate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置用户密码
|
* 重置用户密码
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param password 密码
|
* @param password 密码
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -87,7 +98,7 @@ public interface SysUserMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID删除用户
|
* 通过用户ID删除用户
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -95,7 +106,7 @@ public interface SysUserMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除用户信息
|
* 批量删除用户信息
|
||||||
*
|
*
|
||||||
* @param userIds 需要删除的用户ID
|
* @param userIds 需要删除的用户ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -103,7 +114,7 @@ public interface SysUserMapper
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验用户名称是否唯一
|
* 校验用户名称是否唯一
|
||||||
*
|
*
|
||||||
* @param userName 用户名称
|
* @param userName 用户名称
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
|
@@ -1,18 +1,19 @@
|
|||||||
package com.devttl.system.service;
|
package com.devttl.system.service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import com.devttl.common.core.domain.entity.SysUser;
|
import com.devttl.common.core.domain.entity.SysUser;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户 业务层
|
* 用户 业务层
|
||||||
*
|
*
|
||||||
* @author devttl
|
* @author devttl
|
||||||
*/
|
*/
|
||||||
public interface ISysUserService
|
public interface ISysUserService {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询用户列表
|
* 根据条件分页查询用户列表
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 用户信息集合信息
|
* @return 用户信息集合信息
|
||||||
*/
|
*/
|
||||||
@@ -20,7 +21,7 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询已分配用户角色列表
|
* 根据条件分页查询已分配用户角色列表
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 用户信息集合信息
|
* @return 用户信息集合信息
|
||||||
*/
|
*/
|
||||||
@@ -28,7 +29,7 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询未分配用户角色列表
|
* 根据条件分页查询未分配用户角色列表
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 用户信息集合信息
|
* @return 用户信息集合信息
|
||||||
*/
|
*/
|
||||||
@@ -36,7 +37,7 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户名查询用户
|
* 通过用户名查询用户
|
||||||
*
|
*
|
||||||
* @param userName 用户名
|
* @param userName 用户名
|
||||||
* @return 用户对象信息
|
* @return 用户对象信息
|
||||||
*/
|
*/
|
||||||
@@ -44,7 +45,7 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID查询用户
|
* 通过用户ID查询用户
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @return 用户对象信息
|
* @return 用户对象信息
|
||||||
*/
|
*/
|
||||||
@@ -52,7 +53,7 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID查询用户所属角色组
|
* 根据用户ID查询用户所属角色组
|
||||||
*
|
*
|
||||||
* @param userName 用户名
|
* @param userName 用户名
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -60,7 +61,7 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID查询用户所属岗位组
|
* 根据用户ID查询用户所属岗位组
|
||||||
*
|
*
|
||||||
* @param userName 用户名
|
* @param userName 用户名
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -68,7 +69,7 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验用户名称是否唯一
|
* 校验用户名称是否唯一
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -92,21 +93,21 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验用户是否允许操作
|
* 校验用户是否允许操作
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
*/
|
*/
|
||||||
public void checkUserAllowed(SysUser user);
|
public void checkUserAllowed(SysUser user);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验用户是否有数据权限
|
* 校验用户是否有数据权限
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param userId 用户id
|
||||||
*/
|
*/
|
||||||
public void checkUserDataScope(Long userId);
|
public void checkUserDataScope(Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户信息
|
* 新增用户信息
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -114,7 +115,7 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册用户信息
|
* 注册用户信息
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -122,7 +123,7 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户信息
|
* 修改用户信息
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -130,15 +131,15 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户授权角色
|
* 用户授权角色
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param roleIds 角色组
|
* @param roleIds 角色组
|
||||||
*/
|
*/
|
||||||
public void insertUserAuth(Long userId, Long[] roleIds);
|
public void insertUserAuth(Long userId, Long[] roleIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户状态
|
* 修改用户状态
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -146,7 +147,7 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户基本信息
|
* 修改用户基本信息
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -154,16 +155,26 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户头像
|
* 修改用户头像
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param avatar 头像地址
|
* @param avatar 头像地址
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public boolean updateUserAvatar(Long userId, String avatar);
|
public boolean updateUserAvatar(Long userId, String avatar);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户登录信息(IP和登录时间)
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param loginIp 登录IP地址
|
||||||
|
* @param loginDate 登录时间
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public void updateLoginInfo(Long userId, String loginIp, Date loginDate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置用户密码
|
* 重置用户密码
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -171,8 +182,8 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置用户密码
|
* 重置用户密码
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param password 密码
|
* @param password 密码
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -180,7 +191,7 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID删除用户
|
* 通过用户ID删除用户
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -188,7 +199,7 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除用户信息
|
* 批量删除用户信息
|
||||||
*
|
*
|
||||||
* @param userIds 需要删除的用户ID
|
* @param userIds 需要删除的用户ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@@ -196,10 +207,10 @@ public interface ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入用户数据
|
* 导入用户数据
|
||||||
*
|
*
|
||||||
* @param userList 用户数据列表
|
* @param userList 用户数据列表
|
||||||
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
||||||
* @param operName 操作用户
|
* @param operName 操作用户
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||||
|
@@ -1,15 +1,5 @@
|
|||||||
package com.devttl.system.service.impl;
|
package com.devttl.system.service.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import jakarta.validation.Validator;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
import com.devttl.common.annotation.DataScope;
|
import com.devttl.common.annotation.DataScope;
|
||||||
import com.devttl.common.constant.UserConstants;
|
import com.devttl.common.constant.UserConstants;
|
||||||
import com.devttl.common.core.domain.entity.SysRole;
|
import com.devttl.common.core.domain.entity.SysRole;
|
||||||
@@ -22,23 +12,30 @@ import com.devttl.common.utils.spring.SpringUtils;
|
|||||||
import com.devttl.system.domain.SysPost;
|
import com.devttl.system.domain.SysPost;
|
||||||
import com.devttl.system.domain.SysUserPost;
|
import com.devttl.system.domain.SysUserPost;
|
||||||
import com.devttl.system.domain.SysUserRole;
|
import com.devttl.system.domain.SysUserRole;
|
||||||
import com.devttl.system.mapper.SysPostMapper;
|
import com.devttl.system.mapper.*;
|
||||||
import com.devttl.system.mapper.SysRoleMapper;
|
|
||||||
import com.devttl.system.mapper.SysUserMapper;
|
|
||||||
import com.devttl.system.mapper.SysUserPostMapper;
|
|
||||||
import com.devttl.system.mapper.SysUserRoleMapper;
|
|
||||||
import com.devttl.system.service.ISysConfigService;
|
import com.devttl.system.service.ISysConfigService;
|
||||||
import com.devttl.system.service.ISysDeptService;
|
import com.devttl.system.service.ISysDeptService;
|
||||||
import com.devttl.system.service.ISysUserService;
|
import com.devttl.system.service.ISysUserService;
|
||||||
|
import jakarta.validation.Validator;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户 业务层处理
|
* 用户 业务层处理
|
||||||
*
|
*
|
||||||
* @author devttl
|
* @author devttl
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SysUserServiceImpl implements ISysUserService
|
public class SysUserServiceImpl implements ISysUserService {
|
||||||
{
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -67,79 +64,72 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询用户列表
|
* 根据条件分页查询用户列表
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 用户信息集合信息
|
* @return 用户信息集合信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@DataScope(deptAlias = "d", userAlias = "u")
|
@DataScope(deptAlias = "d", userAlias = "u")
|
||||||
public List<SysUser> selectUserList(SysUser user)
|
public List<SysUser> selectUserList(SysUser user) {
|
||||||
{
|
|
||||||
return userMapper.selectUserList(user);
|
return userMapper.selectUserList(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询已分配用户角色列表
|
* 根据条件分页查询已分配用户角色列表
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 用户信息集合信息
|
* @return 用户信息集合信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@DataScope(deptAlias = "d", userAlias = "u")
|
@DataScope(deptAlias = "d", userAlias = "u")
|
||||||
public List<SysUser> selectAllocatedList(SysUser user)
|
public List<SysUser> selectAllocatedList(SysUser user) {
|
||||||
{
|
|
||||||
return userMapper.selectAllocatedList(user);
|
return userMapper.selectAllocatedList(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询未分配用户角色列表
|
* 根据条件分页查询未分配用户角色列表
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 用户信息集合信息
|
* @return 用户信息集合信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@DataScope(deptAlias = "d", userAlias = "u")
|
@DataScope(deptAlias = "d", userAlias = "u")
|
||||||
public List<SysUser> selectUnallocatedList(SysUser user)
|
public List<SysUser> selectUnallocatedList(SysUser user) {
|
||||||
{
|
|
||||||
return userMapper.selectUnallocatedList(user);
|
return userMapper.selectUnallocatedList(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户名查询用户
|
* 通过用户名查询用户
|
||||||
*
|
*
|
||||||
* @param userName 用户名
|
* @param userName 用户名
|
||||||
* @return 用户对象信息
|
* @return 用户对象信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysUser selectUserByUserName(String userName)
|
public SysUser selectUserByUserName(String userName) {
|
||||||
{
|
|
||||||
return userMapper.selectUserByUserName(userName);
|
return userMapper.selectUserByUserName(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID查询用户
|
* 通过用户ID查询用户
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @return 用户对象信息
|
* @return 用户对象信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysUser selectUserById(Long userId)
|
public SysUser selectUserById(Long userId) {
|
||||||
{
|
|
||||||
return userMapper.selectUserById(userId);
|
return userMapper.selectUserById(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户所属角色组
|
* 查询用户所属角色组
|
||||||
*
|
*
|
||||||
* @param userName 用户名
|
* @param userName 用户名
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String selectUserRoleGroup(String userName)
|
public String selectUserRoleGroup(String userName) {
|
||||||
{
|
|
||||||
List<SysRole> list = roleMapper.selectRolesByUserName(userName);
|
List<SysRole> list = roleMapper.selectRolesByUserName(userName);
|
||||||
if (CollectionUtils.isEmpty(list))
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
return StringUtils.EMPTY;
|
||||||
}
|
}
|
||||||
return list.stream().map(SysRole::getRoleName).collect(Collectors.joining(","));
|
return list.stream().map(SysRole::getRoleName).collect(Collectors.joining(","));
|
||||||
@@ -147,16 +137,14 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户所属岗位组
|
* 查询用户所属岗位组
|
||||||
*
|
*
|
||||||
* @param userName 用户名
|
* @param userName 用户名
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String selectUserPostGroup(String userName)
|
public String selectUserPostGroup(String userName) {
|
||||||
{
|
|
||||||
List<SysPost> list = postMapper.selectPostsByUserName(userName);
|
List<SysPost> list = postMapper.selectPostsByUserName(userName);
|
||||||
if (CollectionUtils.isEmpty(list))
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
{
|
|
||||||
return StringUtils.EMPTY;
|
return StringUtils.EMPTY;
|
||||||
}
|
}
|
||||||
return list.stream().map(SysPost::getPostName).collect(Collectors.joining(","));
|
return list.stream().map(SysPost::getPostName).collect(Collectors.joining(","));
|
||||||
@@ -164,17 +152,15 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验用户名称是否唯一
|
* 校验用户名称是否唯一
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkUserNameUnique(SysUser user)
|
public boolean checkUserNameUnique(SysUser user) {
|
||||||
{
|
|
||||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||||
SysUser info = userMapper.checkUserNameUnique(user.getUserName());
|
SysUser info = userMapper.checkUserNameUnique(user.getUserName());
|
||||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||||
{
|
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
@@ -187,12 +173,10 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkPhoneUnique(SysUser user)
|
public boolean checkPhoneUnique(SysUser user) {
|
||||||
{
|
|
||||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||||
SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
|
SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber());
|
||||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||||
{
|
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
@@ -205,12 +189,10 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean checkEmailUnique(SysUser user)
|
public boolean checkEmailUnique(SysUser user) {
|
||||||
{
|
|
||||||
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
|
||||||
SysUser info = userMapper.checkEmailUnique(user.getEmail());
|
SysUser info = userMapper.checkEmailUnique(user.getEmail());
|
||||||
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue())
|
if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) {
|
||||||
{
|
|
||||||
return UserConstants.NOT_UNIQUE;
|
return UserConstants.NOT_UNIQUE;
|
||||||
}
|
}
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
@@ -218,33 +200,28 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验用户是否允许操作
|
* 校验用户是否允许操作
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkUserAllowed(SysUser user)
|
public void checkUserAllowed(SysUser user) {
|
||||||
{
|
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) {
|
||||||
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin())
|
|
||||||
{
|
|
||||||
throw new ServiceException("不允许操作超级管理员用户");
|
throw new ServiceException("不允许操作超级管理员用户");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验用户是否有数据权限
|
* 校验用户是否有数据权限
|
||||||
*
|
*
|
||||||
* @param userId 用户id
|
* @param userId 用户id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkUserDataScope(Long userId)
|
public void checkUserDataScope(Long userId) {
|
||||||
{
|
if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
|
||||||
if (!SysUser.isAdmin(SecurityUtils.getUserId()))
|
|
||||||
{
|
|
||||||
SysUser user = new SysUser();
|
SysUser user = new SysUser();
|
||||||
user.setUserId(userId);
|
user.setUserId(userId);
|
||||||
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
|
||||||
if (StringUtils.isEmpty(users))
|
if (StringUtils.isEmpty(users)) {
|
||||||
{
|
|
||||||
throw new ServiceException("没有权限访问用户数据!");
|
throw new ServiceException("没有权限访问用户数据!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,14 +229,13 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增保存用户信息
|
* 新增保存用户信息
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public int insertUser(SysUser user)
|
public int insertUser(SysUser user) {
|
||||||
{
|
|
||||||
// 新增用户信息
|
// 新增用户信息
|
||||||
int rows = userMapper.insertUser(user);
|
int rows = userMapper.insertUser(user);
|
||||||
// 新增用户岗位关联
|
// 新增用户岗位关联
|
||||||
@@ -271,26 +247,24 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册用户信息
|
* 注册用户信息
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean registerUser(SysUser user)
|
public boolean registerUser(SysUser user) {
|
||||||
{
|
|
||||||
return userMapper.insertUser(user) > 0;
|
return userMapper.insertUser(user) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存用户信息
|
* 修改保存用户信息
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public int updateUser(SysUser user)
|
public int updateUser(SysUser user) {
|
||||||
{
|
|
||||||
Long userId = user.getUserId();
|
Long userId = user.getUserId();
|
||||||
// 删除用户与角色关联
|
// 删除用户与角色关联
|
||||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||||
@@ -305,104 +279,106 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户授权角色
|
* 用户授权角色
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param roleIds 角色组
|
* @param roleIds 角色组
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void insertUserAuth(Long userId, Long[] roleIds)
|
public void insertUserAuth(Long userId, Long[] roleIds) {
|
||||||
{
|
|
||||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||||
insertUserRole(userId, roleIds);
|
insertUserRole(userId, roleIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户状态
|
* 修改用户状态
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateUserStatus(SysUser user)
|
public int updateUserStatus(SysUser user) {
|
||||||
{
|
|
||||||
return userMapper.updateUser(user);
|
return userMapper.updateUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户基本信息
|
* 修改用户基本信息
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateUserProfile(SysUser user)
|
public int updateUserProfile(SysUser user) {
|
||||||
{
|
|
||||||
return userMapper.updateUser(user);
|
return userMapper.updateUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户头像
|
* 修改用户头像
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param avatar 头像地址
|
* @param avatar 头像地址
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean updateUserAvatar(Long userId, String avatar)
|
public boolean updateUserAvatar(Long userId, String avatar) {
|
||||||
{
|
|
||||||
return userMapper.updateUserAvatar(userId, avatar) > 0;
|
return userMapper.updateUserAvatar(userId, avatar) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新用户登录信息(IP和登录时间)
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @param loginIp 登录IP地址
|
||||||
|
* @param loginDate 登录时间
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public void updateLoginInfo(Long userId, String loginIp, Date loginDate) {
|
||||||
|
userMapper.updateLoginInfo(userId, loginIp, loginDate);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置用户密码
|
* 重置用户密码
|
||||||
*
|
*
|
||||||
* @param user 用户信息
|
* @param user 用户信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int resetPwd(SysUser user)
|
public int resetPwd(SysUser user) {
|
||||||
{
|
|
||||||
return userMapper.updateUser(user);
|
return userMapper.updateUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重置用户密码
|
* 重置用户密码
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param password 密码
|
* @param password 密码
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int resetUserPwd(Long userId, String password)
|
public int resetUserPwd(Long userId, String password) {
|
||||||
{
|
|
||||||
return userMapper.resetUserPwd(userId, password);
|
return userMapper.resetUserPwd(userId, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户角色信息
|
* 新增用户角色信息
|
||||||
*
|
*
|
||||||
* @param user 用户对象
|
* @param user 用户对象
|
||||||
*/
|
*/
|
||||||
public void insertUserRole(SysUser user)
|
public void insertUserRole(SysUser user) {
|
||||||
{
|
|
||||||
this.insertUserRole(user.getUserId(), user.getRoleIds());
|
this.insertUserRole(user.getUserId(), user.getRoleIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户岗位信息
|
* 新增用户岗位信息
|
||||||
*
|
*
|
||||||
* @param user 用户对象
|
* @param user 用户对象
|
||||||
*/
|
*/
|
||||||
public void insertUserPost(SysUser user)
|
public void insertUserPost(SysUser user) {
|
||||||
{
|
|
||||||
Long[] posts = user.getPostIds();
|
Long[] posts = user.getPostIds();
|
||||||
if (StringUtils.isNotEmpty(posts))
|
if (StringUtils.isNotEmpty(posts)) {
|
||||||
{
|
|
||||||
// 新增用户与岗位管理
|
// 新增用户与岗位管理
|
||||||
List<SysUserPost> list = new ArrayList<SysUserPost>(posts.length);
|
List<SysUserPost> list = new ArrayList<SysUserPost>(posts.length);
|
||||||
for (Long postId : posts)
|
for (Long postId : posts) {
|
||||||
{
|
|
||||||
SysUserPost up = new SysUserPost();
|
SysUserPost up = new SysUserPost();
|
||||||
up.setUserId(user.getUserId());
|
up.setUserId(user.getUserId());
|
||||||
up.setPostId(postId);
|
up.setPostId(postId);
|
||||||
@@ -414,18 +390,15 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增用户角色信息
|
* 新增用户角色信息
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @param roleIds 角色组
|
* @param roleIds 角色组
|
||||||
*/
|
*/
|
||||||
public void insertUserRole(Long userId, Long[] roleIds)
|
public void insertUserRole(Long userId, Long[] roleIds) {
|
||||||
{
|
if (StringUtils.isNotEmpty(roleIds)) {
|
||||||
if (StringUtils.isNotEmpty(roleIds))
|
|
||||||
{
|
|
||||||
// 新增用户与角色管理
|
// 新增用户与角色管理
|
||||||
List<SysUserRole> list = new ArrayList<SysUserRole>(roleIds.length);
|
List<SysUserRole> list = new ArrayList<SysUserRole>(roleIds.length);
|
||||||
for (Long roleId : roleIds)
|
for (Long roleId : roleIds) {
|
||||||
{
|
|
||||||
SysUserRole ur = new SysUserRole();
|
SysUserRole ur = new SysUserRole();
|
||||||
ur.setUserId(userId);
|
ur.setUserId(userId);
|
||||||
ur.setRoleId(roleId);
|
ur.setRoleId(roleId);
|
||||||
@@ -437,14 +410,13 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户ID删除用户
|
* 通过用户ID删除用户
|
||||||
*
|
*
|
||||||
* @param userId 用户ID
|
* @param userId 用户ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public int deleteUserById(Long userId)
|
public int deleteUserById(Long userId) {
|
||||||
{
|
|
||||||
// 删除用户与角色关联
|
// 删除用户与角色关联
|
||||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||||
// 删除用户与岗位表
|
// 删除用户与岗位表
|
||||||
@@ -454,16 +426,14 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除用户信息
|
* 批量删除用户信息
|
||||||
*
|
*
|
||||||
* @param userIds 需要删除的用户ID
|
* @param userIds 需要删除的用户ID
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public int deleteUserByIds(Long[] userIds)
|
public int deleteUserByIds(Long[] userIds) {
|
||||||
{
|
for (Long userId : userIds) {
|
||||||
for (Long userId : userIds)
|
|
||||||
{
|
|
||||||
checkUserAllowed(new SysUser(userId));
|
checkUserAllowed(new SysUser(userId));
|
||||||
checkUserDataScope(userId);
|
checkUserDataScope(userId);
|
||||||
}
|
}
|
||||||
@@ -476,31 +446,26 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入用户数据
|
* 导入用户数据
|
||||||
*
|
*
|
||||||
* @param userList 用户数据列表
|
* @param userList 用户数据列表
|
||||||
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
||||||
* @param operName 操作用户
|
* @param operName 操作用户
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName)
|
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) {
|
||||||
{
|
if (StringUtils.isNull(userList) || userList.size() == 0) {
|
||||||
if (StringUtils.isNull(userList) || userList.size() == 0)
|
|
||||||
{
|
|
||||||
throw new ServiceException("导入用户数据不能为空!");
|
throw new ServiceException("导入用户数据不能为空!");
|
||||||
}
|
}
|
||||||
int successNum = 0;
|
int successNum = 0;
|
||||||
int failureNum = 0;
|
int failureNum = 0;
|
||||||
StringBuilder successMsg = new StringBuilder();
|
StringBuilder successMsg = new StringBuilder();
|
||||||
StringBuilder failureMsg = new StringBuilder();
|
StringBuilder failureMsg = new StringBuilder();
|
||||||
for (SysUser user : userList)
|
for (SysUser user : userList) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
// 验证是否存在这个用户
|
// 验证是否存在这个用户
|
||||||
SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
SysUser u = userMapper.selectUserByUserName(user.getUserName());
|
||||||
if (StringUtils.isNull(u))
|
if (StringUtils.isNull(u)) {
|
||||||
{
|
|
||||||
BeanValidators.validateWithException(validator, user);
|
BeanValidators.validateWithException(validator, user);
|
||||||
deptService.checkDeptDataScope(user.getDeptId());
|
deptService.checkDeptDataScope(user.getDeptId());
|
||||||
String password = configService.selectConfigByKey("sys.user.initPassword");
|
String password = configService.selectConfigByKey("sys.user.initPassword");
|
||||||
@@ -509,9 +474,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
userMapper.insertUser(user);
|
userMapper.insertUser(user);
|
||||||
successNum++;
|
successNum++;
|
||||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
|
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
|
||||||
}
|
} else if (isUpdateSupport) {
|
||||||
else if (isUpdateSupport)
|
|
||||||
{
|
|
||||||
BeanValidators.validateWithException(validator, user);
|
BeanValidators.validateWithException(validator, user);
|
||||||
checkUserAllowed(u);
|
checkUserAllowed(u);
|
||||||
checkUserDataScope(u.getUserId());
|
checkUserDataScope(u.getUserId());
|
||||||
@@ -521,28 +484,21 @@ public class SysUserServiceImpl implements ISysUserService
|
|||||||
userMapper.updateUser(user);
|
userMapper.updateUser(user);
|
||||||
successNum++;
|
successNum++;
|
||||||
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
|
successMsg.append("<br/>" + successNum + "、账号 " + user.getUserName() + " 更新成功");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
failureNum++;
|
failureNum++;
|
||||||
failureMsg.append("<br/>" + failureNum + "、账号 " + user.getUserName() + " 已存在");
|
failureMsg.append("<br/>" + failureNum + "、账号 " + user.getUserName() + " 已存在");
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
failureNum++;
|
failureNum++;
|
||||||
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
String msg = "<br/>" + failureNum + "、账号 " + user.getUserName() + " 导入失败:";
|
||||||
failureMsg.append(msg + e.getMessage());
|
failureMsg.append(msg + e.getMessage());
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (failureNum > 0)
|
if (failureNum > 0) {
|
||||||
{
|
|
||||||
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
||||||
throw new ServiceException(failureMsg.toString());
|
throw new ServiceException(failureMsg.toString());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
||||||
}
|
}
|
||||||
return successMsg.toString();
|
return successMsg.toString();
|
||||||
|
@@ -1,223 +1,232 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper
|
<!DOCTYPE mapper
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.devttl.system.mapper.SysUserMapper">
|
<mapper namespace="com.devttl.system.mapper.SysUserMapper">
|
||||||
|
|
||||||
<resultMap type="SysUser" id="SysUserResult">
|
<resultMap type="SysUser" id="SysUserResult">
|
||||||
<id property="userId" column="user_id" />
|
<id property="userId" column="user_id"/>
|
||||||
<result property="deptId" column="dept_id" />
|
<result property="deptId" column="dept_id"/>
|
||||||
<result property="userName" column="user_name" />
|
<result property="userName" column="user_name"/>
|
||||||
<result property="nickName" column="nick_name" />
|
<result property="nickName" column="nick_name"/>
|
||||||
<result property="email" column="email" />
|
<result property="email" column="email"/>
|
||||||
<result property="phonenumber" column="phonenumber" />
|
<result property="phonenumber" column="phonenumber"/>
|
||||||
<result property="sex" column="sex" />
|
<result property="sex" column="sex"/>
|
||||||
<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="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"/>
|
||||||
<result property="pwdUpdateDate" column="pwd_update_date" />
|
<result property="pwdUpdateDate" column="pwd_update_date"/>
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by"/>
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time"/>
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by"/>
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time"/>
|
||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark"/>
|
||||||
<association property="dept" javaType="SysDept" resultMap="deptResult" />
|
<association property="dept" javaType="SysDept" resultMap="deptResult"/>
|
||||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
|
<collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="deptResult" type="SysDept">
|
<resultMap id="deptResult" type="SysDept">
|
||||||
<id property="deptId" column="dept_id" />
|
<id property="deptId" column="dept_id"/>
|
||||||
<result property="parentId" column="parent_id" />
|
<result property="parentId" column="parent_id"/>
|
||||||
<result property="deptName" column="dept_name" />
|
<result property="deptName" column="dept_name"/>
|
||||||
<result property="ancestors" column="ancestors" />
|
<result property="ancestors" column="ancestors"/>
|
||||||
<result property="orderNum" column="order_num" />
|
<result property="orderNum" column="order_num"/>
|
||||||
<result property="leader" column="leader" />
|
<result property="leader" column="leader"/>
|
||||||
<result property="status" column="dept_status" />
|
<result property="status" column="dept_status"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap id="RoleResult" type="SysRole">
|
<resultMap id="RoleResult" type="SysRole">
|
||||||
<id property="roleId" column="role_id" />
|
<id property="roleId" column="role_id"/>
|
||||||
<result property="roleName" column="role_name" />
|
<result property="roleName" column="role_name"/>
|
||||||
<result property="roleKey" column="role_key" />
|
<result property="roleKey" column="role_key"/>
|
||||||
<result property="roleSort" column="role_sort" />
|
<result property="roleSort" column="role_sort"/>
|
||||||
<result property="dataScope" column="data_scope" />
|
<result property="dataScope" column="data_scope"/>
|
||||||
<result property="status" column="role_status" />
|
<result property="status" column="role_status"/>
|
||||||
</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.pwd_update_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.del_flag, u.login_ip, u.login_date, u.pwd_update_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
|
||||||
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
|
||||||
left join sys_role r on r.role_id = ur.role_id
|
left join sys_role r on r.role_id = ur.role_id
|
||||||
</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,
|
||||||
left join sys_dept d on u.dept_id = d.dept_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
|
||||||
where u.del_flag = '0'
|
u
|
||||||
<if test="userId != null and userId != 0">
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
AND u.user_id = #{userId}
|
where u.del_flag = '0'
|
||||||
</if>
|
<if test="userId != null and userId != 0">
|
||||||
<if test="userName != null and userName != ''">
|
AND u.user_id = #{userId}
|
||||||
AND u.user_name like concat('%', #{userName}, '%')
|
</if>
|
||||||
</if>
|
<if test="userName != null and userName != ''">
|
||||||
<if test="status != null and status != ''">
|
AND u.user_name like concat('%', #{userName}, '%')
|
||||||
AND u.status = #{status}
|
</if>
|
||||||
</if>
|
<if test="status != null and status != ''">
|
||||||
<if test="phonenumber != null and phonenumber != ''">
|
AND u.status = #{status}
|
||||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
</if>
|
||||||
</if>
|
<if test="phonenumber != null and phonenumber != ''">
|
||||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||||
AND date_format(u.create_time,'%Y%m%d') >= date_format(#{params.beginTime},'%Y%m%d')
|
</if>
|
||||||
</if>
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
AND date_format(u.create_time,'%Y%m%d') >= date_format(#{params.beginTime},'%Y%m%d')
|
||||||
AND date_format(u.create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d')
|
</if>
|
||||||
</if>
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||||
<if test="deptId != null and deptId != 0">
|
AND date_format(u.create_time,'%Y%m%d') <= date_format(#{params.endTime},'%Y%m%d')
|
||||||
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
|
</if>
|
||||||
</if>
|
<if test="deptId != null and deptId != 0">
|
||||||
<!-- 数据范围过滤 -->
|
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
|
||||||
${params.dataScope}
|
ancestors) ))
|
||||||
</select>
|
</if>
|
||||||
|
<!-- 数据范围过滤 -->
|
||||||
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
${params.dataScope}
|
||||||
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
</select>
|
||||||
from sys_user u
|
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
left join sys_user_role ur on u.user_id = ur.user_id
|
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
||||||
left join sys_role r on r.role_id = ur.role_id
|
from sys_user u
|
||||||
where u.del_flag = '0' and r.role_id = #{roleId}
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
<if test="userName != null and userName != ''">
|
left join sys_user_role ur on u.user_id = ur.user_id
|
||||||
AND u.user_name like concat('%', #{userName}, '%')
|
left join sys_role r on r.role_id = ur.role_id
|
||||||
</if>
|
where u.del_flag = '0' and r.role_id = #{roleId}
|
||||||
<if test="phonenumber != null and phonenumber != ''">
|
<if test="userName != null and userName != ''">
|
||||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
AND u.user_name like concat('%', #{userName}, '%')
|
||||||
</if>
|
</if>
|
||||||
<!-- 数据范围过滤 -->
|
<if test="phonenumber != null and phonenumber != ''">
|
||||||
${params.dataScope}
|
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||||
</select>
|
</if>
|
||||||
|
<!-- 数据范围过滤 -->
|
||||||
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
${params.dataScope}
|
||||||
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
</select>
|
||||||
from sys_user u
|
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
left join sys_user_role ur on u.user_id = ur.user_id
|
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
||||||
left join sys_role r on r.role_id = ur.role_id
|
from sys_user u
|
||||||
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and ur.role_id = #{roleId})
|
left join sys_user_role ur on u.user_id = ur.user_id
|
||||||
<if test="userName != null and userName != ''">
|
left join sys_role r on r.role_id = ur.role_id
|
||||||
AND u.user_name like concat('%', #{userName}, '%')
|
where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
|
||||||
</if>
|
and u.user_id not in (select u.user_id from sys_user u inner join sys_user_role ur on u.user_id = ur.user_id and
|
||||||
<if test="phonenumber != null and phonenumber != ''">
|
ur.role_id = #{roleId})
|
||||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
<if test="userName != null and userName != ''">
|
||||||
</if>
|
AND u.user_name like concat('%', #{userName}, '%')
|
||||||
<!-- 数据范围过滤 -->
|
</if>
|
||||||
${params.dataScope}
|
<if test="phonenumber != null and phonenumber != ''">
|
||||||
</select>
|
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||||
|
</if>
|
||||||
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
<!-- 数据范围过滤 -->
|
||||||
<include refid="selectUserVo"/>
|
${params.dataScope}
|
||||||
where u.user_name = #{userName} and u.del_flag = '0'
|
</select>
|
||||||
</select>
|
|
||||||
|
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||||
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
<include refid="selectUserVo"/>
|
||||||
<include refid="selectUserVo"/>
|
where u.user_name = #{userName} and u.del_flag = '0'
|
||||||
where u.user_id = #{userId}
|
</select>
|
||||||
</select>
|
|
||||||
|
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
|
||||||
<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
|
<include refid="selectUserVo"/>
|
||||||
select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
|
where u.user_id = #{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
|
<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
|
||||||
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
|
select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
|
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
|
||||||
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
|
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
|
||||||
insert into sys_user(
|
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
|
||||||
<if test="userId != null and userId != 0">user_id,</if>
|
</select>
|
||||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
|
||||||
<if test="userName != null and userName != ''">user_name,</if>
|
<insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||||
<if test="nickName != null and nickName != ''">nick_name,</if>
|
insert into sys_user(
|
||||||
<if test="email != null and email != ''">email,</if>
|
<if test="userId != null and userId != 0">user_id,</if>
|
||||||
<if test="avatar != null and avatar != ''">avatar,</if>
|
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||||
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
|
<if test="userName != null and userName != ''">user_name,</if>
|
||||||
<if test="sex != null and sex != ''">sex,</if>
|
<if test="nickName != null and nickName != ''">nick_name,</if>
|
||||||
<if test="password != null and password != ''">password,</if>
|
<if test="email != null and email != ''">email,</if>
|
||||||
<if test="status != null and status != ''">status,</if>
|
<if test="avatar != null and avatar != ''">avatar,</if>
|
||||||
<if test="pwdUpdateDate != null">pwd_update_date,</if>
|
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="sex != null and sex != ''">sex,</if>
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
<if test="password != null and password != ''">password,</if>
|
||||||
create_time
|
<if test="status != null and status != ''">status,</if>
|
||||||
)values(
|
<if test="pwdUpdateDate != null">pwd_update_date,</if>
|
||||||
<if test="userId != null and userId != ''">#{userId},</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
<if test="userName != null and userName != ''">#{userName},</if>
|
create_time
|
||||||
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
)values(
|
||||||
<if test="email != null and email != ''">#{email},</if>
|
<if test="userId != null and userId != ''">#{userId},</if>
|
||||||
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
||||||
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
|
<if test="userName != null and userName != ''">#{userName},</if>
|
||||||
<if test="sex != null and sex != ''">#{sex},</if>
|
<if test="nickName != null and nickName != ''">#{nickName},</if>
|
||||||
<if test="password != null and password != ''">#{password},</if>
|
<if test="email != null and email != ''">#{email},</if>
|
||||||
<if test="status != null and status != ''">#{status},</if>
|
<if test="avatar != null and avatar != ''">#{avatar},</if>
|
||||||
<if test="pwdUpdateDate != null">#{pwdUpdateDate},</if>
|
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="sex != null and sex != ''">#{sex},</if>
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
<if test="password != null and password != ''">#{password},</if>
|
||||||
sysdate()
|
<if test="status != null and status != ''">#{status},</if>
|
||||||
)
|
<if test="pwdUpdateDate != null">#{pwdUpdateDate},</if>
|
||||||
</insert>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
<update id="updateUser" parameterType="SysUser">
|
sysdate()
|
||||||
update sys_user
|
)
|
||||||
<set>
|
</insert>
|
||||||
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
|
||||||
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
<update id="updateUser" parameterType="SysUser">
|
||||||
<if test="email != null ">email = #{email},</if>
|
update sys_user
|
||||||
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
<set>
|
||||||
<if test="sex != null and sex != ''">sex = #{sex},</if>
|
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
||||||
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
||||||
<if test="password != null and password != ''">password = #{password},</if>
|
<if test="email != null ">email = #{email},</if>
|
||||||
<if test="status != null and status != ''">status = #{status},</if>
|
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
||||||
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
<if test="sex != null and sex != ''">sex = #{sex},</if>
|
||||||
<if test="loginDate != null">login_date = #{loginDate},</if>
|
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="password != null and password != ''">password = #{password},</if>
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
<if test="status != null and status != ''">status = #{status},</if>
|
||||||
update_time = sysdate()
|
<if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
|
||||||
</set>
|
<if test="loginDate != null">login_date = #{loginDate},</if>
|
||||||
where user_id = #{userId}
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
</update>
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
update_time = sysdate()
|
||||||
<update id="updateUserStatus" parameterType="SysUser">
|
</set>
|
||||||
update sys_user set status = #{status} where user_id = #{userId}
|
where user_id = #{userId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="updateUserAvatar" parameterType="SysUser">
|
<update id="updateUserStatus" parameterType="SysUser">
|
||||||
update sys_user set avatar = #{avatar} where user_id = #{userId}
|
update sys_user set status = #{status} where user_id = #{userId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<update id="resetUserPwd" parameterType="SysUser">
|
<update id="updateUserAvatar" parameterType="SysUser">
|
||||||
update sys_user set pwd_update_date = sysdate(), password = #{password} where user_id = #{userId}
|
update sys_user set avatar = #{avatar} where user_id = #{userId}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteUserById" parameterType="Long">
|
<update id="updateLoginInfo" parameterType="SysUser">
|
||||||
update sys_user set del_flag = '2' where user_id = #{userId}
|
update sys_user set login_ip = #{loginIp}, login_date = #{loginDate} where user_id = #{userId}
|
||||||
</delete>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteUserByIds" parameterType="Long">
|
<update id="resetUserPwd" parameterType="SysUser">
|
||||||
update sys_user set del_flag = '2' where user_id in
|
update sys_user set pwd_update_date = sysdate(), password = #{password} where user_id = #{userId}
|
||||||
<foreach collection="array" item="userId" open="(" separator="," close=")">
|
</update>
|
||||||
#{userId}
|
|
||||||
</foreach>
|
<delete id="deleteUserById" parameterType="Long">
|
||||||
</delete>
|
update sys_user set del_flag = '2' where user_id = #{userId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteUserByIds" parameterType="Long">
|
||||||
|
update sys_user set del_flag = '2' where user_id in
|
||||||
|
<foreach collection="array" item="userId" open="(" separator="," close=")">
|
||||||
|
#{userId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Reference in New Issue
Block a user