From c20e9a5dc79a642a1d59a3b4b98c9742fa58125b Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期五, 19 一月 2024 14:04:09 +0800
Subject: [PATCH] 代码提交
---
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java | 104 ++--
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java | 246 ++++------
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java | 16
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml | 507 ++++++++++++---------
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java | 30
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java | 70 +-
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java | 280 ++++++------
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java | 50 +
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java | 22
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java | 32
10 files changed, 698 insertions(+), 659 deletions(-)
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
index 79e207c..26f7b38 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
@@ -19,355 +19,351 @@
/**
* 鐢ㄦ埛瀵硅薄 sys_user
- *
+ *
* @author ruoyi
*/
-public class SysUser extends BaseEntity
-{
+public class SysUser extends BaseEntity {
private static final long serialVersionUID = 1L;
- /** 鐢ㄦ埛ID */
+ /**
+ * 鐢ㄦ埛ID
+ */
@Excel(name = "鐢ㄦ埛搴忓彿", cellType = ColumnType.NUMERIC, prompt = "鐢ㄦ埛缂栧彿")
private Long userId;
- /** 閮ㄩ棬ID */
+ /**
+ * 閮ㄩ棬ID
+ */
@Excel(name = "閮ㄩ棬缂栧彿", type = Type.IMPORT)
private Long deptId;
- /** 寰俊openID */
+ /**
+ * 寰俊openID
+ */
@Excel(name = "寰俊openId")
private String openid;
- /** 鐢ㄦ埛璐﹀彿 */
+ /**
+ * 鐢ㄦ埛璐﹀彿
+ */
@Excel(name = "鐧诲綍鍚嶇О")
private String userName;
- /** 鐢ㄦ埛鏄电О */
+ /**
+ * 鐢ㄦ埛鏄电О
+ */
@Excel(name = "鐢ㄦ埛鍚嶇О")
private String nickName;
- /** 鐢ㄦ埛閭 */
+ /**
+ * 鐢ㄦ埛閭
+ */
@Excel(name = "鐢ㄦ埛閭")
private String email;
- /** 鎵嬫満鍙风爜 */
+ /**
+ * 鎵嬫満鍙风爜
+ */
@Excel(name = "鎵嬫満鍙风爜")
private String phonenumber;
- /** 鐢ㄦ埛鎬у埆 */
+ /**
+ * 鐢ㄦ埛鎬у埆
+ */
@Excel(name = "鐢ㄦ埛鎬у埆", readConverterExp = "0=鐢�,1=濂�,2=鏈煡")
private String sex;
- /** 鐢ㄦ埛澶村儚 */
+ /**
+ * 鐢ㄦ埛澶村儚
+ */
private String avatar;
- /** 瀵嗙爜 */
+ /**
+ * 瀵嗙爜
+ */
private String password;
- /** 鐩愬姞瀵� */
+ /**
+ * 鐩愬姞瀵�
+ */
private String salt;
- /** 甯愬彿鐘舵�侊紙0姝e父 1鍋滅敤锛� */
+ /**
+ * 甯愬彿鐘舵�侊紙0姝e父 1鍋滅敤锛�
+ */
@Excel(name = "甯愬彿鐘舵��", readConverterExp = "0=姝e父,1=鍋滅敤")
private String status;
- /** 鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛� */
+ /**
+ * 鍒犻櫎鏍囧織锛�0浠h〃瀛樺湪 2浠h〃鍒犻櫎锛�
+ */
private String delFlag;
- /** 鏈�鍚庣櫥褰旾P */
+ /**
+ * 鏈�鍚庣櫥褰旾P
+ */
@Excel(name = "鏈�鍚庣櫥褰旾P", type = Type.EXPORT)
private String loginIp;
- /** 鏈�鍚庣櫥褰曟椂闂� */
+ /**
+ * 鏈�鍚庣櫥褰曟椂闂�
+ */
@Excel(name = "鏈�鍚庣櫥褰曟椂闂�", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
private Date loginDate;
- /** 鎶ラ攢绾у埆 */
+ /**
+ * 鎶ラ攢绾у埆
+ */
@Excel(name = "鎶ラ攢绾у埆")
private Integer standardlevel;
- /** 閮ㄩ棬瀵硅薄 */
- @Excels({
- @Excel(name = "閮ㄩ棬鍚嶇О", targetAttr = "deptName", type = Type.EXPORT),
- @Excel(name = "閮ㄩ棬璐熻矗浜�", targetAttr = "leader", type = Type.EXPORT)
- })
+ /**
+ * 閮ㄩ棬瀵硅薄
+ */
+ @Excels({@Excel(name = "閮ㄩ棬鍚嶇О", targetAttr = "deptName", type = Type.EXPORT), @Excel(name = "閮ㄩ棬璐熻矗浜�", targetAttr = "leader", type = Type.EXPORT)})
private SysDept dept;
- /** 瑙掕壊瀵硅薄 */
+ /**
+ * 瑙掕壊瀵硅薄
+ */
private List<SysRole> roles;
- /** 瑙掕壊缁� */
+ /**
+ * 瑙掕壊缁�
+ */
private Long[] roleIds;
- /** 宀椾綅缁� */
+ /**
+ * 宀椾綅缁�
+ */
private Long[] postIds;
- /** 瑙掕壊ID */
+ /**
+ * 瑙掕壊ID
+ */
private Long roleId;
- public SysUser()
- {
+ /**
+ * 閿欒娆℃暟
+ */
+ private int errorNums;
+ /**
+ * 閿欒鏃堕棿
+ */
+ private String errorTimes;
+
+ public SysUser() {
}
- public SysUser(Long userId)
- {
+ public int getErrorNums() {
+ return errorNums;
+ }
+
+ public void setErrorNums(int errorNums) {
+ this.errorNums = errorNums;
+ }
+
+ public String getErrorTimes() {
+ return errorTimes;
+ }
+
+ public void setErrorTimes(String errorTimes) {
+ this.errorTimes = errorTimes;
+ }
+
+ public SysUser(Long userId) {
this.userId = userId;
}
- public Long getUserId()
- {
+ public Long getUserId() {
return userId;
}
- public void setUserId(Long userId)
- {
+ public void setUserId(Long userId) {
this.userId = userId;
}
- public String getOpenId()
- {
+ public String getOpenId() {
return openid;
}
- public void setOpenId(String openid)
- {
+ public void setOpenId(String openid) {
this.openid = openid;
}
- public boolean isAdmin()
- {
+ public boolean isAdmin() {
return isAdmin(this.userId);
}
- public static boolean isAdmin(Long userId)
- {
+ public static boolean isAdmin(Long userId) {
return userId != null && 1L == userId;
}
- public Long getDeptId()
- {
+ public Long getDeptId() {
return deptId;
}
- public void setDeptId(Long deptId)
- {
+ public void setDeptId(Long deptId) {
this.deptId = deptId;
}
@Size(min = 0, max = 30, message = "鐢ㄦ埛鏄电О闀垮害涓嶈兘瓒呰繃30涓瓧绗�")
- public String getNickName()
- {
+ public String getNickName() {
return nickName;
}
- public void setNickName(String nickName)
- {
+ public void setNickName(String nickName) {
this.nickName = nickName;
}
@NotBlank(message = "鐢ㄦ埛璐﹀彿涓嶈兘涓虹┖")
@Size(min = 0, max = 30, message = "鐢ㄦ埛璐﹀彿闀垮害涓嶈兘瓒呰繃30涓瓧绗�")
- public String getUserName()
- {
+ public String getUserName() {
return userName;
}
- public void setUserName(String userName)
- {
+ public void setUserName(String userName) {
this.userName = userName;
}
@Email(message = "閭鏍煎紡涓嶆纭�")
@Size(min = 0, max = 50, message = "閭闀垮害涓嶈兘瓒呰繃50涓瓧绗�")
- public String getEmail()
- {
+ public String getEmail() {
return email;
}
- public void setEmail(String email)
- {
+ public void setEmail(String email) {
this.email = email;
}
@Size(min = 0, max = 11, message = "鎵嬫満鍙风爜闀垮害涓嶈兘瓒呰繃11涓瓧绗�")
- public String getPhonenumber()
- {
+ public String getPhonenumber() {
return phonenumber;
}
- public void setPhonenumber(String phonenumber)
- {
+ public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
}
- public Integer getStandardlevel()
- {
+ public Integer getStandardlevel() {
return standardlevel;
}
- public void setStandardlevel(Integer standardlevel)
- {
+ public void setStandardlevel(Integer standardlevel) {
this.standardlevel = standardlevel;
}
- public String getAvatar()
- {
+ public String getAvatar() {
return avatar;
}
- public void setAvatar(String avatar)
- {
+ public void setAvatar(String avatar) {
this.avatar = avatar;
}
- public String getSex()
- {
+ public String getSex() {
return sex;
}
- public void setSex(String sex)
- {
+ public void setSex(String sex) {
this.sex = sex;
}
@JsonIgnore
@JsonProperty
- public String getPassword()
- {
+ public String getPassword() {
return password;
}
- public void setPassword(String password)
- {
+ public void setPassword(String password) {
this.password = password;
}
- public String getSalt()
- {
+ public String getSalt() {
return salt;
}
- public void setSalt(String salt)
- {
+ public void setSalt(String salt) {
this.salt = salt;
}
- public String getStatus()
- {
+ public String getStatus() {
return status;
}
- public void setStatus(String status)
- {
+ public void setStatus(String status) {
this.status = status;
}
- public String getDelFlag()
- {
+ public String getDelFlag() {
return delFlag;
}
- public void setDelFlag(String delFlag)
- {
+ public void setDelFlag(String delFlag) {
this.delFlag = delFlag;
}
- public String getLoginIp()
- {
+ public String getLoginIp() {
return loginIp;
}
- public void setLoginIp(String loginIp)
- {
+ public void setLoginIp(String loginIp) {
this.loginIp = loginIp;
}
- public Date getLoginDate()
- {
+ public Date getLoginDate() {
return loginDate;
}
- public void setLoginDate(Date loginDate)
- {
+ public void setLoginDate(Date loginDate) {
this.loginDate = loginDate;
}
- public SysDept getDept()
- {
+ public SysDept getDept() {
return dept;
}
- public void setDept(SysDept dept)
- {
+ public void setDept(SysDept dept) {
this.dept = dept;
}
- public List<SysRole> getRoles()
- {
+ public List<SysRole> getRoles() {
return roles;
}
- public void setRoles(List<SysRole> roles)
- {
+ public void setRoles(List<SysRole> roles) {
this.roles = roles;
}
- public Long[] getRoleIds()
- {
+ public Long[] getRoleIds() {
return roleIds;
}
- public void setRoleIds(Long[] roleIds)
- {
+ public void setRoleIds(Long[] roleIds) {
this.roleIds = roleIds;
}
- public Long[] getPostIds()
- {
+ public Long[] getPostIds() {
return postIds;
}
- public void setPostIds(Long[] postIds)
- {
+ public void setPostIds(Long[] postIds) {
this.postIds = postIds;
}
- public Long getRoleId()
- {
+ public Long getRoleId() {
return roleId;
}
- public void setRoleId(Long roleId)
- {
+ public void setRoleId(Long roleId) {
this.roleId = roleId;
}
@Override
public String toString() {
- return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
- .append("userId", getUserId())
- .append("deptId", getDeptId())
- .append("userName", getUserName())
- .append("nickName", getNickName())
- .append("email", getEmail())
- .append("phonenumber", getPhonenumber())
- .append("sex", getSex())
- .append("avatar", getAvatar())
- .append("password", getPassword())
- .append("salt", getSalt())
- .append("status", getStatus())
- .append("delFlag", getDelFlag())
- .append("loginIp", getLoginIp())
- .append("loginDate", getLoginDate())
- .append("createBy", getCreateBy())
- .append("createTime", getCreateTime())
- .append("updateBy", getUpdateBy())
- .append("updateTime", getUpdateTime())
- .append("remark", getRemark())
- .append("dept", getDept())
- .toString();
+ return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).append("userId", getUserId()).append("deptId", getDeptId()).append("userName", getUserName()).append("nickName", getNickName()).append("email", getEmail()).append("phonenumber", getPhonenumber()).append("sex", getSex()).append("avatar", getAvatar()).append("password", getPassword()).append("salt", getSalt()).append("status", getStatus()).append("delFlag", getDelFlag()).append("loginIp", getLoginIp()).append("loginDate", getLoginDate()).append("createBy", getCreateBy()).append("createTime", getCreateTime()).append("updateBy", getUpdateBy()).append("updateTime", getUpdateTime()).append("remark", getRemark()).append("dept", getDept()).toString();
}
}
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
index 3dcc042..6e79b6e 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
@@ -3,9 +3,11 @@
import javax.annotation.Resource;
import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.exception.user.WxOpenIDNotFindException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.wxopenidConfig.WxOpenIDAuthenticationToken;
+import com.ruoyi.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
@@ -31,12 +33,11 @@
/**
* 鐧诲綍鏍¢獙鏂规硶
- *
+ *
* @author ruoyi
*/
@Component
-public class SysLoginService
-{
+public class SysLoginService {
@Autowired
private TokenService tokenService;
@@ -45,47 +46,49 @@
@Autowired
private RedisCache redisCache;
-
+
@Autowired
private ISysUserService userService;
@Autowired
private ISysConfigService configService;
+
+ @Autowired
+ private SysUserMapper sysUserMapper;
+
/**
* 鐧诲綍楠岃瘉
- *
+ *
* @param username 鐢ㄦ埛鍚�
* @param password 瀵嗙爜
- * @param code 楠岃瘉鐮�
- * @param uuid 鍞竴鏍囪瘑
+ * @param code 楠岃瘉鐮�
+ * @param uuid 鍞竴鏍囪瘑
* @return 缁撴灉
*/
- public String login(String username, String password, String code, String uuid, String openId)
- {
+ public String login(String username, String password, String code, String uuid, String openId) {
+ SysUser sysUser = sysUserMapper.selectUserByUserName(username);
+ if (sysUser.getErrorNums() >= 3) {
+ //鏍¢獙澶辫触娆℃暟
+ throw new BaseException("浣犵殑瀵嗙爜杈撳叆閿欒娆℃暟杩囧锛岃鑱旂郴绠$悊鍛樺鐞�");
+ }
+
boolean captchaOnOff = configService.selectCaptchaOnOff();
// 楠岃瘉鐮佸紑鍏�
- if (captchaOnOff)
- {
+ if (captchaOnOff) {
validateCaptcha(username, code, uuid);
}
// 鐢ㄦ埛楠岃瘉
Authentication authentication = null;
- try
- {
+ try {
// 璇ユ柟娉曚細鍘昏皟鐢║serDetailsServiceImpl.loadUserByUsername
- authentication = authenticationManager
- .authenticate(new UsernamePasswordAuthenticationToken(username, password));
- }
- catch (Exception e)
- {
- if (e instanceof BadCredentialsException)
- {
+ authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password));
+ } catch (Exception e) {
+ if (e instanceof BadCredentialsException) {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
+ sysUserMapper.updateErrorNums(sysUser);
throw new UserPasswordNotMatchException();
- }
- else
- {
+ } else {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
throw new ServiceException(e.getMessage());
}
@@ -97,52 +100,44 @@
//鏇存柊openid
String userOpenId = user.getOpenId();
- if(StringUtils.isEmpty(openId))
- {
+ if (StringUtils.isEmpty(openId)) {
recordLoginInfo(loginUser.getUserId());
- }else
- {
- if(StringUtils.isNotEmpty(userOpenId))
- {
+ } else {
+ if (StringUtils.isNotEmpty(userOpenId)) {
//褰撴湰娆$櫥褰曠殑寰俊OPENID涓嶇瓑浜庣涓�娆$粦瀹氱殑寰俊OPENID灏变笉鍏佽鐧诲綍锛岄槻姝㈠悓涓�涓处鍙峰寰俊鐧诲綍
- if(!userOpenId.equals(openId))
- {
+ if (!userOpenId.equals(openId)) {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, "璇ヨ处鎴峰凡缁忕粦瀹氬叾浠栬澶囷紝椤诲厛瑙i櫎缁戝畾鍐嶇櫥褰曪紝璇疯窡绯荤粺绠$悊鍛樿仈绯伙紒"));
throw new ServiceException("璇ヨ处鎴峰凡缁忕粦瀹氬叾浠栬澶囷紝椤诲厛瑙i櫎缁戝畾鍐嶇櫥褰曪紝璇疯窡绯荤粺绠$悊鍛樿仈绯伙紒");
- }else
- {
+ } else {
recordLoginInfo(loginUser.getUserId());
}
- }else
- {
+ } else {
recordLoginInfo(loginUser.getUserId(), openId);
}
}
-
+ //娓呴櫎澶辫触娆℃暟
+ sysUserMapper.cleanErrorNums(username);
// 鐢熸垚token
return tokenService.createToken(loginUser);
}
/**
* 鏍¢獙楠岃瘉鐮�
- *
+ *
* @param username 鐢ㄦ埛鍚�
- * @param code 楠岃瘉鐮�
- * @param uuid 鍞竴鏍囪瘑
+ * @param code 楠岃瘉鐮�
+ * @param uuid 鍞竴鏍囪瘑
* @return 缁撴灉
*/
- public void validateCaptcha(String username, String code, String uuid)
- {
+ public void validateCaptcha(String username, String code, String uuid) {
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
String captcha = redisCache.getCacheObject(verifyKey);
redisCache.deleteObject(verifyKey);
- if (captcha == null)
- {
+ if (captcha == null) {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
throw new CaptchaExpireException();
}
- if (!code.equalsIgnoreCase(captcha))
- {
+ if (!code.equalsIgnoreCase(captcha)) {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
throw new CaptchaException();
}
@@ -155,20 +150,15 @@
* @return 缁撴灉
*/
- public AjaxResult wxopenidLogin(String openid)
- {
+ public AjaxResult wxopenidLogin(String openid) {
// 鐢ㄦ埛楠岃瘉
Authentication authentication = null;
- try
- {
+ try {
// 璇ユ柟娉曚細鍘昏皟鐢║serDetailsServiceImpl.loadUserByUsername
- authentication = authenticationManager
- .authenticate(new WxOpenIDAuthenticationToken(openid));
- }
- catch (Exception e)
- {
+ authentication = authenticationManager.authenticate(new WxOpenIDAuthenticationToken(openid));
+ } catch (Exception e) {
AsyncManager.me().execute(AsyncFactory.recordLogininfor(openid, Constants.LOGIN_FAIL, e.getMessage()));
throw new WxOpenIDNotFindException();
@@ -189,8 +179,7 @@
*
* @param userId 鐢ㄦ埛ID
*/
- public void recordLoginInfo(Long userId)
- {
+ public void recordLoginInfo(Long userId) {
SysUser sysUser = new SysUser();
sysUser.setUserId(userId);
sysUser.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
@@ -199,8 +188,7 @@
}
- public void recordLoginInfo(Long userId, String openId)
- {
+ public void recordLoginInfo(Long userId, String openId) {
SysUser sysUser = new SysUser();
sysUser.setUserId(userId);
sysUser.setOpenId(openId);
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java
index b428747..689a1ef 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java
@@ -1,18 +1,20 @@
package com.ruoyi.system.mapper;
import java.util.List;
+
import com.ruoyi.system.domain.SysPost;
+import org.apache.ibatis.annotations.Mapper;
/**
* 宀椾綅淇℃伅 鏁版嵁灞�
- *
+ *
* @author ruoyi
*/
-public interface SysPostMapper
-{
+@Mapper
+public interface SysPostMapper {
/**
* 鏌ヨ宀椾綅鏁版嵁闆嗗悎
- *
+ *
* @param post 宀椾綅淇℃伅
* @return 宀椾綅鏁版嵁闆嗗悎
*/
@@ -20,14 +22,14 @@
/**
* 鏌ヨ鎵�鏈夊矖浣�
- *
+ *
* @return 宀椾綅鍒楄〃
*/
public List<SysPost> selectPostAll();
/**
* 閫氳繃宀椾綅ID鏌ヨ宀椾綅淇℃伅
- *
+ *
* @param postId 宀椾綅ID
* @return 瑙掕壊瀵硅薄淇℃伅
*/
@@ -35,7 +37,7 @@
/**
* 鏍规嵁鐢ㄦ埛ID鑾峰彇宀椾綅閫夋嫨妗嗗垪琛�
- *
+ *
* @param userId 鐢ㄦ埛ID
* @return 閫変腑宀椾綅ID鍒楄〃
*/
@@ -43,7 +45,7 @@
/**
* 鏌ヨ鐢ㄦ埛鎵�灞炲矖浣嶇粍
- *
+ *
* @param userName 鐢ㄦ埛鍚�
* @return 缁撴灉
*/
@@ -51,7 +53,7 @@
/**
* 鍒犻櫎宀椾綅淇℃伅
- *
+ *
* @param postId 宀椾綅ID
* @return 缁撴灉
*/
@@ -59,7 +61,7 @@
/**
* 鎵归噺鍒犻櫎宀椾綅淇℃伅
- *
+ *
* @param postIds 闇�瑕佸垹闄ょ殑宀椾綅ID
* @return 缁撴灉
*/
@@ -67,7 +69,7 @@
/**
* 淇敼宀椾綅淇℃伅
- *
+ *
* @param post 宀椾綅淇℃伅
* @return 缁撴灉
*/
@@ -75,7 +77,7 @@
/**
* 鏂板宀椾綅淇℃伅
- *
+ *
* @param post 宀椾綅淇℃伅
* @return 缁撴灉
*/
@@ -83,7 +85,7 @@
/**
* 鏍¢獙宀椾綅鍚嶇О
- *
+ *
* @param postName 宀椾綅鍚嶇О
* @return 缁撴灉
*/
@@ -91,7 +93,7 @@
/**
* 鏍¢獙宀椾綅缂栫爜
- *
+ *
* @param postCode 宀椾綅缂栫爜
* @return 缁撴灉
*/
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java
index cf2bd8c..f10374b 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java
@@ -1,18 +1,20 @@
package com.ruoyi.system.mapper;
import java.util.List;
+
import com.ruoyi.common.core.domain.entity.SysRole;
+import org.apache.ibatis.annotations.Mapper;
/**
* 瑙掕壊琛� 鏁版嵁灞�
- *
+ *
* @author ruoyi
*/
-public interface SysRoleMapper
-{
+@Mapper
+public interface SysRoleMapper {
/**
* 鏍规嵁鏉′欢鍒嗛〉鏌ヨ瑙掕壊鏁版嵁
- *
+ *
* @param role 瑙掕壊淇℃伅
* @return 瑙掕壊鏁版嵁闆嗗悎淇℃伅
*/
@@ -20,7 +22,7 @@
/**
* 鏍规嵁鐢ㄦ埛ID鏌ヨ瑙掕壊
- *
+ *
* @param userId 鐢ㄦ埛ID
* @return 瑙掕壊鍒楄〃
*/
@@ -28,14 +30,14 @@
/**
* 鏌ヨ鎵�鏈夎鑹�
- *
+ *
* @return 瑙掕壊鍒楄〃
*/
public List<SysRole> selectRoleAll();
/**
* 鏍规嵁鐢ㄦ埛ID鑾峰彇瑙掕壊閫夋嫨妗嗗垪琛�
- *
+ *
* @param userId 鐢ㄦ埛ID
* @return 閫変腑瑙掕壊ID鍒楄〃
*/
@@ -43,7 +45,7 @@
/**
* 閫氳繃瑙掕壊ID鏌ヨ瑙掕壊
- *
+ *
* @param roleId 瑙掕壊ID
* @return 瑙掕壊瀵硅薄淇℃伅
*/
@@ -51,7 +53,7 @@
/**
* 鏍规嵁鐢ㄦ埛ID鏌ヨ瑙掕壊
- *
+ *
* @param userName 鐢ㄦ埛鍚�
* @return 瑙掕壊鍒楄〃
*/
@@ -59,7 +61,7 @@
/**
* 鏍¢獙瑙掕壊鍚嶇О鏄惁鍞竴
- *
+ *
* @param roleName 瑙掕壊鍚嶇О
* @return 瑙掕壊淇℃伅
*/
@@ -67,7 +69,7 @@
/**
* 鏍¢獙瑙掕壊鏉冮檺鏄惁鍞竴
- *
+ *
* @param roleKey 瑙掕壊鏉冮檺
* @return 瑙掕壊淇℃伅
*/
@@ -75,7 +77,7 @@
/**
* 淇敼瑙掕壊淇℃伅
- *
+ *
* @param role 瑙掕壊淇℃伅
* @return 缁撴灉
*/
@@ -83,7 +85,7 @@
/**
* 鏂板瑙掕壊淇℃伅
- *
+ *
* @param role 瑙掕壊淇℃伅
* @return 缁撴灉
*/
@@ -91,7 +93,7 @@
/**
* 閫氳繃瑙掕壊ID鍒犻櫎瑙掕壊
- *
+ *
* @param roleId 瑙掕壊ID
* @return 缁撴灉
*/
@@ -99,7 +101,7 @@
/**
* 鎵归噺鍒犻櫎瑙掕壊淇℃伅
- *
+ *
* @param roleIds 闇�瑕佸垹闄ょ殑瑙掕壊ID
* @return 缁撴灉
*/
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
index f7119bd..6319ea3 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
@@ -3,19 +3,20 @@
import java.util.List;
import com.ruoyi.system.domain.vo.Nickname;
+import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.common.core.domain.entity.SysUser;
/**
* 鐢ㄦ埛琛� 鏁版嵁灞�
- *
+ *
* @author ruoyi
*/
-public interface SysUserMapper
-{
+@Mapper
+public interface SysUserMapper {
/**
* 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鐢ㄦ埛鍒楄〃
- *
+ *
* @param sysUser 鐢ㄦ埛淇℃伅
* @return 鐢ㄦ埛淇℃伅闆嗗悎淇℃伅
*/
@@ -23,7 +24,7 @@
/**
* 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鏈凡閰嶇敤鎴疯鑹插垪琛�
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 鐢ㄦ埛淇℃伅闆嗗悎淇℃伅
*/
@@ -31,7 +32,7 @@
/**
* 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鏈垎閰嶇敤鎴疯鑹插垪琛�
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 鐢ㄦ埛淇℃伅闆嗗悎淇℃伅
*/
@@ -39,7 +40,7 @@
/**
* 閫氳繃鐢ㄦ埛鍚嶆煡璇㈢敤鎴�
- *
+ *
* @param userName 鐢ㄦ埛鍚�
* @return 鐢ㄦ埛瀵硅薄淇℃伅
*/
@@ -52,9 +53,10 @@
* @return 鐢ㄦ埛瀵硅薄淇℃伅
*/
public SysUser selectUserByOpenID(String openid);
+
/**
* 閫氳繃鐢ㄦ埛ID鏌ヨ鐢ㄦ埛
- *
+ *
* @param userId 鐢ㄦ埛ID
* @return 鐢ㄦ埛瀵硅薄淇℃伅
*/
@@ -62,7 +64,7 @@
/**
* 鏂板鐢ㄦ埛淇℃伅
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 缁撴灉
*/
@@ -70,7 +72,7 @@
/**
* 淇敼鐢ㄦ埛淇℃伅
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 缁撴灉
*/
@@ -78,16 +80,16 @@
/**
* 淇敼鐢ㄦ埛澶村儚
- *
+ *
* @param userName 鐢ㄦ埛鍚�
- * @param avatar 澶村儚鍦板潃
+ * @param avatar 澶村儚鍦板潃
* @return 缁撴灉
*/
public int updateUserAvatar(@Param("userName") String userName, @Param("avatar") String avatar);
/**
* 閲嶇疆鐢ㄦ埛瀵嗙爜
- *
+ *
* @param userName 鐢ㄦ埛鍚�
* @param password 瀵嗙爜
* @return 缁撴灉
@@ -96,7 +98,7 @@
/**
* 閫氳繃鐢ㄦ埛ID鍒犻櫎鐢ㄦ埛
- *
+ *
* @param userId 鐢ㄦ埛ID
* @return 缁撴灉
*/
@@ -104,7 +106,7 @@
/**
* 鎵归噺鍒犻櫎鐢ㄦ埛淇℃伅
- *
+ *
* @param userIds 闇�瑕佸垹闄ょ殑鐢ㄦ埛ID
* @return 缁撴灉
*/
@@ -112,7 +114,7 @@
/**
* 鏍¢獙鐢ㄦ埛鍚嶇О鏄惁鍞竴
- *
+ *
* @param userName 鐢ㄦ埛鍚嶇О
* @return 缁撴灉
*/
@@ -135,4 +137,20 @@
public SysUser checkEmailUnique(String email);
List<Nickname> getNickname();
+
+ /**
+ * 澧炲姞瀵嗙爜閿欒娆℃暟
+ *
+ * @param sysUser 鐢ㄦ埛淇℃伅
+ * @return 缁撴灉
+ */
+ public int updateErrorNums(SysUser sysUser);
+
+ /**
+ * 娓呯┖瀵嗙爜閿欒娆℃暟
+ *
+ * @param username 鐢ㄦ埛鍚�
+ * @return 缁撴灉
+ */
+ public int cleanErrorNums(String username);
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java
index e08991d..7c17bf6 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java
@@ -1,18 +1,20 @@
package com.ruoyi.system.mapper;
import java.util.List;
+
import com.ruoyi.system.domain.SysUserPost;
+import org.apache.ibatis.annotations.Mapper;
/**
* 鐢ㄦ埛涓庡矖浣嶅叧鑱旇〃 鏁版嵁灞�
- *
+ *
* @author ruoyi
*/
-public interface SysUserPostMapper
-{
+@Mapper
+public interface SysUserPostMapper {
/**
* 閫氳繃鐢ㄦ埛ID鍒犻櫎鐢ㄦ埛鍜屽矖浣嶅叧鑱�
- *
+ *
* @param userId 鐢ㄦ埛ID
* @return 缁撴灉
*/
@@ -20,7 +22,7 @@
/**
* 閫氳繃宀椾綅ID鏌ヨ宀椾綅浣跨敤鏁伴噺
- *
+ *
* @param postId 宀椾綅ID
* @return 缁撴灉
*/
@@ -28,7 +30,7 @@
/**
* 鎵归噺鍒犻櫎鐢ㄦ埛鍜屽矖浣嶅叧鑱�
- *
+ *
* @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID
* @return 缁撴灉
*/
@@ -36,7 +38,7 @@
/**
* 鎵归噺鏂板鐢ㄦ埛宀椾綅淇℃伅
- *
+ *
* @param userPostList 鐢ㄦ埛瑙掕壊鍒楄〃
* @return 缁撴灉
*/
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java
index 3143ec8..2e15acb 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java
@@ -1,19 +1,21 @@
package com.ruoyi.system.mapper;
import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.system.domain.SysUserRole;
/**
* 鐢ㄦ埛涓庤鑹插叧鑱旇〃 鏁版嵁灞�
- *
+ *
* @author ruoyi
*/
-public interface SysUserRoleMapper
-{
+@Mapper
+public interface SysUserRoleMapper {
/**
* 閫氳繃鐢ㄦ埛ID鍒犻櫎鐢ㄦ埛鍜岃鑹插叧鑱�
- *
+ *
* @param userId 鐢ㄦ埛ID
* @return 缁撴灉
*/
@@ -21,7 +23,7 @@
/**
* 鎵归噺鍒犻櫎鐢ㄦ埛鍜岃鑹插叧鑱�
- *
+ *
* @param ids 闇�瑕佸垹闄ょ殑鏁版嵁ID
* @return 缁撴灉
*/
@@ -29,7 +31,7 @@
/**
* 閫氳繃瑙掕壊ID鏌ヨ瑙掕壊浣跨敤鏁伴噺
- *
+ *
* @param roleId 瑙掕壊ID
* @return 缁撴灉
*/
@@ -37,7 +39,7 @@
/**
* 鎵归噺鏂板鐢ㄦ埛瑙掕壊淇℃伅
- *
+ *
* @param userRoleList 鐢ㄦ埛瑙掕壊鍒楄〃
* @return 缁撴灉
*/
@@ -45,7 +47,7 @@
/**
* 鍒犻櫎鐢ㄦ埛鍜岃鑹插叧鑱斾俊鎭�
- *
+ *
* @param userRole 鐢ㄦ埛鍜岃鑹插叧鑱斾俊鎭�
* @return 缁撴灉
*/
@@ -53,8 +55,8 @@
/**
* 鎵归噺鍙栨秷鎺堟潈鐢ㄦ埛瑙掕壊
- *
- * @param roleId 瑙掕壊ID
+ *
+ * @param roleId 瑙掕壊ID
* @param userIds 闇�瑕佸垹闄ょ殑鐢ㄦ埛鏁版嵁ID
* @return 缁撴灉
*/
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
index a47dde2..265c579 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
@@ -1,19 +1,19 @@
package com.ruoyi.system.service;
import java.util.List;
+
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.domain.vo.Nickname;
/**
* 鐢ㄦ埛 涓氬姟灞�
- *
+ *
* @author ruoyi
*/
-public interface ISysUserService
-{
+public interface ISysUserService {
/**
* 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鐢ㄦ埛鍒楄〃
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 鐢ㄦ埛淇℃伅闆嗗悎淇℃伅
*/
@@ -21,7 +21,7 @@
/**
* 鏍规嵁鏉′欢鍒嗛〉鏌ヨ宸插垎閰嶇敤鎴疯鑹插垪琛�
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 鐢ㄦ埛淇℃伅闆嗗悎淇℃伅
*/
@@ -29,7 +29,7 @@
/**
* 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鏈垎閰嶇敤鎴疯鑹插垪琛�
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 鐢ㄦ埛淇℃伅闆嗗悎淇℃伅
*/
@@ -37,7 +37,7 @@
/**
* 閫氳繃鐢ㄦ埛鍚嶆煡璇㈢敤鎴�
- *
+ *
* @param userName 鐢ㄦ埛鍚�
* @return 鐢ㄦ埛瀵硅薄淇℃伅
*/
@@ -50,9 +50,10 @@
* @return 鐢ㄦ埛瀵硅薄淇℃伅
*/
public SysUser selectUserByOpenID(String openid);
+
/**
* 閫氳繃鐢ㄦ埛ID鏌ヨ鐢ㄦ埛
- *
+ *
* @param userId 鐢ㄦ埛ID
* @return 鐢ㄦ埛瀵硅薄淇℃伅
*/
@@ -60,7 +61,7 @@
/**
* 鏍规嵁鐢ㄦ埛ID鏌ヨ鐢ㄦ埛鎵�灞炶鑹茬粍
- *
+ *
* @param userName 鐢ㄦ埛鍚�
* @return 缁撴灉
*/
@@ -68,7 +69,7 @@
/**
* 鏍规嵁鐢ㄦ埛ID鏌ヨ鐢ㄦ埛鎵�灞炲矖浣嶇粍
- *
+ *
* @param userName 鐢ㄦ埛鍚�
* @return 缁撴灉
*/
@@ -76,7 +77,7 @@
/**
* 鏍¢獙鐢ㄦ埛鍚嶇О鏄惁鍞竴
- *
+ *
* @param userName 鐢ㄦ埛鍚嶇О
* @return 缁撴灉
*/
@@ -100,21 +101,21 @@
/**
* 鏍¢獙鐢ㄦ埛鏄惁鍏佽鎿嶄綔
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
*/
public void checkUserAllowed(SysUser user);
/**
* 鏍¢獙鐢ㄦ埛鏄惁鏈夋暟鎹潈闄�
- *
+ *
* @param userId 鐢ㄦ埛id
*/
public void checkUserDataScope(Long userId);
/**
* 鏂板鐢ㄦ埛淇℃伅
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 缁撴灉
*/
@@ -122,7 +123,7 @@
/**
* 娉ㄥ唽鐢ㄦ埛淇℃伅
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 缁撴灉
*/
@@ -130,7 +131,7 @@
/**
* 淇敼鐢ㄦ埛淇℃伅
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 缁撴灉
*/
@@ -138,15 +139,15 @@
/**
* 鐢ㄦ埛鎺堟潈瑙掕壊
- *
- * @param userId 鐢ㄦ埛ID
+ *
+ * @param userId 鐢ㄦ埛ID
* @param roleIds 瑙掕壊缁�
*/
public void insertUserAuth(Long userId, Long[] roleIds);
/**
* 淇敼鐢ㄦ埛鐘舵��
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 缁撴灉
*/
@@ -154,7 +155,7 @@
/**
* 淇敼鐢ㄦ埛鍩烘湰淇℃伅
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 缁撴灉
*/
@@ -162,16 +163,16 @@
/**
* 淇敼鐢ㄦ埛澶村儚
- *
+ *
* @param userName 鐢ㄦ埛鍚�
- * @param avatar 澶村儚鍦板潃
+ * @param avatar 澶村儚鍦板潃
* @return 缁撴灉
*/
public boolean updateUserAvatar(String userName, String avatar);
/**
* 閲嶇疆鐢ㄦ埛瀵嗙爜
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 缁撴灉
*/
@@ -179,7 +180,7 @@
/**
* 閲嶇疆鐢ㄦ埛瀵嗙爜
- *
+ *
* @param userName 鐢ㄦ埛鍚�
* @param password 瀵嗙爜
* @return 缁撴灉
@@ -188,7 +189,7 @@
/**
* 閫氳繃鐢ㄦ埛ID鍒犻櫎鐢ㄦ埛
- *
+ *
* @param userId 鐢ㄦ埛ID
* @return 缁撴灉
*/
@@ -196,7 +197,7 @@
/**
* 鎵归噺鍒犻櫎鐢ㄦ埛淇℃伅
- *
+ *
* @param userIds 闇�瑕佸垹闄ょ殑鐢ㄦ埛ID
* @return 缁撴灉
*/
@@ -204,13 +205,24 @@
/**
* 瀵煎叆鐢ㄦ埛鏁版嵁
- *
- * @param userList 鐢ㄦ埛鏁版嵁鍒楄〃
+ *
+ * @param userList 鐢ㄦ埛鏁版嵁鍒楄〃
* @param isUpdateSupport 鏄惁鏇存柊鏀寔锛屽鏋滃凡瀛樺湪锛屽垯杩涜鏇存柊鏁版嵁
- * @param operName 鎿嶄綔鐢ㄦ埛
+ * @param operName 鎿嶄綔鐢ㄦ埛
* @return 缁撴灉
*/
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
List<Nickname> getNickName();
+
+
+ /**
+ * 鐧婚檰閿欒闄愬埗
+ * 鏇存柊鏃秙ys_user鍔犱袱瀛楁
+ * error_nums int绫诲瀷(榛樿0!!)
+ * error_times varchar绫诲瀷
+ *
+ * @param sysUser
+ */
+ public void loginError(SysUser sysUser);
}
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
index 7eae14d..eded2e8 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
@@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.List;
+import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.system.domain.vo.Nickname;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,12 +31,11 @@
/**
* 鐢ㄦ埛 涓氬姟灞傚鐞�
- *
+ *
* @author ruoyi
*/
@Service
-public class SysUserServiceImpl implements ISysUserService
-{
+public class SysUserServiceImpl implements ISysUserService {
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
@Autowired
@@ -58,52 +58,48 @@
/**
* 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鐢ㄦ埛鍒楄〃
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 鐢ㄦ埛淇℃伅闆嗗悎淇℃伅
*/
@Override
@DataScope(deptAlias = "d", userAlias = "u")
- public List<SysUser> selectUserList(SysUser user)
- {
+ public List<SysUser> selectUserList(SysUser user) {
return userMapper.selectUserList(user);
}
/**
* 鏍规嵁鏉′欢鍒嗛〉鏌ヨ宸插垎閰嶇敤鎴疯鑹插垪琛�
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 鐢ㄦ埛淇℃伅闆嗗悎淇℃伅
*/
@Override
@DataScope(deptAlias = "d", userAlias = "u")
- public List<SysUser> selectAllocatedList(SysUser user)
- {
+ public List<SysUser> selectAllocatedList(SysUser user) {
return userMapper.selectAllocatedList(user);
}
/**
* 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鏈垎閰嶇敤鎴疯鑹插垪琛�
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 鐢ㄦ埛淇℃伅闆嗗悎淇℃伅
*/
@Override
@DataScope(deptAlias = "d", userAlias = "u")
- public List<SysUser> selectUnallocatedList(SysUser user)
- {
+ public List<SysUser> selectUnallocatedList(SysUser user) {
return userMapper.selectUnallocatedList(user);
}
/**
* 閫氳繃鐢ㄦ埛鍚嶆煡璇㈢敤鎴�
- *
+ *
* @param userName 鐢ㄦ埛鍚�
* @return 鐢ㄦ埛瀵硅薄淇℃伅
*/
@Override
- public SysUser selectUserByUserName(String userName)
- {
+ public SysUser selectUserByUserName(String userName) {
return userMapper.selectUserByUserName(userName);
}
@@ -121,33 +117,29 @@
/**
* 閫氳繃鐢ㄦ埛ID鏌ヨ鐢ㄦ埛
- *
+ *
* @param userId 鐢ㄦ埛ID
* @return 鐢ㄦ埛瀵硅薄淇℃伅
*/
@Override
- public SysUser selectUserById(Long userId)
- {
+ public SysUser selectUserById(Long userId) {
return userMapper.selectUserById(userId);
}
/**
* 鏌ヨ鐢ㄦ埛鎵�灞炶鑹茬粍
- *
+ *
* @param userName 鐢ㄦ埛鍚�
* @return 缁撴灉
*/
@Override
- public String selectUserRoleGroup(String userName)
- {
+ public String selectUserRoleGroup(String userName) {
List<SysRole> list = roleMapper.selectRolesByUserName(userName);
StringBuffer idsStr = new StringBuffer();
- for (SysRole role : list)
- {
+ for (SysRole role : list) {
idsStr.append(role.getRoleName()).append(",");
}
- if (StringUtils.isNotEmpty(idsStr.toString()))
- {
+ if (StringUtils.isNotEmpty(idsStr.toString())) {
return idsStr.substring(0, idsStr.length() - 1);
}
return idsStr.toString();
@@ -155,21 +147,18 @@
/**
* 鏌ヨ鐢ㄦ埛鎵�灞炲矖浣嶇粍
- *
+ *
* @param userName 鐢ㄦ埛鍚�
* @return 缁撴灉
*/
@Override
- public String selectUserPostGroup(String userName)
- {
+ public String selectUserPostGroup(String userName) {
List<SysPost> list = postMapper.selectPostsByUserName(userName);
StringBuffer idsStr = new StringBuffer();
- for (SysPost post : list)
- {
+ for (SysPost post : list) {
idsStr.append(post.getPostName()).append(",");
}
- if (StringUtils.isNotEmpty(idsStr.toString()))
- {
+ if (StringUtils.isNotEmpty(idsStr.toString())) {
return idsStr.substring(0, idsStr.length() - 1);
}
return idsStr.toString();
@@ -177,16 +166,14 @@
/**
* 鏍¢獙鐢ㄦ埛鍚嶇О鏄惁鍞竴
- *
+ *
* @param userName 鐢ㄦ埛鍚嶇О
* @return 缁撴灉
*/
@Override
- public String checkUserNameUnique(String userName)
- {
+ public String checkUserNameUnique(String userName) {
int count = userMapper.checkUserNameUnique(userName);
- if (count > 0)
- {
+ if (count > 0) {
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
@@ -199,12 +186,10 @@
* @return
*/
@Override
- public String checkPhoneUnique(SysUser user)
- {
+ public String checkPhoneUnique(SysUser user) {
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
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.UNIQUE;
@@ -217,12 +202,10 @@
* @return
*/
@Override
- public String checkEmailUnique(SysUser user)
- {
+ public String checkEmailUnique(SysUser user) {
Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId();
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.UNIQUE;
@@ -230,33 +213,28 @@
/**
* 鏍¢獙鐢ㄦ埛鏄惁鍏佽鎿嶄綔
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
*/
@Override
- public void checkUserAllowed(SysUser user)
- {
- if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin())
- {
+ public void checkUserAllowed(SysUser user) {
+ if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin()) {
throw new ServiceException("涓嶅厑璁告搷浣滆秴绾х鐞嗗憳鐢ㄦ埛");
}
}
/**
* 鏍¢獙鐢ㄦ埛鏄惁鏈夋暟鎹潈闄�
- *
+ *
* @param userId 鐢ㄦ埛id
*/
@Override
- public void checkUserDataScope(Long userId)
- {
- if (!SysUser.isAdmin(SecurityUtils.getUserId()))
- {
+ public void checkUserDataScope(Long userId) {
+ if (!SysUser.isAdmin(SecurityUtils.getUserId())) {
SysUser user = new SysUser();
user.setUserId(userId);
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
- if (StringUtils.isEmpty(users))
- {
+ if (StringUtils.isEmpty(users)) {
throw new ServiceException("娌℃湁鏉冮檺璁块棶鐢ㄦ埛鏁版嵁锛�");
}
}
@@ -264,14 +242,13 @@
/**
* 鏂板淇濆瓨鐢ㄦ埛淇℃伅
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 缁撴灉
*/
@Override
@Transactional
- public int insertUser(SysUser user)
- {
+ public int insertUser(SysUser user) {
// 鏂板鐢ㄦ埛淇℃伅
int rows = userMapper.insertUser(user);
// 鏂板鐢ㄦ埛宀椾綅鍏宠仈
@@ -283,26 +260,24 @@
/**
* 娉ㄥ唽鐢ㄦ埛淇℃伅
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 缁撴灉
*/
@Override
- public boolean registerUser(SysUser user)
- {
+ public boolean registerUser(SysUser user) {
return userMapper.insertUser(user) > 0;
}
/**
* 淇敼淇濆瓨鐢ㄦ埛淇℃伅
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 缁撴灉
*/
@Override
@Transactional
- public int updateUser(SysUser user)
- {
+ public int updateUser(SysUser user) {
Long userId = user.getUserId();
// 鍒犻櫎鐢ㄦ埛涓庤鑹插叧鑱�
userRoleMapper.deleteUserRoleByUserId(userId);
@@ -317,101 +292,92 @@
/**
* 鐢ㄦ埛鎺堟潈瑙掕壊
- *
- * @param userId 鐢ㄦ埛ID
+ *
+ * @param userId 鐢ㄦ埛ID
* @param roleIds 瑙掕壊缁�
*/
@Override
@Transactional
- public void insertUserAuth(Long userId, Long[] roleIds)
- {
+ public void insertUserAuth(Long userId, Long[] roleIds) {
userRoleMapper.deleteUserRoleByUserId(userId);
insertUserRole(userId, roleIds);
}
/**
* 淇敼鐢ㄦ埛鐘舵��
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 缁撴灉
*/
@Override
- public int updateUserStatus(SysUser user)
- {
+ public int updateUserStatus(SysUser user) {
return userMapper.updateUser(user);
}
/**
* 淇敼鐢ㄦ埛鍩烘湰淇℃伅
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 缁撴灉
*/
@Override
- public int updateUserProfile(SysUser user)
- {
+ public int updateUserProfile(SysUser user) {
return userMapper.updateUser(user);
}
/**
* 淇敼鐢ㄦ埛澶村儚
- *
+ *
* @param userName 鐢ㄦ埛鍚�
- * @param avatar 澶村儚鍦板潃
+ * @param avatar 澶村儚鍦板潃
* @return 缁撴灉
*/
@Override
- public boolean updateUserAvatar(String userName, String avatar)
- {
+ public boolean updateUserAvatar(String userName, String avatar) {
return userMapper.updateUserAvatar(userName, avatar) > 0;
}
/**
* 閲嶇疆鐢ㄦ埛瀵嗙爜
- *
+ *
* @param user 鐢ㄦ埛淇℃伅
* @return 缁撴灉
*/
@Override
- public int resetPwd(SysUser user)
- {
+ public int resetPwd(SysUser user) {
+ user.setErrorNums(0);
return userMapper.updateUser(user);
}
/**
* 閲嶇疆鐢ㄦ埛瀵嗙爜
- *
+ *
* @param userName 鐢ㄦ埛鍚�
* @param password 瀵嗙爜
* @return 缁撴灉
*/
@Override
- public int resetUserPwd(String userName, String password)
- {
+ public int resetUserPwd(String userName, String password) {
return userMapper.resetUserPwd(userName, password);
}
/**
* 鏂板鐢ㄦ埛瑙掕壊淇℃伅
- *
+ *
* @param user 鐢ㄦ埛瀵硅薄
*/
- public void insertUserRole(SysUser user)
- {
+ public void insertUserRole(SysUser user) {
Long[] roles = user.getRoleIds();
- if (StringUtils.isNotNull(roles))
- {
+ if (StringUtils.isNotNull(roles)) {
// 鏂板鐢ㄦ埛涓庤鑹茬鐞�
List<SysUserRole> list = new ArrayList<SysUserRole>();
- for (Long roleId : roles)
- {
+ for (Long roleId : roles) {
SysUserRole ur = new SysUserRole();
ur.setUserId(user.getUserId());
ur.setRoleId(roleId);
list.add(ur);
}
- if (list.size() > 0)
- {
+ if (list.size() > 0) {
userRoleMapper.batchUserRole(list);
}
}
@@ -419,25 +385,21 @@
/**
* 鏂板鐢ㄦ埛宀椾綅淇℃伅
- *
+ *
* @param user 鐢ㄦ埛瀵硅薄
*/
- public void insertUserPost(SysUser user)
- {
+ public void insertUserPost(SysUser user) {
Long[] posts = user.getPostIds();
- if (StringUtils.isNotNull(posts))
- {
+ if (StringUtils.isNotNull(posts)) {
// 鏂板鐢ㄦ埛涓庡矖浣嶇鐞�
List<SysUserPost> list = new ArrayList<SysUserPost>();
- for (Long postId : posts)
- {
+ for (Long postId : posts) {
SysUserPost up = new SysUserPost();
up.setUserId(user.getUserId());
up.setPostId(postId);
list.add(up);
}
- if (list.size() > 0)
- {
+ if (list.size() > 0) {
userPostMapper.batchUserPost(list);
}
}
@@ -445,25 +407,21 @@
/**
* 鏂板鐢ㄦ埛瑙掕壊淇℃伅
- *
- * @param userId 鐢ㄦ埛ID
+ *
+ * @param userId 鐢ㄦ埛ID
* @param roleIds 瑙掕壊缁�
*/
- public void insertUserRole(Long userId, Long[] roleIds)
- {
- if (StringUtils.isNotNull(roleIds))
- {
+ public void insertUserRole(Long userId, Long[] roleIds) {
+ if (StringUtils.isNotNull(roleIds)) {
// 鏂板鐢ㄦ埛涓庤鑹茬鐞�
List<SysUserRole> list = new ArrayList<SysUserRole>();
- for (Long roleId : roleIds)
- {
+ for (Long roleId : roleIds) {
SysUserRole ur = new SysUserRole();
ur.setUserId(userId);
ur.setRoleId(roleId);
list.add(ur);
}
- if (list.size() > 0)
- {
+ if (list.size() > 0) {
userRoleMapper.batchUserRole(list);
}
}
@@ -471,14 +429,13 @@
/**
* 閫氳繃鐢ㄦ埛ID鍒犻櫎鐢ㄦ埛
- *
+ *
* @param userId 鐢ㄦ埛ID
* @return 缁撴灉
*/
@Override
@Transactional
- public int deleteUserById(Long userId)
- {
+ public int deleteUserById(Long userId) {
// 鍒犻櫎鐢ㄦ埛涓庤鑹插叧鑱�
userRoleMapper.deleteUserRoleByUserId(userId);
// 鍒犻櫎鐢ㄦ埛涓庡矖浣嶈〃
@@ -488,16 +445,14 @@
/**
* 鎵归噺鍒犻櫎鐢ㄦ埛淇℃伅
- *
+ *
* @param userIds 闇�瑕佸垹闄ょ殑鐢ㄦ埛ID
* @return 缁撴灉
*/
@Override
@Transactional
- public int deleteUserByIds(Long[] userIds)
- {
- for (Long userId : userIds)
- {
+ public int deleteUserByIds(Long[] userIds) {
+ for (Long userId : userIds) {
checkUserAllowed(new SysUser(userId));
}
// 鍒犻櫎鐢ㄦ埛涓庤鑹插叧鑱�
@@ -509,17 +464,15 @@
/**
* 瀵煎叆鐢ㄦ埛鏁版嵁
- *
- * @param userList 鐢ㄦ埛鏁版嵁鍒楄〃
+ *
+ * @param userList 鐢ㄦ埛鏁版嵁鍒楄〃
* @param isUpdateSupport 鏄惁鏇存柊鏀寔锛屽鏋滃凡瀛樺湪锛屽垯杩涜鏇存柊鏁版嵁
- * @param operName 鎿嶄綔鐢ㄦ埛
+ * @param operName 鎿嶄綔鐢ㄦ埛
* @return 缁撴灉
*/
@Override
- public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName)
- {
- if (StringUtils.isNull(userList) || userList.size() == 0)
- {
+ public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName) {
+ if (StringUtils.isNull(userList) || userList.size() == 0) {
throw new ServiceException("瀵煎叆鐢ㄦ埛鏁版嵁涓嶈兘涓虹┖锛�");
}
int successNum = 0;
@@ -527,48 +480,36 @@
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
String password = configService.selectConfigByKey("sys.user.initPassword");
- for (SysUser user : userList)
- {
- try
- {
+ for (SysUser user : userList) {
+ try {
// 楠岃瘉鏄惁瀛樺湪杩欎釜鐢ㄦ埛
SysUser u = userMapper.selectUserByUserName(user.getUserName());
- if (StringUtils.isNull(u))
- {
+ if (StringUtils.isNull(u)) {
user.setPassword(SecurityUtils.encryptPassword(password));
user.setCreateBy(operName);
this.insertUser(user);
successNum++;
successMsg.append("<br/>" + successNum + "銆佽处鍙� " + user.getUserName() + " 瀵煎叆鎴愬姛");
- }
- else if (isUpdateSupport)
- {
+ } else if (isUpdateSupport) {
user.setUpdateBy(operName);
this.updateUser(user);
successNum++;
successMsg.append("<br/>" + successNum + "銆佽处鍙� " + user.getUserName() + " 鏇存柊鎴愬姛");
- }
- else
- {
+ } else {
failureNum++;
failureMsg.append("<br/>" + failureNum + "銆佽处鍙� " + user.getUserName() + " 宸插瓨鍦�");
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
failureNum++;
String msg = "<br/>" + failureNum + "銆佽处鍙� " + user.getUserName() + " 瀵煎叆澶辫触锛�";
failureMsg.append(msg + e.getMessage());
log.error(msg, e);
}
}
- if (failureNum > 0)
- {
+ if (failureNum > 0) {
failureMsg.insert(0, "寰堟姳姝夛紝瀵煎叆澶辫触锛佸叡 " + failureNum + " 鏉℃暟鎹牸寮忎笉姝g‘锛岄敊璇涓嬶細");
throw new ServiceException(failureMsg.toString());
- }
- else
- {
+ } else {
successMsg.insert(0, "鎭枩鎮紝鏁版嵁宸插叏閮ㄥ鍏ユ垚鍔燂紒鍏� " + successNum + " 鏉★紝鏁版嵁濡備笅锛�");
}
return successMsg.toString();
@@ -578,4 +519,11 @@
public List<Nickname> getNickName() {
return userMapper.getNickname();
}
+
+ @Override
+ public void loginError(SysUser sysUser) {
+ if (sysUser.getErrorNums() > 3) {
+ throw new BaseException("瀵逛笉璧凤紝鎮ㄧ殑璐﹀彿宸茶閿佸畾锛岃鑱旂郴绠$悊鍛樹慨鏀瑰瘑鐮佸悗锛屽啀娆″皾璇�");
+ }
+ }
}
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
index cc00d58..af9ab1e 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -1,231 +1,300 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysUserMapper">
- <resultMap type="SysUser" id="SysUserResult">
- <id property="userId" column="user_id" />
- <result property="openid" column="openid" />
- <result property="deptId" column="dept_id" />
- <result property="userName" column="user_name" />
- <result property="nickName" column="nick_name" />
- <result property="email" column="email" />
- <result property="phonenumber" column="phonenumber" />
- <result property="sex" column="sex" />
- <result property="avatar" column="avatar" />
- <result property="password" column="password" />
- <result property="status" column="status" />
- <result property="delFlag" column="del_flag" />
- <result property="loginIp" column="login_ip" />
- <result property="loginDate" column="login_date" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- <result property="remark" column="remark" />
- <result property="standardlevel" column="standardlevel" />
- <association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult" />
- <collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
- </resultMap>
-
- <resultMap id="deptResult" type="SysDept">
- <id property="deptId" column="dept_id" />
- <result property="parentId" column="parent_id" />
- <result property="deptName" column="dept_name" />
- <result property="orderNum" column="order_num" />
- <result property="leader" column="leader" />
- <result property="status" column="dept_status" />
- </resultMap>
-
- <resultMap id="RoleResult" type="SysRole">
- <id property="roleId" column="role_id" />
- <result property="roleName" column="role_name" />
- <result property="roleKey" column="role_key" />
- <result property="roleSort" column="role_sort" />
- <result property="dataScope" column="data_scope" />
- <result property="status" column="role_status" />
- </resultMap>
-
- <sql id="selectUserVo">
- select u.user_id,u.openid, 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,u.standardlevel,
- d.dept_id, d.parent_id, 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
+ <resultMap type="com.ruoyi.common.core.domain.entity.SysUser" id="SysUserResult">
+ <id property="userId" column="user_id"/>
+ <result property="openid" column="openid"/>
+ <result property="deptId" column="dept_id"/>
+ <result property="userName" column="user_name"/>
+ <result property="nickName" column="nick_name"/>
+ <result property="email" column="email"/>
+ <result property="phonenumber" column="phonenumber"/>
+ <result property="sex" column="sex"/>
+ <result property="avatar" column="avatar"/>
+ <result property="password" column="password"/>
+ <result property="status" column="status"/>
+ <result property="delFlag" column="del_flag"/>
+ <result property="loginIp" column="login_ip"/>
+ <result property="loginDate" column="login_date"/>
+ <result property="createBy" column="create_by"/>
+ <result property="createTime" column="create_time"/>
+ <result property="updateBy" column="update_by"/>
+ <result property="updateTime" column="update_time"/>
+ <result property="remark" column="remark"/>
+ <result property="errorNums" column="error_nums"/>
+ <result property="errorTimes" column="error_times"/>
+ <result property="standardlevel" column="standardlevel"/>
+ <association property="dept" column="dept_id" javaType="com.ruoyi.common.core.domain.entity.SysDept"
+ resultMap="deptResult"/>
+ <collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
+ </resultMap>
+
+ <resultMap id="deptResult" type="com.ruoyi.common.core.domain.entity.SysDept">
+ <id property="deptId" column="dept_id"/>
+ <result property="parentId" column="parent_id"/>
+ <result property="deptName" column="dept_name"/>
+ <result property="orderNum" column="order_num"/>
+ <result property="leader" column="leader"/>
+ <result property="status" column="dept_status"/>
+ </resultMap>
+
+ <resultMap id="RoleResult" type="com.ruoyi.common.core.domain.entity.SysRole">
+ <id property="roleId" column="role_id"/>
+ <result property="roleName" column="role_name"/>
+ <result property="roleKey" column="role_key"/>
+ <result property="roleSort" column="role_sort"/>
+ <result property="dataScope" column="data_scope"/>
+ <result property="status" column="role_status"/>
+ </resultMap>
+
+ <sql id="selectUserVo">
+ select u.user_id,
+ u.openid,
+ u.dept_id,
+ u.error_nums,
+ u.error_times,
+ 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,
+ u.standardlevel,
+ d.dept_id,
+ d.parent_id,
+ 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
from sys_user u
- 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_role r on r.role_id = ur.role_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_role r on r.role_id = ur.role_id
</sql>
-
- <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.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.standardlevel, d.dept_name, d.leader from sys_user u
- left join sys_dept d on u.dept_id = d.dept_id
- where u.del_flag = '0'
- <if test="userId != null and userId != 0">
- AND u.user_id = #{userId}
- </if>
- <if test="userName != null and userName != ''">
- AND u.user_name like concat('%', #{userName}, '%')
- </if>
- <if test="status != null and status != ''">
- AND u.status = #{status}
- </if>
- <if test="phonenumber != null and phonenumber != ''">
- AND u.phonenumber like concat('%', #{phonenumber}, '%')
- </if>
- <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
- AND date_format(u.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
- </if>
- <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
- AND date_format(u.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
- </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}, ancestors) ))
- </if>
- <!-- 鏁版嵁鑼冨洿杩囨护 -->
- ${params.dataScope}
- </select>
-
- <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
- from sys_user u
- 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_role r on r.role_id = ur.role_id
- where u.del_flag = '0' and r.role_id = #{roleId}
- <if test="userName != null and userName != ''">
- AND u.user_name like concat('%', #{userName}, '%')
- </if>
- <if test="phonenumber != null and phonenumber != ''">
- AND u.phonenumber like concat('%', #{phonenumber}, '%')
- </if>
- <!-- 鏁版嵁鑼冨洿杩囨护 -->
- ${params.dataScope}
- </select>
-
- <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
- from sys_user u
- 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_role r on r.role_id = ur.role_id
- where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
- 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})
- <if test="userName != null and userName != ''">
- AND u.user_name like concat('%', #{userName}, '%')
- </if>
- <if test="phonenumber != null and phonenumber != ''">
- AND u.phonenumber like concat('%', #{phonenumber}, '%')
- </if>
- <!-- 鏁版嵁鑼冨洿杩囨护 -->
- ${params.dataScope}
- </select>
-
- <select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
- <include refid="selectUserVo"/>
- where u.user_name = #{userName}
- </select>
- <select id="selectUserByOpenID" parameterType="String" resultMap="SysUserResult">
- <include refid="selectUserVo"/>
- where u.openid = #{openid}
- </select>
+ <select id="selectUserList" parameterType="com.ruoyi.common.core.domain.entity.SysUser" resultMap="SysUserResult">
+ select u.user_id, u.dept_id, u.nick_name, u.user_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,u.standardlevel,
+ d.dept_name, d.leader from sys_user u
+ left join sys_dept d on u.dept_id = d.dept_id
+ where u.del_flag = '0'
+ <if test="userId != null and userId != 0">
+ AND u.user_id = #{userId}
+ </if>
+ <if test="userName != null and userName != ''">
+ AND u.user_name like concat('%', #{userName}, '%')
+ </if>
+ <if test="status != null and status != ''">
+ AND u.status = #{status}
+ </if>
+ <if test="phonenumber != null and phonenumber != ''">
+ AND u.phonenumber like concat('%', #{phonenumber}, '%')
+ </if>
+ <if test="params.beginTime != null and params.beginTime != ''"><!-- 寮�濮嬫椂闂存绱� -->
+ AND date_format(u.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
+ </if>
+ <if test="params.endTime != null and params.endTime != ''"><!-- 缁撴潫鏃堕棿妫�绱� -->
+ AND date_format(u.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
+ </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},
+ ancestors) ))
+ </if>
+ <!-- 鏁版嵁鑼冨洿杩囨护 -->
+ ${params.dataScope}
+ </select>
- <select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
- <include refid="selectUserVo"/>
- where u.user_id = #{userId}
- </select>
-
- <select id="checkUserNameUnique" parameterType="String" resultType="int">
- select count(1) from sys_user where user_name = #{userName} limit 1
- </select>
-
- <select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
- select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} limit 1
- </select>
-
- <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
- select user_id, email from sys_user where email = #{email} limit 1
- </select>
+ <select id="selectAllocatedList" parameterType="com.ruoyi.common.core.domain.entity.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
+ from sys_user u
+ 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_role r on r.role_id = ur.role_id
+ where u.del_flag = '0' and r.role_id = #{roleId}
+ <if test="userName != null and userName != ''">
+ AND u.user_name like concat('%', #{userName}, '%')
+ </if>
+ <if test="phonenumber != null and phonenumber != ''">
+ AND u.phonenumber like concat('%', #{phonenumber}, '%')
+ </if>
+ <!-- 鏁版嵁鑼冨洿杩囨护 -->
+ ${params.dataScope}
+ </select>
+
+ <select id="selectUnallocatedList" parameterType="com.ruoyi.common.core.domain.entity.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
+ from sys_user u
+ 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_role r on r.role_id = ur.role_id
+ where u.del_flag = '0' and (r.role_id != #{roleId} or r.role_id IS NULL)
+ 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})
+ <if test="userName != null and userName != ''">
+ AND u.user_name like concat('%', #{userName}, '%')
+ </if>
+ <if test="phonenumber != null and phonenumber != ''">
+ AND u.phonenumber like concat('%', #{phonenumber}, '%')
+ </if>
+ <!-- 鏁版嵁鑼冨洿杩囨护 -->
+ ${params.dataScope}
+ </select>
+
+ <select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
+ <include refid="selectUserVo"/>
+ where u.user_name = #{userName}
+ </select>
+
+ <select id="selectUserByOpenID" parameterType="String" resultMap="SysUserResult">
+ <include refid="selectUserVo"/>
+ where u.openid = #{openid}
+ </select>
+
+ <select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
+ <include refid="selectUserVo"/>
+ where u.user_id = #{userId}
+ </select>
+
+ <select id="checkUserNameUnique" parameterType="String" resultType="int">
+ select count(1)
+ from sys_user
+ where user_name = #{userName} limit 1
+ </select>
+
+ <select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
+ select user_id, phonenumber
+ from sys_user
+ where phonenumber = #{phonenumber} limit 1
+ </select>
+
+ <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
+ select user_id, email
+ from sys_user
+ where email = #{email} limit 1
+ </select>
<select id="getNickname" resultType="com.ruoyi.system.domain.vo.Nickname">
- select user_name, nick_name,phonenumber from sys_user
- </select>
+ select user_name, nick_name, phonenumber
+ from sys_user
+ </select>
- <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId">
- insert into sys_user(
- <if test="userId != null and userId != 0">user_id,</if>
- <if test="deptId != null and deptId != 0">dept_id,</if>
- <if test="userName != null and userName != ''">user_name,</if>
- <if test="nickName != null and nickName != ''">nick_name,</if>
- <if test="email != null and email != ''">email,</if>
- <if test="avatar != null and avatar != ''">avatar,</if>
- <if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
- <if test="sex != null and sex != ''">sex,</if>
- <if test="password != null and password != ''">password,</if>
- <if test="status != null and status != ''">status,</if>
- <if test="createBy != null and createBy != ''">create_by,</if>
- <if test="remark != null and remark != ''">remark,</if>
- create_time
- )values(
- <if test="userId != null and userId != ''">#{userId},</if>
- <if test="deptId != null and deptId != ''">#{deptId},</if>
- <if test="userName != null and userName != ''">#{userName},</if>
- <if test="nickName != null and nickName != ''">#{nickName},</if>
- <if test="email != null and email != ''">#{email},</if>
- <if test="avatar != null and avatar != ''">#{avatar},</if>
- <if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
- <if test="sex != null and sex != ''">#{sex},</if>
- <if test="password != null and password != ''">#{password},</if>
- <if test="status != null and status != ''">#{status},</if>
- <if test="createBy != null and createBy != ''">#{createBy},</if>
- <if test="remark != null and remark != ''">#{remark},</if>
- sysdate()
- )
- </insert>
-
- <update id="updateUser" parameterType="SysUser">
- update sys_user
- <set>
- <if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
+ <insert id="insertUser" parameterType="com.ruoyi.common.core.domain.entity.SysUser" useGeneratedKeys="true"
+ keyProperty="userId">
+ insert into sys_user(
+ <if test="userId != null and userId != 0">user_id,</if>
+ <if test="deptId != null and deptId != 0">dept_id,</if>
+ <if test="userName != null and userName != ''">user_name,</if>
+ <if test="nickName != null and nickName != ''">nick_name,</if>
+ <if test="email != null and email != ''">email,</if>
+ <if test="avatar != null and avatar != ''">avatar,</if>
+ <if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
+ <if test="sex != null and sex != ''">sex,</if>
+ <if test="password != null and password != ''">password,</if>
+ <if test="status != null and status != ''">status,</if>
+ <if test="createBy != null and createBy != ''">create_by,</if>
+ <if test="remark != null and remark != ''">remark,</if>
+ create_time
+ )values(
+ <if test="userId != null and userId != ''">#{userId},</if>
+ <if test="deptId != null and deptId != ''">#{deptId},</if>
+ <if test="userName != null and userName != ''">#{userName},</if>
+ <if test="nickName != null and nickName != ''">#{nickName},</if>
+ <if test="email != null and email != ''">#{email},</if>
+ <if test="avatar != null and avatar != ''">#{avatar},</if>
+ <if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
+ <if test="sex != null and sex != ''">#{sex},</if>
+ <if test="password != null and password != ''">#{password},</if>
+ <if test="status != null and status != ''">#{status},</if>
+ <if test="createBy != null and createBy != ''">#{createBy},</if>
+ <if test="remark != null and remark != ''">#{remark},</if>
+ sysdate()
+ )
+ </insert>
+
+ <update id="updateUser" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
+ update sys_user
+ <set>
+ <if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
<if test="openid != null and openid != ''">openid = #{openid},</if>
- <if test="userName != null and userName != ''">user_name = #{userName},</if>
- <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
- <if test="email != null ">email = #{email},</if>
- <if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
- <if test="sex != null and sex != ''">sex = #{sex},</if>
- <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
- <if test="password != null and password != ''">password = #{password},</if>
- <if test="status != null and status != ''">status = #{status},</if>
- <if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
- <if test="loginDate != null">login_date = #{loginDate},</if>
- <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- <if test="remark != null">remark = #{remark},</if>
- update_time = sysdate()
- </set>
- where user_id = #{userId}
- </update>
-
- <update id="updateUserStatus" parameterType="SysUser">
- update sys_user set status = #{status} where user_id = #{userId}
- </update>
-
- <update id="updateUserAvatar" parameterType="SysUser">
- update sys_user set avatar = #{avatar} where user_name = #{userName}
- </update>
-
- <update id="resetUserPwd" parameterType="SysUser">
- update sys_user set password = #{password} where user_name = #{userName}
- </update>
-
- <delete id="deleteUserById" parameterType="Long">
- 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>
-
+ <if test="userName != null and userName != ''">user_name = #{userName},</if>
+ <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
+ <if test="email != null ">email = #{email},</if>
+ <if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
+ <if test="sex != null and sex != ''">sex = #{sex},</if>
+ <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
+ <if test="password != null and password != ''">password = #{password},</if>
+ <if test="status != null and status != ''">status = #{status},</if>
+ <if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if>
+ <if test="loginDate != null">login_date = #{loginDate},</if>
+ <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
+ <if test="remark != null">remark = #{remark},</if>
+ <if test="errorNums != null">error_nums = #{errorNums},</if>
+ update_time = sysdate()
+ </set>
+ where user_id = #{userId}
+ </update>
+
+ <update id="updateUserStatus" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
+ update sys_user
+ set status = #{status}
+ where user_id = #{userId}
+ </update>
+
+ <update id="updateUserAvatar" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
+ update sys_user
+ set avatar = #{avatar}
+ where user_name = #{userName}
+ </update>
+
+ <update id="resetUserPwd" parameterType="SysUser">
+ update sys_user
+ set password = #{password}
+ where user_name = #{userName}
+ </update>
+
+ <delete id="deleteUserById" parameterType="Long">
+ 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>
+
+ <!--is null or LENGTH( trim( 瀛楁 ) 鍒ゆ柇鏄惁涓虹┖ 鎴栨棤鍊� -->
+ <update id="updateErrorNums" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
+ update sys_user
+ set error_nums = if(error_nums is null or LENGTH(trim(error_nums)) = 0, 0, error_nums) + 1,
+ error_times = if(#{errorTimes} is null, now(), #{errorTimes})
+ where user_name = #{userName}
+ </update>
+
+ <update id="cleanErrorNums" parameterType="String">
+ update sys_user
+ set error_nums = 0
+ where user_name = #{userName}
+ </update>
+
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3