添加岗位分页列表
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
package org.jiayunet.controller;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.jiayunet.pojo.PageResult;
|
||||
import org.jiayunet.pojo.dto.recruitAnnouncement.RecruitAnnouncementDto;
|
||||
import org.jiayunet.pojo.dto.recruitAnnouncement.RecruitAnnouncementStatisticsDto;
|
||||
import org.jiayunet.pojo.param.recruitAnnouncement.RecruitAnnouncementQueryParam;
|
||||
import org.jiayunet.service.RecruitAnnouncementService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -37,6 +42,12 @@ public class RecruitAnnouncementController {
|
||||
return recruitAnnouncementService.getStatistics();
|
||||
}
|
||||
|
||||
/** 分页查询公告列表 */
|
||||
@PostMapping("/page")
|
||||
public PageResult<RecruitAnnouncementDto> pageAnnouncement(@Validated @RequestBody RecruitAnnouncementQueryParam param) {
|
||||
return recruitAnnouncementService.pageAnnouncement(param);
|
||||
}
|
||||
|
||||
/** 查询公告批次列表(去重) */
|
||||
@GetMapping("/batch")
|
||||
public List<String> listBatchName() {
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package org.jiayunet.pojo.dto.recruitAnnouncement;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 招聘公告列表返回
|
||||
*
|
||||
* @author zk
|
||||
*/
|
||||
@Data
|
||||
public class RecruitAnnouncementDto {
|
||||
|
||||
/** 公告ID */
|
||||
private Long id;
|
||||
|
||||
/** 公司ID */
|
||||
private Long companyId;
|
||||
|
||||
/** 公司名称 */
|
||||
private String companyName;
|
||||
|
||||
/** 公司logo */
|
||||
private String logoUrl;
|
||||
|
||||
/** 公告标题 */
|
||||
private String title;
|
||||
|
||||
/** 专业要求 */
|
||||
private String majorRequire;
|
||||
|
||||
/** 投递结束时间 */
|
||||
private Instant applyEndTime;
|
||||
|
||||
/** 投递截止描述 */
|
||||
private String applyEndDesc;
|
||||
|
||||
/** 行业列表 */
|
||||
private List<String> industryNames;
|
||||
|
||||
/** 岗位大类列表 */
|
||||
private List<String> categoryNames;
|
||||
|
||||
/** 热招城市列表 */
|
||||
private List<String> cityNames;
|
||||
|
||||
/** 学历要求列表 */
|
||||
private List<String> educationNames;
|
||||
|
||||
/** 招聘届数列表 */
|
||||
private List<Integer> recruitYears;
|
||||
|
||||
/** 批次列表 */
|
||||
private List<String> batchNames;
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package org.jiayunet.pojo.param.recruitAnnouncement;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.jiayunet.pojo.PageParam;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 招聘公告查询入参
|
||||
* <p>各筛选条件之间为“且”关系,为空则不参与筛选</p>
|
||||
*
|
||||
* @author zk
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class RecruitAnnouncementQueryParam extends PageParam {
|
||||
|
||||
/** 发布时间起(不含) */
|
||||
private Instant publishTimeStart;
|
||||
|
||||
/** 发布时间止(含) */
|
||||
private Instant publishTimeEnd;
|
||||
|
||||
/** 投递截止时间起(不含) */
|
||||
private Instant applyEndTimeStart;
|
||||
|
||||
/** 投递截止时间止(含) */
|
||||
private Instant applyEndTimeEnd;
|
||||
|
||||
/** 公司类型列表 */
|
||||
private List<String> companyTypes;
|
||||
|
||||
/** 学历要求列表 */
|
||||
private List<String> educationNames;
|
||||
|
||||
/** 招聘届数列表 */
|
||||
private List<Integer> recruitYears;
|
||||
|
||||
/** 批次列表 */
|
||||
private List<String> batchNames;
|
||||
|
||||
/** 岗位大类列表 */
|
||||
private List<String> categoryNames;
|
||||
|
||||
/** 热招城市列表 */
|
||||
private List<String> cityNames;
|
||||
|
||||
/** 行业列表 */
|
||||
private List<String> industryNames;
|
||||
|
||||
/** 标签列表 */
|
||||
private List<String> tagNames;
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.jiayunet.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jiayunet.mapper.RecruitAnnouncementBatchMapper;
|
||||
import org.jiayunet.mapper.RecruitAnnouncementMapper;
|
||||
@@ -9,7 +11,17 @@ import org.jiayunet.mapper.RecruitAnnouncementEducationMapper;
|
||||
import org.jiayunet.mapper.RecruitAnnouncementIndustryMapper;
|
||||
import org.jiayunet.mapper.RecruitAnnouncementTagMapper;
|
||||
import org.jiayunet.mapper.RecruitAnnouncementYearMapper;
|
||||
import org.jiayunet.pojo.PageResult;
|
||||
import org.jiayunet.pojo.dto.recruitAnnouncement.RecruitAnnouncementDto;
|
||||
import org.jiayunet.pojo.dto.recruitAnnouncement.RecruitAnnouncementStatisticsDto;
|
||||
import org.jiayunet.pojo.param.recruitAnnouncement.RecruitAnnouncementQueryParam;
|
||||
import org.jiayunet.pojo.po.RecruitAnnouncementBatch;
|
||||
import org.jiayunet.pojo.po.RecruitAnnouncementCategory;
|
||||
import org.jiayunet.pojo.po.RecruitAnnouncementCity;
|
||||
import org.jiayunet.pojo.po.RecruitAnnouncementEducation;
|
||||
import org.jiayunet.pojo.po.RecruitAnnouncementIndustry;
|
||||
import org.jiayunet.pojo.po.RecruitAnnouncementYear;
|
||||
import org.jiayunet.pojo.vo.RecruitAnnouncementListItemVo;
|
||||
import org.jiayunet.pojo.vo.RecruitAnnouncementStatisticsVo;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -19,6 +31,8 @@ import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 招聘公告服务
|
||||
@@ -69,6 +83,46 @@ public class RecruitAnnouncementService {
|
||||
return recruitAnnouncementMapper.selectLastCreateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询招聘公告列表
|
||||
* <p>1. 主表分页查询(多值维度不参与) 2. 按本页id批量查6张从表 3. Java侧分组组装DTO</p>
|
||||
*/
|
||||
public PageResult<RecruitAnnouncementDto> pageAnnouncement(RecruitAnnouncementQueryParam param) {
|
||||
|
||||
//查询数据
|
||||
Page<RecruitAnnouncementListItemVo> pageParam = param.toPage();
|
||||
pageParam.setSearchCount(false);
|
||||
Page<RecruitAnnouncementListItemVo> page = recruitAnnouncementMapper.selectAnnouncementPage(pageParam, param.getPublishTimeStart(), param.getPublishTimeEnd(), param.getApplyEndTimeStart(), param.getApplyEndTimeEnd(), param.getCompanyTypes(), param.getEducationNames(), param.getRecruitYears(), param.getBatchNames(), param.getCategoryNames(), param.getCityNames(), param.getIndustryNames(), param.getTagNames());
|
||||
|
||||
List<Long> announcementIds = page.getRecords().stream().map(RecruitAnnouncementListItemVo::getId).collect(Collectors.toList());
|
||||
if (announcementIds.isEmpty()) {
|
||||
return new PageResult<>(page.getCurrent(), page.getSize(), page.getTotal(), List.of());
|
||||
}
|
||||
|
||||
|
||||
// 按本页id批量查从表,各自按公告id分组
|
||||
Map<Long, List<String>> industryMap = industryMapper.selectList(new LambdaQueryWrapper<RecruitAnnouncementIndustry>().in(RecruitAnnouncementIndustry::getAnnouncementId, announcementIds)).stream().collect(Collectors.groupingBy(RecruitAnnouncementIndustry::getAnnouncementId, Collectors.mapping(RecruitAnnouncementIndustry::getIndustryName, Collectors.toList())));
|
||||
Map<Long, List<String>> categoryMap = categoryMapper.selectList(new LambdaQueryWrapper<RecruitAnnouncementCategory>().in(RecruitAnnouncementCategory::getAnnouncementId, announcementIds)).stream().collect(Collectors.groupingBy(RecruitAnnouncementCategory::getAnnouncementId, Collectors.mapping(RecruitAnnouncementCategory::getCategoryName, Collectors.toList())));
|
||||
Map<Long, List<String>> cityMap = cityMapper.selectList(new LambdaQueryWrapper<RecruitAnnouncementCity>().in(RecruitAnnouncementCity::getAnnouncementId, announcementIds)).stream().collect(Collectors.groupingBy(RecruitAnnouncementCity::getAnnouncementId, Collectors.mapping(RecruitAnnouncementCity::getCityName, Collectors.toList())));
|
||||
Map<Long, List<String>> educationMap = educationMapper.selectList(new LambdaQueryWrapper<RecruitAnnouncementEducation>().in(RecruitAnnouncementEducation::getAnnouncementId, announcementIds)).stream().collect(Collectors.groupingBy(RecruitAnnouncementEducation::getAnnouncementId, Collectors.mapping(RecruitAnnouncementEducation::getEducationName, Collectors.toList())));
|
||||
Map<Long, List<Integer>> yearMap = yearMapper.selectList(new LambdaQueryWrapper<RecruitAnnouncementYear>().in(RecruitAnnouncementYear::getAnnouncementId, announcementIds)).stream().collect(Collectors.groupingBy(RecruitAnnouncementYear::getAnnouncementId, Collectors.mapping(RecruitAnnouncementYear::getRecruitYear, Collectors.toList())));
|
||||
Map<Long, List<String>> batchMap = batchMapper.selectList(new LambdaQueryWrapper<RecruitAnnouncementBatch>().in(RecruitAnnouncementBatch::getAnnouncementId, announcementIds)).stream().collect(Collectors.groupingBy(RecruitAnnouncementBatch::getAnnouncementId, Collectors.mapping(RecruitAnnouncementBatch::getBatchName, Collectors.toList())));
|
||||
|
||||
// 组装返回数据
|
||||
List<RecruitAnnouncementDto> dtoList = page.getRecords().stream().map(vo -> {
|
||||
RecruitAnnouncementDto dto = new RecruitAnnouncementDto();
|
||||
BeanUtils.copyProperties(vo, dto);
|
||||
dto.setIndustryNames(industryMap.getOrDefault(vo.getId(), List.of()));
|
||||
dto.setCategoryNames(categoryMap.getOrDefault(vo.getId(), List.of()));
|
||||
dto.setCityNames(cityMap.getOrDefault(vo.getId(), List.of()));
|
||||
dto.setEducationNames(educationMap.getOrDefault(vo.getId(), List.of()));
|
||||
dto.setRecruitYears(yearMap.getOrDefault(vo.getId(), List.of()));
|
||||
dto.setBatchNames(batchMap.getOrDefault(vo.getId(), List.of()));
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
return new PageResult<>(page.getCurrent(), page.getSize(), page.getTotal(), dtoList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计公告数量(今日新增/本月新增/累计)
|
||||
* <p>1. 按东八区算出今日零点、本月1号零点 2. 一次SQL条件聚合出三个计数 3. 转DTO返回</p>
|
||||
|
||||
@@ -20,7 +20,7 @@ public class PageParam {
|
||||
|
||||
/** 每页条数 */
|
||||
@Min(value = 1, message = "每页条数最小为1")
|
||||
@Max(value = 1000, message = "每页条数最大为100")
|
||||
@Max(value = 200, message = "每页条数最大为200")
|
||||
private Integer pageSize = 10;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package org.jiayunet.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jiayunet.pojo.po.RecruitAnnouncement;
|
||||
import org.jiayunet.pojo.vo.RecruitAnnouncementListItemVo;
|
||||
import org.jiayunet.pojo.vo.RecruitAnnouncementStatisticsVo;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 招聘公告主表Mapper
|
||||
@@ -29,4 +32,10 @@ public interface RecruitAnnouncementMapper extends CommonMapper<RecruitAnnouncem
|
||||
* @param monthStart 本月开始时间
|
||||
*/
|
||||
RecruitAnnouncementStatisticsVo selectStatistics(@Param("dayStart") Instant dayStart, @Param("monthStart") Instant monthStart);
|
||||
|
||||
/**
|
||||
* 分页查询招聘公告列表
|
||||
* <p>各筛选条件为“且”关系,为空则不参与筛选;多值维度不在此查询,由Java侧按id批量组装</p>
|
||||
*/
|
||||
Page<RecruitAnnouncementListItemVo> selectAnnouncementPage(Page<RecruitAnnouncementListItemVo> page, @Param("publishTimeStart") Instant publishTimeStart, @Param("publishTimeEnd") Instant publishTimeEnd, @Param("applyEndTimeStart") Instant applyEndTimeStart, @Param("applyEndTimeEnd") Instant applyEndTimeEnd, @Param("companyTypes") List<String> companyTypes, @Param("educationNames") List<String> educationNames, @Param("recruitYears") List<Integer> recruitYears, @Param("batchNames") List<String> batchNames, @Param("categoryNames") List<String> categoryNames, @Param("cityNames") List<String> cityNames, @Param("industryNames") List<String> industryNames, @Param("tagNames") List<String> tagNames);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.jiayunet.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 招聘公告查询条件(Mapper入参)
|
||||
* <p>各条件之间为“且”关系,为空则不参与筛选</p>
|
||||
*
|
||||
* @author zk
|
||||
*/
|
||||
@Data
|
||||
public class RecruitAnnouncementQueryDto {
|
||||
|
||||
/** 发布时间起(不含) */
|
||||
private Instant publishTimeStart;
|
||||
|
||||
/** 发布时间止(含) */
|
||||
private Instant publishTimeEnd;
|
||||
|
||||
/** 投递截止时间起(不含) */
|
||||
private Instant applyEndTimeStart;
|
||||
|
||||
/** 投递截止时间止(含) */
|
||||
private Instant applyEndTimeEnd;
|
||||
|
||||
/** 公司类型列表 */
|
||||
private List<String> companyTypes;
|
||||
|
||||
/** 学历要求列表 */
|
||||
private List<String> educationNames;
|
||||
|
||||
/** 招聘届数列表 */
|
||||
private List<Integer> recruitYears;
|
||||
|
||||
/** 批次列表 */
|
||||
private List<String> batchNames;
|
||||
|
||||
/** 岗位大类列表 */
|
||||
private List<String> categoryNames;
|
||||
|
||||
/** 热招城市列表 */
|
||||
private List<String> cityNames;
|
||||
|
||||
/** 行业列表 */
|
||||
private List<String> industryNames;
|
||||
|
||||
/** 标签列表 */
|
||||
private List<String> tagNames;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.jiayunet.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/**
|
||||
* 招聘公告列表项VO(SQL查询结果,多值维度由Java侧组装)
|
||||
*
|
||||
* @author zk
|
||||
*/
|
||||
@Data
|
||||
public class RecruitAnnouncementListItemVo {
|
||||
|
||||
/** 公告ID */
|
||||
private Long id;
|
||||
|
||||
/** 公司ID */
|
||||
private Long companyId;
|
||||
|
||||
/** 公司名称 */
|
||||
private String companyName;
|
||||
|
||||
/** 公司logo */
|
||||
private String logoUrl;
|
||||
|
||||
/** 公告标题 */
|
||||
private String title;
|
||||
|
||||
/** 专业要求 */
|
||||
private String majorRequire;
|
||||
|
||||
/** 投递结束时间 */
|
||||
private Instant applyEndTime;
|
||||
|
||||
/** 投递截止描述 */
|
||||
private String applyEndDesc;
|
||||
}
|
||||
@@ -25,4 +25,131 @@
|
||||
FROM bg_recruit_announcement
|
||||
</select>
|
||||
|
||||
<resultMap id="RecruitAnnouncementListItemVoMap" type="org.jiayunet.pojo.vo.RecruitAnnouncementListItemVo">
|
||||
<id column="id" property="id"/>
|
||||
<result column="company_id" property="companyId"/>
|
||||
<result column="company_name" property="companyName"/>
|
||||
<result column="logo_url" property="logoUrl"/>
|
||||
<result column="title" property="title"/>
|
||||
<result column="major_require" property="majorRequire"/>
|
||||
<result column="apply_end_time" property="applyEndTime"/>
|
||||
<result column="apply_end_desc" property="applyEndDesc"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 分页查询公告列表:多值维度不在此取,由Java侧按id批量组装 -->
|
||||
<select id="selectAnnouncementPage" resultMap="RecruitAnnouncementListItemVoMap">
|
||||
SELECT
|
||||
ra.id,
|
||||
ra.company_id,
|
||||
ra.company_name,
|
||||
c.logo_url,
|
||||
ra.title,
|
||||
ra.major_require,
|
||||
ra.apply_end_time,
|
||||
ra.apply_end_desc
|
||||
FROM bg_recruit_announcement ra
|
||||
INNER JOIN bg_company c ON ra.company_id = c.id
|
||||
WHERE c.status = 1
|
||||
AND ra.status = 1
|
||||
<!-- 筛选条件:发布时间区间 -->
|
||||
<if test="publishTimeStart != null">
|
||||
AND ra.publish_time <![CDATA[>]]> #{publishTimeStart}
|
||||
</if>
|
||||
<if test="publishTimeEnd != null">
|
||||
AND ra.publish_time <![CDATA[<=]]> #{publishTimeEnd}
|
||||
</if>
|
||||
<!-- 筛选条件:投递截止时间区间 -->
|
||||
<if test="applyEndTimeStart != null">
|
||||
AND ra.apply_end_time <![CDATA[>]]> #{applyEndTimeStart}
|
||||
</if>
|
||||
<if test="applyEndTimeEnd != null">
|
||||
AND ra.apply_end_time <![CDATA[<=]]> #{applyEndTimeEnd}
|
||||
</if>
|
||||
<!-- 筛选条件:公司类型 -->
|
||||
<if test="companyTypes != null and companyTypes.size() > 0">
|
||||
AND c.company_type IN
|
||||
<foreach collection="companyTypes" item="type" open="(" separator="," close=")">
|
||||
#{type}
|
||||
</foreach>
|
||||
</if>
|
||||
<!-- 筛选条件:学历要求 -->
|
||||
<if test="educationNames != null and educationNames.size() > 0">
|
||||
AND ra.id IN (
|
||||
SELECT rae.announcement_id
|
||||
FROM bg_recruit_announcement_education rae
|
||||
WHERE rae.education_name IN
|
||||
<foreach collection="educationNames" item="name" open="(" separator="," close=")">
|
||||
#{name}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<!-- 筛选条件:招聘届数 -->
|
||||
<if test="recruitYears != null and recruitYears.size() > 0">
|
||||
AND ra.id IN (
|
||||
SELECT ray.announcement_id
|
||||
FROM bg_recruit_announcement_year ray
|
||||
WHERE ray.recruit_year IN
|
||||
<foreach collection="recruitYears" item="year" open="(" separator="," close=")">
|
||||
#{year}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<!-- 筛选条件:批次 -->
|
||||
<if test="batchNames != null and batchNames.size() > 0">
|
||||
AND ra.id IN (
|
||||
SELECT rab.announcement_id
|
||||
FROM bg_recruit_announcement_batch rab
|
||||
WHERE rab.batch_name IN
|
||||
<foreach collection="batchNames" item="name" open="(" separator="," close=")">
|
||||
#{name}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<!-- 筛选条件:岗位大类 -->
|
||||
<if test="categoryNames != null and categoryNames.size() > 0">
|
||||
AND ra.id IN (
|
||||
SELECT rac.announcement_id
|
||||
FROM bg_recruit_announcement_category rac
|
||||
WHERE rac.category_name IN
|
||||
<foreach collection="categoryNames" item="name" open="(" separator="," close=")">
|
||||
#{name}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<!-- 筛选条件:热招城市 -->
|
||||
<if test="cityNames != null and cityNames.size() > 0">
|
||||
AND ra.id IN (
|
||||
SELECT ract.announcement_id
|
||||
FROM bg_recruit_announcement_city ract
|
||||
WHERE ract.city_name IN
|
||||
<foreach collection="cityNames" item="name" open="(" separator="," close=")">
|
||||
#{name}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<!-- 筛选条件:行业 -->
|
||||
<if test="industryNames != null and industryNames.size() > 0">
|
||||
AND ra.id IN (
|
||||
SELECT rai.announcement_id
|
||||
FROM bg_recruit_announcement_industry rai
|
||||
WHERE rai.industry_name IN
|
||||
<foreach collection="industryNames" item="name" open="(" separator="," close=")">
|
||||
#{name}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<!-- 筛选条件:标签 -->
|
||||
<if test="tagNames != null and tagNames.size() > 0">
|
||||
AND ra.id IN (
|
||||
SELECT rat.announcement_id
|
||||
FROM bg_recruit_announcement_tag rat
|
||||
WHERE rat.tag_name IN
|
||||
<foreach collection="tagNames" item="name" open="(" separator="," close=")">
|
||||
#{name}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
ORDER BY ra.id DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user