refactor: 将getSpecification重命名为getSearchSpecification以提高方法命名清晰度

This commit is contained in:
2025-12-13 17:59:16 +08:00
parent 5d6fb961b6
commit e3661630fe
82 changed files with 431 additions and 341 deletions

View File

@@ -41,56 +41,155 @@ public abstract class EntityService<T extends Voable<VO>, VO, ID> {
return getRepository().findById(id).orElse(null);
}
/**
* 创建新实体实例
* 设置默认值或必要的属性
* 实例是游离态的,未存储到数据库
*
* @return 新实体实例
*/
public abstract T createNewEntity();
/**
* 统计所有实体数量
*
* @return 实体数量
*/
public long count() {
return getRepository().count();
}
/**
* 根据查询规范统计实体数量
*
* @param spec 查询规范
* @return 符合规范的实体数量
*/
public long count(Specification<T> spec) {
return getRepository().count(spec);
}
/**
* 根据JSON参数节点统计实体数量
*
* @param paramsNode JSON参数节点
* @return 符合参数节点规范的实体数量
*/
public long count(JsonNode paramsNode) {
return getRepository().count(buildParameterSpecification(paramsNode));
return count(applyJsonParameter(paramsNode));
}
/**
* 保存实体到数据库
*
* @param entity 要保存的实体
* @return 保存后的实体
*/
public T save(T entity) {
return getRepository().save(entity);
}
/**
* 删除实体
*
* @param entity 要删除的实体
*/
public void delete(T entity) {
getRepository().delete(entity);
}
@Deprecated
protected abstract Specification<T> buildParameterSpecification(JsonNode paramsNode);
public Page<VO> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<T> spec = SpecificationUtils.applySearchText(paramsNode, this::getSpecification);
JsonNode filterNode = paramsNode.get(ParamConstant.KEY_FILTER);
/**
* 应用JSON参数节点到查询规范
*
* @param node JSON参数节点
* @return 应用参数节点后的查询规范
*/
protected Specification<T> applyJsonParameter(JsonNode node) {
Specification<T> spec = SpecificationUtils.applySearchText(node, this::getSearchSpecification);
JsonNode filterNode = node.get(ParamConstant.KEY_FILTER);
if (filterNode != null) {
Specification<T> childSpec = buildFilterCondition(filterNode);
if (childSpec != null) {
spec = SpecificationUtils.and(spec, childSpec);
}
}
return findAll(spec, pageable).map(T::toVo);
return spec;
}
/**
* 根据JSON参数节点查询所有实体
*
* @param paramsNode JSON参数节点
* @param pageable 分页信息
* @return 符合参数节点规范的实体分页结果
*/
public Page<VO> findAll(JsonNode paramsNode, Pageable pageable) {
return findAll(applyJsonParameter(paramsNode), pageable).map(T::toVo);
}
/**
* 根据查询规范查询所有实体
*
* @param spec 查询规范
* @param pageable 分页信息
* @return 符合规范的实体分页结果
*/
public Page<T> findAll(Specification<T> spec, Pageable pageable) {
return getRepository().findAll(spec, pageable);
}
/**
* 根据查询规范查询所有实体
*
* @param spec 查询规范
* @param sort 排序信息
* @return 符合规范的实体列表
*/
public List<T> findAll(Specification<T> spec, Sort sort) {
return getRepository().findAll(spec, sort);
}
protected abstract Specification<T> buildSearchSpecification(String searchText);
/**
* 根据搜索文本查询所有实体
*
* @param searchText 搜索文本
* @return 符合搜索文本规范的实体列表
*/
public List<T> search(String searchText) {
Specification<T> spec = getSearchSpecification(searchText);
return getRepository().findAll(spec, Pageable.ofSize(10)).getContent();
}
public Specification<T> getSpecification(String searchText) {
/**
* 根据搜索文本构建查询规范
*
* @param searchText 搜索文本
* @return 符合搜索文本规范的查询规范
*/
public Specification<T> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
return SpecificationUtils.andWith(searchText, this::buildSearchSpecification);
}
public List<T> search(String searchText) {
Specification<T> spec = getSpecification(searchText);
return getRepository().findAll(spec, Pageable.ofSize(10)).getContent();
}
/**
* 构建搜索规范
*
* @param searchText 搜索文本,非空
* @return 符合搜索文本规范的查询规范
*/
protected abstract Specification<T> buildSearchSpecification(String searchText);
/**
* 构建过滤条件规范
*
* @param filterNode 过滤条件节点
* @return 过滤条件规范
*/
private Specification<T> buildFilterCondition(JsonNode filterNode) {
String operatorStr = filterNode.get(ParamConstant.KEY_OPERATOR).asText();

View File

@@ -23,7 +23,7 @@ public interface IEntityService<T> {
* @param searchText 要搜索的文本
* @return 规格化查询
*/
Specification<T> getSpecification(String searchText);
Specification<T> getSearchSpecification(String searchText);
/**
* 根据搜索文本查询列表

View File

@@ -98,14 +98,24 @@ public class CloudRkService extends EntityService<CloudRk, CloudRkVo, Integer>
@Autowired
private CloudRkRepository cloudRKRepository;
@Override
protected CloudRkRepository getRepository() {
return cloudRKRepository;
}
@Override
public CloudRk getById(Integer id) {
return cloudRKRepository.findById(id).orElse(null);
return super.getById(id);
}
@Cacheable(key = "#p0")
public CloudRkVo findById(Integer id) {
return cloudRKRepository.findById(id).map(CloudRk::toVo).orElse(null);
return getRepository().findById(id).map(CloudRk::toVo).orElse(null);
}
@Override
public CloudRk createNewEntity() {
return new CloudRk();
}
@Override
@@ -377,15 +387,4 @@ public class CloudRkService extends EntityService<CloudRk, CloudRkVo, Integer>
cloudRk.setVersion(vo.getVersion());
}
@Override
protected MyRepository<CloudRk, Integer> getRepository() {
return cloudRKRepository;
}
@Override
public CloudRk createNewEntity() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'createNewEntity'");
}
}

View File

@@ -20,6 +20,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.MessageHolder;
import com.ecep.contract.SpringApp;
@@ -27,6 +28,7 @@ import com.ecep.contract.cloud.CloudInfo;
import com.ecep.contract.constant.CloudServiceConstant;
import com.ecep.contract.ds.company.service.CompanyService;
import com.ecep.contract.ds.other.model.CloudTyc;
import com.ecep.contract.ds.MyRepository;
import com.ecep.contract.ds.company.model.Company;
import com.ecep.contract.service.VoableService;
import com.ecep.contract.util.MyStringUtils;
@@ -35,7 +37,8 @@ import com.ecep.contract.vo.CloudTycVo;
@Lazy
@Service
@CacheConfig(cacheNames = "cloud-tyc")
public class CloudTycService implements IEntityService<CloudTyc>, QueryService<CloudTycVo>, VoableService<CloudTyc, CloudTycVo> {
public class CloudTycService extends EntityService<CloudTyc, CloudTycVo, Integer>
implements IEntityService<CloudTyc>, QueryService<CloudTycVo>, VoableService<CloudTyc, CloudTycVo> {
private static final Logger logger = LoggerFactory.getLogger(CloudTycService.class);
/**
@@ -49,12 +52,18 @@ public class CloudTycService implements IEntityService<CloudTyc>, QueryService<C
return fileName.contains(CloudServiceConstant.TYC_NAME);
}
@Lazy
@Autowired
private CloudTycRepository cloudTycRepository;
@Override
public CloudTyc getById(Integer id) {
return cloudTycRepository.findById(id).orElse(null);
protected CloudTycRepository getRepository() {
return cloudTycRepository;
}
@Override
public CloudTyc createNewEntity() {
return new CloudTyc();
}
public CloudTyc getOrCreateCloudTyc(CloudInfo info) {
@@ -163,30 +172,15 @@ public class CloudTycService implements IEntityService<CloudTyc>, QueryService<C
return cloudTycRepository.findById(id).map(CloudTyc::toVo).orElse(null);
}
public Page<CloudTyc> findAll(Specification<CloudTyc> spec, PageRequest pageable) {
return cloudTycRepository.findAll(spec, pageable);
}
public Page<CloudTyc> findAll(Specification<CloudTyc> spec, Pageable pageable) {
return cloudTycRepository.findAll(spec, pageable);
}
@Override
public Page<CloudTycVo> findAll(JsonNode paramsNode, Pageable pageable) {
protected Specification<CloudTyc> buildParameterSpecification(JsonNode paramsNode) {
Specification<CloudTyc> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
}
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
// 可以根据需要添加更多参数处理
return findAll(spec, pageable).map(CloudTyc::toVo);
return spec;
}
@Override
public Specification<CloudTyc> getSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
protected Specification<CloudTyc> buildSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.like(root.get("cloudId"), "%" + searchText + "%");
};
@@ -227,4 +221,5 @@ public class CloudTycService implements IEntityService<CloudTyc>, QueryService<C
}
cloudTyc.setVersion(vo.getVersion());
}
}

View File

@@ -1,6 +1,13 @@
package com.ecep.contract.cloud.u8;
import com.ecep.contract.ds.vendor.model.PurchaseOrder;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
@@ -11,13 +18,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import com.ecep.contract.ContractPayWay;
import javax.sql.DataSource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
import com.ecep.contract.ds.vendor.model.PurchaseOrder;
@Lazy
@Repository
@@ -36,7 +37,6 @@ public class YongYouU8Repository {
return jdbcTemplate;
}
/**
* 返回 U8 系统中 供应商总数
*
@@ -57,11 +57,9 @@ public class YongYouU8Repository {
"cVCCode,cVenAddress,cast(dVenDevDate as DATE) as venDevDate," +
"cVenBank, cVenAccount, cCreatePerson,cModifyPerson,dModifyDate " +
"from Vendor",
new ColumnMapRowMapper()
);
new ColumnMapRowMapper());
}
/**
* 以 U8 供应商 的代码查询 供应商
*
@@ -102,8 +100,7 @@ public class YongYouU8Repository {
"cCCCode,cCusAddress,cast(dCusDevDate as DATE) as cusDevDate," +
"cCusBank,cCusAccount, cCreatePerson,cModifyPerson,dModifyDate " +
"from Customer",
new ColumnMapRowMapper()
);
new ColumnMapRowMapper());
}
/**
@@ -146,30 +143,27 @@ public class YongYouU8Repository {
return getJdbcTemplate().queryForObject(
"select count(*) " +
"from CM_Contract_B " +
"where strSetupDate>=? or (dtVaryDate is not null and dtVaryDate>=?)"
, Long.class, latestDate, latestDate);
"where strSetupDate>=? or (dtVaryDate is not null and dtVaryDate>=?)",
Long.class, latestDate, latestDate);
}
public Stream<Map<String, Object>> queryAllContractForStream() {
return getJdbcTemplate().queryForStream(
"select * from CM_List", new ColumnMapRowMapper()
);
"select * from CM_List", new ColumnMapRowMapper());
}
public Stream<Map<String, Object>> queryAllContractForStream(int latestId) {
return getJdbcTemplate().queryForStream(
"select * from CM_List where ID > ?",
new ColumnMapRowMapper(),
latestId
);
latestId);
}
public Stream<Map<String, Object>> queryAllContractForStream(LocalDateTime dateTime) {
return getJdbcTemplate().queryForStream(
"select * from CM_List where dtDate > ?",
new ColumnMapRowMapper(),
dateTime
);
dateTime);
}
public Stream<Map<String, Object>> queryAllContractBForStream() {
@@ -188,8 +182,7 @@ public class YongYouU8Repository {
"strPersonID, " +
"dblTotalCurrency,dblExecCurrency,dblTotalQuantity,dblExecQuqantity " +
"from CM_Contract_B ",
new ColumnMapRowMapper()
);
new ColumnMapRowMapper());
}
public Stream<Map<String, Object>> queryAllContractBForStream(LocalDate latestDate) {
@@ -208,8 +201,7 @@ public class YongYouU8Repository {
"strPersonID, " +
"dblTotalCurrency,dblExecCurrency,dblTotalQuantity,dblExecQuqantity " +
"from CM_Contract_B where strSetupDate>=? or (dtVaryDate is not null and dtVaryDate>=?)",
new ColumnMapRowMapper(), latestDate, latestDate
);
new ColumnMapRowMapper(), latestDate, latestDate);
}
/**
@@ -234,25 +226,26 @@ public class YongYouU8Repository {
"strPersonID, " +
"dblTotalCurrency,dblExecCurrency,dblTotalQuantity,dblExecQuqantity " +
"from CM_Contract_B where strBisectionUnit=? and strWay=?",
new ColumnMapRowMapper(), unit, payWay.getText()
);
new ColumnMapRowMapper(), unit, payWay.getText());
}
public Map<String, Object> queryContractDetail(String guid) {
return getJdbcTemplate().queryForObject("select GUID,strContractID,strContractName,strContractType,strParentID,strContractKind,strWay," +
"strContractGrp, strContractDesc,strBisectionUnit," +
// 时间
"strContractOrderDate,strContractStartDate,strContractEndDate," +
// 创建人和时间
"strSetupPerson,strSetupDate," +
// 生效人和时间
"strInurePerson,strInureDate," +
// 修改人和时间
"strVaryPerson,dtVaryDate," +
// 业务员
"strPersonID, " +
"dblTotalCurrency,dblExecCurrency,dblTotalQuantity,dblExecQuqantity " +
" from CM_Contract_B where GUID = ?", new ColumnMapRowMapper(), guid);
return getJdbcTemplate().queryForObject(
"select GUID,strContractID,strContractName,strContractType,strParentID,strContractKind,strWay," +
"strContractGrp, strContractDesc,strBisectionUnit," +
// 时间
"strContractOrderDate,strContractStartDate,strContractEndDate," +
// 创建人和时间
"strSetupPerson,strSetupDate," +
// 生效人和时间
"strInurePerson,strInureDate," +
// 修改人和时间
"strVaryPerson,dtVaryDate," +
// 业务员
"strPersonID, " +
"dblTotalCurrency,dblExecCurrency,dblTotalQuantity,dblExecQuqantity " +
" from CM_Contract_B where GUID = ?",
new ColumnMapRowMapper(), guid);
}
/**
@@ -262,9 +255,12 @@ public class YongYouU8Repository {
* @return Map<String, Object>
*/
public Map<String, Object> sumContractExec(String code) {
return getJdbcTemplate().queryForObject("select sum(decCount) as execQuantity, sum(decRateMoney) as execAmount, sum(decNoRateMoney) as execUnTaxAmount " +
"from CM_ExecInterface " +
"where cContractID = ?;", new ColumnMapRowMapper(), code);
return getJdbcTemplate().queryForObject(
"select sum(decCount) as execQuantity, sum(decRateMoney) as execAmount, sum(decNoRateMoney) as execUnTaxAmount "
+
"from CM_ExecInterface " +
"where cContractID = ?;",
new ColumnMapRowMapper(), code);
}
public List<Map<String, Object>> findAllContractExecByContractCode(String code) {
@@ -293,7 +289,6 @@ public class YongYouU8Repository {
" from PO_Pomain where POID = ?", new ColumnMapRowMapper(), code);
}
/**
* 采购合同项
*
@@ -321,7 +316,9 @@ public class YongYouU8Repository {
* @return Map<String, Object>
*/
public Map<String, Object> queryInventoryDetail(String code) {
return getJdbcTemplate().queryForObject("select I.*, U.cComUnitName from Inventory as I left join ComputationUnit as U on I.cComUnitCode=U.cComunitCode where cInvCode = ?", new ColumnMapRowMapper(), code);
return getJdbcTemplate().queryForObject(
"select I.*, U.cComUnitName from Inventory as I left join ComputationUnit as U on I.cComUnitCode=U.cComunitCode where cInvCode = ?",
new ColumnMapRowMapper(), code);
}
public List<Map<String, Object>> queryAllPerson() {
@@ -350,13 +347,13 @@ public class YongYouU8Repository {
return getJdbcTemplate().queryForList("select cCCCode, cCCName, iCCGrade from CustomerClass;");
}
public List<Map<String, Object>> findAllPurchaseBillVoucherByVendorCode(String code) {
return getJdbcTemplate().queryForList("select * from PurBillVouch where cVenCode=?", code);
}
public Map<String, Object> findPurchaseBillVoucherById(Integer pbvId) {
return getJdbcTemplate().queryForObject("select * from PurBillVouch where PBVID = ?", new ColumnMapRowMapper(), pbvId);
return getJdbcTemplate().queryForObject("select * from PurBillVouch where PBVID = ?", new ColumnMapRowMapper(),
pbvId);
}
public List<Map<String, Object>> findAllPurchaseBillVoucherItemByPbvId(int pbvId) {

View File

@@ -22,6 +22,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.SpringApp;
@@ -38,7 +39,7 @@ import com.fasterxml.jackson.databind.JsonNode;
@Lazy
@Service
@CacheConfig(cacheNames = "cloud-yu")
public class YongYouU8Service
public class YongYouU8Service extends EntityService<CloudYu, CloudYuVo, Integer>
implements IEntityService<CloudYu>, QueryService<CloudYuVo>, VoableService<CloudYu, CloudYuVo> {
private static final Logger logger = LoggerFactory.getLogger(YongYouU8Service.class);
@@ -61,6 +62,11 @@ public class YongYouU8Service
}
@Override
protected CloudYuRepository getRepository() {
return cloudYuRepository;
}
@Cacheable(key = "#id")
public CloudYuVo findById(Integer id) {
Optional<CloudYu> optional = cloudYuRepository.findById(id);
@@ -68,8 +74,8 @@ public class YongYouU8Service
}
@Override
public CloudYu getById(Integer id) {
return cloudYuRepository.findById(id).orElse(null);
public CloudYu createNewEntity() {
return new CloudYu();
}
/**
@@ -120,13 +126,13 @@ public class YongYouU8Service
* @param cloudYu Cloud Yu 对象
* @return 更新的 Cloud Yu
*/
@Caching(evict = {@CacheEvict(key = "#cloudYu.id")})
@Caching(evict = { @CacheEvict(key = "#cloudYu.id") })
@Override
public CloudYu save(CloudYu cloudYu) {
return cloudYuRepository.save(cloudYu);
}
@Caching(evict = {@CacheEvict(key = "#cloudYu.id")})
@Caching(evict = { @CacheEvict(key = "#cloudYu.id") })
@Override
public void delete(CloudYu vo) {
CloudYu entity = cloudYuRepository.findById(vo.getId()).orElse(null);
@@ -157,26 +163,15 @@ public class YongYouU8Service
cloudYuRepository.saveAll(list);
}
public Page<CloudYu> findAll(Specification<CloudYu> spec, Pageable pageable) {
return cloudYuRepository.findAll(spec, pageable);
}
@Override
public Page<CloudYuVo> findAll(JsonNode paramsNode, Pageable pageable) {
protected Specification<CloudYu> buildParameterSpecification(JsonNode paramsNode) {
Specification<CloudYu> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
String searchText = paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText();
spec = getSpecification(searchText);
}
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
return findAll(spec, pageable).map(CloudYu::toVo);
return spec;
}
@Override
public Specification<CloudYu> getSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
protected Specification<CloudYu> buildSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.like(root.get("cloudId"), "%" + searchText + "%");
};

View File

@@ -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;
@@ -17,14 +18,15 @@ 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.MessageHolder;
import com.ecep.contract.QueryService;
import com.ecep.contract.SpringApp;
import com.ecep.contract.ds.company.repository.CompanyBankAccountRepository;
import com.ecep.contract.ds.other.service.BankService;
import com.ecep.contract.ds.company.model.Company;
import com.ecep.contract.ds.company.model.CompanyBankAccount;
import com.ecep.contract.ds.company.repository.CompanyBankAccountRepository;
import com.ecep.contract.ds.other.service.BankService;
import com.ecep.contract.service.ServiceException;
import com.ecep.contract.service.VoableService;
import com.ecep.contract.util.SpecificationUtils;
@@ -34,13 +36,46 @@ import com.fasterxml.jackson.databind.JsonNode;
@Lazy
@Service
@CacheConfig(cacheNames = "company-bank-account")
public class CompanyBankAccountService implements IEntityService<CompanyBankAccount>, QueryService<CompanyBankAccountVo>,
public class CompanyBankAccountService
extends EntityService<CompanyBankAccount, CompanyBankAccountVo, Integer>
implements IEntityService<CompanyBankAccount>, QueryService<CompanyBankAccountVo>,
VoableService<CompanyBankAccount, CompanyBankAccountVo> {
private static final Logger logger = LoggerFactory.getLogger(CompanyBankAccountService.class);
@Lazy
@Autowired
private CompanyBankAccountRepository repository;
@Override
protected CompanyBankAccountRepository getRepository() {
return repository;
}
@Override
public CompanyBankAccount createNewEntity() {
return new CompanyBankAccount();
}
@Override
public Specification<CompanyBankAccount> buildParameterSpecification(JsonNode paramsNode) {
Specification<CompanyBankAccount> spec = null;
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
return spec;
}
@Override
public Specification<CompanyBankAccount> buildSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(
builder.and(
builder.isNotNull(root.get("bank")),
builder.or(
builder.like(root.get("bank").get("name"), "%" + searchText + "%"),
builder.like(root.get("bank").get("code"), "%" + searchText + "%"))),
builder.like(root.get("openingBank"), "%" + searchText + "%"),
builder.like(root.get("account"), "%" + searchText + "%"));
};
}
public CompanyBankAccount findByAccount(Company company, String account) {
return repository.findByCompanyAndAccount(company, account).orElse(null);
}
@@ -76,13 +111,16 @@ public class CompanyBankAccountService implements IEntityService<CompanyBankAcco
}
}
@CacheEvict(key = "#p0.id")
public CompanyBankAccount save(CompanyBankAccount account) {
return repository.save(account);
return super.save(account);
}
@CacheEvict(key = "#p0.id")
public void delete(CompanyBankAccount entity) {
super.delete(entity);
}
public List<CompanyBankAccount> findAll(Specification<CompanyBankAccount> spec, Sort sort) {
return repository.findAll(spec, sort);
}
@Cacheable(key = "#p0")
@Override
@@ -90,39 +128,9 @@ public class CompanyBankAccountService implements IEntityService<CompanyBankAcco
return repository.findById(id).map(CompanyBankAccount::toVo).orElse(null);
}
@Override
public CompanyBankAccount getById(Integer id) {
return repository.findById(id).orElse(null);
}
@Override
public Specification<CompanyBankAccount> getSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
return (root, query, builder) -> {
return builder.or(
builder.and(
builder.isNotNull(root.get("bank")),
builder.or(
builder.like(root.get("bank").get("name"), "%" + searchText + "%"),
builder.like(root.get("bank").get("code"), "%" + searchText + "%"))),
builder.like(root.get("openingBank"), "%" + searchText + "%"),
builder.like(root.get("account"), "%" + searchText + "%"));
};
}
@Override
public Page<CompanyBankAccount> findAll(Specification<CompanyBankAccount> spec, Pageable pageable) {
return repository.findAll(spec, pageable);
}
public void delete(CompanyBankAccount entity) {
repository.delete(entity);
}
public List<CompanyBankAccount> searchByCompany(Company company, String searchText) {
Specification<CompanyBankAccount> spec = getSpecification(searchText);
Specification<CompanyBankAccount> spec = getSearchSpecification(searchText);
if (company != null) {
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
return builder.equal(root.get("company"), company);
@@ -131,17 +139,6 @@ public class CompanyBankAccountService implements IEntityService<CompanyBankAcco
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
}
@Override
public Page<CompanyBankAccountVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyBankAccount> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
return findAll(spec, pageable).map(CompanyBankAccount::toVo);
}
@Override
public void updateByVo(CompanyBankAccount model, CompanyBankAccountVo vo) {
if (model == null) {
@@ -173,4 +170,5 @@ public class CompanyBankAccountService implements IEntityService<CompanyBankAcco
model.setCreated(vo.getCreated());
model.setActive(vo.isActive());
}
}

View File

@@ -43,7 +43,7 @@ public class CompanyBlackReasonService
}
@Override
public Specification<CompanyBlackReason> getSpecification(String searchText) {
public Specification<CompanyBlackReason> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -85,7 +85,7 @@ public class CompanyBlackReasonService
public Page<CompanyBlackReasonVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyBlackReason> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "company");

View File

@@ -95,7 +95,7 @@ public class CompanyContactService implements IEntityService<CompanyContact>, Qu
}
@Override
public Specification<CompanyContact> getSpecification(String searchText) {
public Specification<CompanyContact> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -117,7 +117,7 @@ public class CompanyContactService implements IEntityService<CompanyContact>, Qu
public List<CompanyContact> searchByCompany(Company company, String userText) {
Specification<CompanyContact> spec = SpecificationUtils.and((root, query, builder) -> {
return builder.equal(root.get("company"), company);
}, getSpecification(userText));
}, getSearchSpecification(userText));
return repository.findAll(spec);
}
@@ -133,7 +133,7 @@ public class CompanyContactService implements IEntityService<CompanyContact>, Qu
public Page<CompanyContactVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyContact> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "company");

View File

@@ -52,7 +52,7 @@ public class CompanyExtendInfoService implements IEntityService<CompanyExtendInf
return repository.findAll(spec, sort);
}
public Specification<CompanyExtendInfo> getSpecification(String searchText) {
public Specification<CompanyExtendInfo> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -72,7 +72,7 @@ public class CompanyExtendInfoService implements IEntityService<CompanyExtendInf
public Page<CompanyExtendInfoVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyExtendInfo> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "company");

View File

@@ -437,7 +437,7 @@ public class CompanyFileService
public Page<CompanyFileVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyFile> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
spec = SpecificationUtils.and(spec, buildParameterSpecification(paramsNode));
return findAll(spec, pageable).map(CompanyFile::toVo);
@@ -448,7 +448,7 @@ public class CompanyFileService
}
@Override
public Specification<CompanyFile> getSpecification(String searchText) {
public Specification<CompanyFile> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -54,7 +54,7 @@ public class CompanyFileTypeService
public Page<CompanyFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyFileTypeLocal> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
if (paramsNode.has("type")) {
@@ -79,7 +79,7 @@ public class CompanyFileTypeService
}
@Override
public Specification<CompanyFileTypeLocal> getSpecification(String searchText) {
public Specification<CompanyFileTypeLocal> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -64,7 +64,7 @@ public class CompanyInvoiceInfoService implements IEntityService<CompanyInvoiceI
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
}
public Specification<CompanyInvoiceInfo> getSpecification(String searchText) {
public Specification<CompanyInvoiceInfo> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -87,7 +87,7 @@ public class CompanyInvoiceInfoService implements IEntityService<CompanyInvoiceI
public Page<CompanyInvoiceInfoVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyInvoiceInfo> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "company");

View File

@@ -50,7 +50,7 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
}
@Override
public Specification<CompanyOldName> getSpecification(String searchText) {
public Specification<CompanyOldName> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -201,7 +201,7 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
* @return 包含匹配的公司旧名称的列表列表中的每个元素都是一个CompanyOldName对象。
*/
public List<CompanyOldName> search(String searchText) {
return companyOldNameRepository.findAll(getSpecification(searchText), Pageable.ofSize(10)).getContent();
return companyOldNameRepository.findAll(getSearchSpecification(searchText), Pageable.ofSize(10)).getContent();
}
@Override
@@ -218,7 +218,7 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
public Page<CompanyOldNameVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyOldName> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
if (paramsNode.has("company")) {
JsonNode param = paramsNode.get("company");

View File

@@ -455,7 +455,7 @@ public class CompanyService extends EntityService<Company, CompanyVo, Integer>
}
@Override
public Specification<Company> getSpecification(String searchText) {
public Specification<Company> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -131,7 +131,7 @@ public class HolidayService implements IEntityService<HolidayTable>, QueryServic
}
@Override
public Specification<HolidayTable> getSpecification(String searchText) {
public Specification<HolidayTable> getSearchSpecification(String searchText) {
// 实现根据搜索文本构建规格化查询
return (Root<HolidayTable> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) -> {
List<Predicate> predicates = new ArrayList<>();

View File

@@ -49,7 +49,7 @@ public class InvoiceService implements IEntityService<Invoice>, QueryService<Inv
}
@Override
public Specification<Invoice> getSpecification(String searchText) {
public Specification<Invoice> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -91,7 +91,7 @@ public class InvoiceService implements IEntityService<Invoice>, QueryService<Inv
public Page<InvoiceVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<Invoice> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field

View File

@@ -48,7 +48,7 @@ public class ContractBalanceService implements IEntityService<ContractBalance>,
}
@Override
public Specification<ContractBalance> getSpecification(String searchText) {
public Specification<ContractBalance> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -86,7 +86,7 @@ public class ContractBalanceService implements IEntityService<ContractBalance>,
public Page<ContractBalanceVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ContractBalance> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// 字段等值查询 - 只包含ContractBalanceVo中存在的字段

View File

@@ -53,7 +53,7 @@ public class ContractBidVendorService implements IEntityService<ContractBidVendo
}
@Override
public Specification<ContractBidVendor> getSpecification(String searchText) {
public Specification<ContractBidVendor> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -111,7 +111,7 @@ public class ContractBidVendorService implements IEntityService<ContractBidVendo
public Page<ContractBidVendorVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ContractBidVendor> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "contract", "company");

View File

@@ -81,7 +81,7 @@ public class ContractCatalogService implements IEntityService<ContractCatalog>,
}
@Override
public Specification<ContractCatalog> getSpecification(String searchText) {
public Specification<ContractCatalog> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -102,7 +102,7 @@ public class ContractCatalogService implements IEntityService<ContractCatalog>,
public Page<ContractCatalogVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ContractCatalog> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
return findAll(spec, pageable).map(ContractCatalog::toVo);
}

View File

@@ -53,7 +53,7 @@ public class ContractFileService implements IEntityService<ContractFile>, QueryS
}
@Override
public Specification<ContractFile> getSpecification(String searchText) {
public Specification<ContractFile> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -73,7 +73,7 @@ public class ContractFileService implements IEntityService<ContractFile>, QueryS
public Page<ContractFileVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ContractFile> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field

View File

@@ -42,7 +42,7 @@ public class ContractFileTypeService
public Page<ContractFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ContractFileTypeLocal> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
if (paramsNode.has("type")) {
@@ -79,7 +79,7 @@ public class ContractFileTypeService
}
@Override
public Specification<ContractFileTypeLocal> getSpecification(String searchText) {
public Specification<ContractFileTypeLocal> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -58,13 +58,13 @@ public class ContractGroupService implements IEntityService<ContractGroup>, Quer
public Page<ContractGroupVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ContractGroup> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
return findAll(spec, pageable).map(ContractGroup::toVo);
}
@Override
public Specification<ContractGroup> getSpecification(String searchText) {
public Specification<ContractGroup> getSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(
builder.like(root.get("code"), "%" + searchText + "%"),

View File

@@ -161,7 +161,7 @@ public class ContractInvoiceService implements IEntityService<ContractInvoice>,
if (paramsNode.has("searchText")) {
String searchText = paramsNode.get("searchText").asText();
if (searchText != null && !searchText.isEmpty()) {
spec = SpecificationUtils.and(spec, getSpecification(searchText));
spec = SpecificationUtils.and(spec, getSearchSpecification(searchText));
}
}
@@ -179,7 +179,7 @@ public class ContractInvoiceService implements IEntityService<ContractInvoice>,
}
@Override
public Specification<ContractInvoice> getSpecification(String searchText) {
public Specification<ContractInvoice> getSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(
builder.like(root.get("name"), "%" + searchText + "%"),

View File

@@ -67,7 +67,7 @@ public class ContractItemService implements IEntityService<ContractItem>, QueryS
}
@Override
public Specification<ContractItem> getSpecification(String searchText) {
public Specification<ContractItem> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -96,7 +96,7 @@ public class ContractItemService implements IEntityService<ContractItem>, QueryS
public Page<ContractItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ContractItem> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "contract", "inventory", "creator", "updater");

View File

@@ -56,13 +56,13 @@ public class ContractKindService implements IEntityService<ContractKind>, QueryS
public Page<ContractKindVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ContractKind> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
return findAll(spec, pageable).map(ContractKind::toVo);
}
@Override
public Specification<ContractKind> getSpecification(String searchText) {
public Specification<ContractKind> getSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(
builder.like(root.get("code"), "%" + searchText + "%"),

View File

@@ -50,7 +50,7 @@ public class ContractPayPlanService implements IEntityService<ContractPayPlan>,
}
@Override
public Specification<ContractPayPlan> getSpecification(String searchText) {
public Specification<ContractPayPlan> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -68,7 +68,7 @@ public class ContractPayPlanService implements IEntityService<ContractPayPlan>,
public Page<ContractPayPlanVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ContractPayPlan> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "contract");

View File

@@ -56,7 +56,7 @@ public class ContractTypeService implements IEntityService<ContractType>, QueryS
public Page<ContractTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ContractType> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
return findAll(spec, pageable).map(ContractType::toVo);
}
@@ -76,7 +76,7 @@ public class ContractTypeService implements IEntityService<ContractType>, QueryS
}
@Override
public Specification<ContractType> getSpecification(String searchText) {
public Specification<ContractType> getSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(
builder.like(root.get("code"), "%" + searchText + "%"),

View File

@@ -87,7 +87,7 @@ public class ExtendVendorInfoService implements IEntityService<ExtendVendorInfo>
}
@Override
public Specification<ExtendVendorInfo> getSpecification(String searchText) {
public Specification<ExtendVendorInfo> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -103,7 +103,7 @@ public class ExtendVendorInfoService implements IEntityService<ExtendVendorInfo>
public Page<ExtendVendorInfoVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ExtendVendorInfo> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "contract");

View File

@@ -46,7 +46,7 @@ public class PurchaseBillVoucherItemService
}
@Override
public Specification<PurchaseBillVoucherItem> getSpecification(String searchText) {
public Specification<PurchaseBillVoucherItem> getSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(
builder.like(root.get("description"), "%" + searchText + "%"));
@@ -62,7 +62,7 @@ public class PurchaseBillVoucherItemService
public Page<PurchaseBillVoucherItem> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<PurchaseBillVoucherItem> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
spec = SpecificationUtils.andParam(spec, paramsNode, "voucher");

View File

@@ -60,7 +60,7 @@ public class PurchaseBillVoucherService
}
@Override
public Specification<PurchaseBillVoucher> getSpecification(String searchText) {
public Specification<PurchaseBillVoucher> getSearchSpecification(String searchText) {
// if null
if (!StringUtils.hasText(searchText)) {
return null;
@@ -129,7 +129,7 @@ public class PurchaseBillVoucherService
public Page<PurchaseBillVoucherVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<PurchaseBillVoucher> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "company", "inventory");
@@ -152,7 +152,7 @@ public class PurchaseBillVoucherService
}
public List<PurchaseBillVoucher> search(String searchText) {
return repository.findAll(getSpecification(searchText), Pageable.ofSize(10)).getContent();
return repository.findAll(getSearchSpecification(searchText), Pageable.ofSize(10)).getContent();
}
@Override

View File

@@ -70,7 +70,7 @@ public class PurchaseOrderItemService implements IEntityService<PurchaseOrderIte
}
@Override
public Specification<PurchaseOrderItem> getSpecification(String searchText) {
public Specification<PurchaseOrderItem> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -88,7 +88,7 @@ public class PurchaseOrderItemService implements IEntityService<PurchaseOrderIte
public Page<PurchaseOrderItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<PurchaseOrderItem> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "order", "inventory", "contractItem");

View File

@@ -60,7 +60,7 @@ public class PurchaseOrdersService implements IEntityService<PurchaseOrder>, Que
}
@Override
public Specification<PurchaseOrder> getSpecification(String searchText) {
public Specification<PurchaseOrder> getSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(
builder.like(root.get("code"), "%" + searchText + "%"),
@@ -125,7 +125,7 @@ public class PurchaseOrdersService implements IEntityService<PurchaseOrder>, Que
public Page<PurchaseOrderVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<PurchaseOrder> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
spec = SpecificationUtils.andParam(spec, paramsNode, "contract");
return findAll(spec, pageable).map(PurchaseOrder::toVo);

View File

@@ -44,7 +44,7 @@ public class SalesBillVoucherItemService
}
@Override
public Specification<SalesBillVoucherItem> getSpecification(String searchText) {
public Specification<SalesBillVoucherItem> getSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(
builder.like(root.get("description"), "%" + searchText + "%"));
@@ -64,7 +64,7 @@ public class SalesBillVoucherItemService
public Page<SalesBillVoucherItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<SalesBillVoucherItem> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
return findAll(spec, pageable).map(SalesBillVoucherItem::toVo);
}

View File

@@ -54,7 +54,7 @@ public class CompanyCustomerEntityService implements IEntityService<CompanyCusto
}
@Override
public Specification<CompanyCustomerEntity> getSpecification(String searchText) {
public Specification<CompanyCustomerEntity> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -71,7 +71,7 @@ public class CompanyCustomerEntityService implements IEntityService<CompanyCusto
}
public List<CompanyCustomerEntity> search(String searchText) {
Specification<CompanyCustomerEntity> spec = getSpecification(searchText);
Specification<CompanyCustomerEntity> spec = getSearchSpecification(searchText);
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
}
@@ -84,7 +84,7 @@ public class CompanyCustomerEntityService implements IEntityService<CompanyCusto
public Page<CompanyCustomerEntityVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyCustomerEntity> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "customer");

View File

@@ -53,7 +53,7 @@ public class CompanyCustomerEvaluationFormFileService
}
@Override
public Specification<CompanyCustomerEvaluationFormFile> getSpecification(String searchText) {
public Specification<CompanyCustomerEvaluationFormFile> getSearchSpecification(String searchText) {
if (!org.springframework.util.StringUtils.hasText(searchText)) {
return null;
}
@@ -95,7 +95,7 @@ public class CompanyCustomerEvaluationFormFileService
public Page<CompanyCustomerEvaluationFormFile> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyCustomerEvaluationFormFile> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
if (paramsNode.has("customer")) {

View File

@@ -72,7 +72,7 @@ public class CompanyCustomerFileService
}
@Override
public Specification<CompanyCustomerFile> getSpecification(String searchText) {
public Specification<CompanyCustomerFile> getSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(builder.like(root.get("filePath"), "%" + searchText + "%"));
};
@@ -108,7 +108,7 @@ public class CompanyCustomerFileService
public Page<CompanyCustomerFile> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyCustomerFile> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "customer");

View File

@@ -50,7 +50,7 @@ public class CompanyCustomerFileTypeService implements IEntityService<CompanyCus
public Page<CompanyCustomerFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyCustomerFileTypeLocal> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
if (paramsNode.has("type")) {
@@ -75,7 +75,7 @@ public class CompanyCustomerFileTypeService implements IEntityService<CompanyCus
}
@Override
public Specification<CompanyCustomerFileTypeLocal> getSpecification(String searchText) {
public Specification<CompanyCustomerFileTypeLocal> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -115,7 +115,7 @@ public class CustomerCatalogService implements IEntityService<CustomerCatalog>,
public Page<CustomerCatalogVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CustomerCatalog> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// 字段等值查询
@@ -126,7 +126,7 @@ public class CustomerCatalogService implements IEntityService<CustomerCatalog>,
/**
* 根据搜索文本创建查询条件
*/
public Specification<CustomerCatalog> getSpecification(String searchText) {
public Specification<CustomerCatalog> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -143,7 +143,7 @@ public class CustomerCatalogService implements IEntityService<CustomerCatalog>,
* 搜索 CustomerCatalog
*/
public List<CustomerCatalog> search(String searchText) {
return repository.findAll(getSpecification(searchText), Pageable.ofSize(10)).getContent();
return repository.findAll(getSearchSpecification(searchText), Pageable.ofSize(10)).getContent();
}
@Override

View File

@@ -41,7 +41,7 @@ public class CustomerFileTypeService implements IEntityService<CustomerFileTypeL
public Page<CustomerFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CustomerFileTypeLocal> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
if (paramsNode.has("type")) {
@@ -78,7 +78,7 @@ public class CustomerFileTypeService implements IEntityService<CustomerFileTypeL
}
@Override
public Specification<CustomerFileTypeLocal> getSpecification(String searchText) {
public Specification<CustomerFileTypeLocal> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -112,7 +112,7 @@ public class CustomerService extends CompanyBasicService
}
@Override
public Specification<CompanyCustomer> getSpecification(String searchText) {
public Specification<CompanyCustomer> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -148,7 +148,7 @@ public class CustomerService extends CompanyBasicService
@Override
public List<CompanyCustomer> search(String searchText) {
Specification<CompanyCustomer> spec = getSpecification(searchText);
Specification<CompanyCustomer> spec = getSearchSpecification(searchText);
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
}
@@ -343,7 +343,7 @@ public class CustomerService extends CompanyBasicService
public Page<CustomerVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyCustomer> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "company");

View File

@@ -43,7 +43,7 @@ public class EmployeeRoleController {
String searchText = (String) params.get("searchText");
if (StringUtils.hasText(searchText)) {
spec = SpecificationUtils.and(spec, employeeRoleService.getSpecification(searchText));
spec = SpecificationUtils.and(spec, employeeRoleService.getSearchSpecification(searchText));
}
Sort sort = Sort.by(Sort.Order.desc("id"));

View File

@@ -48,7 +48,7 @@ public class BankService implements IEntityService<Bank>, QueryService<BankVo>,
public Page<BankVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<Bank> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// 可以根据需要添加更多参数处理
return findAll(spec, pageable).map(Bank::toVo);
@@ -62,7 +62,7 @@ public class BankService implements IEntityService<Bank>, QueryService<BankVo>,
}
@Override
public Specification<Bank> getSpecification(String searchText) {
public Specification<Bank> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -74,7 +74,7 @@ public class BankService implements IEntityService<Bank>, QueryService<BankVo>,
}
public List<Bank> search(String searchText) {
Specification<Bank> spec = getSpecification(searchText);
Specification<Bank> spec = getSearchSpecification(searchText);
return bankRepository.findAll(spec, Pageable.ofSize(10)).getContent();
}

View File

@@ -59,14 +59,14 @@ public class DepartmentService implements IEntityService<Department>, QueryServi
public Page<DepartmentVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<Department> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// 可以根据需要添加更多参数处理
return findAll(spec, pageable).map(Department::toVo);
}
@Override
public Specification<Department> getSpecification(String searchText) {
public Specification<Department> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -79,7 +79,7 @@ public class DepartmentService implements IEntityService<Department>, QueryServi
}
public List<Department> search(String searchText) {
Specification<Department> spec = getSpecification(searchText);
Specification<Department> spec = getSearchSpecification(searchText);
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
}

View File

@@ -44,7 +44,7 @@ public class EmployeeAuthBindService implements IEntityService<EmployeeAuthBind>
}
@Override
public Specification<EmployeeAuthBind> getSpecification(String searchText) {
public Specification<EmployeeAuthBind> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -65,7 +65,7 @@ public class EmployeeAuthBindService implements IEntityService<EmployeeAuthBind>
public Page<EmployeeAuthBindVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<EmployeeAuthBind> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// 可以根据需要添加更多参数处理
spec = SpecificationUtils.andParam(spec, paramsNode, "employee");

View File

@@ -42,7 +42,7 @@ public class EmployeeLoginHistoryService
}
@Override
public Specification<EmployeeLoginHistory> getSpecification(String searchText) {
public Specification<EmployeeLoginHistory> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -62,7 +62,7 @@ public class EmployeeLoginHistoryService
public Page<EmployeeLoginHistoryVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<EmployeeLoginHistory> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// 可以根据需要添加更多参数处理
spec = SpecificationUtils.andParam(spec, paramsNode, "employee");

View File

@@ -51,7 +51,7 @@ public class EmployeeRoleService implements IEntityService<EmployeeRole>, QueryS
}
@Override
public Specification<EmployeeRole> getSpecification(String searchText) {
public Specification<EmployeeRole> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -92,7 +92,7 @@ public class EmployeeRoleService implements IEntityService<EmployeeRole>, QueryS
public Page<EmployeeRoleVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<EmployeeRole> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// 可以根据需要添加更多参数处理
return findAll(spec, pageable).map(EmployeeRole::toVo);

View File

@@ -126,7 +126,7 @@ public class EmployeeService
public Page<EmployeeVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<Employee> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// 可以根据需要添加更多参数处理
spec = SpecificationUtils.andParam(spec, paramsNode, "department");
@@ -135,7 +135,7 @@ public class EmployeeService
}
@Override
public Specification<Employee> getSpecification(String searchText) {
public Specification<Employee> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -162,7 +162,7 @@ public class EmployeeService
*/
public List<Employee> search(String searchText) {
// 创建一个Specification对象用于定义复杂的查询条件
Specification<Employee> spec = getSpecification(searchText);
Specification<Employee> spec = getSearchSpecification(searchText);
return employeeRepository.findAll(spec, Pageable.ofSize(10)).getContent();
}

View File

@@ -62,14 +62,14 @@ public class FunctionService implements IEntityService<Function>, QueryService<F
public Page<FunctionVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<Function> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// 可以根据需要添加更多参数处理
return findAll(spec, pageable).map(Function::toVo);
}
@Override
public Specification<Function> getSpecification(String searchText) {
public Specification<Function> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -60,14 +60,14 @@ public class InventoryCatalogService implements IEntityService<InventoryCatalog>
public Page<InventoryCatalogVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<InventoryCatalog> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// 可以根据需要添加更多参数处理
return findAll(spec, pageable).map(InventoryCatalog::toVo);
}
@Override
public Specification<InventoryCatalog> getSpecification(String searchText) {
public Specification<InventoryCatalog> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -47,7 +47,7 @@ public class InventoryHistoryPriceService
}
@Override
public Specification<InventoryHistoryPrice> getSpecification(String searchText) {
public Specification<InventoryHistoryPrice> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -68,7 +68,7 @@ public class InventoryHistoryPriceService
public Page<InventoryHistoryPriceVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<InventoryHistoryPrice> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// 可以根据需要添加更多参数处理
return findAll(spec, pageable).map(InventoryHistoryPrice::toVo);

View File

@@ -63,14 +63,14 @@ public class InventoryService
public Page<InventoryVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<Inventory> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// 可以根据需要添加更多参数处理
return findAll(spec, pageable).map(Inventory::toVo);
}
@Override
public Specification<Inventory> getSpecification(String searchText) {
public Specification<Inventory> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -96,7 +96,7 @@ public class InventoryService
public List<Inventory> search(String searchText) {
Pageable pageable = Pageable.ofSize(getSearchPageSize());
pageable.getSort().and(Sort.by(Sort.Direction.DESC, "id"));
Specification<Inventory> specification = getSpecification(searchText);
Specification<Inventory> specification = getSearchSpecification(searchText);
return inventoryRepository.findAll(specification, pageable).getContent();
}

View File

@@ -47,7 +47,7 @@ public class PermissionService
}
@Override
public Specification<Permission> getSpecification(String searchText) {
public Specification<Permission> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -80,7 +80,7 @@ public class PermissionService
public Page<PermissionVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<Permission> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// 可以根据需要添加更多参数处理
return findAll(spec, pageable).map(Permission::toVo);

View File

@@ -61,7 +61,7 @@ public class CustomerSatisfactionSurveyService
}
@Override
public Specification<CustomerSatisfactionSurvey> getSpecification(String searchText) {
public Specification<CustomerSatisfactionSurvey> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -117,7 +117,7 @@ public class CustomerSatisfactionSurveyService
public Page<CustomerSatisfactionSurveyVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CustomerSatisfactionSurvey> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
if (paramsNode.has("project.customer")) {

View File

@@ -61,7 +61,7 @@ public class DeliverySignMethodService
public Page<DeliverySignMethodVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<DeliverySignMethod> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "saleType");
@@ -117,7 +117,7 @@ public class DeliverySignMethodService
}
@Override
public Specification<DeliverySignMethod> getSpecification(String searchText) {
public Specification<DeliverySignMethod> getSearchSpecification(String searchText) {
return null;
}

View File

@@ -66,7 +66,7 @@ public class ProductTypeService implements IEntityService<ProductType>, QuerySer
public Page<ProductTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ProductType> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
// spec = SpecificationUtils.andParam(spec, paramsNode, "company");
@@ -74,7 +74,7 @@ public class ProductTypeService implements IEntityService<ProductType>, QuerySer
}
@Override
public Specification<ProductType> getSpecification(String searchText) {
public Specification<ProductType> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -78,7 +78,7 @@ public class ProductUsageService implements IEntityService<ProductUsage>, QueryS
public Page<ProductUsageVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ProductUsage> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
// spec = SpecificationUtils.andParam(spec, paramsNode, "company");
@@ -87,7 +87,7 @@ public class ProductUsageService implements IEntityService<ProductUsage>, QueryS
}
@Override
public Specification<ProductUsage> getSpecification(String searchText) {
public Specification<ProductUsage> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -61,7 +61,7 @@ public class ProjectBidService implements IEntityService<ProjectBid>, QueryServi
public Page<ProjectBidVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ProjectBid> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// field
@@ -78,7 +78,7 @@ public class ProjectBidService implements IEntityService<ProjectBid>, QueryServi
}
@Override
public Specification<ProjectBid> getSpecification(String searchText) {
public Specification<ProjectBid> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -60,7 +60,7 @@ public class ProjectCostItemService implements IEntityService<ProjectCostItem>,
public Page<ProjectCostItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ProjectCostItem> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// field
@@ -71,7 +71,7 @@ public class ProjectCostItemService implements IEntityService<ProjectCostItem>,
}
@Override
public Specification<ProjectCostItem> getSpecification(String searchText) {
public Specification<ProjectCostItem> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -62,7 +62,7 @@ public class ProjectCostService implements IEntityService<ProjectCost>, QuerySer
public Page<ProjectCostVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ProjectCost> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// field
@@ -79,7 +79,7 @@ public class ProjectCostService implements IEntityService<ProjectCost>, QuerySer
}
@Override
public Specification<ProjectCost> getSpecification(String searchText) {
public Specification<ProjectCost> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -69,7 +69,7 @@ public class ProjectFileService implements IEntityService<ProjectFile>, QuerySer
}
@Override
public Specification<ProjectFile> getSpecification(String searchText) {
public Specification<ProjectFile> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -80,7 +80,7 @@ public class ProjectFileService implements IEntityService<ProjectFile>, QuerySer
@Override
public List<ProjectFile> search(String searchText) {
Specification<ProjectFile> spec = getSpecification(searchText);
Specification<ProjectFile> spec = getSearchSpecification(searchText);
return repository.findAll(spec);
}

View File

@@ -42,7 +42,7 @@ public class ProjectFileTypeService
public Page<ProjectFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ProjectFileTypeLocal> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
if (paramsNode.has("type")) {
@@ -78,7 +78,7 @@ public class ProjectFileTypeService
}
@Override
public Specification<ProjectFileTypeLocal> getSpecification(String searchText) {
public Specification<ProjectFileTypeLocal> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -61,7 +61,7 @@ public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>,
public Page<ProjectFundPlanVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ProjectFundPlan> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "project");
@@ -70,7 +70,7 @@ public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>,
}
@Override
public Specification<ProjectFundPlan> getSpecification(String searchText) {
public Specification<ProjectFundPlan> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -80,7 +80,7 @@ public class ProjectIndustryService implements IEntityService<ProjectIndustry>,
public Page<ProjectIndustryVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ProjectIndustry> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// field
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code", "name");
@@ -89,7 +89,7 @@ public class ProjectIndustryService implements IEntityService<ProjectIndustry>,
}
@Override
public Specification<ProjectIndustry> getSpecification(String searchText) {
public Specification<ProjectIndustry> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -61,7 +61,7 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
public Page<ProjectQuotationVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ProjectQuotation> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "project", "applicant", "authorizer");
@@ -83,7 +83,7 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
}
@Override
public Specification<ProjectQuotation> getSpecification(String searchText) {
public Specification<ProjectQuotation> getSearchSpecification(String searchText) {
return null;
}

View File

@@ -73,7 +73,7 @@ public class ProjectSaleTypeRequireFileTypeService
public Page<ProjectSaleTypeRequireFileTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ProjectSaleTypeRequireFileType> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "saleType");
@@ -81,7 +81,7 @@ public class ProjectSaleTypeRequireFileTypeService
}
@Override
public Specification<ProjectSaleTypeRequireFileType> getSpecification(String searchText) {
public Specification<ProjectSaleTypeRequireFileType> getSearchSpecification(String searchText) {
return null;
}

View File

@@ -72,7 +72,7 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
public Page<ProjectSaleTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ProjectSaleType> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "active");
@@ -80,7 +80,7 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
}
@Override
public Specification<ProjectSaleType> getSpecification(String searchText) {
public Specification<ProjectSaleType> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -8,9 +8,6 @@ import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.ecep.contract.MessageHolder;
import com.ecep.contract.ds.company.model.Company;
import com.ecep.contract.vo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -24,20 +21,31 @@ 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.MessageHolder;
import com.ecep.contract.QueryService;
import com.ecep.contract.SpringApp;
import com.ecep.contract.constant.ProjectConstant;
import com.ecep.contract.ds.MyRepository;
import com.ecep.contract.ds.company.model.Company;
import com.ecep.contract.ds.company.service.CompanyService;
import com.ecep.contract.ds.contract.model.Contract;
import com.ecep.contract.ds.other.service.EmployeeService;
import com.ecep.contract.ds.other.service.SysConfService;
import com.ecep.contract.ds.project.model.Project;
import com.ecep.contract.ds.project.repository.ProductDeliverySignMethodRepository;
import com.ecep.contract.ds.project.repository.ProjectRepository;
import com.ecep.contract.ds.contract.model.Contract;
import com.ecep.contract.ds.project.model.Project;
import com.ecep.contract.model.ProjectSaleType;
import com.ecep.contract.service.VoableService;
import com.ecep.contract.util.SpecificationUtils;
import com.ecep.contract.vo.DeliverySignMethodVo;
import com.ecep.contract.vo.ProductTypeVo;
import com.ecep.contract.vo.ProductUsageVo;
import com.ecep.contract.vo.ProjectIndustryVo;
import com.ecep.contract.vo.ProjectSaleTypeVo;
import com.ecep.contract.vo.ProjectTypeVo;
import com.ecep.contract.vo.ProjectVo;
import com.fasterxml.jackson.databind.JsonNode;
/**
@@ -46,7 +54,7 @@ import com.fasterxml.jackson.databind.JsonNode;
@Lazy
@Service
@CacheConfig(cacheNames = "project")
public class ProjectService
public class ProjectService extends EntityService<Project, ProjectVo, Integer>
implements IEntityService<Project>, QueryService<ProjectVo>, VoableService<Project, ProjectVo> {
private final ProductDeliverySignMethodRepository productDeliverySignMethodRepository;
@@ -84,6 +92,18 @@ public class ProjectService
this.productDeliverySignMethodRepository = productDeliverySignMethodRepository;
}
@Override
protected ProjectRepository getRepository() {
return projectRepository;
}
@Override
public Project createNewEntity() {
Project project = new Project();
project.setCodeYear(LocalDate.now().getYear());
return project;
}
public Project getById(Integer id) {
return projectRepository.findById(id).orElse(null);
}
@@ -149,20 +169,15 @@ public class ProjectService
}
@Override
public Page<ProjectVo> findAll(JsonNode paramsNode, Pageable pageable) {
protected Specification<Project> buildParameterSpecification(JsonNode paramsNode) {
Specification<Project> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
}
// field
spec = SpecificationUtils.andParam(spec, paramsNode, "customer", "industry", "saleType", "projectType",
"productType", "deliverySignMethod", "productUsage");
spec = SpecificationUtils.andParam(spec, paramsNode, "applicant", "authorizer");
//
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code");
return findAll(spec, pageable).map(Project::toVo);
return spec;
}
@CacheEvict(key = "#p0.id")
@@ -180,14 +195,6 @@ public class ProjectService
return project.getCodeSequenceNumber() + 1;
}
@Override
public Specification<Project> getSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
return SpecificationUtils.andWith(searchText, this::buildSearchSpecification);
}
protected Specification<Project> buildSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(
@@ -198,7 +205,7 @@ public class ProjectService
}
public List<Project> search(String userText) {
Specification<Project> spec = getSpecification(userText);
Specification<Project> spec = getSearchSpecification(userText);
return projectRepository.findAll(spec, Pageable.ofSize(10)).getContent();
}

View File

@@ -79,7 +79,7 @@ public class ProjectTypeService
public Page<ProjectTypeVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<ProjectType> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// field
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "name", "code");
@@ -87,7 +87,7 @@ public class ProjectTypeService
}
@Override
public Specification<ProjectType> getSpecification(String searchText) {
public Specification<ProjectType> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -47,7 +47,7 @@ public class VendorApprovedFileService
public Page<VendorApprovedFileVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorApprovedFile> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
spec = SpecificationUtils.andParam(spec, paramsNode, "list");
return findAll(spec, pageable).map(VendorApprovedFile::toVo);
@@ -72,7 +72,7 @@ public class VendorApprovedFileService
* @return 构建的查询规格
*/
@Override
public Specification<VendorApprovedFile> getSpecification(String searchText) {
public Specification<VendorApprovedFile> getSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(
builder.like(root.get("fileName"), "%" + searchText + "%"),

View File

@@ -59,7 +59,7 @@ public class VendorApprovedItemService
}
@Override
public Specification<VendorApprovedItem> getSpecification(String searchText) {
public Specification<VendorApprovedItem> getSearchSpecification(String searchText) {
return (root, query, builder) -> {
Path<Vendor> vendor = root.get("vendor");
Path<Company> company = vendor.get("company");
@@ -104,7 +104,7 @@ public class VendorApprovedItemService
public Page<VendorApprovedItemVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorApprovedItem> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// 添加额外的参数过滤
if (paramsNode.has("type")) {

View File

@@ -80,7 +80,7 @@ public class VendorApprovedService implements IEntityService<VendorApproved>, Qu
public Page<VendorApprovedVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorApproved> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// 添加额外的参数过滤
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "title");
@@ -88,7 +88,7 @@ public class VendorApprovedService implements IEntityService<VendorApproved>, Qu
}
@Override
public Specification<VendorApproved> getSpecification(String searchText) {
public Specification<VendorApproved> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -40,7 +40,7 @@ public class VendorCatalogService implements IEntityService<VendorCatalog>, Quer
public Page<VendorCatalogVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorCatalog> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// field
@@ -65,7 +65,7 @@ public class VendorCatalogService implements IEntityService<VendorCatalog>, Quer
}
@Override
public Specification<VendorCatalog> getSpecification(String searchText) {
public Specification<VendorCatalog> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -58,7 +58,7 @@ public class VendorEntityService implements IEntityService<VendorEntity>, QueryS
}
@Override
public Specification<VendorEntity> getSpecification(String searchText) {
public Specification<VendorEntity> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -76,7 +76,7 @@ public class VendorEntityService implements IEntityService<VendorEntity>, QueryS
@Override
public List<VendorEntity> search(String searchText) {
Specification<VendorEntity> spec = getSpecification(searchText);
Specification<VendorEntity> spec = getSearchSpecification(searchText);
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
}
@@ -89,7 +89,7 @@ public class VendorEntityService implements IEntityService<VendorEntity>, QueryS
public Page<VendorEntityVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorEntity> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// 添加额外的参数过滤s
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor");

View File

@@ -69,7 +69,7 @@ public class VendorFileService
}
@Override
public Specification<VendorFile> getSpecification(String searchText) {
public Specification<VendorFile> getSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(builder.like(root.get("filePath"), "%" + searchText + "%"));
};
@@ -84,7 +84,7 @@ public class VendorFileService
public Page<VendorFile> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorFile> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// 添加额外的参数过滤
if (paramsNode.has("type")) {

View File

@@ -45,7 +45,7 @@ public class VendorFileTypeService implements IEntityService<VendorFileTypeLocal
public Page<VendorFileTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorFileTypeLocal> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
if (paramsNode.has("type")) {
@@ -82,7 +82,7 @@ public class VendorFileTypeService implements IEntityService<VendorFileTypeLocal
}
@Override
public Specification<VendorFileTypeLocal> getSpecification(String searchText) {
public Specification<VendorFileTypeLocal> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -54,7 +54,7 @@ public class VendorGroupRequireFileTypeService
public Page<VendorGroupRequireFileType> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorGroupRequireFileType> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
spec = SpecificationUtils.andParam(spec, paramsNode, "group");
// 添加额外的参数过滤
@@ -62,7 +62,7 @@ public class VendorGroupRequireFileTypeService
}
@Override
public Specification<VendorGroupRequireFileType> getSpecification(String searchText) {
public Specification<VendorGroupRequireFileType> getSearchSpecification(String searchText) {
return null;
}

View File

@@ -65,7 +65,7 @@ public class VendorGroupService
public Page<VendorGroupVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorGroup> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
spec = getSearchSpecification(paramsNode.get("searchText").asText());
}
// 添加额外的参数过滤
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "active", "name", "code");
@@ -73,7 +73,7 @@ public class VendorGroupService
}
@Override
public Specification<VendorGroup> getSpecification(String searchText) {
public Specification<VendorGroup> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -116,7 +116,7 @@ public class VendorService extends CompanyBasicService
public Page<VendorVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<Vendor> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
// 添加额外的参数过滤
if (paramsNode.has("type")) {
@@ -151,7 +151,7 @@ public class VendorService extends CompanyBasicService
}
@Override
public Specification<Vendor> getSpecification(String searchText) {
public Specification<Vendor> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -185,7 +185,7 @@ public class VendorService extends CompanyBasicService
@Override
public List<Vendor> search(String searchText) {
Specification<Vendor> spec = getSpecification(searchText);
Specification<Vendor> spec = getSearchSpecification(searchText);
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
}

View File

@@ -40,7 +40,7 @@ public class VendorTypeService implements IEntityService<VendorTypeLocal>, Query
public Page<VendorTypeLocalVo> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorTypeLocal> spec = null;
if (paramsNode.has(ParamConstant.KEY_SEARCH_TEXT)) {
spec = getSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
spec = getSearchSpecification(paramsNode.get(ParamConstant.KEY_SEARCH_TEXT).asText());
}
if (paramsNode.has("type")) {
@@ -75,7 +75,7 @@ public class VendorTypeService implements IEntityService<VendorTypeLocal>, Query
}
@Override
public Specification<VendorTypeLocal> getSpecification(String searchText) {
public Specification<VendorTypeLocal> getSearchSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}

View File

@@ -173,7 +173,7 @@ public abstract class BaseServiceTest<T extends Voable<VO>, VO> {
Page<T> page = new PageImpl<>(entityList);
// 使用默认的分页参数
Pageable pageable = PageRequest.of(0, 10);
Specification<T> spec = getEntityService().getSpecification(getSearchText());
Specification<T> spec = getEntityService().getSearchSpecification(getSearchText());
// 模拟findAll方法调用
when(getEntityService().findAll(spec, pageable)).thenReturn(page);

View File

@@ -377,7 +377,7 @@ class WebSocketServerCallbackManagerTest {
Page<MockModel> findAll(Specification<MockModel> spec, Pageable pageable);
@Override
Specification<MockModel> getSpecification(String searchText);
Specification<MockModel> getSearchSpecification(String searchText);
@Override
void delete(MockModel entity);
@@ -404,7 +404,7 @@ class WebSocketServerCallbackManagerTest {
}
@Override
public Specification<MockModel> getSpecification(String searchText) {
public Specification<MockModel> getSearchSpecification(String searchText) {
return null;
}