Compare commits
2
Commits
c5de219122
...
7c21c82dba
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c21c82dba | ||
|
|
7601f9c5a5 |
@@ -0,0 +1,29 @@
|
||||
package org.jiayunet.controller;
|
||||
|
||||
import org.jiayunet.service.CompanyService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 公司接口
|
||||
*
|
||||
* @author zk
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/company")
|
||||
public class CompanyController {
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
/**
|
||||
* 查询公司类型列表
|
||||
*/
|
||||
@GetMapping("/types")
|
||||
public List<String> listCompanyTypes() {
|
||||
return companyService.listCompanyTypes();
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,9 @@ public class JobQueryParam extends PageParam {
|
||||
/** 行业ID列表 */
|
||||
private List<Long> industryIds;
|
||||
|
||||
/** 公司类型列表(上市企业、独角兽、国企等,可多选) */
|
||||
private List<String> companyTypes;
|
||||
|
||||
/** 工作类型 0=全职 1=兼职 */
|
||||
private Integer employmentType;
|
||||
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.jiayunet.service;
|
||||
|
||||
import org.jiayunet.mapper.CompanyMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 公司服务
|
||||
* <p>主要功能:公司信息查询</p>
|
||||
* <p>依赖服务:无</p>
|
||||
* <p>使用的表:bg_company</p>
|
||||
*
|
||||
* @author zk
|
||||
*/
|
||||
@Service
|
||||
public class CompanyService {
|
||||
@Autowired
|
||||
private CompanyMapper companyMapper;
|
||||
|
||||
/**
|
||||
* 查询已完善公司(status=1)去重后的公司类型列表
|
||||
* <p>Service层再次过滤NULL和空白值,兜底脏数据</p>
|
||||
*/
|
||||
public List<String> listCompanyTypes() {
|
||||
return companyMapper.selectDistinctCompanyTypes().stream()
|
||||
.filter(StringUtils::hasText)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ public class JobService {
|
||||
// 6. 执行分页查询
|
||||
Page<JobListItemVo> pageParam = param.toPage();
|
||||
pageParam.setSearchCount(false);
|
||||
Page<JobListItemVo> page = jobMapper.selectJobPage(pageParam, param.getJobIds(),param.getStatusFilter(), param.getKeyword(), expandedRegionCodes, expandedCategoryIds, expandedIndustryIds, param.getEmploymentType(), excludeJobIds, excludeCompanyIds, excludeRegionCodes, excludeIndustryIds, param.getRecruitCategory());
|
||||
Page<JobListItemVo> page = jobMapper.selectJobPage(pageParam, param.getJobIds(),param.getStatusFilter(), param.getKeyword(), expandedRegionCodes, expandedCategoryIds, expandedIndustryIds, param.getEmploymentType(), excludeJobIds, excludeCompanyIds, excludeRegionCodes, excludeIndustryIds, param.getRecruitCategory(), param.getCompanyTypes());
|
||||
|
||||
// 7. 查询收藏状态
|
||||
List<Long> jobIds = page.getRecords().stream().map(JobListItemVo::getId).collect(Collectors.toList());
|
||||
|
||||
@@ -21,4 +21,12 @@ public interface CompanyMapper extends CommonMapper<Company> {
|
||||
*/
|
||||
@Select("SELECT * FROM bg_company WHERE status = 0 LIMIT #{limit} FOR UPDATE")
|
||||
List<Company> selectForUpdate(@Param("limit") int limit);
|
||||
|
||||
/**
|
||||
* 查询已完善公司(status=1)去重后的公司类型
|
||||
* <p>依赖复合索引 idx_status_type(status, company_type) 走松散索引扫描 + 覆盖索引,不回表</p>
|
||||
* <p>NULL/空值的清洗交由 Service 层处理,SQL 只做分组去重</p>
|
||||
*/
|
||||
@Select("SELECT company_type FROM bg_company WHERE status = 1 GROUP BY company_type")
|
||||
List<String> selectDistinctCompanyTypes();
|
||||
}
|
||||
|
||||
@@ -19,5 +19,5 @@ public interface JobMapper extends CommonMapper<Job> {
|
||||
/**
|
||||
* 分页查询岗位列表
|
||||
*/
|
||||
Page<JobListItemVo> selectJobPage(Page<JobListItemVo> page, @Param("jobIds") List<Long> jobIds, @Param("statusFilter") List<Integer> statusFilter, @Param("keyword") String keyword, @Param("regionCodes") List<String> regionCodes, @Param("categoryIds") List<Long> categoryIds, @Param("industryIds") List<Long> industryIds, @Param("employmentType") Integer employmentType, @Param("excludeJobIds") List<Long> excludeJobIds, @Param("excludeCompanyIds") List<Long> excludeCompanyIds, @Param("excludeRegionCodes") List<String> excludeRegionCodes, @Param("excludeIndustryIds") List<Long> excludeIndustryIds, @Param("recruitCategory") Integer recruitCategory);
|
||||
Page<JobListItemVo> selectJobPage(Page<JobListItemVo> page, @Param("jobIds") List<Long> jobIds, @Param("statusFilter") List<Integer> statusFilter, @Param("keyword") String keyword, @Param("regionCodes") List<String> regionCodes, @Param("categoryIds") List<Long> categoryIds, @Param("industryIds") List<Long> industryIds, @Param("employmentType") Integer employmentType, @Param("excludeJobIds") List<Long> excludeJobIds, @Param("excludeCompanyIds") List<Long> excludeCompanyIds, @Param("excludeRegionCodes") List<String> excludeRegionCodes, @Param("excludeIndustryIds") List<Long> excludeIndustryIds, @Param("recruitCategory") Integer recruitCategory, @Param("companyTypes") List<String> companyTypes);
|
||||
}
|
||||
|
||||
@@ -142,6 +142,13 @@
|
||||
<if test="recruitCategory != null">
|
||||
AND j.recruit_category = #{recruitCategory}
|
||||
</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>
|
||||
ORDER BY j.id DESC
|
||||
</select>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user