重构Service类实现,将QueryService泛型参数调整为VO类型,确保缓存VO对象而非实体。优化关联实体处理逻辑,减少重复代码。修改findById方法返回VO对象,新增getById方法获取实体。更新相关调用点以适配新接口。 调整WebSocket处理、控制器及Service实现,确保数据类型一致性。完善文档记录重构过程及发现的问题。为后续优化提供基础架构支持。
39 lines
994 B
Java
39 lines
994 B
Java
package com.ecep.contract;
|
|
|
|
import java.util.List;
|
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Pageable;
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
|
public interface IEntityService<T> {
|
|
/**
|
|
* 根据ID查询实体
|
|
* <b> 注意:如果实体类有关联实体此方法不能使用 @Cacheable 注解 </b>
|
|
* @param id 实体ID
|
|
* @return 实体对象
|
|
*/
|
|
T getById(Integer id);
|
|
|
|
Page<T> findAll(Specification<T> spec, Pageable pageable);
|
|
|
|
/**
|
|
* 根据搜索文本构建了一个特定的规格化查询,以实现对实体模糊搜索
|
|
*
|
|
* @param searchText 要搜索的文本
|
|
* @return 规格化查询
|
|
*/
|
|
Specification<T> getSpecification(String searchText);
|
|
|
|
/**
|
|
* 根据搜索文本查询列表
|
|
*/
|
|
default List<T> search(String searchText) {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
|
|
void delete(T entity);
|
|
|
|
T save(T entity);
|
|
}
|