refactor(service): 统一Service缓存为VO对象并优化关联实体处理

重构Service类实现,将QueryService泛型参数调整为VO类型,确保缓存VO对象而非实体。优化关联实体处理逻辑,减少重复代码。修改findById方法返回VO对象,新增getById方法获取实体。更新相关调用点以适配新接口。

调整WebSocket处理、控制器及Service实现,确保数据类型一致性。完善文档记录重构过程及发现的问题。为后续优化提供基础架构支持。
This commit is contained in:
2025-09-29 19:31:51 +08:00
parent 64471b46f8
commit 49413ad473
167 changed files with 6840 additions and 1811 deletions

View File

@@ -27,6 +27,7 @@ import org.springframework.security.web.SecurityFilterChain;
import com.ecep.contract.ds.other.service.EmployeeService;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.EmployeeRole;
import com.ecep.contract.vo.EmployeeVo;
/**
* Spring Security配置类
@@ -110,13 +111,16 @@ public class SecurityConfig {
public UserDetailsService userDetailsService() {
return username -> {
// 使用EmployeeService根据用户名查找员工
Employee employee = employeeService.findByAccount(username);
EmployeeVo employeeVo = employeeService.findByAccount(username);
// 如果找不到员工抛出UsernameNotFoundException异常
if (employee == null) {
if (employeeVo == null) {
throw new UsernameNotFoundException("用户不存在: " + username);
}
// 获取员工实体
Employee employee = employeeService.getById(employeeVo.getId());
// 检查员工是否活跃
if (!employee.isActive()) {
throw new UsernameNotFoundException("用户已禁用: " + username);