feat: 新增查看职位下简历的接口

This commit is contained in:
wangjx 2025-02-22 11:37:51 +08:00
parent 3aacff04ce
commit 3942ae7513
4 changed files with 58 additions and 16 deletions

View File

@ -24,6 +24,10 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/**
* @author wangjx
* @data 2025.2.21
*/
@RestController @RestController
@Api(tags = "职位管理") @Api(tags = "职位管理")
@RequestMapping("recruit/position") @RequestMapping("recruit/position")

View File

@ -4,6 +4,7 @@ import cn.zgfxrc.boot.common.core.entity.interfaces.AddGroup;
import cn.zgfxrc.boot.common.core.entity.interfaces.DelGroup; import cn.zgfxrc.boot.common.core.entity.interfaces.DelGroup;
import cn.zgfxrc.boot.common.core.entity.interfaces.EditGroup; import cn.zgfxrc.boot.common.core.entity.interfaces.EditGroup;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -19,15 +20,11 @@ import io.swagger.annotations.ApiParam;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.UUID;
import javax.validation.Valid; import javax.validation.Valid;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @author huanghs@zgfxrc.cn * @author huanghs@zgfxrc.cn
@ -115,32 +112,65 @@ public class RecruitResumeController {
} }
/** /**
* 把简历投给职位通过外键去关联表 选完职位点击确定投递才会触发这边 * 把简历投给职位通过外键去关联表
*
* @param entity 实体类
* @author wangjx
* @data 2025.2.21
*/ */
@Log("投递") @Log("投递")
@ApiOperation("根据外键去关联,将简历投给职位") @ApiOperation("根据外键去关联,将简历投给职位")
@PostMapping("add_delivery") @PostMapping("add_delivery")
public void addDelivery( public void addDelivery(
@ApiParam("简历信息,包含关联职位的外键 positionId") @ApiParam("简历信息,包含关联职位的外键 positionId") @RequestBody @Valid RecruitResume entity) {
@RequestBody @Valid RecruitResume entity) {
// 检查职位 ID 是否为空如果为空则抛出异常 // 检查职位 ID 是否为空如果为空则抛出异常
if (entity.getPositionId() == null) { if (entity.getPositionId() == null) {
throw new RuntimeException("关联的职位 ID 不能为空"); throw new RuntimeException("关联的职位 ID 不能为空");
} }
// 检查简历 id 是否为空如果为空则抛出异常
// 检查 id 是否为空如果为空则生成 UUID
if (entity.getId() == null) { if (entity.getId() == null) {
entity.setId(Long.valueOf(UUID.randomUUID().toString())); throw new RuntimeException("关联的简历 ID 不能为空");
} }
// 设置创建时间为当前时间 // 创建更新条件包装器根据简历 id 进行更新
entity.setCreateTime(Timestamp.valueOf(LocalDateTime.now()).toLocalDateTime()); UpdateWrapper<RecruitResume> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", entity.getId());
// 调用服务层的 save 方法保存简历信息 // 创建要更新的字段
boolean result = service.save(entity); RecruitResume updateEntity = new RecruitResume();
updateEntity.setPositionId(entity.getPositionId());
// 设置更新时间为当前时间
updateEntity.setUpdateTime(Timestamp.valueOf(LocalDateTime.now()).toLocalDateTime());
// 调用服务层的 update 方法更新简历信息
boolean result = service.update(updateEntity, updateWrapper);
if (!result) { if (!result) {
throw new RuntimeException("简历投递失败"); throw new RuntimeException("简历投递失败");
} }
} }
}
/**
* 根据传进来的职位id查询目标下面的简历
*
* @param positionId 职位id
* @author wangjx
* @data 2025.2.22
*/
@Log("查询岗位下的简历")
@ApiOperation("根据传进来的职位id查询目标下面的简历")
@GetMapping("getResumesByPositionId")
public List<RecruitResume> getResumesByPositionId(
@ApiParam("职位id") @RequestParam String positionId) {
// 检查职位 ID 是否为空如果为空则抛出异常
if (positionId == null || positionId.isEmpty() || positionId.equals("null")) {
throw new RuntimeException("职位 ID 不能为空");
}
// 创建查询条件包装器根据职位id进行查询
LambdaQueryWrapper<RecruitResume> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(RecruitResume::getPositionId, positionId);
// 调用服务层的 list 方法查询简历信息
return service.list(queryWrapper);
}
} }

View File

@ -4,5 +4,9 @@ import cn.zgfxrc.boot.common.mybatis.base.MpBaseMapper;
import com.rsjst.hcm.recruit.api.entity.RecruitPositionPojo; import com.rsjst.hcm.recruit.api.entity.RecruitPositionPojo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/**
* @author wangjx
* @data 2025.2.21
*/
@Mapper @Mapper
public interface RecruitPositionMapper extends MpBaseMapper<RecruitPositionPojo> {} public interface RecruitPositionMapper extends MpBaseMapper<RecruitPositionPojo> {}

View File

@ -11,6 +11,10 @@ import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/**
* @author wangjx
* @data 2025.2.21
*/
@Slf4j @Slf4j
@Service @Service
@AllArgsConstructor @AllArgsConstructor