|
@@ -1,6 +1,7 @@
|
|
|
package com.citu.module.menduner.system.controller.admin.fair;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import com.citu.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
import com.citu.framework.common.pojo.CommonResult;
|
|
|
import com.citu.framework.common.pojo.PageParam;
|
|
@@ -8,12 +9,16 @@ import com.citu.framework.common.pojo.PageResult;
|
|
|
import com.citu.framework.common.util.object.BeanUtils;
|
|
|
import com.citu.framework.common.util.string.StrUtils;
|
|
|
import com.citu.framework.excel.core.util.ExcelUtils;
|
|
|
+import com.citu.module.menduner.system.controller.base.enterprise.vo.EnterpriseRespVO;
|
|
|
import com.citu.module.menduner.system.controller.base.fair.*;
|
|
|
import com.citu.module.menduner.system.controller.base.fair.white.FairWhiteDetailRespVO;
|
|
|
import com.citu.module.menduner.system.controller.base.fair.white.FairWhitePageReqVO;
|
|
|
import com.citu.module.menduner.system.controller.base.fair.white.FairWhiteReqVO;
|
|
|
+import com.citu.module.menduner.system.dal.dataobject.enterprise.EnterpriseDO;
|
|
|
import com.citu.module.menduner.system.dal.dataobject.fair.FairDO;
|
|
|
+import com.citu.module.menduner.system.dal.dataobject.fair.FairWhiteDO;
|
|
|
import com.citu.module.menduner.system.enums.MendunerStatusEnum;
|
|
|
+import com.citu.module.menduner.system.service.enterprise.EnterpriseService;
|
|
|
import com.citu.module.menduner.system.service.fair.FairService;
|
|
|
import com.citu.module.menduner.system.service.fair.FairWhiteService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
@@ -27,7 +32,10 @@ import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Optional;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.citu.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
import static com.citu.framework.common.pojo.CommonResult.success;
|
|
@@ -45,6 +53,9 @@ public class FairController {
|
|
|
@Resource
|
|
|
private FairWhiteService fairWhiteService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private EnterpriseService enterpriseService;
|
|
|
+
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建招聘会")
|
|
|
@PreAuthorize("@ss.hasPermission('menduner:system:job-fair:create')")
|
|
@@ -75,15 +86,57 @@ public class FairController {
|
|
|
@PreAuthorize("@ss.hasPermission('menduner:system:job-fair:query')")
|
|
|
public CommonResult<JobFairRespVO> getJobFair(@RequestParam("id") Long id) {
|
|
|
FairDO jobFair = fairService.getJobFair(id);
|
|
|
- return success(BeanUtils.toBean(jobFair, JobFairRespVO.class));
|
|
|
+ JobFairRespVO resp =
|
|
|
+ BeanUtils.toBean(jobFair, JobFairRespVO.class);
|
|
|
+ setTagSort(resp);
|
|
|
+ return success(resp);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setTagSort(JobFairRespVO resp) {
|
|
|
+ if (resp == null || !JobFairCategoryUpdateReqVO.ENTERPRISE.equals(resp.getCategory())
|
|
|
+ || CollUtil.isEmpty(resp.getTag())) {
|
|
|
+ return; // 提前返回,减少嵌套
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取招聘会白名单企业
|
|
|
+ List<FairWhiteDO> fairWhiteList = fairWhiteService.getByJobFairId(resp.getId());
|
|
|
+
|
|
|
+ // 过滤出 enterpriseId 的标签,并处理每个标签
|
|
|
+ resp.getTag().stream()
|
|
|
+ .filter(tag -> "enterpriseId".equals(tag.getKey())) // 过滤出 enterpriseId 的标签
|
|
|
+ .flatMap(tag -> tag.getContent().stream()) // 将标签内容扁平化
|
|
|
+ .forEach(value -> {
|
|
|
+ Long enterpriseId = Long.valueOf(value.getValue());
|
|
|
+
|
|
|
+ // 查找白名单顺序信息
|
|
|
+ fairWhiteList.stream()
|
|
|
+ .filter(fairWhite -> fairWhite.getEnterpriseId().equals(enterpriseId))
|
|
|
+ .findFirst()
|
|
|
+ .ifPresent(fairWhite -> value.setSort(fairWhite.getSort())); // 设置顺序信息
|
|
|
+ });
|
|
|
+
|
|
|
+ // 获取企业信息并添加到响应中
|
|
|
+ List<Long> enterpriseIdList = resp.getTag().stream()
|
|
|
+ .filter(tag -> "enterpriseId".equals(tag.getKey()))
|
|
|
+ .flatMap(tag -> tag.getContent().stream())
|
|
|
+ .map(value -> Long.valueOf(value.getValue()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<EnterpriseDO> enterpriseList = enterpriseService.getByIdList(enterpriseIdList);
|
|
|
+ List<EnterpriseRespVO> enterpriseRespList = BeanUtils.toBean(enterpriseList, EnterpriseRespVO.class);
|
|
|
+ // 假设 resp 中有方法可以设置企业列表
|
|
|
+ resp.setEnterprise(enterpriseRespList);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@GetMapping("/page")
|
|
|
@Operation(summary = "获得招聘会分页")
|
|
|
@PreAuthorize("@ss.hasPermission('menduner:system:job-fair:query')")
|
|
|
public CommonResult<PageResult<JobFairRespVO>> getJobFairPage(@Valid JobFairPageReqVO pageReqVO) {
|
|
|
PageResult<FairDO> pageResult = fairService.getJobFairPage(pageReqVO);
|
|
|
- return success(BeanUtils.toBean(pageResult, JobFairRespVO.class));
|
|
|
+ PageResult<JobFairRespVO> resp = BeanUtils.toBean(pageResult, JobFairRespVO.class);
|
|
|
+ resp.getList().forEach(this::setTagSort);
|
|
|
+ return success(resp);
|
|
|
}
|
|
|
|
|
|
@GetMapping("/export-excel")
|
|
@@ -124,7 +177,10 @@ public class FairController {
|
|
|
@PutMapping("/add-white-list")
|
|
|
@Operation(summary = "添加企业白名单")
|
|
|
public CommonResult<Boolean> addWhiteList(@Valid @RequestBody FairWhiteReqVO reqVO) {
|
|
|
- fairWhiteService.addWhiteList(reqVO.getJobFairId(), StrUtils.splitToLong(reqVO.getEnterpriseIds()));
|
|
|
+ fairWhiteService.addWhiteList(
|
|
|
+ reqVO.getJobFairId(),
|
|
|
+ StrUtils.splitToLong(reqVO.getEnterpriseIds()),
|
|
|
+ reqVO.getSort());
|
|
|
return success(true);
|
|
|
}
|
|
|
|