diff --git a/client-api/src/main/java/org/jiayunet/controller/JobIntentionController.java b/client-api/src/main/java/org/jiayunet/controller/JobIntentionController.java new file mode 100644 index 0000000..3b1b8bf --- /dev/null +++ b/client-api/src/main/java/org/jiayunet/controller/JobIntentionController.java @@ -0,0 +1,35 @@ +package org.jiayunet.controller; + +import org.jiayunet.pojo.dto.job.JobIntentionDto; +import org.jiayunet.pojo.param.job.JobIntentionParam; +import org.jiayunet.service.JobIntentionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +/** + * 求职意向接口 + * + * @author zk + */ +@RestController +@RequestMapping("/job-intention") +public class JobIntentionController { + @Autowired + private JobIntentionService intentionService; + + /** + * 查询当前用户的求职意向 + */ + @GetMapping + public JobIntentionDto getJobIntention() { + return intentionService.getJobIntention(); + } + + /** + * 保存/更新求职意向 + */ + @PostMapping + public void saveJobIntention(@RequestBody JobIntentionParam param) { + intentionService.saveJobIntention(param); + } +} diff --git a/client-api/src/main/java/org/jiayunet/pojo/dto/job/JobIntentionDto.java b/client-api/src/main/java/org/jiayunet/pojo/dto/job/JobIntentionDto.java new file mode 100644 index 0000000..556188f --- /dev/null +++ b/client-api/src/main/java/org/jiayunet/pojo/dto/job/JobIntentionDto.java @@ -0,0 +1,33 @@ +package org.jiayunet.pojo.dto.job; + +import lombok.Data; + +import java.util.List; + +/** + * 求职意向出参 + * + * @author zk + */ +@Data +public class JobIntentionDto { + /** + * 期望岗位分类ID列表 + */ + private List categoryIds; + + /** + * 期望地区编码列表 + */ + private List regionCodes; + + /** + * 期望行业ID列表 + */ + private List industryIds; + + /** + * 就业类型:0=全职,1=实习 + */ + private Integer employmentType; +} diff --git a/client-api/src/main/java/org/jiayunet/pojo/param/job/JobIntentionParam.java b/client-api/src/main/java/org/jiayunet/pojo/param/job/JobIntentionParam.java new file mode 100644 index 0000000..8a6bd22 --- /dev/null +++ b/client-api/src/main/java/org/jiayunet/pojo/param/job/JobIntentionParam.java @@ -0,0 +1,33 @@ +package org.jiayunet.pojo.param.job; + +import lombok.Data; + +import java.util.List; + +/** + * 求职意向入参 + * + * @author zk + */ +@Data +public class JobIntentionParam { + /** + * 期望岗位分类ID列表(可以是任意层级) + */ + private List categoryIds; + + /** + * 期望地区编码列表(可以是省/市/区任意层级) + */ + private List regionCodes; + + /** + * 期望行业ID列表(可以是一级/二级任意层级) + */ + private List industryIds; + + /** + * 就业类型:0=全职,1=实习 + */ + private Integer employmentType; +} diff --git a/client-api/src/main/java/org/jiayunet/service/JobIntentionService.java b/client-api/src/main/java/org/jiayunet/service/JobIntentionService.java new file mode 100644 index 0000000..71e5a00 --- /dev/null +++ b/client-api/src/main/java/org/jiayunet/service/JobIntentionService.java @@ -0,0 +1,58 @@ +package org.jiayunet.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.jiayunet.mapper.UserJobIntentionMapper; +import org.jiayunet.pojo.dto.job.JobIntentionDto; +import org.jiayunet.pojo.param.job.JobIntentionParam; +import org.jiayunet.pojo.po.UserJobIntention; +import org.jiayunet.tool.UserSecurityTool; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 求职意向服务 + * 主要功能:用户求职意向的查询和保存 + * 依赖服务:无 + * 使用的表:bg_user_job_intention + * + * @author zk + */ +@Service +public class JobIntentionService { + @Autowired + private UserJobIntentionMapper intentionMapper; + + /** + * 查询当前用户的求职意向 + * 逻辑:根据userId查询,不存在返回null + */ + public JobIntentionDto getJobIntention() { + Long userId = UserSecurityTool.getUserId(); + UserJobIntention po = intentionMapper.selectOne(new LambdaQueryWrapper().eq(UserJobIntention::getUserId, userId)); + if (po == null) { + return null; + } + JobIntentionDto dto = new JobIntentionDto(); + BeanUtils.copyProperties(po, dto); + return dto; + } + + /** + * 保存/更新求职意向 + * 逻辑:先查询是否存在,存在则更新,不存在则新增 + */ + public void saveJobIntention(JobIntentionParam param) { + Long userId = UserSecurityTool.getUserId(); + UserJobIntention po = intentionMapper.selectOne(new LambdaQueryWrapper().eq(UserJobIntention::getUserId, userId)); + if (po == null) { + po = new UserJobIntention(); + po.setUserId(userId); + BeanUtils.copyProperties(param, po); + intentionMapper.insert(po); + } else { + BeanUtils.copyProperties(param, po); + intentionMapper.updateById(po); + } + } +}