refactor(service): 实现VoableService接口以统一VO与实体映射逻辑
refactor(model): 重构实体类与VO类的字段映射关系 style: 调整代码格式与注释 fix: 修复部分字段映射错误
This commit is contained in:
@@ -28,6 +28,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.BlackReasonType;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.cloud.CloudInfo;
|
||||
import com.ecep.contract.ds.company.repository.CompanyBlackReasonRepository;
|
||||
import com.ecep.contract.ds.company.repository.CompanyOldNameRepository;
|
||||
@@ -36,9 +37,11 @@ import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.model.CloudRk;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyBlackReason;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.HttpJsonUtils;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
import com.ecep.contract.vo.CloudRkVo;
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
@@ -52,7 +55,7 @@ import lombok.Data;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "cloud-rk")
|
||||
public class CloudRkService implements IEntityService<CloudRk> {
|
||||
public class CloudRkService implements IEntityService<CloudRk>, VoableService<CloudRk, CloudRkVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CloudRkService.class);
|
||||
|
||||
public static final String KEY_PROXY = "cloud.rk.proxy";
|
||||
@@ -375,4 +378,68 @@ public class CloudRkService implements IEntityService<CloudRk> {
|
||||
}
|
||||
cloudRKRepository.saveAll(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(CloudRk cloudRk, CloudRkVo vo) {
|
||||
if (cloudRk == null || vo == null) {
|
||||
throw new IllegalArgumentException("CloudRk and CloudRkVo cannot be null");
|
||||
}
|
||||
|
||||
// 更新基本属性
|
||||
if (vo.getCloudId() != null) {
|
||||
cloudRk.setCloudId(vo.getCloudId());
|
||||
}
|
||||
|
||||
cloudRk.setAutoUpdate(vo.isAutoUpdate());
|
||||
cloudRk.setUpdateDays(vo.getUpdateDays());
|
||||
|
||||
if (vo.getCustomerGrade() != null) {
|
||||
cloudRk.setCustomerGrade(vo.getCustomerGrade());
|
||||
}
|
||||
if (vo.getCustomerScore() != null) {
|
||||
cloudRk.setCustomerScore(vo.getCustomerScore());
|
||||
}
|
||||
if (vo.getCustomerDescription() != null) {
|
||||
cloudRk.setCustomerDescription(vo.getCustomerDescription());
|
||||
}
|
||||
if (vo.getVendorGrade() != null) {
|
||||
cloudRk.setVendorGrade(vo.getVendorGrade());
|
||||
}
|
||||
if (vo.getVendorScore() != null) {
|
||||
cloudRk.setVendorScore(vo.getVendorScore());
|
||||
}
|
||||
if (vo.getVendorDescription() != null) {
|
||||
cloudRk.setVendorDescription(vo.getVendorDescription());
|
||||
}
|
||||
if (vo.getRank() != null) {
|
||||
cloudRk.setRank(vo.getRank());
|
||||
}
|
||||
if (vo.getRankDescription() != null) {
|
||||
cloudRk.setRankDescription(vo.getRankDescription());
|
||||
}
|
||||
if (vo.getCloudLatest() != null) {
|
||||
cloudRk.setCloudLatest(vo.getCloudLatest());
|
||||
}
|
||||
if (vo.getCloudBlackListUpdated() != null) {
|
||||
cloudRk.setCloudBlackListUpdated(vo.getCloudBlackListUpdated());
|
||||
}
|
||||
if (vo.getCloudEntUpdate() != null) {
|
||||
cloudRk.setCloudEntUpdate(vo.getCloudEntUpdate());
|
||||
}
|
||||
if (vo.getDescription() != null) {
|
||||
cloudRk.setDescription(vo.getDescription());
|
||||
}
|
||||
if (vo.getLatestUpdate() != null) {
|
||||
cloudRk.setLatestUpdate(vo.getLatestUpdate());
|
||||
}
|
||||
|
||||
// 更新关联的公司
|
||||
if (vo.getCompanyId() != null) {
|
||||
CompanyService companyService = SpringApp.getBean(CompanyService.class);
|
||||
Company company = companyService.findById(vo.getCompanyId());
|
||||
if (company != null) {
|
||||
cloudRk.setCompany(company);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,19 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.cloud.CloudInfo;
|
||||
import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.model.CloudTyc;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
import com.ecep.contract.vo.CloudTycVo;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class CloudTycService implements IEntityService<CloudTyc> {
|
||||
public class CloudTycService implements IEntityService<CloudTyc>, VoableService<CloudTyc, CloudTycVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CloudTycService.class);
|
||||
|
||||
/**
|
||||
@@ -121,7 +125,6 @@ public class CloudTycService implements IEntityService<CloudTyc> {
|
||||
cloudTycRepository.delete(entity);
|
||||
}
|
||||
|
||||
|
||||
public void deleteByCompany(Company company) {
|
||||
int deleted = cloudTycRepository.deleteAllByCompany(company);
|
||||
if (deleted > 0) {
|
||||
@@ -165,4 +168,34 @@ public class CloudTycService implements IEntityService<CloudTyc> {
|
||||
// TODO 从天眼查同步公司信息
|
||||
holder.warn("TODO 未实现");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(CloudTyc cloudTyc, CloudTycVo vo) {
|
||||
if (cloudTyc == null || vo == null) {
|
||||
throw new IllegalArgumentException("CloudTyc and CloudTycVo cannot be null");
|
||||
}
|
||||
|
||||
// 更新基本属性
|
||||
if (vo.getScore() != null) {
|
||||
cloudTyc.setScore(vo.getScore());
|
||||
}
|
||||
if (vo.getCloudLatest() != null) {
|
||||
cloudTyc.setCloudLatest(vo.getCloudLatest());
|
||||
}
|
||||
if (vo.getCloudId() != null) {
|
||||
cloudTyc.setCloudId(vo.getCloudId());
|
||||
}
|
||||
if (vo.getLatestUpdate() != null) {
|
||||
cloudTyc.setLatestUpdate(vo.getLatestUpdate());
|
||||
}
|
||||
|
||||
// 更新关联的公司
|
||||
if (vo.getCompanyId() != null) {
|
||||
CompanyService companyService = SpringApp.getBean(CompanyService.class);
|
||||
Company company = companyService.findById(vo.getCompanyId());
|
||||
if (company != null) {
|
||||
cloudTyc.setCompany(company);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,21 +17,22 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.cloud.CloudInfo;
|
||||
import com.ecep.contract.cloud.CloudInfoRepository;
|
||||
import com.ecep.contract.cloud.u8.ctx.AbstractYongYouU8Ctx;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorService;
|
||||
import com.ecep.contract.model.CloudYu;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.vo.CloudYuVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
// @ConditionalOnProperty(name = "cloud.u8.enabled", havingValue = "true")
|
||||
public class YongYouU8Service implements IEntityService<CloudYu>, QueryService<CloudYu> {
|
||||
// @ConditionalOnProperty(name = "cloud.u8.enabled", havingValue = "true")
|
||||
public class YongYouU8Service
|
||||
implements IEntityService<CloudYu>, QueryService<CloudYu>, VoableService<CloudYu, CloudYuVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(YongYouU8Service.class);
|
||||
|
||||
public static final String KEY_HOST_IP = "u8.db.server.ip";
|
||||
@@ -47,19 +48,7 @@ public class YongYouU8Service implements IEntityService<CloudYu>, QueryService<C
|
||||
private CloudInfoRepository cloudInfoRepository;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private VendorService vendorService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CloudYuRepository cloudYuRepository;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private EmployeeService employeeService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyCustomerService companyCustomerService;
|
||||
|
||||
public YongYouU8Service() {
|
||||
|
||||
@@ -210,4 +199,37 @@ public class YongYouU8Service implements IEntityService<CloudYu>, QueryService<C
|
||||
public Iterable<CloudInfo> findAllCloudYu() {
|
||||
return cloudInfoRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(CloudYu cloudYu, CloudYuVo vo) {
|
||||
if (cloudYu == null || vo == null) {
|
||||
throw new IllegalArgumentException("CloudYu and CloudYuVo cannot be null");
|
||||
}
|
||||
|
||||
// 更新基本属性
|
||||
if (vo.getLatestUpdate() != null) {
|
||||
cloudYu.setLatestUpdate(vo.getLatestUpdate());
|
||||
}
|
||||
if (vo.getExceptionMessage() != null) {
|
||||
cloudYu.setExceptionMessage(vo.getExceptionMessage());
|
||||
}
|
||||
if (vo.getVendorUpdateDate() != null) {
|
||||
cloudYu.setVendorUpdateDate(vo.getVendorUpdateDate());
|
||||
}
|
||||
if (vo.getCustomerUpdateDate() != null) {
|
||||
cloudYu.setCustomerUpdateDate(vo.getCustomerUpdateDate());
|
||||
}
|
||||
if (vo.getCloudLatest() != null) {
|
||||
cloudYu.setCloudLatest(vo.getCloudLatest());
|
||||
}
|
||||
|
||||
// 更新关联的公司
|
||||
if (vo.getCompanyId() != null) {
|
||||
CompanyService companyService = SpringApp.getBean(CompanyService.class);
|
||||
Company company = companyService.findById(vo.getCompanyId());
|
||||
if (company != null) {
|
||||
cloudYu.setCompany(company);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user