添加岗位投递接口
This commit is contained in:
@@ -5,6 +5,7 @@ import org.jiayunet.pojo.PageParam;
|
||||
import org.jiayunet.pojo.PageResult;
|
||||
import org.jiayunet.pojo.dto.job.JobDetailDto;
|
||||
import org.jiayunet.pojo.dto.job.JobDto;
|
||||
import org.jiayunet.pojo.param.job.JobApplyParam;
|
||||
import org.jiayunet.pojo.param.job.JobApplyQueryParam;
|
||||
import org.jiayunet.pojo.param.job.JobDislikeParam;
|
||||
import org.jiayunet.pojo.param.job.JobQueryParam;
|
||||
@@ -19,7 +20,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
* @author zk
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/job")
|
||||
@RequestMapping("/api/job")
|
||||
@AllArgsConstructor
|
||||
public class JobController {
|
||||
|
||||
@@ -89,4 +90,13 @@ public class JobController {
|
||||
Long userId = UserSecurityTool.getUserId();
|
||||
return jobService.listApplications(param, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 投递岗位
|
||||
*/
|
||||
@PostMapping("/apply")
|
||||
public void applyJob(@Validated @RequestBody JobApplyParam param) {
|
||||
Long userId = UserSecurityTool.getUserId();
|
||||
jobService.applyJob(param.getJobId(), param.getStatus(), userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.jiayunet.pojo.param.job;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 投递岗位参数
|
||||
*
|
||||
* @author zk
|
||||
*/
|
||||
@Data
|
||||
public class JobApplyParam {
|
||||
|
||||
/** 岗位ID */
|
||||
@NotNull(message = "岗位ID不能为空")
|
||||
private Long jobId;
|
||||
|
||||
/** 投递状态 0=已投递 1=面试中 2=有Offer 3=未通过 4=已结束 */
|
||||
@NotNull(message = "投递状态不能为空")
|
||||
@Min(value = 0, message = "投递状态值范围0-4")
|
||||
@Max(value = 4, message = "投递状态值范围0-4")
|
||||
private Integer status;
|
||||
}
|
||||
@@ -429,4 +429,36 @@ public class JobService {
|
||||
|
||||
return listJobs(queryParam, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 投递岗位
|
||||
* <p>方法逻辑流程:</p>
|
||||
* <p>1. 查询岗位信息(校验存在性)</p>
|
||||
* <p>2. 检查是否已投递(已投递则更新状态)</p>
|
||||
* <p>3. 插入或更新投递记录</p>
|
||||
*/
|
||||
public void applyJob(Long jobId, Integer status, Long userId) {
|
||||
// 1. 查询岗位
|
||||
Job job = jobMapper.selectOne(new LambdaQueryWrapper<Job>().eq(Job::getId, jobId).eq(Job::getStatus, 0));
|
||||
if (job == null) throw new RuntimeException("岗位不存在或已下架");
|
||||
|
||||
// 2. 检查是否已投递
|
||||
UserJobApplication existing = userJobApplicationMapper.selectOne(new LambdaQueryWrapper<UserJobApplication>().eq(UserJobApplication::getUserId, userId).eq(UserJobApplication::getJobId, jobId));
|
||||
|
||||
if (existing != null) {
|
||||
// 3a. 已投递,更新状态
|
||||
existing.setStatus(status);
|
||||
existing.setUpdateTime(Instant.now());
|
||||
userJobApplicationMapper.updateById(existing);
|
||||
} else {
|
||||
// 3b. 未投递,插入记录
|
||||
UserJobApplication application = new UserJobApplication();
|
||||
application.setUserId(userId);
|
||||
application.setJobId(jobId);
|
||||
application.setStatus(status);
|
||||
application.setApplyTime(Instant.now());
|
||||
application.setCreateTime(Instant.now());
|
||||
userJobApplicationMapper.insert(application);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user