|
|
@@ -0,0 +1,304 @@
|
|
|
+package com.jpsoft.enterprise.modules.mobile.controller;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.CooperationInfoListDTO;
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.RecruitInfoListDTO;
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.*;
|
|
|
+import com.jpsoft.enterprise.modules.base.service.CompanyInfoService;
|
|
|
+import com.jpsoft.enterprise.modules.base.service.PersonInfoService;
|
|
|
+import com.jpsoft.enterprise.modules.base.service.RecruitInfoService;
|
|
|
+import com.jpsoft.enterprise.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.enterprise.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.enterprise.modules.sys.service.DataDictionaryService;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author 墨鱼_mo
|
|
|
+ * @date 2021-1-18 9:08
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/mobile/recruitInfoApi")
|
|
|
+@Slf4j
|
|
|
+public class RecruitInfoApiController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RecruitInfoService recruitInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CompanyInfoService companyInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DataDictionaryService dataDictionaryService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PersonInfoService personInfoService;
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("recruitInfoList")
|
|
|
+ @ApiOperation(value = "招聘列表(公开接口)")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "region", value = "区域", required = false, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "salaryLevel", value = "薪资水平", required = false, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "workYear", value = "工作年限", required = false, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "education", value = "学历", required = false, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "companyId", value = "公司id", required = false, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "key", value = "关键字", required = false, paramType = "form"),
|
|
|
+ })
|
|
|
+ public MessageResult<Map> recruitInfoList(String region, String salaryLevel, String workYear, String education, String companyId, String key, @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<RecruitInfoListDTO> list = new ArrayList<>();
|
|
|
+
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(region)) {
|
|
|
+ searchParams.put("region", region);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(salaryLevel)) {
|
|
|
+ searchParams.put("salaryLevel", salaryLevel);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(workYear)) {
|
|
|
+ searchParams.put("workYear", workYear);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(education)) {
|
|
|
+ searchParams.put("education", education);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(companyId)) {
|
|
|
+ searchParams.put("companyId", companyId);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(key)) {
|
|
|
+ searchParams.put("key", "%" + key + "%");
|
|
|
+ }
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("create_time", "desc"));
|
|
|
+ Page<RecruitInfo> page = recruitInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
+ List<RecruitInfo> recruitInfoList = page.getResult();
|
|
|
+ if (recruitInfoList.size() > 0) {
|
|
|
+
|
|
|
+ for (RecruitInfo recruitInfo : recruitInfoList) {
|
|
|
+ RecruitInfoListDTO recruitInfoListDTO = new RecruitInfoListDTO();
|
|
|
+ BeanUtils.copyProperties(recruitInfo, recruitInfoListDTO);
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(recruitInfo.getCompanyId());
|
|
|
+ recruitInfoListDTO.setCompanyName(companyInfo.getCompanyName());
|
|
|
+ String workRegionName = dataDictionaryService.findNameByCatalogNameAndValue("区域", recruitInfo.getWorkRegion());
|
|
|
+ recruitInfoListDTO.setWorkRegionName(workRegionName);
|
|
|
+ String workYearName = dataDictionaryService.findNameByCatalogNameAndValue("工作年限", recruitInfo.getWorkYear());
|
|
|
+ recruitInfoListDTO.setWorkYearName(workYearName);
|
|
|
+ String educationName = dataDictionaryService.findNameByCatalogNameAndValue("学历", recruitInfo.getEducation());
|
|
|
+ recruitInfoListDTO.setEducationName(educationName);
|
|
|
+ String salaryLevelName = dataDictionaryService.findNameByCatalogNameAndValue("薪资水平", recruitInfo.getSalaryLevel());
|
|
|
+ recruitInfoListDTO.setSalaryLevelName(salaryLevelName);
|
|
|
+ list.add(recruitInfoListDTO);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Object> pageMap = new HashMap<>();
|
|
|
+
|
|
|
+ pageMap.put("recordsTotal", page.getTotal());
|
|
|
+ pageMap.put("recordsFiltered", page.getTotal());
|
|
|
+ pageMap.put("totalPage", page.getPages());
|
|
|
+ pageMap.put("pageNumber", page.getPageNum());
|
|
|
+ pageMap.put("pageSize", page.getPageSize());
|
|
|
+ pageMap.put("data", list);
|
|
|
+
|
|
|
+ messageResult.setData(pageMap);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("recruitInfoDetail")
|
|
|
+ @ApiOperation(value = "招聘详情(公开接口)")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> recruitInfoDetail(String id) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ RecruitInfo recruitInfo = recruitInfoService.get(id);
|
|
|
+ if (recruitInfo == null) {
|
|
|
+ throw new Exception("招聘信息不存在");
|
|
|
+ }
|
|
|
+ RecruitInfoListDTO recruitInfoListDTO = new RecruitInfoListDTO();
|
|
|
+ BeanUtils.copyProperties(recruitInfo, recruitInfoListDTO);
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(recruitInfo.getCompanyId());
|
|
|
+ recruitInfoListDTO.setCompanyName(companyInfo.getCompanyName());
|
|
|
+ String workRegionName = dataDictionaryService.findNameByCatalogNameAndValue("区域", recruitInfo.getWorkRegion());
|
|
|
+ recruitInfoListDTO.setWorkRegionName(workRegionName);
|
|
|
+ String workYearName = dataDictionaryService.findNameByCatalogNameAndValue("工作年限", recruitInfo.getWorkYear());
|
|
|
+ recruitInfoListDTO.setWorkYearName(workYearName);
|
|
|
+ String educationName = dataDictionaryService.findNameByCatalogNameAndValue("学历", recruitInfo.getEducation());
|
|
|
+ recruitInfoListDTO.setEducationName(educationName);
|
|
|
+ String salaryLevelName = dataDictionaryService.findNameByCatalogNameAndValue("薪资水平", recruitInfo.getSalaryLevel());
|
|
|
+ recruitInfoListDTO.setSalaryLevelName(salaryLevelName);
|
|
|
+
|
|
|
+ map.put("recruitInfo", recruitInfoListDTO);
|
|
|
+
|
|
|
+ messageResult.setData(map);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("recruitInfoListForOwn")
|
|
|
+ @ApiOperation(value = "个人招聘信息列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form")
|
|
|
+ })
|
|
|
+ public MessageResult<Map> recruitInfoListForOwn(String token, @RequestAttribute String subject, @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ List<RecruitInfoListDTO> list = new ArrayList<>();
|
|
|
+
|
|
|
+ PersonInfo personInfo = personInfoService.get(subject);
|
|
|
+ if (personInfo == null) {
|
|
|
+ throw new Exception("用户不存在");
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
+ if (companyInfo == null) {
|
|
|
+ throw new Exception("公司信息有误");
|
|
|
+ }
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
+ searchParams.put("companyId", companyInfo.getId());
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("status", "desc"));
|
|
|
+ sortList.add(new Sort("create_time", "desc"));
|
|
|
+ Page<RecruitInfo> page = recruitInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
+ List<RecruitInfo> recruitInfoList = page.getResult();
|
|
|
+ if (recruitInfoList.size() > 0) {
|
|
|
+ for (RecruitInfo recruitInfo : recruitInfoList) {
|
|
|
+ RecruitInfoListDTO recruitInfoListDTO = new RecruitInfoListDTO();
|
|
|
+ BeanUtils.copyProperties(recruitInfo, recruitInfoListDTO);
|
|
|
+ recruitInfoListDTO.setCompanyName(companyInfo.getCompanyName());
|
|
|
+ String workRegionName = dataDictionaryService.findNameByCatalogNameAndValue("区域", recruitInfo.getWorkRegion());
|
|
|
+ recruitInfoListDTO.setWorkRegionName(workRegionName);
|
|
|
+ String workYearName = dataDictionaryService.findNameByCatalogNameAndValue("工作年限", recruitInfo.getWorkYear());
|
|
|
+ recruitInfoListDTO.setWorkYearName(workYearName);
|
|
|
+ String educationName = dataDictionaryService.findNameByCatalogNameAndValue("学历", recruitInfo.getEducation());
|
|
|
+ recruitInfoListDTO.setEducationName(educationName);
|
|
|
+ String salaryLevelName = dataDictionaryService.findNameByCatalogNameAndValue("薪资水平", recruitInfo.getSalaryLevel());
|
|
|
+ recruitInfoListDTO.setSalaryLevelName(salaryLevelName);
|
|
|
+ list.add(recruitInfoListDTO);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> pageMap = new HashMap<>();
|
|
|
+
|
|
|
+ pageMap.put("recordsTotal", page.getTotal());
|
|
|
+ pageMap.put("recordsFiltered", page.getTotal());
|
|
|
+ pageMap.put("totalPage", page.getPages());
|
|
|
+ pageMap.put("pageNumber", page.getPageNum());
|
|
|
+ pageMap.put("pageSize", page.getPageSize());
|
|
|
+ pageMap.put("data", list);
|
|
|
+
|
|
|
+ messageResult.setData(pageMap);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("submitRecruitInfo")
|
|
|
+ @ApiOperation(value = "个人招聘信息提交")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "positionName", value = "职务名称", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "workRegion", value = "区域", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "workYear", value = "工作年限", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "education", value = "学历", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "salaryLevel", value = "薪资水平", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "describe", value = "描述", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "contactPhone", value = "联系电话", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "status", value = "是否上架(0:否,1:是)", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "token", value = "令牌", required = true, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "subject", value = "目标(不传)", paramType = "form"),
|
|
|
+ })
|
|
|
+ public MessageResult<Map> submitRecruitInfo(String positionName, String workRegion, String workYear, String education, String salaryLevel, String describe, String contactPhone, String status, String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ PersonInfo personInfo = personInfoService.get(subject);
|
|
|
+ if (personInfo == null) {
|
|
|
+ throw new Exception("用户不存在");
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(personInfo.getCompanyId());
|
|
|
+ if (companyInfo == null) {
|
|
|
+ throw new Exception("公司信息有误");
|
|
|
+ }
|
|
|
+ RecruitInfo recruitInfo = new RecruitInfo();
|
|
|
+ recruitInfo.setId(UUID.randomUUID().toString());
|
|
|
+ recruitInfo.setCompanyId(companyInfo.getId());
|
|
|
+ recruitInfo.setPositionName(positionName);
|
|
|
+ recruitInfo.setWorkRegion(workRegion);
|
|
|
+ recruitInfo.setWorkYear(workYear);
|
|
|
+ recruitInfo.setEducation(education);
|
|
|
+ recruitInfo.setSalaryLevel(salaryLevel);
|
|
|
+ recruitInfo.setDescribe(describe);
|
|
|
+ recruitInfo.setContactPhone(contactPhone);
|
|
|
+ if ("0".equals(status)){
|
|
|
+ recruitInfo.setStatus(false);
|
|
|
+ }
|
|
|
+ if ("1".equals(status)){
|
|
|
+ recruitInfo.setStatus(true);
|
|
|
+ }
|
|
|
+ recruitInfo.setCreateTime(new Date());
|
|
|
+ recruitInfo.setCreateBy(personInfo.getId());
|
|
|
+ recruitInfo.setDelFlag(false);
|
|
|
+ recruitInfo.setKey(companyInfo.getCompanyName()+"+"+positionName);
|
|
|
+ recruitInfoService.insert(recruitInfo);
|
|
|
+
|
|
|
+
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+}
|