|
@@ -3,13 +3,16 @@ package com.izouma.wenlvju.web;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import com.izouma.wenlvju.domain.GradingOrganization;
|
|
|
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.domain.User;
|
|
import com.izouma.wenlvju.domain.User;
|
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
import com.izouma.wenlvju.dto.PageQuery;
|
|
|
|
|
+import com.izouma.wenlvju.dto.RateDTO;
|
|
|
import com.izouma.wenlvju.dto.ReviewTime;
|
|
import com.izouma.wenlvju.dto.ReviewTime;
|
|
|
import com.izouma.wenlvju.enums.RateStatus;
|
|
import com.izouma.wenlvju.enums.RateStatus;
|
|
|
import com.izouma.wenlvju.exception.BusinessException;
|
|
import com.izouma.wenlvju.exception.BusinessException;
|
|
|
|
|
+import com.izouma.wenlvju.repo.GradingOrganizationRepo;
|
|
|
import com.izouma.wenlvju.repo.OrganizationRepo;
|
|
import com.izouma.wenlvju.repo.OrganizationRepo;
|
|
|
import com.izouma.wenlvju.repo.RateRepo;
|
|
import com.izouma.wenlvju.repo.RateRepo;
|
|
|
import com.izouma.wenlvju.repo.UserRepo;
|
|
import com.izouma.wenlvju.repo.UserRepo;
|
|
@@ -34,11 +37,12 @@ import java.util.stream.Collectors;
|
|
|
@RequestMapping("/rate")
|
|
@RequestMapping("/rate")
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
public class RateController extends BaseController {
|
|
public class RateController extends BaseController {
|
|
|
- private RateService rateService;
|
|
|
|
|
- private RateRepo rateRepo;
|
|
|
|
|
- private OrganizationRepo organizationRepo;
|
|
|
|
|
- private OrganizationService organizationService;
|
|
|
|
|
- private UserRepo userRepo;
|
|
|
|
|
|
|
+ private final RateService rateService;
|
|
|
|
|
+ private final RateRepo rateRepo;
|
|
|
|
|
+ private final OrganizationRepo organizationRepo;
|
|
|
|
|
+ private final OrganizationService organizationService;
|
|
|
|
|
+ private final UserRepo userRepo;
|
|
|
|
|
+ private final GradingOrganizationRepo gradingOrganizationRepo;
|
|
|
|
|
|
|
|
//@PreAuthorize("hasRole('ADMIN')")
|
|
//@PreAuthorize("hasRole('ADMIN')")
|
|
|
@PostMapping("/save")
|
|
@PostMapping("/save")
|
|
@@ -74,23 +78,18 @@ public class RateController extends BaseController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("/all2")
|
|
@PostMapping("/all2")
|
|
|
- public Page<Rate> all2(@RequestBody PageQuery pageQuery) {
|
|
|
|
|
|
|
+ public Page<RateDTO> all2(@RequestBody PageQuery pageQuery) {
|
|
|
pageQuery.setSort("createdAt,desc");
|
|
pageQuery.setSort("createdAt,desc");
|
|
|
Map<Long, Organization> organizationMap = organizationRepo.findAll()
|
|
Map<Long, Organization> organizationMap = organizationRepo.findAll()
|
|
|
.stream()
|
|
.stream()
|
|
|
.collect(Collectors.toMap(Organization::getId, organization -> organization));
|
|
.collect(Collectors.toMap(Organization::getId, organization -> organization));
|
|
|
|
|
+ Map<Long, String> gradeMap = gradingOrganizationRepo.findAll()
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .collect(Collectors.toMap(GradingOrganization::getId, GradingOrganization::getName));
|
|
|
|
|
+
|
|
|
return rateService.all(pageQuery).map(rate -> {
|
|
return rateService.all(pageQuery).map(rate -> {
|
|
|
Organization organization = organizationMap.get(rate.getOrganizationId());
|
|
Organization organization = organizationMap.get(rate.getOrganizationId());
|
|
|
- if (ObjectUtil.isNotEmpty(organization)) {
|
|
|
|
|
- rate.setOrganizer(organization.getName());
|
|
|
|
|
- String address = "南京市" + organization.getDistrict();
|
|
|
|
|
- if (StrUtil.isNotBlank(organization.getAddress())) {
|
|
|
|
|
- address += organization.getAddress();
|
|
|
|
|
- }
|
|
|
|
|
- rate.setAddress(address);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return rate;
|
|
|
|
|
|
|
+ return new RateDTO(rate, organization, gradeMap.get(organization.getGradingOrganizationId()));
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -119,7 +118,7 @@ public class RateController extends BaseController {
|
|
|
@GetMapping("/excel")
|
|
@GetMapping("/excel")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
|
|
public void excel(HttpServletResponse response, PageQuery pageQuery) throws IOException {
|
|
|
- List<Rate> data = all(pageQuery).getContent();
|
|
|
|
|
|
|
+ List<RateDTO> data = all2(pageQuery).getContent();
|
|
|
ExcelUtils.export(response, data);
|
|
ExcelUtils.export(response, data);
|
|
|
}
|
|
}
|
|
|
|
|
|