Compare commits
2 Commits
18057a657e
...
e8c8305f40
| Author | SHA1 | Date | |
|---|---|---|---|
| e8c8305f40 | |||
| be63ff62a4 |
@@ -27,7 +27,6 @@ import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.cloud.CloudInfo;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.company.model.CompanyBlackReason;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
|
||||
@@ -2,18 +2,16 @@ package com.ecep.contract.ds.project.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.model.ProjectSaleType;
|
||||
import com.ecep.contract.model.ProjectSaleTypeRequireFileType;
|
||||
|
||||
@Repository
|
||||
public interface ProjectSaleTypeRequireFileTypeRepository extends
|
||||
JpaRepository<ProjectSaleTypeRequireFileType, Integer>,
|
||||
JpaSpecificationExecutor<ProjectSaleTypeRequireFileType> {
|
||||
|
||||
MyRepository<ProjectSaleTypeRequireFileType, Integer> {
|
||||
|
||||
List<ProjectSaleTypeRequireFileType> findBySaleTypeId(int saleTypeId);
|
||||
|
||||
List<ProjectSaleTypeRequireFileType> findBySaleType(ProjectSaleType saleType);
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -16,15 +17,17 @@ import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerEvaluationFormFileService;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.ds.project.repository.ProjectQuotationRepository;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.ds.project.model.Project;
|
||||
import com.ecep.contract.ds.project.model.ProjectQuotation;
|
||||
import com.ecep.contract.ds.project.repository.ProjectQuotationRepository;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
@@ -34,7 +37,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-quotation")
|
||||
public class ProjectQuotationService implements IEntityService<ProjectQuotation>, QueryService<ProjectQuotationVo>,
|
||||
public class ProjectQuotationService extends EntityService<ProjectQuotation, ProjectQuotationVo, Integer>
|
||||
implements IEntityService<ProjectQuotation>, QueryService<ProjectQuotationVo>,
|
||||
VoableService<ProjectQuotation, ProjectQuotationVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProjectQuotationService.class);
|
||||
|
||||
@@ -43,8 +47,8 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
|
||||
private ProjectQuotationRepository repository;
|
||||
|
||||
@Override
|
||||
public ProjectQuotation getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected ProjectQuotationRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -56,39 +60,36 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
|
||||
return null;
|
||||
}
|
||||
|
||||
// 实现QueryService接口的findAll方法
|
||||
@Override
|
||||
public Page<ProjectQuotationVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectQuotation> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "project", "applicant", "authorizer");
|
||||
return findAll(spec, pageable).map(ProjectQuotation::toVo);
|
||||
}
|
||||
|
||||
// 实现IEntityService接口的findAll方法
|
||||
@Override
|
||||
public Page<ProjectQuotation> findAll(Specification<ProjectQuotation> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public List<ProjectQuotation> findAllByProject(Project project) {
|
||||
return repository.findAllByProject(project);
|
||||
}
|
||||
|
||||
public ProjectQuotation save(ProjectQuotation approval) {
|
||||
return repository.save(approval);
|
||||
@Override
|
||||
public ProjectQuotation createNewEntity() {
|
||||
return new ProjectQuotation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectQuotation> getSearchSpecification(String searchText) {
|
||||
protected Specification<ProjectQuotation> buildSearchSpecification(String searchText) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void delete(ProjectQuotation approval) {
|
||||
repository.delete(approval);
|
||||
@Override
|
||||
protected Specification<ProjectQuotation> buildParameterSpecification(JsonNode paramsNode) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||
}
|
||||
|
||||
@CacheEvict(key = "#p0.id")
|
||||
@Override
|
||||
public ProjectQuotation save(ProjectQuotation entity) {
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@CacheEvict(key = "#p0.id")
|
||||
@Override
|
||||
public void delete(ProjectQuotation entity) {
|
||||
repository.delete(entity);
|
||||
}
|
||||
|
||||
public ProjectQuotation newInstanceByProject(Project project) {
|
||||
@@ -100,10 +101,6 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
|
||||
return approval;
|
||||
}
|
||||
|
||||
public List<ProjectQuotation> findAll(Specification<ProjectQuotation> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(ProjectQuotation entity, ProjectQuotationVo vo) {
|
||||
if (entity == null) {
|
||||
@@ -160,4 +157,5 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
|
||||
entity.setEvaluationFile(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,35 +2,33 @@ package com.ecep.contract.ds.project.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.vo.ProjectSaleTypeVo;
|
||||
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 com.ecep.contract.ContractFileType;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.project.repository.ProjectSaleTypeRequireFileTypeRepository;
|
||||
import com.ecep.contract.ds.project.service.ProjectSaleTypeService;
|
||||
import com.ecep.contract.model.ProjectSaleType;
|
||||
import com.ecep.contract.model.ProjectSaleTypeRequireFileType;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.ProjectSaleTypeRequireFileTypeVo;
|
||||
import com.ecep.contract.vo.ProjectSaleTypeVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-sale-type-require-file-type")
|
||||
public class ProjectSaleTypeRequireFileTypeService
|
||||
extends EntityService<ProjectSaleTypeRequireFileType, ProjectSaleTypeRequireFileTypeVo, Integer>
|
||||
implements IEntityService<ProjectSaleTypeRequireFileType>, QueryService<ProjectSaleTypeRequireFileTypeVo>,
|
||||
VoableService<ProjectSaleTypeRequireFileType, ProjectSaleTypeRequireFileTypeVo> {
|
||||
@Lazy
|
||||
@@ -38,8 +36,8 @@ public class ProjectSaleTypeRequireFileTypeService
|
||||
private ProjectSaleTypeRequireFileTypeRepository repository;
|
||||
|
||||
@Override
|
||||
public ProjectSaleTypeRequireFileType getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
protected ProjectSaleTypeRequireFileTypeRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -47,15 +45,10 @@ public class ProjectSaleTypeRequireFileTypeService
|
||||
return repository.findById(id).map(ProjectSaleTypeRequireFileType::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectSaleTypeRequireFileType> findAll(Specification<ProjectSaleTypeRequireFileType> spec,
|
||||
Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Cacheable(key = "'bySaleType-'+#p0")
|
||||
public List<ProjectSaleTypeRequireFileTypeVo> findBySaleType(ProjectSaleTypeVo saleType) {
|
||||
return repository.findBySaleTypeId(saleType.getId()).stream().map(ProjectSaleTypeRequireFileType::toVo).toList();
|
||||
return repository.findBySaleTypeId(saleType.getId()).stream().map(ProjectSaleTypeRequireFileType::toVo)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Cacheable(key = "'by-sale-type-'+#p0.id")
|
||||
@@ -70,21 +63,20 @@ public class ProjectSaleTypeRequireFileTypeService
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectSaleTypeRequireFileTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectSaleTypeRequireFileType> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "saleType");
|
||||
return findAll(spec, pageable).map(ProjectSaleTypeRequireFileType::toVo);
|
||||
public ProjectSaleTypeRequireFileType createNewEntity() {
|
||||
return new ProjectSaleTypeRequireFileType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectSaleTypeRequireFileType> getSearchSpecification(String searchText) {
|
||||
protected Specification<ProjectSaleTypeRequireFileType> buildSearchSpecification(String searchText) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ProjectSaleTypeRequireFileType> buildParameterSpecification(JsonNode paramsNode) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'buildParameterSpecification'");
|
||||
}
|
||||
|
||||
// save
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@@ -92,6 +84,7 @@ public class ProjectSaleTypeRequireFileTypeService
|
||||
@CacheEvict(key = "'by-sale-type-'+#p0.saleType.id"),
|
||||
@CacheEvict(key = "'all'")
|
||||
})
|
||||
@Override
|
||||
public ProjectSaleTypeRequireFileType save(ProjectSaleTypeRequireFileType type) {
|
||||
return repository.save(type);
|
||||
}
|
||||
@@ -103,6 +96,7 @@ public class ProjectSaleTypeRequireFileTypeService
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'all'")
|
||||
})
|
||||
@Override
|
||||
public void delete(ProjectSaleTypeRequireFileType type) {
|
||||
repository.delete(type);
|
||||
}
|
||||
@@ -135,4 +129,5 @@ public class ProjectSaleTypeRequireFileTypeService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.project.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -15,7 +16,6 @@ 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.ds.project.repository.ProjectSaleTypeRepository;
|
||||
@@ -26,14 +26,21 @@ import com.ecep.contract.vo.ProjectSaleTypeVo;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-sale-type")
|
||||
public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>, QueryService<ProjectSaleTypeVo>,
|
||||
public class ProjectSaleTypeService extends EntityService<ProjectSaleType, ProjectSaleTypeVo, Integer>
|
||||
implements IEntityService<ProjectSaleType>, QueryService<ProjectSaleTypeVo>,
|
||||
VoableService<ProjectSaleType, ProjectSaleTypeVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectSaleTypeRepository saleTypeRepository;
|
||||
|
||||
public ProjectSaleType getById(Integer id) {
|
||||
return saleTypeRepository.findById(id).orElse(null);
|
||||
@Override
|
||||
protected ProjectSaleTypeRepository getRepository() {
|
||||
return saleTypeRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectSaleType createNewEntity() {
|
||||
return new ProjectSaleType();
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -64,26 +71,16 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
|
||||
return entities.stream().map(ProjectSaleType::toVo).toList();
|
||||
}
|
||||
|
||||
public Page<ProjectSaleType> findAll(Specification<ProjectSaleType> spec, Pageable pageable) {
|
||||
return saleTypeRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectSaleTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
protected Specification<ProjectSaleType> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<ProjectSaleType> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "active");
|
||||
return findAll(spec, pageable).map(ProjectSaleType::toVo);
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectSaleType> getSearchSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<ProjectSaleType> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
@@ -96,6 +93,7 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
|
||||
@CacheEvict(key = "'code-'+#p0.name"),
|
||||
@CacheEvict(key = "'all'"),
|
||||
})
|
||||
@Override
|
||||
public ProjectSaleType save(ProjectSaleType type) {
|
||||
return saleTypeRepository.save(type);
|
||||
}
|
||||
@@ -105,6 +103,7 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
|
||||
@CacheEvict(key = "'code-'+#p0.name"),
|
||||
@CacheEvict(key = "'all'"),
|
||||
})
|
||||
@Override
|
||||
public void delete(ProjectSaleType type) {
|
||||
saleTypeRepository.delete(type);
|
||||
}
|
||||
@@ -132,4 +131,5 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
|
||||
// ProjectSaleTypeVo中的created和version字段在ProjectSaleType实体中不存在,这里不做处理
|
||||
// 如果需要处理,可以添加日志记录或者其他逻辑
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.project.repository.ProjectTypeRepository;
|
||||
@@ -27,14 +28,20 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-type")
|
||||
public class ProjectTypeService
|
||||
public class ProjectTypeService extends EntityService<ProjectType, ProjectTypeVo, Integer>
|
||||
implements IEntityService<ProjectType>, QueryService<ProjectTypeVo>, VoableService<ProjectType, ProjectTypeVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectTypeRepository repository;
|
||||
|
||||
public ProjectType getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
@Override
|
||||
protected ProjectTypeRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectType createNewEntity() {
|
||||
return new ProjectType();
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@@ -71,33 +78,6 @@ public class ProjectTypeService
|
||||
return entities.stream().map(ProjectType::toVo).toList();
|
||||
}
|
||||
|
||||
public Page<ProjectType> findAll(Specification<ProjectType> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectType> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "name", "code");
|
||||
return findAll(spec, pageable).map(ProjectType::toVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectType> getSearchSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
builder.like(root.get("name"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'all'"),
|
||||
@@ -125,6 +105,21 @@ public class ProjectTypeService
|
||||
model.setDescription(vo.getDescription());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ProjectType> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<ProjectType> spec = null;
|
||||
// field
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "name", "code");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<ProjectType> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
builder.like(root.get("name"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,9 @@ package com.ecep.contract.ds.vendor.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.vendor.model.Vendor;
|
||||
import com.ecep.contract.ds.vendor.model.VendorApprovedItem;
|
||||
import com.ecep.contract.model.VendorApproved;
|
||||
@@ -14,8 +13,7 @@ import com.ecep.contract.model.VendorApproved;
|
||||
* 合格供方名录
|
||||
*/
|
||||
@Repository
|
||||
public interface VendorApprovedItemRepository extends
|
||||
JpaRepository<VendorApprovedItem, Integer>, JpaSpecificationExecutor<VendorApprovedItem> {
|
||||
public interface VendorApprovedItemRepository extends MyRepository<VendorApprovedItem, Integer> {
|
||||
|
||||
List<VendorApprovedItem> findAllByList(VendorApproved list);
|
||||
|
||||
|
||||
@@ -2,15 +2,14 @@ package com.ecep.contract.ds.vendor.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.model.VendorGroup;
|
||||
|
||||
@Repository
|
||||
public interface VendorGroupRepository extends
|
||||
JpaRepository<VendorGroup, Integer>, JpaSpecificationExecutor<VendorGroup> {
|
||||
MyRepository<VendorGroup, Integer> {
|
||||
|
||||
Optional<VendorGroup> findByName(String name);
|
||||
|
||||
|
||||
@@ -2,16 +2,14 @@ package com.ecep.contract.ds.vendor.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.model.VendorGroupRequireFileType;
|
||||
|
||||
@Repository
|
||||
public interface VendorGroupRequireFileTypeRepository extends
|
||||
JpaRepository<VendorGroupRequireFileType, Integer>, JpaSpecificationExecutor<VendorGroupRequireFileType> {
|
||||
|
||||
MyRepository<VendorGroupRequireFileType, Integer> {
|
||||
|
||||
List<VendorGroupRequireFileType> findByGroupId(int groupId);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
package com.ecep.contract.ds.vendor.service;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import java.util.List;
|
||||
|
||||
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.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorApprovedFileRepository;
|
||||
import com.ecep.contract.model.VendorApproved;
|
||||
import com.ecep.contract.model.VendorApprovedFile;
|
||||
@@ -13,16 +22,6 @@ import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.VendorApprovedFileVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
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 java.util.List;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@@ -72,30 +71,15 @@ public class VendorApprovedFileService extends EntityService<VendorApprovedFile,
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VendorApprovedFile getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据查询规格和分页参数获取供应商已批准文件列表
|
||||
*
|
||||
* @param spec 查询规格
|
||||
* @param pageable 分页参数
|
||||
* @return 分页的文件列表
|
||||
*/
|
||||
@Override
|
||||
public Page<VendorApprovedFile> findAll(Specification<VendorApprovedFile> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除供应商已批准文件
|
||||
*
|
||||
* @param entity 要删除的文件实体
|
||||
*/
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'byList-'+#p0.list.id")
|
||||
})
|
||||
@Override
|
||||
public void delete(VendorApprovedFile entity) {
|
||||
repository.delete(entity);
|
||||
@@ -107,6 +91,10 @@ public class VendorApprovedFileService extends EntityService<VendorApprovedFile,
|
||||
* @param entity 要保存的文件实体
|
||||
* @return 保存后的文件实体
|
||||
*/
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'byList-'+#p0.list.id")
|
||||
})
|
||||
@Override
|
||||
public VendorApprovedFile save(VendorApprovedFile entity) {
|
||||
return repository.save(entity);
|
||||
@@ -158,4 +146,4 @@ public class VendorApprovedFileService extends EntityService<VendorApprovedFile,
|
||||
entity.setList(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,13 @@ package com.ecep.contract.ds.vendor.service;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.VendorType;
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -34,7 +34,7 @@ import jakarta.persistence.criteria.Predicate;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class VendorApprovedItemService
|
||||
public class VendorApprovedItemService extends EntityService<VendorApprovedItem, VendorApprovedItemVo, Integer>
|
||||
implements IEntityService<VendorApprovedItem>, QueryService<VendorApprovedItemVo>,
|
||||
VoableService<VendorApprovedItem, VendorApprovedItemVo> {
|
||||
|
||||
@@ -45,7 +45,14 @@ public class VendorApprovedItemService
|
||||
@Autowired
|
||||
private CompanyOldNameService companyOldNameService;
|
||||
|
||||
public VendorApprovedItemService() {
|
||||
@Override
|
||||
protected VendorApprovedItemRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VendorApprovedItem createNewEntity() {
|
||||
return new VendorApprovedItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,12 +61,7 @@ public class VendorApprovedItemService
|
||||
}
|
||||
|
||||
@Override
|
||||
public VendorApprovedItem getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<VendorApprovedItem> getSearchSpecification(String searchText) {
|
||||
protected Specification<VendorApprovedItem> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
Path<Vendor> vendor = root.get("vendor");
|
||||
Path<Company> company = vendor.get("company");
|
||||
@@ -82,30 +84,8 @@ public class VendorApprovedItemService
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VendorApprovedItem> findAll(Specification<VendorApprovedItem> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(VendorApprovedItem entity) {
|
||||
repository.delete(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VendorApprovedItem save(VendorApprovedItem entity) {
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
public List<VendorApprovedItem> findAll(Specification<VendorApprovedItem> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VendorApprovedItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
protected Specification<VendorApprovedItem> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<VendorApprovedItem> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
// 添加额外的参数过滤
|
||||
if (paramsNode.has("type")) {
|
||||
String typeText = paramsNode.get("type").asText();
|
||||
@@ -115,7 +95,7 @@ public class VendorApprovedItemService
|
||||
});
|
||||
}
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor", "list");
|
||||
return findAll(spec, pageable).map(VendorApprovedItem::toVo);
|
||||
return spec;
|
||||
}
|
||||
|
||||
public List<VendorApprovedItem> findAllByListAndVendor(VendorApproved approvedList, Vendor vendor) {
|
||||
@@ -153,4 +133,4 @@ public class VendorApprovedItemService
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,36 +8,32 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
import com.ecep.contract.service.SmbFileService;
|
||||
import com.hierynomus.smbj.common.SmbPath;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
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.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorApprovedRepository;
|
||||
import com.ecep.contract.model.VendorApproved;
|
||||
import com.ecep.contract.model.VendorApprovedFile;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
import com.ecep.contract.service.SmbFileService;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.VendorApprovedVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.hierynomus.smbj.common.SmbPath;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@@ -78,11 +74,6 @@ public class VendorApprovedService extends EntityService<VendorApproved, VendorA
|
||||
return repository.findById(id).map(VendorApproved::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VendorApproved getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected org.springframework.data.jpa.domain.Specification<VendorApproved> buildParameterSpecification(
|
||||
JsonNode paramsNode) {
|
||||
@@ -108,10 +99,6 @@ public class VendorApprovedService extends EntityService<VendorApproved, VendorA
|
||||
repository.delete(entity);
|
||||
}
|
||||
|
||||
public Page<VendorApproved> findAll(Specification<VendorApproved> spec, PageRequest pageRequest) {
|
||||
return repository.findAll(spec, pageRequest);
|
||||
}
|
||||
|
||||
public boolean makePathAbsent(VendorApproved list) {
|
||||
String path = list.getPath();
|
||||
if (StringUtils.hasText(path)) {
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
package com.ecep.contract.ds.vendor.service;
|
||||
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
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.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorClassRepository;
|
||||
import com.ecep.contract.model.VendorCatalog;
|
||||
@@ -48,34 +44,12 @@ public class VendorCatalogService extends EntityService<VendorCatalog, VendorCat
|
||||
return new VendorCatalog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VendorCatalogVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<VendorCatalog> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
|
||||
// field
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "name", "code", "parentId");
|
||||
return findAll(spec, pageable).map(VendorCatalog::toVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VendorCatalog getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public VendorCatalogVo findById(Integer id) {
|
||||
return repository.findById(id).map(VendorCatalog::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VendorCatalog> findAll(Specification<VendorCatalog> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected org.springframework.data.jpa.domain.Specification<VendorCatalog> buildParameterSpecification(
|
||||
JsonNode paramsNode) {
|
||||
@@ -121,4 +95,4 @@ public class VendorCatalogService extends EntityService<VendorCatalog, VendorCat
|
||||
model.setCode(vo.getCode());
|
||||
model.setType(vo.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,20 +8,17 @@ 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.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorEntityRepository;
|
||||
import com.ecep.contract.ds.vendor.model.Vendor;
|
||||
import com.ecep.contract.ds.vendor.model.VendorEntity;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorEntityRepository;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.VendorEntityVo;
|
||||
@@ -30,7 +27,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-vendor-entity")
|
||||
public class VendorEntityService extends EntityService<VendorEntity, VendorEntityVo, Integer> implements IEntityService<VendorEntity>, QueryService<VendorEntityVo>,
|
||||
public class VendorEntityService extends EntityService<VendorEntity, VendorEntityVo, Integer>
|
||||
implements IEntityService<VendorEntity>, QueryService<VendorEntityVo>,
|
||||
VoableService<VendorEntity, VendorEntityVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -46,11 +44,6 @@ public class VendorEntityService extends EntityService<VendorEntity, VendorEntit
|
||||
return new VendorEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VendorEntity getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public VendorEntityVo findById(Integer id) {
|
||||
@@ -69,13 +62,6 @@ public class VendorEntityService extends EntityService<VendorEntity, VendorEntit
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<VendorEntity> getSearchSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
return SpecificationUtils.andWith(searchText, this::buildSearchSpecification);
|
||||
}
|
||||
|
||||
protected Specification<VendorEntity> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
@@ -86,35 +72,14 @@ public class VendorEntityService extends EntityService<VendorEntity, VendorEntit
|
||||
}
|
||||
|
||||
@Override
|
||||
protected org.springframework.data.jpa.domain.Specification<VendorEntity> buildParameterSpecification(JsonNode paramsNode) {
|
||||
protected org.springframework.data.jpa.domain.Specification<VendorEntity> buildParameterSpecification(
|
||||
JsonNode paramsNode) {
|
||||
org.springframework.data.jpa.domain.Specification<VendorEntity> spec = null;
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor");
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "name", "abbName", "code");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VendorEntity> search(String searchText) {
|
||||
Specification<VendorEntity> spec = getSearchSpecification(searchText);
|
||||
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VendorEntity> findAll(Specification<VendorEntity> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VendorEntityVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<VendorEntity> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// 添加额外的参数过滤s
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor");
|
||||
return findAll(spec, pageable).map(VendorEntity::toVo);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code")
|
||||
@@ -173,4 +138,4 @@ public class VendorEntityService extends EntityService<VendorEntity, VendorEntit
|
||||
model.setModifier(employeeService.getById(vo.getModifierId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.ContractPayWay;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
@@ -42,8 +41,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class VendorFileService
|
||||
implements IEntityService<VendorFile>, QueryService<VendorFile>, VoableService<VendorFile, VendorFileVo> {
|
||||
public class VendorFileService extends EntityService<VendorFile, VendorFileVo, Integer>
|
||||
implements IEntityService<VendorFile>, QueryService<VendorFileVo>, VoableService<VendorFile, VendorFileVo> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(VendorFileService.class);
|
||||
|
||||
@@ -59,42 +58,8 @@ public class VendorFileService
|
||||
@Autowired
|
||||
private VendorFileRepository repository;
|
||||
|
||||
@Override
|
||||
public VendorFile getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public VendorFile findById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<VendorFile> getSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(builder.like(root.get("filePath"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VendorFile> findAll(Specification<VendorFile> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VendorFile> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<VendorFile> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
// 添加额外的参数过滤
|
||||
if (paramsNode.has("type")) {
|
||||
VendorFileType type = VendorFileType.valueOf(paramsNode.get("type").asText());
|
||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), type));
|
||||
}
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "valid");
|
||||
spec = SpecificationUtils.andFieldBetweenParam(spec, paramsNode, "signDate", LocalDate.class);
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor");
|
||||
return findAll(spec, pageable);
|
||||
public VendorFileVo findById(Integer id) {
|
||||
return repository.findById(id).map(VendorFile::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public List<VendorFile> findAllByVendor(Vendor vendor) {
|
||||
@@ -105,10 +70,6 @@ public class VendorFileService
|
||||
return repository.findAllByVendorId(vendor.getId()).stream().map(VendorFile::toVo).toList();
|
||||
}
|
||||
|
||||
public void delete(VendorFile file) {
|
||||
repository.delete(file);
|
||||
}
|
||||
|
||||
public void deleteById(int id) {
|
||||
repository.deleteById(id);
|
||||
}
|
||||
@@ -117,14 +78,6 @@ public class VendorFileService
|
||||
repository.saveAll(files);
|
||||
}
|
||||
|
||||
public VendorFile save(VendorFile file) {
|
||||
return repository.save(file);
|
||||
}
|
||||
|
||||
public List<VendorFile> findAll(Specification<VendorFile> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
public List<VendorFile> findAllByVendorAndType(Vendor vendor, VendorFileType type) {
|
||||
return repository.findAllByVendorAndType(vendor, type);
|
||||
}
|
||||
@@ -133,6 +86,40 @@ public class VendorFileService
|
||||
return repository.findAllByVendorIdAndType(vendor.getId(), type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VendorFileRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VendorFile createNewEntity() {
|
||||
return new VendorFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<VendorFile> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(builder.like(root.get("filePath"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<VendorFile> buildParameterSpecification(JsonNode node) {
|
||||
Specification<VendorFile> spec = null;
|
||||
if (node.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSearchSpecification(node.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
// 添加额外的参数过滤
|
||||
if (node.has("type")) {
|
||||
VendorFileType type = VendorFileType.valueOf(node.get("type").asText());
|
||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), type));
|
||||
}
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, node, "valid");
|
||||
spec = SpecificationUtils.andFieldBetweenParam(spec, node, "signDate", LocalDate.class);
|
||||
spec = SpecificationUtils.andParam(spec, node, "vendor");
|
||||
return spec;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证供应商文件
|
||||
*
|
||||
|
||||
@@ -3,23 +3,21 @@ package com.ecep.contract.ds.vendor.service;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
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.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.VendorType;
|
||||
import com.ecep.contract.constant.ParamConstant;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorFileTypeLocalRepository;
|
||||
import com.ecep.contract.model.VendorFileTypeLocal;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
@@ -35,44 +33,19 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "vendor-file-type")
|
||||
public class VendorFileTypeService implements IEntityService<VendorFileTypeLocal>, QueryService<VendorFileTypeLocalVo>,
|
||||
public class VendorFileTypeService extends EntityService<VendorFileTypeLocal, VendorFileTypeLocalVo, Integer>
|
||||
implements IEntityService<VendorFileTypeLocal>, QueryService<VendorFileTypeLocalVo>,
|
||||
VoableService<VendorFileTypeLocal, VendorFileTypeLocalVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private VendorFileTypeLocalRepository repository;
|
||||
|
||||
@Override
|
||||
public Page<VendorFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<VendorFileTypeLocal> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
|
||||
if (paramsNode.has("type")) {
|
||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"),
|
||||
VendorType.valueOf(paramsNode.get("type").asText())));
|
||||
}
|
||||
|
||||
// field
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value");
|
||||
return findAll(spec, pageable).map(VendorFileTypeLocal::toVo);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public VendorFileTypeLocalVo findById(Integer id) {
|
||||
return repository.findById(id).map(VendorFileTypeLocal::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public VendorFileTypeLocal getById(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, VendorFileTypeLocalVo> findAll(Locale locale) {
|
||||
return repository.getCompleteMapByLocal(locale.toLanguageTag()).entrySet().stream()
|
||||
@@ -81,20 +54,6 @@ public class VendorFileTypeService implements IEntityService<VendorFileTypeLocal
|
||||
entry -> entry.getValue().toVo()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<VendorFileTypeLocal> getSearchSpecification(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()")
|
||||
@@ -113,6 +72,40 @@ public class VendorFileTypeService implements IEntityService<VendorFileTypeLocal
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VendorFileTypeLocalRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VendorFileTypeLocal createNewEntity() {
|
||||
return new VendorFileTypeLocal();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<VendorFileTypeLocal> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.like(root.get("type"), "%" + searchText + "%");
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<VendorFileTypeLocal> buildParameterSpecification(JsonNode node) {
|
||||
Specification<VendorFileTypeLocal> spec = null;
|
||||
if (node.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSearchSpecification(node.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
|
||||
if (node.has("type")) {
|
||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"),
|
||||
VendorType.valueOf(node.get("type").asText())));
|
||||
}
|
||||
|
||||
// field
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, node, "lang", "value");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(VendorFileTypeLocal entity, VendorFileTypeLocalVo vo) throws ServiceException {
|
||||
if (entity == null) {
|
||||
|
||||
@@ -2,18 +2,16 @@ package com.ecep.contract.ds.vendor.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
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 com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
@@ -22,6 +20,7 @@ import com.ecep.contract.model.VendorGroup;
|
||||
import com.ecep.contract.model.VendorGroupRequireFileType;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.VendorGroupRequireFileTypeVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@@ -29,55 +28,47 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "vendor-group-require-file-type")
|
||||
public class VendorGroupRequireFileTypeService
|
||||
implements IEntityService<VendorGroupRequireFileType>, QueryService<VendorGroupRequireFileType>,
|
||||
extends EntityService<VendorGroupRequireFileType, VendorGroupRequireFileTypeVo, Integer>
|
||||
implements IEntityService<VendorGroupRequireFileType>, QueryService<VendorGroupRequireFileTypeVo>,
|
||||
VoableService<VendorGroupRequireFileType, VendorGroupRequireFileTypeVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private VendorGroupRequireFileTypeRepository repository;
|
||||
|
||||
@Override
|
||||
public VendorGroupRequireFileType getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public VendorGroupRequireFileType findById(Integer id) {
|
||||
return getById(id);
|
||||
protected VendorGroupRequireFileTypeRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VendorGroupRequireFileType> findAll(Specification<VendorGroupRequireFileType> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
public VendorGroupRequireFileType createNewEntity() {
|
||||
return new VendorGroupRequireFileType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VendorGroupRequireFileType> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<VendorGroupRequireFileType> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "group");
|
||||
// 添加额外的参数过滤
|
||||
return findAll(spec, pageable);
|
||||
public VendorGroupRequireFileTypeVo findById(Integer id) {
|
||||
return repository.findById(id).map(VendorGroupRequireFileType::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<VendorGroupRequireFileType> getSearchSpecification(String searchText) {
|
||||
protected Specification<VendorGroupRequireFileType> buildSearchSpecification(String searchText) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<VendorGroupRequireFileType> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<VendorGroupRequireFileType> spec = null;
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "group");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Cacheable(key = "'byGroup-'+#p0")
|
||||
public List<VendorGroupRequireFileTypeVo> findByGroupId(int groupId) {
|
||||
return repository.findByGroupId(groupId).stream().map(VendorGroupRequireFileType::toVo).toList();
|
||||
}
|
||||
|
||||
// findAll
|
||||
@Cacheable(key = "'all'")
|
||||
public List<VendorGroupRequireFileType> findAll() {
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
// save
|
||||
@Override
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'byGroup-'+#p0.group.id"),
|
||||
@@ -90,6 +81,7 @@ public class VendorGroupRequireFileTypeService
|
||||
/**
|
||||
* delete and evict cache
|
||||
*/
|
||||
@Override
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'byGroup-'+#p0.group.id"),
|
||||
@CacheEvict(key = "'all'")
|
||||
@@ -121,4 +113,5 @@ public class VendorGroupRequireFileTypeService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,12 +8,11 @@ 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.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorGroupRepository;
|
||||
@@ -27,22 +26,36 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "vendor-group")
|
||||
public class VendorGroupService
|
||||
public class VendorGroupService extends EntityService<VendorGroup, VendorGroupVo, Integer>
|
||||
implements IEntityService<VendorGroup>, QueryService<VendorGroupVo>, VoableService<VendorGroup, VendorGroupVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private VendorGroupRepository vendorGroupRepository;
|
||||
|
||||
@Override
|
||||
protected VendorGroupRepository getRepository() {
|
||||
return vendorGroupRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VendorGroup createNewEntity() {
|
||||
VendorGroup group = new VendorGroup();
|
||||
group.setCode("");
|
||||
group.setName("");
|
||||
group.setDescription("");
|
||||
group.setActive(true);
|
||||
group.setPriceComparison(true);
|
||||
group.setRequireQuotationSheetForBid(true);
|
||||
group.setCanPrePurchase(false);
|
||||
return group;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public VendorGroupVo findById(Integer id) {
|
||||
return vendorGroupRepository.findById(id).map(VendorGroup::toVo).orElse(null);
|
||||
}
|
||||
|
||||
public VendorGroup getById(Integer id) {
|
||||
return vendorGroupRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public VendorGroup findByName(String name) {
|
||||
return vendorGroupRepository.findByName(name).orElse(null);
|
||||
}
|
||||
@@ -57,63 +70,21 @@ public class VendorGroupService
|
||||
return vendorGroupRepository.findAll();
|
||||
}
|
||||
|
||||
public Page<VendorGroup> findAll(Specification<VendorGroup> spec, Pageable pageable) {
|
||||
return vendorGroupRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<VendorGroupVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<VendorGroup> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSearchSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// 添加额外的参数过滤
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "active", "name", "code");
|
||||
return findAll(spec, pageable).map(entity -> entity.toVo());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<VendorGroup> getSearchSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<VendorGroup> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
builder.like(root.get("description"), "%" + searchText + "%")
|
||||
);
|
||||
builder.like(root.get("description"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.name"),
|
||||
@CacheEvict(key = "'all'"),
|
||||
})
|
||||
public VendorGroup saveEntity(VendorGroup group) {
|
||||
return vendorGroupRepository.save(group);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.name"),
|
||||
@CacheEvict(key = "'all'"),
|
||||
})
|
||||
public void deleteEntity(VendorGroup entity) {
|
||||
vendorGroupRepository.delete(entity);
|
||||
}
|
||||
|
||||
public VendorGroup newInstance() {
|
||||
VendorGroup group = new VendorGroup();
|
||||
group.setCode("");
|
||||
group.setName("");
|
||||
group.setDescription("");
|
||||
group.setActive(true);
|
||||
group.setPriceComparison(true);
|
||||
group.setRequireQuotationSheetForBid(true);
|
||||
group.setCanPrePurchase(false);
|
||||
return group;
|
||||
@Override
|
||||
protected Specification<VendorGroup> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<VendorGroup> spec = null;
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "active", "name", "code");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -134,14 +105,23 @@ public class VendorGroupService
|
||||
model.setCanPrePurchase(vo.isCanPrePurchase());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.name"),
|
||||
@CacheEvict(key = "'all'"),
|
||||
})
|
||||
public VendorGroup save(VendorGroup entity) {
|
||||
return saveEntity(entity);
|
||||
return vendorGroupRepository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.name"),
|
||||
@CacheEvict(key = "'all'"),
|
||||
})
|
||||
public void delete(VendorGroup entity) {
|
||||
deleteEntity(entity);
|
||||
vendorGroupRepository.delete(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,10 +77,7 @@ public class VendorTypeService extends EntityService<VendorTypeLocal, VendorType
|
||||
return repository.findById(id).map(VendorTypeLocal::toVo).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VendorTypeLocal getById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
||||
public Map<VendorType, VendorTypeLocal> findAll(Locale locale) {
|
||||
|
||||
@@ -1,4 +1,94 @@
|
||||
# 服务器端继承IEntityService接口的Service列表
|
||||
# 服务器端 Service 继承IEntityService接口任务
|
||||
|
||||
`IEntityService` 接口定义了若干基本 CRUD 操作(相对项目路径:src/main/java/com/contract/service/IEntityService.java),包括保存、删除、查询等方法。
|
||||
|
||||
## Service 继承 EntityService 类的任务
|
||||
|
||||
参考 `server\src\main\java\com\ecep\contract\cloud\rk\CloudRkService.java` 类
|
||||
|
||||
1. 实现 `server\src\main\java\com\ecep\contract\EntityService.java` 类的方法
|
||||
1.1 实现 `getRepository` 方法,用于获取实体的Repository
|
||||
1.1.1 确认的Repository是否为`server\src\main\java\com\ecep\contract\ds\MyRepository.java`的子接口
|
||||
1.2 实现 `createNewEntity` 方法,用于创建新实体
|
||||
1.3 实现 `buildSearchSpecification` 方法,根据搜索参数构建查询规范
|
||||
1.3.1 方法内容如下
|
||||
|
||||
```java
|
||||
@Override
|
||||
protected org.springframework.data.jpa.domain.Specification<VendorApprovedFile> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("fileName"), "%" + searchText + "%"),
|
||||
builder.like(root.get("description"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
1.4 实现 `buildParameterSpecification` 方法,根据参数构建查询规范
|
||||
1.4.1 方法内容从 `findAll(JsonNode paramsNode, Pageable pageable)` 中提取,然后删除 findAll 方法
|
||||
比如 findAll 方法中定义如下
|
||||
```java
|
||||
@Override
|
||||
public Page<VendorApprovedItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<VendorApprovedItem> spec = null;
|
||||
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
|
||||
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
|
||||
}
|
||||
// 添加额外的参数过滤
|
||||
if (paramsNode.has("type")) {
|
||||
String typeText = paramsNode.get("type").asText();
|
||||
VendorType type = VendorType.valueOf(typeText);
|
||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||
return builder.equal(root.get("type"), type);
|
||||
});
|
||||
}
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor", "list");
|
||||
return findAll(spec, pageable).map(VendorApprovedItem::toVo);
|
||||
}
|
||||
```
|
||||
|
||||
则 `buildParameterSpecification` 方法的实现如下(删除 searchText 部分以及直接返回spec,不调用findAll方法)
|
||||
```java
|
||||
|
||||
@Override
|
||||
protected Specification<VendorApprovedItem> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<VendorApprovedItem> spec = null;
|
||||
// 添加额外的参数过滤
|
||||
if (paramsNode.has("type")) {
|
||||
String typeText = paramsNode.get("type").asText();
|
||||
VendorType type = VendorType.valueOf(typeText);
|
||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||
return builder.equal(root.get("type"), type);
|
||||
});
|
||||
}
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor", "list");
|
||||
return spec;
|
||||
}
|
||||
```
|
||||
|
||||
1.5 检查`count`方法的功能实现是否与父类相同,相同则移除
|
||||
1.6 检查`findAll`方法的功能实现是否与父类相同,相同则移除
|
||||
1.7 检查`getById`方法的功能实现是否与父类相同,相同则移除
|
||||
1.8 检查`findById`f方法的返回值类型,须 Vo 类型,如未实现,则添加如下代码
|
||||
|
||||
```java
|
||||
@Override
|
||||
public VendorGroupRequireFileTypeVo findById(Integer id) {
|
||||
return repository.findById(id).map(VendorGroupRequireFileType::toVo).orElse(null);
|
||||
}
|
||||
```
|
||||
|
||||
2. 缓存相关任务
|
||||
2.1 确认Service类是否有 @CacheConfig 注解,没有注解,则没有应用缓存功能,跳过后续缓存检查
|
||||
2.2 检查 `findById` 方法,注解 @Cacheable(key = "#p0")
|
||||
2.3 检查 `save` 方法,注解 @CacheEvict(key = "#p0.id") 或者 @Caching(evict = @CacheEvict(key = "#p0.id"))
|
||||
2.4 检查 `delete` 方法,注解 @CacheEvict(key = "#p0.id") 或者 @Caching(evict = @CacheEvict(key = "#p0.id"))
|
||||
|
||||
|
||||
3. 处理异常情况
|
||||
|
||||
|
||||
## Service 继承 IEntityService 接口的列表
|
||||
|
||||
| 类名 | 是否继承EntityService |
|
||||
|------|----------------------|
|
||||
@@ -65,39 +155,21 @@
|
||||
| ProjectFileService | 是 |
|
||||
| ProjectFileTypeService | 是 |
|
||||
| ProjectFundPlanService | 是 |
|
||||
| ProjectIndustryService | 否 |
|
||||
| ProjectQuotationService | 否 |
|
||||
| ProjectSaleTypeRequireFileTypeService | 否 |
|
||||
| ProjectSaleTypeService | 否 |
|
||||
| ProjectIndustryService | 是 |
|
||||
| ProjectQuotationService | 是 |
|
||||
| ProjectSaleTypeRequireFileTypeService | 是 |
|
||||
| ProjectSaleTypeService | 是 |
|
||||
| ProjectService | 是 |
|
||||
| ProjectTypeService | 否 |
|
||||
| VendorApprovedFileService | 否 |
|
||||
| VendorApprovedItemService | 否 |
|
||||
| VendorApprovedService | 否 |
|
||||
| VendorCatalogService | 否 |
|
||||
| VendorEntityService | 否 |
|
||||
| VendorFileService | 否 |
|
||||
| VendorFileTypeService | 否 |
|
||||
| VendorGroupRequireFileTypeService | 否 |
|
||||
| VendorGroupService | 否 |
|
||||
| VendorService | 否 |
|
||||
| VendorTypeService | 否 |
|
||||
| ProjectTypeService | 是 |
|
||||
| VendorApprovedFileService | 是 |
|
||||
| VendorApprovedItemService | 是 |
|
||||
| VendorApprovedService | 是 |
|
||||
| VendorCatalogService | 是 |
|
||||
| VendorEntityService | 是 |
|
||||
| VendorFileService | 是 |
|
||||
| VendorFileTypeService | 是 |
|
||||
| VendorGroupRequireFileTypeService | 是 |
|
||||
| VendorGroupService | 是 |
|
||||
| VendorService | 是 |
|
||||
| VendorTypeService | 是 |
|
||||
|
||||
## 分析结果
|
||||
|
||||
- 共找到81个实现了IEntityService接口的服务类
|
||||
- 其中有12个类同时继承了EntityService类
|
||||
- 大多数服务类(69个)仅实现了IEntityService接口,没有继承EntityService类
|
||||
|
||||
继承EntityService类的服务类包括:
|
||||
- CloudRkService
|
||||
- CloudTycService
|
||||
- YongYouU8Service
|
||||
- CompanyBankAccountService
|
||||
- CompanyService
|
||||
- ContractService
|
||||
- SaleOrdersService
|
||||
- SalesBillVoucherService
|
||||
- SalesOrderItemService
|
||||
- ProjectService
|
||||
- 以及其他几个核心业务服务类
|
||||
Reference in New Issue
Block a user