From 3a740faa161ec976986c0735ba18837f570a525f Mon Sep 17 00:00:00 2001
From: hyingbo <1363390067@qq.com>
Date: 星期二, 27 五月 2025 19:04:07 +0800
Subject: [PATCH] 消息类型拆分并按类型推送至不同角色

---
 lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 56 insertions(+), 1 deletions(-)

diff --git a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
index d466081..f19edce 100644
--- a/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
+++ b/lxzn-module-system/lxzn-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java
@@ -11,8 +11,10 @@
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.constant.enums.RoleIndexConfigEnum;
 import org.jeecg.common.desensitization.annotation.SensitiveEncode;
+import org.jeecg.common.system.vo.DictModel;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.system.vo.SysUserCacheInfo;
+import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.PasswordUtil;
 import org.jeecg.common.util.UUIDGenerator;
 import org.jeecg.common.util.oConvertUtils;
@@ -20,6 +22,7 @@
 import org.jeecg.modules.system.entity.*;
 import org.jeecg.modules.system.mapper.*;
 import org.jeecg.modules.system.model.SysUserSysDepartModel;
+import org.jeecg.modules.system.service.ISysDictService;
 import org.jeecg.modules.system.service.ISysUserService;
 import org.jeecg.modules.system.vo.MdcUserProVo;
 import org.jeecg.modules.system.vo.SysUserDepVo;
@@ -74,6 +77,8 @@
 	SysRoleIndexMapper sysRoleIndexMapper;
 	@Resource
 	MdcUserProductionMapper mdcUserProductionMapper;
+	@Resource
+	private ISysDictService sysDictService;
 
     @Override
     @CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true)
@@ -89,8 +94,12 @@
         if (!newpassword.equals(confirmpassword)) {
             return Result.error("涓ゆ杈撳叆瀵嗙爜涓嶄竴鑷�!");
         }
+		//璁剧疆瀵嗙爜鏇存柊鏃堕棿
+		//sysUser.setPasswordTime(new Date());
+		//璁剧疆瀵嗙爜棣栨鐧诲綍澶辨晥
+		//sysUser.setPasswordFlag(CommonConstant.DEL_FLAG_0);
         String password = PasswordUtil.encrypt(username, newpassword, user.getSalt());
-        this.userMapper.update(new SysUser().setPassword(password), new LambdaQueryWrapper<SysUser>().eq(SysUser::getId, user.getId()));
+        this.userMapper.update(new SysUser().setPassword(password).setPasswordTime(new Date()).setPasswordFlag(CommonConstant.DEL_FLAG_0), new LambdaQueryWrapper<SysUser>().eq(SysUser::getId, user.getId()));
         return Result.ok("瀵嗙爜閲嶇疆鎴愬姛!");
     }
 
@@ -99,6 +108,10 @@
     public Result<?> changePassword(SysUser sysUser) {
         String salt = oConvertUtils.randomGen(8);
         sysUser.setSalt(salt);
+		//璁剧疆瀵嗙爜鏇存柊鏃堕棿
+		sysUser.setPasswordTime(new Date());
+		//绠$悊鍛樹慨鏀瑰瘑鐮侊紝璁剧疆鐢ㄦ埛棣栨鐧诲綍
+		//sysUser.setPasswordFlag();
         String password = sysUser.getPassword();
         String passwordEncode = PasswordUtil.encrypt(sysUser.getUsername(), password, salt);
         sysUser.setPassword(passwordEncode);
@@ -442,6 +455,32 @@
 			result.error500("璇ョ敤鎴峰凡鍐荤粨");
 			return result;
 		}
+		//鎯呭喌4锛氭牴鎹敤鎴蜂俊鎭煡璇紝璇ョ敤鎴峰瘑鐮佺郴棣栨浣跨敤锛岄渶淇敼瀵嗙爜
+		List<DictModel> dictList = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_USER_FIRST_LOGIN);
+		if (dictList != null && !dictList.isEmpty()) {
+			if (CommonConstant.DEL_FLAG_1.equals(Integer.valueOf(dictList.get(0).getValue())) && CommonConstant.DEL_FLAG_1.equals(sysUser.getPasswordFlag())) {
+				baseCommonService.addLog("鐢ㄦ埛鐧诲綍澶辫触锛岀敤鎴峰悕:" + sysUser.getUsername() + "绯婚娆$櫥褰曠郴缁燂紝璇烽噸缃瘑鐮侊紒", CommonConstant.LOG_TYPE_1, null);
+				result.setCode(5001);
+				result.setMessage("鐢ㄦ埛瀵嗙爜绯婚粯璁ゅ瘑鐮侊紝闇�閲嶇疆瀵嗙爜鍚庨噸鏂扮櫥褰曞瘑鐮侊紒");
+				result.setSuccess(false);
+				return result;
+			}
+		}
+		//鎯呭喌5锛氭牴鎹敤鎴蜂俊鎭煡璇紝璇ョ敤鎴峰瘑鐮佹槸鍚﹀凡杩囨洿鏀瑰懆鏈�
+		Date passwordTime = sysUser.getPasswordTime();
+		//Integer passwordExpirationPeriod = CommonConstant.PASSWORD_EXPIRATION_PERIOD;
+		List<DictModel> dictModelList = sysDictService.queryEnableDictItemsByCode(CommonConstant.DICT_PASSWORD_EXPIRATION);
+		if (dictModelList != null && !dictModelList.isEmpty()) {
+			Integer passwordExpirationPeriod = Integer.valueOf(dictModelList.get(0).getValue());
+			Date dayAfter = DateUtils.getDayAfter(passwordTime, passwordExpirationPeriod);
+			if (new Date().after(dayAfter)) {
+				baseCommonService.addLog("鐢ㄦ埛鐧诲綍澶辫触锛岀敤鎴峰悕:" + sysUser.getUsername() + "瀵嗙爜宸茶繃鏈夋晥鏈燂紝璇烽噸缃瘑鐮侊紒", CommonConstant.LOG_TYPE_1, null);
+				result.setCode(5002);
+				result.setMessage("鐢ㄦ埛瀵嗙爜宸茶繃鏈夋晥鏈燂紝璇烽噸缃瘑鐮侊紒");
+				result.setSuccess(false);
+				return result;
+			}
+		}
 		return result;
 	}
 
@@ -666,4 +705,20 @@
 	public List<String> getUserByRoleCode(String roleCode) {
 		return this.baseMapper.getUserByRoleCode(roleCode);
 	}
+
+	/**
+	 * 鏍规嵁瑙掕壊缂栫爜鍒楄〃鏌ヨ鐢ㄦ埛id闆嗗悎
+	 */
+	@Override
+	public List<SysUser> getUserByRoleCodeList(List<String> roleCodeList) {
+		return this.baseMapper.getUserByRoleCodeList(roleCodeList);
+	}
+
+	/**
+	 * 鏍规嵁瑙掕壊缂栫爜鍜岃澶囩紪鍙锋煡璇㈢敤鎴�
+	 */
+	@Override
+	public List<SysUser> getEquipmentAdmin(String roleCode, String equipmentId) {
+		return this.baseMapper.getEquipmentAdmin(roleCode, equipmentId);
+	}
 }

--
Gitblit v1.9.3