添加简历相关CRUD

This commit is contained in:
zk
2026-04-01 17:07:46 +08:00
parent d9a854fbf2
commit 2645d610ae
22 changed files with 958 additions and 18 deletions
+2
View File
@@ -39,10 +39,12 @@ offerpie/back-end
│ └─ pojo/
│ ├─ param/
│ │ ├─ userProfile/ # 个人资料入参(UserProfileParam、各子表Param
│ │ ├─ resume/ # 简历入参(ResumeParam、各子表Param、ResumeSubTableParam
│ │ └─ job/ # 岗位相关入参(JobIntentionParam、JobQueryParam
│ ├─ dto/
│ │ ├─ SmsLoginDto.java # 短信登录入参(mobileNumber + code + inviteCode
│ │ ├─ userProfile/ # 个人资料出参(UserProfileDto、各子表Dto
│ │ ├─ resume/ # 简历出参(ResumeDto、ResumeListItemDto、各子表Dto
│ │ └─ job/ # 岗位相关出参(JobIntentionDto、JobDto、JobMatchScoreDto
│ └─ vo/
│ ├─ LoginVo.java # 登录返回(userId + nick
@@ -1,18 +1,22 @@
package org.jiayunet.controller;
import lombok.AllArgsConstructor;
import org.jiayunet.pojo.dto.resume.ResumeListItemDto;
import org.jiayunet.pojo.dto.resume.*;
import org.jiayunet.pojo.param.resume.*;
import org.jiayunet.pojo.po.*;
import org.jiayunet.service.UserResumeService;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
import java.util.stream.Collectors;
/**
* 用户简历接口
* 提供简历列表查询等功能
* <p>提供简历列表、主表及5张子表(教育/工作/实习/项目/竞赛)的查询与保存、简历删除功能</p>
* <p>所有保存接口支持自动创建:前端不传resumeId时自动创建新简历并返回resumeId</p>
*
* @author zk
*/
@@ -24,9 +28,9 @@ public class UserResumeController {
private UserResumeService userResumeService;
/**
* 查询当前用户的简历列表
*/
// ==================== 简历列表 ====================
/** 查询当前用户的简历列表 */
@GetMapping("/list")
public List<ResumeListItemDto> listResume() {
return userResumeService.listResume().stream().map(po -> {
@@ -35,4 +39,144 @@ public class UserResumeController {
return dto;
}).collect(Collectors.toList());
}
// ==================== 主表 ====================
/** 查询简历主表 */
@GetMapping
public ResumeDto getResume(@RequestParam Long resumeId) {
UserResume po = userResumeService.getResume(resumeId);
ResumeDto dto = new ResumeDto();
BeanUtils.copyProperties(po, dto);
return dto;
}
/** 保存简历主表,返回resumeId(resumeId为空则自动创建新简历) */
@PostMapping
public Long saveResume(@Validated @RequestBody ResumeParam param) {
UserResume po = new UserResume();
BeanUtils.copyProperties(param, po);
return userResumeService.saveResume(po, param.getResumeId());
}
/** 删除简历(主表 + 全部子表) */
@PostMapping("/delete")
public void deleteResume(@RequestParam Long resumeId) {
userResumeService.deleteResume(resumeId);
}
// ==================== 教育经历 ====================
/** 查询简历的教育经历列表 */
@GetMapping("/education")
public List<ResumeEducationDto> listEducation(@RequestParam Long resumeId) {
return userResumeService.listEducation(resumeId).stream().map(po -> {
ResumeEducationDto dto = new ResumeEducationDto();
BeanUtils.copyProperties(po, dto);
return dto;
}).collect(Collectors.toList());
}
/** 保存简历的教育经历列表(先删后插),返回resumeId */
@PostMapping("/education")
public Long saveEducation(@Validated @RequestBody ResumeSubTableParam<@Valid ResumeEducationParam> param) {
List<UserResumeEducation> list = param.getItems().stream().map(p -> {
UserResumeEducation po = new UserResumeEducation();
BeanUtils.copyProperties(p, po);
return po;
}).collect(Collectors.toList());
return userResumeService.saveEducationList(list, param.getResumeId());
}
// ==================== 工作经历 ====================
/** 查询简历的工作经历列表 */
@GetMapping("/work")
public List<ResumeWorkDto> listWork(@RequestParam Long resumeId) {
return userResumeService.listWork(resumeId).stream().map(po -> {
ResumeWorkDto dto = new ResumeWorkDto();
BeanUtils.copyProperties(po, dto);
return dto;
}).collect(Collectors.toList());
}
/** 保存简历的工作经历列表(先删后插),返回resumeId */
@PostMapping("/work")
public Long saveWork(@Validated @RequestBody ResumeSubTableParam<@Valid ResumeWorkParam> param) {
List<UserResumeWork> list = param.getItems().stream().map(p -> {
UserResumeWork po = new UserResumeWork();
BeanUtils.copyProperties(p, po);
return po;
}).collect(Collectors.toList());
return userResumeService.saveWorkList(list, param.getResumeId());
}
// ==================== 实习经历 ====================
/** 查询简历的实习经历列表 */
@GetMapping("/internship")
public List<ResumeInternshipDto> listInternship(@RequestParam Long resumeId) {
return userResumeService.listInternship(resumeId).stream().map(po -> {
ResumeInternshipDto dto = new ResumeInternshipDto();
BeanUtils.copyProperties(po, dto);
return dto;
}).collect(Collectors.toList());
}
/** 保存简历的实习经历列表(先删后插),返回resumeId */
@PostMapping("/internship")
public Long saveInternship(@Validated @RequestBody ResumeSubTableParam<@Valid ResumeInternshipParam> param) {
List<UserResumeInternship> list = param.getItems().stream().map(p -> {
UserResumeInternship po = new UserResumeInternship();
BeanUtils.copyProperties(p, po);
return po;
}).collect(Collectors.toList());
return userResumeService.saveInternshipList(list, param.getResumeId());
}
// ==================== 项目经历 ====================
/** 查询简历的项目经历列表 */
@GetMapping("/project")
public List<ResumeProjectDto> listProject(@RequestParam Long resumeId) {
return userResumeService.listProject(resumeId).stream().map(po -> {
ResumeProjectDto dto = new ResumeProjectDto();
BeanUtils.copyProperties(po, dto);
return dto;
}).collect(Collectors.toList());
}
/** 保存简历的项目经历列表(先删后插),返回resumeId */
@PostMapping("/project")
public Long saveProject(@Validated @RequestBody ResumeSubTableParam<@Valid ResumeProjectParam> param) {
List<UserResumeProject> list = param.getItems().stream().map(p -> {
UserResumeProject po = new UserResumeProject();
BeanUtils.copyProperties(p, po);
return po;
}).collect(Collectors.toList());
return userResumeService.saveProjectList(list, param.getResumeId());
}
// ==================== 竞赛经历 ====================
/** 查询简历的竞赛经历列表 */
@GetMapping("/competition")
public List<ResumeCompetitionDto> listCompetition(@RequestParam Long resumeId) {
return userResumeService.listCompetition(resumeId).stream().map(po -> {
ResumeCompetitionDto dto = new ResumeCompetitionDto();
BeanUtils.copyProperties(po, dto);
return dto;
}).collect(Collectors.toList());
}
/** 保存简历的竞赛经历列表(先删后插),返回resumeId */
@PostMapping("/competition")
public Long saveCompetition(@Validated @RequestBody ResumeSubTableParam<@Valid ResumeCompetitionParam> param) {
List<UserResumeCompetition> list = param.getItems().stream().map(p -> {
UserResumeCompetition po = new UserResumeCompetition();
BeanUtils.copyProperties(p, po);
return po;
}).collect(Collectors.toList());
return userResumeService.saveCompetitionList(list, param.getResumeId());
}
}
@@ -0,0 +1,29 @@
package org.jiayunet.pojo.dto.resume;
import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph;
import java.util.List;
/**
* 简历-竞赛经历返回
*
* @author zk
*/
@Data
public class ResumeCompetitionDto {
private Long id;
/** 竞赛名称 */
private String competitionName;
/** 获奖情况 */
private String award;
/** 获奖时间,格式:2023.07 */
private String awardDate;
/** 描述段落 */
private List<DescriptionParagraph> description;
}
@@ -0,0 +1,55 @@
package org.jiayunet.pojo.dto.resume;
import lombok.Data;
import java.util.List;
/**
* 简历主表返回
*
* @author zk
*/
@Data
public class ResumeDto {
private Long id;
/** 简历名称 */
private String resumeName;
/** 目标岗位 */
private String targetPosition;
/** 是否默认简历 0=否 1=是 */
private Integer isDefault;
/** 头像URL */
private String avatarUrl;
/** 真实姓名 */
private String name;
/** 邮箱 */
private String email;
/** 手机号码 */
private String mobileNumber;
/** 所在城市 */
private String city;
/** 微信号 */
private String wechatNumber;
/** 作品集链接 */
private String portfolioUrl;
/** 技能标签列表 */
private List<String> skills;
/** 证书标签列表 */
private List<String> certificates;
/** 个人概述 */
private String summary;
}
@@ -0,0 +1,38 @@
package org.jiayunet.pojo.dto.resume;
import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph;
import java.util.List;
/**
* 简历-教育经历返回
*
* @author zk
*/
@Data
public class ResumeEducationDto {
private Long id;
/** 学校名称 */
private String school;
/** 专业 */
private String major;
/** 学历:大专/本科/硕士/博士 */
private String degree;
/** 学习形式:全日制/非全日制 */
private String studyType;
/** 开始时间,格式:2023.09 */
private String startDate;
/** 结束时间,格式:2024.06 */
private String endDate;
/** 描述段落 */
private List<DescriptionParagraph> description;
}
@@ -0,0 +1,32 @@
package org.jiayunet.pojo.dto.resume;
import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph;
import java.util.List;
/**
* 简历-实习经历返回
*
* @author zk
*/
@Data
public class ResumeInternshipDto {
private Long id;
/** 公司名称 */
private String companyName;
/** 职位 */
private String position;
/** 开始时间 */
private String startDate;
/** 结束时间 */
private String endDate;
/** 描述段落 */
private List<DescriptionParagraph> description;
}
@@ -0,0 +1,35 @@
package org.jiayunet.pojo.dto.resume;
import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph;
import java.util.List;
/**
* 简历-项目经历返回
*
* @author zk
*/
@Data
public class ResumeProjectDto {
private Long id;
/** 所属公司 */
private String companyName;
/** 项目名称 */
private String projectName;
/** 担任角色 */
private String role;
/** 开始时间 */
private String startDate;
/** 结束时间 */
private String endDate;
/** 描述段落 */
private List<DescriptionParagraph> description;
}
@@ -0,0 +1,32 @@
package org.jiayunet.pojo.dto.resume;
import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph;
import java.util.List;
/**
* 简历-工作经历返回
*
* @author zk
*/
@Data
public class ResumeWorkDto {
private Long id;
/** 公司名称 */
private String companyName;
/** 职位 */
private String position;
/** 开始时间 */
private String startDate;
/** 结束时间 */
private String endDate;
/** 描述段落 */
private List<DescriptionParagraph> description;
}
@@ -0,0 +1,29 @@
package org.jiayunet.pojo.param.resume;
import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* 简历-竞赛经历保存入参
*
* @author zk
*/
@Data
public class ResumeCompetitionParam {
/** 竞赛名称 */
@NotBlank(message = "竞赛名称不能为空")
private String competitionName;
/** 获奖情况,如全国二等奖 */
private String award;
/** 获奖时间,格式:2023.07 */
private String awardDate;
/** 描述段落 */
private List<DescriptionParagraph> description;
}
@@ -0,0 +1,38 @@
package org.jiayunet.pojo.param.resume;
import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* 简历-教育经历保存入参
*
* @author zk
*/
@Data
public class ResumeEducationParam {
/** 学校名称 */
@NotBlank(message = "学校名称不能为空")
private String school;
/** 专业 */
private String major;
/** 学历:大专/本科/硕士/博士 */
private String degree;
/** 学习形式:全日制/非全日制 */
private String studyType;
/** 开始时间,格式:2023.09 */
private String startDate;
/** 结束时间,格式:2024.06 */
private String endDate;
/** 描述段落 */
private List<DescriptionParagraph> description;
}
@@ -0,0 +1,34 @@
package org.jiayunet.pojo.param.resume;
import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* 简历-实习经历保存入参
*
* @author zk
*/
@Data
public class ResumeInternshipParam {
/** 公司名称 */
@NotBlank(message = "公司名称不能为空")
private String companyName;
/** 职位 */
@NotBlank(message = "职位不能为空")
private String position;
/** 开始时间,格式:2023.06 */
@NotBlank(message = "开始时间不能为空")
private String startDate;
/** 结束时间,格式:2023.09,至今则为空 */
private String endDate;
/** 描述段落 */
private List<DescriptionParagraph> description;
}
@@ -0,0 +1,53 @@
package org.jiayunet.pojo.param.resume;
import lombok.Data;
import java.util.List;
/**
* 简历主表保存入参
*
* @author zk
*/
@Data
public class ResumeParam {
/** 简历ID,为空则自动创建新简历 */
private Long resumeId;
/** 简历名称 */
private String resumeName;
/** 目标岗位 */
private String targetPosition;
/** 头像URL */
private String avatarUrl;
/** 真实姓名 */
private String name;
/** 邮箱 */
private String email;
/** 手机号码 */
private String mobileNumber;
/** 所在城市 */
private String city;
/** 微信号 */
private String wechatNumber;
/** 作品集链接 */
private String portfolioUrl;
/** 技能标签列表 */
private List<String> skills;
/** 证书标签列表 */
private List<String> certificates;
/** 个人概述 */
private String summary;
}
@@ -0,0 +1,36 @@
package org.jiayunet.pojo.param.resume;
import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* 简历-项目经历保存入参
*
* @author zk
*/
@Data
public class ResumeProjectParam {
/** 所属公司 */
private String companyName;
/** 项目名称 */
@NotBlank(message = "项目名称不能为空")
private String projectName;
/** 担任角色 */
private String role;
/** 开始时间,格式:2023.06 */
@NotBlank(message = "开始时间不能为空")
private String startDate;
/** 结束时间,格式:2023.09,至今则为空 */
private String endDate;
/** 描述段落 */
private List<DescriptionParagraph> description;
}
@@ -0,0 +1,23 @@
package org.jiayunet.pojo.param.resume;
import lombok.Data;
import javax.validation.Valid;
import java.util.List;
/**
* 简历子表保存通用包装入参
* <p>携带可选的resumeId,为空则自动创建新简历</p>
*
* @author zk
*/
@Data
public class ResumeSubTableParam<T> {
/** 简历ID,为空则自动创建新简历 */
private Long resumeId;
/** 子表数据列表 */
@Valid
private List<T> items;
}
@@ -0,0 +1,34 @@
package org.jiayunet.pojo.param.resume;
import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank;
import java.util.List;
/**
* 简历-工作经历保存入参
*
* @author zk
*/
@Data
public class ResumeWorkParam {
/** 公司名称 */
@NotBlank(message = "公司名称不能为空")
private String companyName;
/** 职位 */
@NotBlank(message = "职位不能为空")
private String position;
/** 开始时间,格式:2023.06 */
@NotBlank(message = "开始时间不能为空")
private String startDate;
/** 结束时间,格式:2023.09,至今则为空 */
private String endDate;
/** 描述段落 */
private List<DescriptionParagraph> description;
}
@@ -1,19 +1,27 @@
package org.jiayunet.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.jiayunet.exception.BusinessException;
import org.jiayunet.exception.BusinessExpCodeEnum;
import org.jiayunet.mapper.*;
import org.jiayunet.pojo.po.*;
import org.jiayunet.tool.UserSecurityTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.Instant;
import java.util.List;
import java.util.stream.IntStream;
/**
* 用户简历服务
* <p>依赖:无</p>
* <p>使用表:bg_user_resume(简历主表查询)</p>
* <p>使用表:bg_user_resume(简历主表CRUD)、bg_user_resume_education(教育经历)、
* bg_user_resume_work(工作经历)、bg_user_resume_internship(实习经历)、
* bg_user_resume_project(项目经历)、bg_user_resume_competition(竞赛经历)</p>
*
* @author zk
*/
@@ -24,6 +32,23 @@ public class UserResumeService {
@Autowired
private UserResumeMapper userResumeMapper;
@Autowired
private UserResumeEducationMapper educationMapper;
@Autowired
private UserResumeWorkMapper workMapper;
@Autowired
private UserResumeInternshipMapper internshipMapper;
@Autowired
private UserResumeProjectMapper projectMapper;
@Autowired
private UserResumeCompetitionMapper competitionMapper;
// ==================== 简历列表 ====================
/**
* 查询当前用户的简历列表
* <p>按sort_order升序、create_time降序排列</p>
@@ -35,4 +60,299 @@ public class UserResumeService {
.orderByAsc(UserResume::getSortOrder)
.orderByDesc(UserResume::getCreateTime));
}
// ==================== 主表 ====================
/**
* 查询简历主表
* <p>校验简历归属当前用户</p>
*/
public UserResume getResume(Long resumeId) {
UserResume resume = userResumeMapper.selectById(resumeId);
checkOwnership(resume);
return resume;
}
/**
* 保存简历主表
* <p>1. resumeId为空则创建新简历(默认名"我的简历") 2. 不为空则更新 3. 返回resumeId</p>
*/
@Transactional(rollbackFor = Exception.class)
public Long saveResume(UserResume resume, Long resumeId) {
Long userId = UserSecurityTool.getUserId();
Instant now = Instant.now();
if (resumeId == null) {
// 创建新简历
resume.setUserId(userId);
if (resume.getResumeName() == null) {
resume.setResumeName("我的简历");
}
resume.setIsDefault(0);
resume.setSortOrder(0);
resume.setCreateTime(now);
resume.setUpdateTime(now);
userResumeMapper.insert(resume);
return resume.getId();
}
// 更新已有简历
UserResume existing = userResumeMapper.selectById(resumeId);
checkOwnership(existing);
resume.setId(resumeId);
resume.setUserId(userId);
resume.setCreateTime(existing.getCreateTime());
resume.setUpdateTime(now);
resume.setIsDefault(existing.getIsDefault());
resume.setSortOrder(existing.getSortOrder());
userResumeMapper.updateById(resume);
return resumeId;
}
/**
* 删除简历(物理删除主表 + 全部子表)
* <p>1. 校验归属 2. 删除5张子表 3. 删除主表</p>
*/
@Transactional(rollbackFor = Exception.class)
public void deleteResume(Long resumeId) {
UserResume resume = userResumeMapper.selectById(resumeId);
checkOwnership(resume);
// 删除全部子表
educationMapper.delete(new LambdaQueryWrapper<UserResumeEducation>().eq(UserResumeEducation::getResumeId, resumeId));
workMapper.delete(new LambdaQueryWrapper<UserResumeWork>().eq(UserResumeWork::getResumeId, resumeId));
internshipMapper.delete(new LambdaQueryWrapper<UserResumeInternship>().eq(UserResumeInternship::getResumeId, resumeId));
projectMapper.delete(new LambdaQueryWrapper<UserResumeProject>().eq(UserResumeProject::getResumeId, resumeId));
competitionMapper.delete(new LambdaQueryWrapper<UserResumeCompetition>().eq(UserResumeCompetition::getResumeId, resumeId));
// 删除主表
userResumeMapper.deleteById(resumeId);
}
// ==================== 教育经历 ====================
/** 查询简历的教育经历列表 */
public List<UserResumeEducation> listEducation(Long resumeId) {
checkResumeOwnership(resumeId);
return educationMapper.selectList(new LambdaQueryWrapper<UserResumeEducation>()
.eq(UserResumeEducation::getResumeId, resumeId)
.orderByAsc(UserResumeEducation::getSortOrder));
}
/**
* 保存简历的教育经历列表(先删后插)
* <p>1. resumeId为空则自动创建新简历 2. 按resumeId删除旧数据 3. 批量插入 4. 更新主表修改时间</p>
*/
@Transactional(rollbackFor = Exception.class)
public Long saveEducationList(List<UserResumeEducation> list, Long resumeId) {
Long userId = UserSecurityTool.getUserId();
resumeId = getOrCreateResumeId(resumeId, userId);
educationMapper.delete(new LambdaQueryWrapper<UserResumeEducation>().eq(UserResumeEducation::getResumeId, resumeId));
if (!list.isEmpty()) {
Instant now = Instant.now();
Long finalResumeId = resumeId;
IntStream.range(0, list.size()).forEach(i -> {
UserResumeEducation item = list.get(i);
item.setUserId(userId);
item.setResumeId(finalResumeId);
item.setSortOrder(i);
item.setCreateTime(now);
item.setUpdateTime(now);
});
educationMapper.batchInsert(list);
}
touchResumeUpdateTime(resumeId);
return resumeId;
}
// ==================== 工作经历 ====================
/** 查询简历的工作经历列表 */
public List<UserResumeWork> listWork(Long resumeId) {
checkResumeOwnership(resumeId);
return workMapper.selectList(new LambdaQueryWrapper<UserResumeWork>()
.eq(UserResumeWork::getResumeId, resumeId)
.orderByAsc(UserResumeWork::getSortOrder));
}
/**
* 保存简历的工作经历列表(先删后插)
* <p>1. resumeId为空则自动创建新简历 2. 按resumeId删除旧数据 3. 批量插入 4. 更新主表修改时间</p>
*/
@Transactional(rollbackFor = Exception.class)
public Long saveWorkList(List<UserResumeWork> list, Long resumeId) {
Long userId = UserSecurityTool.getUserId();
resumeId = getOrCreateResumeId(resumeId, userId);
workMapper.delete(new LambdaQueryWrapper<UserResumeWork>().eq(UserResumeWork::getResumeId, resumeId));
if (!list.isEmpty()) {
Instant now = Instant.now();
Long finalResumeId = resumeId;
IntStream.range(0, list.size()).forEach(i -> {
UserResumeWork item = list.get(i);
item.setUserId(userId);
item.setResumeId(finalResumeId);
item.setSortOrder(i);
item.setCreateTime(now);
item.setUpdateTime(now);
});
workMapper.batchInsert(list);
}
touchResumeUpdateTime(resumeId);
return resumeId;
}
// ==================== 实习经历 ====================
/** 查询简历的实习经历列表 */
public List<UserResumeInternship> listInternship(Long resumeId) {
checkResumeOwnership(resumeId);
return internshipMapper.selectList(new LambdaQueryWrapper<UserResumeInternship>()
.eq(UserResumeInternship::getResumeId, resumeId)
.orderByAsc(UserResumeInternship::getSortOrder));
}
/**
* 保存简历的实习经历列表(先删后插)
* <p>1. resumeId为空则自动创建新简历 2. 按resumeId删除旧数据 3. 批量插入 4. 更新主表修改时间</p>
*/
@Transactional(rollbackFor = Exception.class)
public Long saveInternshipList(List<UserResumeInternship> list, Long resumeId) {
Long userId = UserSecurityTool.getUserId();
resumeId = getOrCreateResumeId(resumeId, userId);
internshipMapper.delete(new LambdaQueryWrapper<UserResumeInternship>().eq(UserResumeInternship::getResumeId, resumeId));
if (!list.isEmpty()) {
Instant now = Instant.now();
Long finalResumeId = resumeId;
IntStream.range(0, list.size()).forEach(i -> {
UserResumeInternship item = list.get(i);
item.setUserId(userId);
item.setResumeId(finalResumeId);
item.setSortOrder(i);
item.setCreateTime(now);
item.setUpdateTime(now);
});
internshipMapper.batchInsert(list);
}
touchResumeUpdateTime(resumeId);
return resumeId;
}
// ==================== 项目经历 ====================
/** 查询简历的项目经历列表 */
public List<UserResumeProject> listProject(Long resumeId) {
checkResumeOwnership(resumeId);
return projectMapper.selectList(new LambdaQueryWrapper<UserResumeProject>()
.eq(UserResumeProject::getResumeId, resumeId)
.orderByAsc(UserResumeProject::getSortOrder));
}
/**
* 保存简历的项目经历列表(先删后插)
* <p>1. resumeId为空则自动创建新简历 2. 按resumeId删除旧数据 3. 批量插入 4. 更新主表修改时间</p>
*/
@Transactional(rollbackFor = Exception.class)
public Long saveProjectList(List<UserResumeProject> list, Long resumeId) {
Long userId = UserSecurityTool.getUserId();
resumeId = getOrCreateResumeId(resumeId, userId);
projectMapper.delete(new LambdaQueryWrapper<UserResumeProject>().eq(UserResumeProject::getResumeId, resumeId));
if (!list.isEmpty()) {
Instant now = Instant.now();
Long finalResumeId = resumeId;
IntStream.range(0, list.size()).forEach(i -> {
UserResumeProject item = list.get(i);
item.setUserId(userId);
item.setResumeId(finalResumeId);
item.setSortOrder(i);
item.setCreateTime(now);
item.setUpdateTime(now);
});
projectMapper.batchInsert(list);
}
touchResumeUpdateTime(resumeId);
return resumeId;
}
// ==================== 竞赛经历 ====================
/** 查询简历的竞赛经历列表 */
public List<UserResumeCompetition> listCompetition(Long resumeId) {
checkResumeOwnership(resumeId);
return competitionMapper.selectList(new LambdaQueryWrapper<UserResumeCompetition>()
.eq(UserResumeCompetition::getResumeId, resumeId)
.orderByAsc(UserResumeCompetition::getSortOrder));
}
/**
* 保存简历的竞赛经历列表(先删后插)
* <p>1. resumeId为空则自动创建新简历 2. 按resumeId删除旧数据 3. 批量插入 4. 更新主表修改时间</p>
*/
@Transactional(rollbackFor = Exception.class)
public Long saveCompetitionList(List<UserResumeCompetition> list, Long resumeId) {
Long userId = UserSecurityTool.getUserId();
resumeId = getOrCreateResumeId(resumeId, userId);
competitionMapper.delete(new LambdaQueryWrapper<UserResumeCompetition>().eq(UserResumeCompetition::getResumeId, resumeId));
if (!list.isEmpty()) {
Instant now = Instant.now();
Long finalResumeId = resumeId;
IntStream.range(0, list.size()).forEach(i -> {
UserResumeCompetition item = list.get(i);
item.setUserId(userId);
item.setResumeId(finalResumeId);
item.setSortOrder(i);
item.setCreateTime(now);
item.setUpdateTime(now);
});
competitionMapper.batchInsert(list);
}
touchResumeUpdateTime(resumeId);
return resumeId;
}
// ==================== 内部方法 ====================
/**
* 获取或创建简历,返回resumeId
* <p>resumeId为空则创建新简历(默认名"我的简历"),不为空则校验归属后返回</p>
*/
private Long getOrCreateResumeId(Long resumeId, Long userId) {
if (resumeId != null) {
checkResumeOwnership(resumeId);
return resumeId;
}
UserResume resume = new UserResume();
resume.setUserId(userId);
resume.setResumeName("我的简历");
resume.setIsDefault(0);
resume.setSortOrder(0);
Instant now = Instant.now();
resume.setCreateTime(now);
resume.setUpdateTime(now);
userResumeMapper.insert(resume);
return resume.getId();
}
/**
* 更新简历主表的修改时间
* <p>子表保存后调用,确保主表update_time反映简历整体最后修改时间</p>
*/
private void touchResumeUpdateTime(Long resumeId) {
userResumeMapper.update(null, new LambdaUpdateWrapper<UserResume>()
.eq(UserResume::getId, resumeId)
.set(UserResume::getUpdateTime, Instant.now()));
}
/**
* 校验简历归属当前用户
*/
private void checkOwnership(UserResume resume) {
Long userId = UserSecurityTool.getUserId();
if (resume == null || !resume.getUserId().equals(userId)) {
throw new BusinessException(BusinessExpCodeEnum.PERMISSION_DENIED, "简历不存在或无权操作");
}
}
/**
* 根据resumeId校验简历归属当前用户
*/
private void checkResumeOwnership(Long resumeId) {
UserResume resume = userResumeMapper.selectById(resumeId);
checkOwnership(resume);
}
}
@@ -1,6 +1,6 @@
package org.jiayunet.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jiayunet.pojo.po.UserResumeCompetition;
/**
@@ -8,5 +8,6 @@ import org.jiayunet.pojo.po.UserResumeCompetition;
*
* @author zk
*/
public interface UserResumeCompetitionMapper extends BaseMapper<UserResumeCompetition> {
@Mapper
public interface UserResumeCompetitionMapper extends CommonMapper<UserResumeCompetition> {
}
@@ -1,6 +1,6 @@
package org.jiayunet.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jiayunet.pojo.po.UserResumeEducation;
/**
@@ -8,5 +8,6 @@ import org.jiayunet.pojo.po.UserResumeEducation;
*
* @author zk
*/
public interface UserResumeEducationMapper extends BaseMapper<UserResumeEducation> {
@Mapper
public interface UserResumeEducationMapper extends CommonMapper<UserResumeEducation> {
}
@@ -1,6 +1,6 @@
package org.jiayunet.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jiayunet.pojo.po.UserResumeInternship;
/**
@@ -8,5 +8,6 @@ import org.jiayunet.pojo.po.UserResumeInternship;
*
* @author zk
*/
public interface UserResumeInternshipMapper extends BaseMapper<UserResumeInternship> {
@Mapper
public interface UserResumeInternshipMapper extends CommonMapper<UserResumeInternship> {
}
@@ -1,6 +1,6 @@
package org.jiayunet.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jiayunet.pojo.po.UserResume;
/**
@@ -8,5 +8,6 @@ import org.jiayunet.pojo.po.UserResume;
*
* @author zk
*/
public interface UserResumeMapper extends BaseMapper<UserResume> {
@Mapper
public interface UserResumeMapper extends CommonMapper<UserResume> {
}
@@ -1,6 +1,6 @@
package org.jiayunet.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jiayunet.pojo.po.UserResumeProject;
/**
@@ -8,5 +8,6 @@ import org.jiayunet.pojo.po.UserResumeProject;
*
* @author zk
*/
public interface UserResumeProjectMapper extends BaseMapper<UserResumeProject> {
@Mapper
public interface UserResumeProjectMapper extends CommonMapper<UserResumeProject> {
}
@@ -1,6 +1,6 @@
package org.jiayunet.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jiayunet.pojo.po.UserResumeWork;
/**
@@ -8,5 +8,6 @@ import org.jiayunet.pojo.po.UserResumeWork;
*
* @author zk
*/
public interface UserResumeWorkMapper extends BaseMapper<UserResumeWork> {
@Mapper
public interface UserResumeWorkMapper extends CommonMapper<UserResumeWork> {
}