feat:使用SSE实现轻量消息推送

This commit is contained in:
czhqwer
2025-03-30 02:26:21 +08:00
parent a312010f17
commit 71909ce798
11 changed files with 253 additions and 3 deletions

View File

@@ -1,20 +1,26 @@
package cn.czh.service.impl;
import cn.czh.dto.NotifyMessage;
import cn.czh.entity.UserConfig;
import cn.czh.mapper.UserConfigMapper;
import cn.czh.service.IAuthService;
import cn.czh.service.ISseService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
@Service
public class AuthServiceImpl implements IAuthService {
@Resource
private UserConfigMapper userConfigMapper;
@Resource
private ISseService sseService;
@Override
public String getMainUserPassword() {
@@ -48,6 +54,11 @@ public class AuthServiceImpl implements IAuthService {
} else {
userConfigMapper.updateById(user);
}
Map<String, Object> data = new HashMap<>();
data.put("password", password);
NotifyMessage message = new NotifyMessage("setPassword", data);
sseService.notifySystemEvent(message);
}
@Override