|
@@ -6,6 +6,9 @@ import com.backendsys.modules.common.config.redis.utils.RedisUtil;
|
|
|
import com.backendsys.modules.common.config.security.utils.SecurityUtil;
|
|
|
import com.backendsys.modules.common.config.security.utils.TokenUtil;
|
|
|
import com.backendsys.modules.common.utils.MybatisUtil;
|
|
|
+import com.backendsys.modules.sse.entity.SseResponse;
|
|
|
+import com.backendsys.modules.sse.entity.SseResponseEnum;
|
|
|
+import com.backendsys.modules.sse.utils.SseUtil;
|
|
|
import com.backendsys.modules.system.dao.*;
|
|
|
import com.backendsys.modules.system.entity.*;
|
|
|
import com.backendsys.modules.system.service.SysUserIntegralService;
|
|
@@ -41,6 +44,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUser> impleme
|
|
|
@Value("${REDIS_LOGIN_TOKEN_PREFIX}")
|
|
|
private String REDIS_LOGIN_TOKEN_PREFIX;
|
|
|
|
|
|
+ @Value("${spring.application.name}")
|
|
|
+ private String APPLICATION_NAME;
|
|
|
+ @Autowired
|
|
|
+ private SseUtil sseUtil;
|
|
|
@Lazy
|
|
|
@Autowired
|
|
|
RedissonClient redissonClient;
|
|
@@ -321,10 +328,16 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUser> impleme
|
|
|
// 加盐加密 (前端会传已加密过的密码)
|
|
|
String encodedPassword = encoder.encode(sysUserDTO.getPassword());
|
|
|
entity.setPassword(encodedPassword);
|
|
|
- //
|
|
|
System.out.println(entity);
|
|
|
+
|
|
|
+ // [编辑] 用户密码
|
|
|
sysUserDao.updateById(entity);
|
|
|
|
|
|
+ // [SSE] 发送退出登录的消息
|
|
|
+ String emitterKey = APPLICATION_NAME + "-userid-" + Convert.toStr(sysUserDTO.getUser_id());
|
|
|
+ String dataStr = (new SseResponse(SseResponseEnum.LOGOUT)).toJsonStr();
|
|
|
+ sseUtil.send(emitterKey, dataStr);
|
|
|
+
|
|
|
return Map.of("user_id", sysUserDTO.getUser_id());
|
|
|
|
|
|
} catch (InterruptedException e) {
|
|
@@ -355,8 +368,15 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUser> impleme
|
|
|
entity.setId(sysUserDTO.getUser_id());
|
|
|
entity.setPassword(encodedPassword);
|
|
|
System.out.println(entity);
|
|
|
+
|
|
|
+ // [编辑] 用户密码
|
|
|
sysUserDao.updateById(entity);
|
|
|
|
|
|
+ // [SSE] 发送退出登录的消息
|
|
|
+ String emitterKey = APPLICATION_NAME + "-userid-" + Convert.toStr(sysUserDTO.getUser_id());
|
|
|
+ String dataStr = (new SseResponse(SseResponseEnum.LOGOUT)).toJsonStr();
|
|
|
+ sseUtil.send(emitterKey, dataStr);
|
|
|
+
|
|
|
Map<String, Object> response = new LinkedHashMap<>();
|
|
|
response.put("user_id", sysUserDTO.getUser_id());
|
|
|
response.put("plain_password", password);
|
|
@@ -419,6 +439,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserDao, SysUser> impleme
|
|
|
// 更新用户信息 (查询最后登录uuid,并清除)
|
|
|
Wrapper updateWrapper = new UpdateWrapper<SysUserInfo>().lambda().set(SysUserInfo::getLast_login_uuid, "").eq(SysUserInfo::getUser_id, user_id);
|
|
|
sysUserInfoDao.update(null, updateWrapper);
|
|
|
+
|
|
|
+ // [SSE] 发送退出登录的消息
|
|
|
+ String emitterKey = APPLICATION_NAME + "-userid-" + Convert.toStr(sysUserInfo.getUser_id());
|
|
|
+ String dataStr = (new SseResponse(SseResponseEnum.LOGOUT)).toJsonStr();
|
|
|
+ sseUtil.send(emitterKey, dataStr);
|
|
|
}
|
|
|
|
|
|
return Map.of("user_id", user_id);
|