refactor(vo): 重构VO类及相关模型,添加Voable接口实现

feat(constant): 添加WebSocket错误码常量
docs(model): 为模型类添加注释
fix(service): 修复ProductUsageService缓存键问题
refactor(converter): 重构字符串转换器,移除EntityStringConverter依赖
feat(tab): 添加ComboBoxUtils工具类,优化下拉框初始化
style: 移除无用导入和字段
This commit is contained in:
2025-09-22 23:11:21 +08:00
parent 8aac509e51
commit 866e08224a
84 changed files with 1061 additions and 285 deletions

View File

@@ -1,5 +1,6 @@
package com.ecep.contract.ds.company.service;
import com.ecep.contract.constant.ServiceConstant;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
@@ -28,8 +29,8 @@ public class CompanyFileTypeService
@Override
public Page<CompanyFileTypeLocal> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyFileTypeLocal> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
if (paramsNode.has(ServiceConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
}
// field
return findAll(spec, pageable);

View File

@@ -18,6 +18,7 @@ import org.springframework.util.StringUtils;
import com.ecep.contract.ContractFileType;
import com.ecep.contract.IEntityService;
import com.ecep.contract.QueryService;
import com.ecep.contract.constant.ServiceConstant;
import com.ecep.contract.ds.contract.repository.ContractFileTypeLocalRepository;
import com.ecep.contract.model.ContractFileTypeLocal;
import com.ecep.contract.util.SpecificationUtils;
@@ -35,8 +36,8 @@ public class ContractFileTypeService
@Override
public Page<ContractFileTypeLocal> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ContractFileTypeLocal> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
if (paramsNode.has(ServiceConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
}
// field

View File

@@ -0,0 +1,98 @@
package com.ecep.contract.ds.vendor.service;
import java.util.Locale;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.ecep.contract.IEntityService;
import com.ecep.contract.QueryService;
import com.ecep.contract.VendorFileType;
import com.ecep.contract.constant.ServiceConstant;
import com.ecep.contract.ds.vendor.repository.CompanyVendorFileTypeLocalRepository;
import com.ecep.contract.model.VendorFileTypeLocal;
import com.ecep.contract.util.SpecificationUtils;
import com.fasterxml.jackson.databind.JsonNode;
/**
* 供应商文件类型服务类
* 提供对供应商文件类型的查询、创建、更新和删除操作
*/
@Lazy
@Service
@CacheConfig(cacheNames = "vendor-file-type")
public class VendorFileTypeService implements IEntityService<VendorFileTypeLocal>, QueryService<VendorFileTypeLocal> {
@Lazy
@Autowired
private CompanyVendorFileTypeLocalRepository repository;
@Override
public Page<VendorFileTypeLocal> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorFileTypeLocal> spec = null;
if (paramsNode.has(ServiceConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
}
// field
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value");
return findAll(spec, pageable);
}
@Cacheable(key = "#p0")
@Override
public VendorFileTypeLocal findById(Integer id) {
return repository.findById(id).orElse(null);
}
@Override
public Page<VendorFileTypeLocal> findAll(Specification<VendorFileTypeLocal> spec, Pageable pageable) {
return repository.findAll(spec, pageable);
}
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
public Map<VendorFileType, VendorFileTypeLocal> findAll(Locale locale) {
return repository.getCompleteMapByLocal(locale.toLanguageTag());
}
@Override
public Specification<VendorFileTypeLocal> getSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
return (root, query, builder) -> {
return
// builder.or(
builder.like(root.get("type"), "%" + searchText + "%")
// )
;
};
}
@Caching(evict = {
@CacheEvict(key = "#p0.id"),
@CacheEvict(key = "'all-'+#p0.getLang()")
})
@Override
public void delete(VendorFileTypeLocal entity) {
repository.delete(entity);
}
@Caching(evict = {
@CacheEvict(key = "#p0.id"),
@CacheEvict(key = "'all-'+#p0.getLang()")
})
@Override
public VendorFileTypeLocal save(VendorFileTypeLocal entity) {
return repository.save(entity);
}
}

View File

@@ -1,4 +1,94 @@
package com.ecep.contract.ds.vendor.service;
public class VendorTypeService {
import java.util.Locale;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.ecep.contract.IEntityService;
import com.ecep.contract.QueryService;
import com.ecep.contract.VendorType;
import com.ecep.contract.constant.ServiceConstant;
import com.ecep.contract.ds.vendor.repository.VendorTypeLocalRepository;
import com.ecep.contract.model.VendorTypeLocal;
import com.ecep.contract.util.SpecificationUtils;
import com.fasterxml.jackson.databind.JsonNode;
@Lazy
@Service
@CacheConfig(cacheNames = "vendor-type")
public class VendorTypeService implements IEntityService<VendorTypeLocal>, QueryService<VendorTypeLocal> {
@Lazy
@Autowired
private VendorTypeLocalRepository repository;
@Override
public Page<VendorTypeLocal> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorTypeLocal> spec = null;
if (paramsNode.has(ServiceConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
}
// field
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value");
return findAll(spec, pageable);
}
@Cacheable(key = "#p0")
@Override
public VendorTypeLocal findById(Integer id) {
return repository.findById(id).orElse(null);
}
@Override
public Page<VendorTypeLocal> findAll(Specification<VendorTypeLocal> spec, Pageable pageable) {
return repository.findAll(spec, pageable);
}
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
public Map<VendorType, VendorTypeLocal> findAll(Locale locale) {
return repository.getCompleteMapByLocal(locale.toLanguageTag());
}
@Override
public Specification<VendorTypeLocal> getSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
return (root, query, builder) -> {
return
// builder.or(
builder.like(root.get("type"), "%" + searchText + "%")
// )
;
};
}
@Caching(evict = {
@CacheEvict(key = "#p0.id"),
@CacheEvict(key = "'all-'+#p0.getLang()")
})
@Override
public void delete(VendorTypeLocal entity) {
repository.delete(entity);
}
@Caching(evict = {
@CacheEvict(key = "#p0.id"),
@CacheEvict(key = "'all-'+#p0.getLang()")
})
@Override
public VendorTypeLocal save(VendorTypeLocal entity) {
return repository.save(entity);
}
}

View File

@@ -95,7 +95,7 @@ public class WebSocketServerHandler extends TextWebSocketHandler {
if (sessionInfo.getEmployeeId() == null) {
logger.error("会话未绑定用户: {}", session.getId());
sendError(session, 401, "会话未绑定用户");
sendError(session, WebSocketConstant.ERROR_CODE_UNAUTHORIZED, "会话未绑定用户");
session.close(CloseStatus.NOT_ACCEPTABLE);
return;
}