|
@@ -1,21 +1,31 @@
|
|
|
package com.izouma.wenlvju.service;
|
|
package com.izouma.wenlvju.service;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.izouma.wenlvju.domain.Organization;
|
|
import com.izouma.wenlvju.domain.Organization;
|
|
|
import com.izouma.wenlvju.domain.Rate;
|
|
import com.izouma.wenlvju.domain.Rate;
|
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
|
import com.izouma.wenlvju.exception.BusinessException;
|
|
import com.izouma.wenlvju.exception.BusinessException;
|
|
|
import com.izouma.wenlvju.repo.OrganizationRepo;
|
|
import com.izouma.wenlvju.repo.OrganizationRepo;
|
|
|
|
|
+import com.izouma.wenlvju.repo.RateAuditRepo;
|
|
|
|
|
+import com.izouma.wenlvju.repo.RateExpertAuditRepo;
|
|
|
|
|
+import com.izouma.wenlvju.repo.RateRepo;
|
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
import com.izouma.wenlvju.utils.JpaUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
@Service
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
public class OrganizationService {
|
|
public class OrganizationService {
|
|
|
|
|
|
|
|
- private OrganizationRepo organizationRepo;
|
|
|
|
|
|
|
+ private final OrganizationRepo organizationRepo;
|
|
|
|
|
+ private final RateRepo rateRepo;
|
|
|
|
|
+ private final RateAuditRepo rateAuditRepo;
|
|
|
|
|
+ private final RateExpertAuditRepo rateExpertAuditRepo;
|
|
|
|
|
|
|
|
public Page<Organization> all(PageQuery pageQuery) {
|
|
public Page<Organization> all(PageQuery pageQuery) {
|
|
|
return organizationRepo.findAll(JpaUtils.toSpecification(pageQuery, Organization.class), JpaUtils.toPageRequest(pageQuery));
|
|
return organizationRepo.findAll(JpaUtils.toSpecification(pageQuery, Organization.class), JpaUtils.toPageRequest(pageQuery));
|
|
@@ -41,4 +51,19 @@ public class OrganizationService {
|
|
|
organizationRepo.save(organization);
|
|
organizationRepo.save(organization);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public void del(Long id) {
|
|
|
|
|
+ List<Rate> rates = rateRepo.findAllByOrganizationId(id);
|
|
|
|
|
+ List<Long> rateIds = rates.stream().map(Rate::getId).collect(Collectors.toList());
|
|
|
|
|
+ if (CollUtil.isNotEmpty(rateIds)) {
|
|
|
|
|
+ // 评分审核记录
|
|
|
|
|
+ rateAuditRepo.softDeleteByRateIdIn(rateIds);
|
|
|
|
|
+ // 评分细则
|
|
|
|
|
+ rateExpertAuditRepo.softDeleteByRateIdIn(rateIds);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 评定申请
|
|
|
|
|
+ rateRepo.softDeleteByOrganizationId(id);
|
|
|
|
|
+ organizationRepo.softDelete(id);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|