Compare commits

...
4 Commits
Author SHA1 Message Date
zk 38cd49d292 添加接口 跟据个人信息创建简历 2026-07-02 14:30:17 +08:00
zk a915d709f4 处理简历不在限制非空 2026-07-02 14:12:45 +08:00
zk 80af170d18 限制个人信息参数长度 2026-07-02 11:52:25 +08:00
zk cb5ea2c7e9 处理个人信息大部分允许为null 2026-07-02 11:49:29 +08:00
15 changed files with 339 additions and 86 deletions
@@ -61,6 +61,14 @@ public class UserProfileController {
userProfileService.syncProfileFromResume(resumeId); userProfileService.syncProfileFromResume(resumeId);
} }
/**
* 根据当前用户个人资料创建一份新简历(名"个人资料简历"),返回新简历ID
*/
@PostMapping("/createResume")
public Long createResumeFromProfile() {
return userProfileService.createResumeFromProfile();
}
// ==================== 教育经历 ==================== // ==================== 教育经历 ====================
/** /**
@@ -3,7 +3,7 @@ package org.jiayunet.pojo.param.resume;
import lombok.Data; import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph; import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
/** /**
@@ -15,13 +15,15 @@ import java.util.List;
public class ResumeCompetitionParam { public class ResumeCompetitionParam {
/** 竞赛名称 */ /** 竞赛名称 */
@NotBlank(message = "竞赛名称不能为空") @Size(max = 200, message = "竞赛名称长度不能超过200")
private String competitionName; private String competitionName;
/** 获奖情况,如全国二等奖 */ /** 获奖情况,如全国二等奖 */
@Size(max = 200, message = "获奖情况长度不能超过200")
private String award; private String award;
/** 获奖时间,格式:2023.07 */ /** 获奖时间,格式:2023.07 */
@Size(max = 10, message = "获奖时间长度不能超过10")
private String awardDate; private String awardDate;
/** 描述段落 */ /** 描述段落 */
@@ -3,7 +3,7 @@ package org.jiayunet.pojo.param.resume;
import lombok.Data; import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph; import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
/** /**
@@ -15,22 +15,27 @@ import java.util.List;
public class ResumeEducationParam { public class ResumeEducationParam {
/** 学校名称 */ /** 学校名称 */
@NotBlank(message = "学校名称不能为空") @Size(max = 100, message = "学校名称长度不能超过100")
private String school; private String school;
/** 专业 */ /** 专业 */
@Size(max = 100, message = "专业长度不能超过100")
private String major; private String major;
/** 学历:大专/本科/硕士/博士 */ /** 学历:大专/本科/硕士/博士 */
@Size(max = 20, message = "学历长度不能超过20")
private String degree; private String degree;
/** 学习形式:全日制/非全日制 */ /** 学习形式:全日制/非全日制 */
@Size(max = 20, message = "学习形式长度不能超过20")
private String studyType; private String studyType;
/** 开始时间,格式:2023.09 */ /** 开始时间,格式:2023.09 */
@Size(max = 10, message = "开始时间长度不能超过10")
private String startDate; private String startDate;
/** 结束时间,格式:2024.06 */ /** 结束时间,格式:2024.06 */
@Size(max = 10, message = "结束时间长度不能超过10")
private String endDate; private String endDate;
/** 描述段落 */ /** 描述段落 */
@@ -3,7 +3,7 @@ package org.jiayunet.pojo.param.resume;
import lombok.Data; import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph; import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
/** /**
@@ -15,18 +15,19 @@ import java.util.List;
public class ResumeInternshipParam { public class ResumeInternshipParam {
/** 公司名称 */ /** 公司名称 */
@NotBlank(message = "公司名称不能为空") @Size(max = 200, message = "公司名称长度不能超过200")
private String companyName; private String companyName;
/** 职位 */ /** 职位 */
@NotBlank(message = "职位不能为空") @Size(max = 100, message = "职位长度不能超过100")
private String position; private String position;
/** 开始时间,格式:2023.06 */ /** 开始时间,格式:2023.06 */
@NotBlank(message = "开始时间不能为空") @Size(max = 10, message = "开始时间长度不能超过10")
private String startDate; private String startDate;
/** 结束时间,格式:2023.09,至今则为空 */ /** 结束时间,格式:2023.09,至今则为空 */
@Size(max = 10, message = "结束时间长度不能超过10")
private String endDate; private String endDate;
/** 描述段落 */ /** 描述段落 */
@@ -2,6 +2,7 @@ package org.jiayunet.pojo.param.resume;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
/** /**
@@ -16,30 +17,39 @@ public class ResumeParam {
private Long resumeId; private Long resumeId;
/** 简历名称 */ /** 简历名称 */
@Size(max = 100, message = "简历名称长度不能超过100")
private String resumeName; private String resumeName;
/** 目标岗位 */ /** 目标岗位 */
@Size(max = 100, message = "目标岗位长度不能超过100")
private String targetPosition; private String targetPosition;
/** 头像URL */ /** 头像URL */
@Size(max = 500, message = "头像URL长度不能超过500")
private String avatarUrl; private String avatarUrl;
/** 真实姓名 */ /** 真实姓名 */
@Size(max = 50, message = "真实姓名长度不能超过50")
private String name; private String name;
/** 邮箱 */ /** 邮箱 */
@Size(max = 100, message = "邮箱长度不能超过100")
private String email; private String email;
/** 手机号码 */ /** 手机号码 */
@Size(max = 20, message = "手机号码长度不能超过20")
private String mobileNumber; private String mobileNumber;
/** 所在城市 */ /** 所在城市 */
@Size(max = 50, message = "所在城市长度不能超过50")
private String city; private String city;
/** 微信号 */ /** 微信号 */
@Size(max = 50, message = "微信号长度不能超过50")
private String wechatNumber; private String wechatNumber;
/** 作品集链接 */ /** 作品集链接 */
@Size(max = 500, message = "作品集链接长度不能超过500")
private String portfolioUrl; private String portfolioUrl;
/** 技能标签列表 */ /** 技能标签列表 */
@@ -3,7 +3,7 @@ package org.jiayunet.pojo.param.resume;
import lombok.Data; import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph; import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
/** /**
@@ -15,20 +15,23 @@ import java.util.List;
public class ResumeProjectParam { public class ResumeProjectParam {
/** 所属公司 */ /** 所属公司 */
@Size(max = 200, message = "所属公司长度不能超过200")
private String companyName; private String companyName;
/** 项目名称 */ /** 项目名称 */
@NotBlank(message = "项目名称不能为空") @Size(max = 200, message = "项目名称长度不能超过200")
private String projectName; private String projectName;
/** 担任角色 */ /** 担任角色 */
@Size(max = 100, message = "担任角色长度不能超过100")
private String role; private String role;
/** 开始时间,格式:2023.06 */ /** 开始时间,格式:2023.06 */
@NotBlank(message = "开始时间不能为空") @Size(max = 10, message = "开始时间长度不能超过10")
private String startDate; private String startDate;
/** 结束时间,格式:2023.09,至今则为空 */ /** 结束时间,格式:2023.09,至今则为空 */
@Size(max = 10, message = "结束时间长度不能超过10")
private String endDate; private String endDate;
/** 描述段落 */ /** 描述段落 */
@@ -3,7 +3,7 @@ package org.jiayunet.pojo.param.resume;
import lombok.Data; import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph; import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
/** /**
@@ -15,18 +15,19 @@ import java.util.List;
public class ResumeWorkParam { public class ResumeWorkParam {
/** 公司名称 */ /** 公司名称 */
@NotBlank(message = "公司名称不能为空") @Size(max = 200, message = "公司名称长度不能超过200")
private String companyName; private String companyName;
/** 职位 */ /** 职位 */
@NotBlank(message = "职位不能为空") @Size(max = 100, message = "职位长度不能超过100")
private String position; private String position;
/** 开始时间,格式:2023.06 */ /** 开始时间,格式:2023.06 */
@NotBlank(message = "开始时间不能为空") @Size(max = 10, message = "开始时间长度不能超过10")
private String startDate; private String startDate;
/** 结束时间,格式:2023.09,至今则为空 */ /** 结束时间,格式:2023.09,至今则为空 */
@Size(max = 10, message = "结束时间长度不能超过10")
private String endDate; private String endDate;
/** 描述段落 */ /** 描述段落 */
@@ -3,7 +3,7 @@ package org.jiayunet.pojo.param.userProfile;
import lombok.Data; import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph; import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
/** /**
@@ -15,13 +15,15 @@ import java.util.List;
public class UserProfileCompetitionParam { public class UserProfileCompetitionParam {
/** 竞赛名称 */ /** 竞赛名称 */
@NotBlank(message = "竞赛名称不能为空") @Size(max = 200, message = "竞赛名称长度不能超过200")
private String competitionName; private String competitionName;
/** 获奖情况,如全国二等奖 */ /** 获奖情况,如全国二等奖 */
@Size(max = 100, message = "获奖情况长度不能超过100")
private String award; private String award;
/** 获奖时间,格式:2023.07 */ /** 获奖时间,格式:2023.07 */
@Size(max = 20, message = "获奖时间长度不能超过20")
private String awardDate; private String awardDate;
/** 描述段落 */ /** 描述段落 */
@@ -3,8 +3,7 @@ package org.jiayunet.pojo.param.userProfile;
import lombok.Data; import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph; import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size;
import javax.validation.constraints.NotNull;
import java.util.List; import java.util.List;
/** /**
@@ -16,23 +15,25 @@ import java.util.List;
public class UserProfileEducationParam { public class UserProfileEducationParam {
/** 学校名称 */ /** 学校名称 */
@NotBlank(message = "学校名称不能为空") @Size(max = 100, message = "学校名称长度不能超过100")
private String school; private String school;
/** 专业 */ /** 专业 */
@Size(max = 100, message = "专业长度不能超过100")
private String major; private String major;
/** 学历 1=大专 2=本科 3=硕士 4=博士 */ /** 学历 1=大专 2=本科 3=硕士 4=博士 */
@NotNull(message = "学历不能为空")
private Integer degree; private Integer degree;
/** 学习形式 0=全日制 1=非全日制 */ /** 学习形式 0=全日制 1=非全日制 */
private Integer studyType; private Integer studyType;
/** 开始时间,格式:2023.09 */ /** 开始时间,格式:2023.09 */
@Size(max = 10, message = "开始时间长度不能超过10")
private String startDate; private String startDate;
/** 结束时间,格式:2024.06 */ /** 结束时间,格式:2024.06 */
@Size(max = 10, message = "结束时间长度不能超过10")
private String endDate; private String endDate;
/** 描述段落 */ /** 描述段落 */
@@ -3,7 +3,7 @@ package org.jiayunet.pojo.param.userProfile;
import lombok.Data; import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph; import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
/** /**
@@ -15,18 +15,19 @@ import java.util.List;
public class UserProfileInternshipParam { public class UserProfileInternshipParam {
/** 公司名称 */ /** 公司名称 */
@NotBlank(message = "公司名称不能为空") @Size(max = 100, message = "公司名称长度不能超过100")
private String companyName; private String companyName;
/** 职位 */ /** 职位 */
@NotBlank(message = "职位不能为空") @Size(max = 100, message = "职位长度不能超过100")
private String position; private String position;
/** 开始时间,格式:2023.06 */ /** 开始时间,格式:2023.06 */
@NotBlank(message = "开始时间不能为空") @Size(max = 10, message = "开始时间长度不能超过10")
private String startDate; private String startDate;
/** 结束时间,格式:2023.09,至今则为空 */ /** 结束时间,格式:2023.09,至今则为空 */
@Size(max = 10, message = "结束时间长度不能超过10")
private String endDate; private String endDate;
/** 描述段落 */ /** 描述段落 */
@@ -2,7 +2,7 @@ package org.jiayunet.pojo.param.userProfile;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
/** /**
@@ -14,25 +14,31 @@ import java.util.List;
public class UserProfileParam { public class UserProfileParam {
/** 真实姓名 */ /** 真实姓名 */
@Size(max = 50, message = "真实姓名长度不能超过50")
private String name; private String name;
/** 邮箱 */ /** 邮箱 */
@Size(max = 100, message = "邮箱长度不能超过100")
private String email; private String email;
/** 手机号码 */ /** 手机号码 */
@Size(max = 50, message = "手机号码长度不能超过50")
private String mobileNumber; private String mobileNumber;
/** 身份证号 */ /** 身份证号 */
@Size(max = 50, message = "身份证号长度不能超过50")
private String idCard; private String idCard;
/** 所在城市编码 */ /** 所在城市编码 */
@NotBlank(message = "所在城市不能为空") @Size(max = 20, message = "所在城市编码长度不能超过20")
private String regionCode; private String regionCode;
/** 微信号 */ /** 微信号 */
@Size(max = 50, message = "微信号长度不能超过50")
private String wechatNumber; private String wechatNumber;
/** 作品集链接 */ /** 作品集链接 */
@Size(max = 500, message = "作品集链接长度不能超过500")
private String portfolioUrl; private String portfolioUrl;
/** 工作年限 */ /** 工作年限 */
@@ -3,7 +3,7 @@ package org.jiayunet.pojo.param.userProfile;
import lombok.Data; import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph; import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
/** /**
@@ -15,20 +15,23 @@ import java.util.List;
public class UserProfileProjectParam { public class UserProfileProjectParam {
/** 所属公司 */ /** 所属公司 */
@Size(max = 100, message = "所属公司长度不能超过100")
private String companyName; private String companyName;
/** 项目名称 */ /** 项目名称 */
@NotBlank(message = "项目名称不能为空") @Size(max = 200, message = "项目名称长度不能超过200")
private String projectName; private String projectName;
/** 担任角色 */ /** 担任角色 */
@Size(max = 100, message = "担任角色长度不能超过100")
private String role; private String role;
/** 开始时间,格式:2023.06 */ /** 开始时间,格式:2023.06 */
@NotBlank(message = "开始时间不能为空") @Size(max = 10, message = "开始时间长度不能超过10")
private String startDate; private String startDate;
/** 结束时间,格式:2023.09,至今则为空 */ /** 结束时间,格式:2023.09,至今则为空 */
@Size(max = 10, message = "结束时间长度不能超过10")
private String endDate; private String endDate;
/** 描述段落 */ /** 描述段落 */
@@ -3,7 +3,7 @@ package org.jiayunet.pojo.param.userProfile;
import lombok.Data; import lombok.Data;
import org.jiayunet.pojo.vo.DescriptionParagraph; import org.jiayunet.pojo.vo.DescriptionParagraph;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size;
import java.util.List; import java.util.List;
/** /**
@@ -15,18 +15,19 @@ import java.util.List;
public class UserProfileWorkParam { public class UserProfileWorkParam {
/** 公司名称 */ /** 公司名称 */
@NotBlank(message = "公司名称不能为空") @Size(max = 100, message = "公司名称长度不能超过100")
private String companyName; private String companyName;
/** 职位 */ /** 职位 */
@NotBlank(message = "职位不能为空") @Size(max = 100, message = "职位长度不能超过100")
private String position; private String position;
/** 开始时间,格式:2023.06 */ /** 开始时间,格式:2023.06 */
@NotBlank(message = "开始时间不能为空") @Size(max = 10, message = "开始时间长度不能超过10")
private String startDate; private String startDate;
/** 结束时间,格式:2023.09,至今则为空 */ /** 结束时间,格式:2023.09,至今则为空 */
@Size(max = 10, message = "结束时间长度不能超过10")
private String endDate; private String endDate;
/** 描述段落 */ /** 描述段落 */
@@ -80,6 +80,16 @@ public class UserProfileService {
"全日制", 0, "非全日制", 1 "全日制", 0, "非全日制", 1
); );
/** 学历枚举→文本映射(个人资料→简历反向映射) */
private static final Map<Integer, String> REVERSE_DEGREE_MAP = Map.of(
1, "大专", 2, "本科", 3, "硕士", 4, "博士"
);
/** 学习形式枚举→文本映射(个人资料→简历反向映射) */
private static final Map<Integer, String> REVERSE_STUDY_TYPE_MAP = Map.of(
0, "全日制", 1, "非全日制"
);
// ==================== 主表 ==================== // ==================== 主表 ====================
/** 查询当前用户个人资料 */ /** 查询当前用户个人资料 */
@@ -89,9 +99,14 @@ public class UserProfileService {
new LambdaQueryWrapper<UserProfile>().eq(UserProfile::getUserId, userId)); new LambdaQueryWrapper<UserProfile>().eq(UserProfile::getUserId, userId));
} }
/** JSON字段的TypeHandlerUpdateWrapper显式set时需指定,否则JSON字段不会正确序列化 */
private static final String JSON_TYPE_HANDLER = "typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler";
/** /**
* 保存个人资料主表(upsert) * 保存个人资料主表(upsert)
* <p>1. 按userId查询是否存在 2. 存在则更新,不存在则插入</p> * <p>1. 按userId查询是否存在 2. 存在则更新,不存在则插入</p>
* <p>更新时用LambdaUpdateWrapper显式set用户可编辑字段(允许清空为null,绕过全局update-strategy=not_null),
* AI派生字段(schoolRank/companyPrestige/majorIds/honors等)不在更新范围内,保留原值</p>
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void saveProfile(UserProfile profile) { public void saveProfile(UserProfile profile) {
@@ -100,11 +115,18 @@ public class UserProfileService {
new LambdaQueryWrapper<UserProfile>().eq(UserProfile::getUserId, userId)); new LambdaQueryWrapper<UserProfile>().eq(UserProfile::getUserId, userId));
Instant now = Instant.now(); Instant now = Instant.now();
if (existing != null) { if (existing != null) {
profile.setId(existing.getId()); userProfileMapper.update(null, new com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper<UserProfile>()
profile.setUserId(userId); .eq(UserProfile::getId, existing.getId())
profile.setCreateTime(existing.getCreateTime()); .set(UserProfile::getName, profile.getName())
profile.setUpdateTime(now); .set(UserProfile::getEmail, profile.getEmail())
userProfileMapper.updateById(profile); .set(UserProfile::getMobileNumber, profile.getMobileNumber())
.set(UserProfile::getIdCard, profile.getIdCard())
.set(UserProfile::getRegionCode, profile.getRegionCode())
.set(UserProfile::getWechatNumber, profile.getWechatNumber())
.set(UserProfile::getPortfolioUrl, profile.getPortfolioUrl())
.set(UserProfile::getSkills, profile.getSkills(), JSON_TYPE_HANDLER)
.set(UserProfile::getCertificates, profile.getCertificates(), JSON_TYPE_HANDLER)
.set(UserProfile::getUpdateTime, now));
} else { } else {
profile.setUserId(userId); profile.setUserId(userId);
profile.setCreateTime(now); profile.setCreateTime(now);
@@ -329,15 +351,18 @@ public class UserProfileService {
Long profileId; Long profileId;
if (existing != null) { if (existing != null) {
profileId = existing.getId(); profileId = existing.getId();
existing.setName(resume.getName()); // A语义:严格镜像简历共有字段(含清空为null),与子表先删后插的镜像行为一致;
existing.setEmail(resume.getEmail()); // idCard/regionCode及AI派生字段(schoolRank/majorIds等)为个人资料独有,不在同步范围
existing.setMobileNumber(resume.getMobileNumber()); userProfileMapper.update(null, new com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper<UserProfile>()
existing.setWechatNumber(resume.getWechatNumber()); .eq(UserProfile::getId, profileId)
existing.setPortfolioUrl(resume.getPortfolioUrl()); .set(UserProfile::getName, resume.getName())
existing.setSkills(resume.getSkills()); .set(UserProfile::getEmail, resume.getEmail())
existing.setCertificates(resume.getCertificates()); .set(UserProfile::getMobileNumber, resume.getMobileNumber())
existing.setUpdateTime(now); .set(UserProfile::getWechatNumber, resume.getWechatNumber())
userProfileMapper.updateById(existing); .set(UserProfile::getPortfolioUrl, resume.getPortfolioUrl())
.set(UserProfile::getSkills, resume.getSkills(), JSON_TYPE_HANDLER)
.set(UserProfile::getCertificates, resume.getCertificates(), JSON_TYPE_HANDLER)
.set(UserProfile::getUpdateTime, now));
} else { } else {
UserProfile profile = new UserProfile(); UserProfile profile = new UserProfile();
profile.setUserId(userId); profile.setUserId(userId);
@@ -465,6 +490,162 @@ public class UserProfileService {
userProfileAnalyzeService.analyzeUserProfile(userId); userProfileAnalyzeService.analyzeUserProfile(userId);
} }
// ==================== 从个人资料生成简历 ====================
/**
* 根据当前用户的个人资料创建一份新简历
* <p>syncProfileFromResume 的反向操作:读取个人资料主表+5子表,新建一份简历(名"个人资料简历")及对应子表,返回新简历ID</p>
* <p>1. 校验个人资料存在 2. 读取个人资料5子表 3. 新建简历主表(复制共有字段,简历独有字段targetPosition/avatarUrl/city/summary留空)
* 4. 转换并批量插入5张简历子表(含degree/studyType反向映射) 5. 返回新简历ID</p>
* <p>注意:这是创建新简历(非覆盖),不删除已有简历;简历侧无AI分析,故不触发分析</p>
*/
@Transactional(rollbackFor = Exception.class)
public Long createResumeFromProfile() {
Long userId = UserSecurityTool.getUserId();
// 1. 校验个人资料存在
UserProfile profile = userProfileMapper.selectOne(
new LambdaQueryWrapper<UserProfile>().eq(UserProfile::getUserId, userId));
if (profile == null) {
throw new BusinessException(BusinessExpCodeEnum.DATA_NOT_EXIST, "个人资料不存在");
}
Long profileId = profile.getId();
// 2. 读取个人资料5张子表
List<UserProfileEducation> profileEducationList = educationMapper.selectList(new LambdaQueryWrapper<UserProfileEducation>().eq(UserProfileEducation::getProfileId, profileId).orderByAsc(UserProfileEducation::getSortOrder));
List<UserProfileWork> profileWorkList = workMapper.selectList(new LambdaQueryWrapper<UserProfileWork>().eq(UserProfileWork::getProfileId, profileId).orderByAsc(UserProfileWork::getSortOrder));
List<UserProfileInternship> profileInternshipList = internshipMapper.selectList(new LambdaQueryWrapper<UserProfileInternship>().eq(UserProfileInternship::getProfileId, profileId).orderByAsc(UserProfileInternship::getSortOrder));
List<UserProfileProject> profileProjectList = projectMapper.selectList(new LambdaQueryWrapper<UserProfileProject>().eq(UserProfileProject::getProfileId, profileId).orderByAsc(UserProfileProject::getSortOrder));
List<UserProfileCompetition> profileCompetitionList = competitionMapper.selectList(new LambdaQueryWrapper<UserProfileCompetition>().eq(UserProfileCompetition::getProfileId, profileId).orderByAsc(UserProfileCompetition::getSortOrder));
Instant now = Instant.now();
// 3. 新建简历主表(复制共有字段,简历独有字段targetPosition/avatarUrl/city/summary留空)
UserResume resume = new UserResume();
resume.setUserId(userId);
resume.setResumeName("个人资料简历");
resume.setName(profile.getName());
resume.setEmail(profile.getEmail());
resume.setMobileNumber(profile.getMobileNumber());
resume.setWechatNumber(profile.getWechatNumber());
resume.setPortfolioUrl(profile.getPortfolioUrl());
resume.setSkills(profile.getSkills());
resume.setCertificates(profile.getCertificates());
// 无简历时新建的这份自动设为默认,与 UserResumeService.saveResume 逻辑一致
boolean hasResume = userResumeMapper.selectCount(new LambdaQueryWrapper<UserResume>().eq(UserResume::getUserId, userId)) > 0;
resume.setIsDefault(hasResume ? 0 : 1);
resume.setSortOrder(0);
resume.setCreateTime(now);
resume.setUpdateTime(now);
userResumeMapper.insert(resume);
Long resumeId = resume.getId();
// 4. 转换并插入简历教育经历(含degree/studyType枚举→文本反向映射)
if (!profileEducationList.isEmpty()) {
List<UserResumeEducation> resumeEducationList = IntStream.range(0, profileEducationList.size()).mapToObj(i -> {
UserProfileEducation src = profileEducationList.get(i);
UserResumeEducation dest = new UserResumeEducation();
dest.setResumeId(resumeId);
dest.setUserId(userId);
dest.setSchool(src.getSchool());
dest.setMajor(src.getMajor());
dest.setDegree(Objects.isNull(src.getDegree()) ? null : REVERSE_DEGREE_MAP.get(src.getDegree()));
dest.setStudyType(Objects.isNull(src.getStudyType()) ? null : REVERSE_STUDY_TYPE_MAP.get(src.getStudyType()));
dest.setStartDate(src.getStartDate());
dest.setEndDate(src.getEndDate());
dest.setDescription(src.getDescription());
dest.setSortOrder(i);
dest.setCreateTime(now);
dest.setUpdateTime(now);
return dest;
}).collect(Collectors.toList());
resumeEducationMapper.batchInsert(resumeEducationList);
}
// 5. 转换并插入简历工作经历
if (!profileWorkList.isEmpty()) {
List<UserResumeWork> resumeWorkList = IntStream.range(0, profileWorkList.size()).mapToObj(i -> {
UserProfileWork src = profileWorkList.get(i);
UserResumeWork dest = new UserResumeWork();
dest.setResumeId(resumeId);
dest.setUserId(userId);
dest.setCompanyName(src.getCompanyName());
dest.setPosition(src.getPosition());
dest.setStartDate(src.getStartDate());
dest.setEndDate(src.getEndDate());
dest.setDescription(src.getDescription());
dest.setSortOrder(i);
dest.setCreateTime(now);
dest.setUpdateTime(now);
return dest;
}).collect(Collectors.toList());
resumeWorkMapper.batchInsert(resumeWorkList);
}
// 6. 转换并插入简历实习经历
if (!profileInternshipList.isEmpty()) {
List<UserResumeInternship> resumeInternshipList = IntStream.range(0, profileInternshipList.size()).mapToObj(i -> {
UserProfileInternship src = profileInternshipList.get(i);
UserResumeInternship dest = new UserResumeInternship();
dest.setResumeId(resumeId);
dest.setUserId(userId);
dest.setCompanyName(src.getCompanyName());
dest.setPosition(src.getPosition());
dest.setStartDate(src.getStartDate());
dest.setEndDate(src.getEndDate());
dest.setDescription(src.getDescription());
dest.setSortOrder(i);
dest.setCreateTime(now);
dest.setUpdateTime(now);
return dest;
}).collect(Collectors.toList());
resumeInternshipMapper.batchInsert(resumeInternshipList);
}
// 7. 转换并插入简历项目经历
if (!profileProjectList.isEmpty()) {
List<UserResumeProject> resumeProjectList = IntStream.range(0, profileProjectList.size()).mapToObj(i -> {
UserProfileProject src = profileProjectList.get(i);
UserResumeProject dest = new UserResumeProject();
dest.setResumeId(resumeId);
dest.setUserId(userId);
dest.setCompanyName(src.getCompanyName());
dest.setProjectName(src.getProjectName());
dest.setRole(src.getRole());
dest.setStartDate(src.getStartDate());
dest.setEndDate(src.getEndDate());
dest.setDescription(src.getDescription());
dest.setSortOrder(i);
dest.setCreateTime(now);
dest.setUpdateTime(now);
return dest;
}).collect(Collectors.toList());
resumeProjectMapper.batchInsert(resumeProjectList);
}
// 8. 转换并插入简历竞赛经历
if (!profileCompetitionList.isEmpty()) {
List<UserResumeCompetition> resumeCompetitionList = IntStream.range(0, profileCompetitionList.size()).mapToObj(i -> {
UserProfileCompetition src = profileCompetitionList.get(i);
UserResumeCompetition dest = new UserResumeCompetition();
dest.setResumeId(resumeId);
dest.setUserId(userId);
dest.setCompetitionName(src.getCompetitionName());
dest.setAward(src.getAward());
dest.setAwardDate(src.getAwardDate());
dest.setDescription(src.getDescription());
dest.setSortOrder(i);
dest.setCreateTime(now);
dest.setUpdateTime(now);
return dest;
}).collect(Collectors.toList());
resumeCompetitionMapper.batchInsert(resumeCompetitionList);
}
// 9. 返回新简历ID
return resumeId;
}
// ==================== 内部方法 ==================== // ==================== 内部方法 ====================
/** /**
@@ -40,6 +40,9 @@ public class UserResumeService {
@Value("${app.resume.max-count:5}") @Value("${app.resume.max-count:5}")
private int maxResumeCount; private int maxResumeCount;
/** JSON字段的TypeHandlerUpdateWrapper显式set时需指定,否则JSON字段不会正确序列化 */
private static final String JSON_TYPE_HANDLER = "typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler";
@Autowired @Autowired
private UserResumeEducationMapper educationMapper; private UserResumeEducationMapper educationMapper;
@@ -115,16 +118,24 @@ public class UserResumeService {
userResumeMapper.insert(resume); userResumeMapper.insert(resume);
return resume.getId(); return resume.getId();
} }
// 更新已有简历 // 更新已有简历(用户可编辑字段用LambdaUpdateWrapper显式set,允许清空为null,绕过全局update-strategy=not_null
UserResume existing = userResumeMapper.selectById(resumeId); UserResume existing = userResumeMapper.selectById(resumeId);
checkOwnership(existing); checkOwnership(existing);
resume.setId(resumeId); userResumeMapper.update(null, new LambdaUpdateWrapper<UserResume>()
resume.setUserId(userId); .eq(UserResume::getId, resumeId)
resume.setCreateTime(existing.getCreateTime()); .set(UserResume::getResumeName, resume.getResumeName())
resume.setUpdateTime(now); .set(UserResume::getTargetPosition, resume.getTargetPosition())
resume.setIsDefault(existing.getIsDefault()); .set(UserResume::getAvatarUrl, resume.getAvatarUrl())
resume.setSortOrder(existing.getSortOrder()); .set(UserResume::getName, resume.getName())
userResumeMapper.updateById(resume); .set(UserResume::getEmail, resume.getEmail())
.set(UserResume::getMobileNumber, resume.getMobileNumber())
.set(UserResume::getCity, resume.getCity())
.set(UserResume::getWechatNumber, resume.getWechatNumber())
.set(UserResume::getPortfolioUrl, resume.getPortfolioUrl())
.set(UserResume::getSkills, resume.getSkills(), JSON_TYPE_HANDLER)
.set(UserResume::getCertificates, resume.getCertificates(), JSON_TYPE_HANDLER)
.set(UserResume::getSummary, resume.getSummary())
.set(UserResume::getUpdateTime, now));
return resumeId; return resumeId;
} }
@@ -491,12 +502,17 @@ public class UserResumeService {
UserResumeEducation existing = educationMapper.selectById(po.getId()); UserResumeEducation existing = educationMapper.selectById(po.getId());
Assert.notNull(existing, "教育经历不存在"); Assert.notNull(existing, "教育经历不存在");
checkResumeOwnership(existing.getResumeId()); checkResumeOwnership(existing.getResumeId());
po.setResumeId(existing.getResumeId()); // 显式set用户可编辑字段(允许清空为null);resumeId/userId/sortOrder/createTime保留原值
po.setUserId(existing.getUserId()); educationMapper.update(null, new LambdaUpdateWrapper<UserResumeEducation>()
po.setSortOrder(existing.getSortOrder()); .eq(UserResumeEducation::getId, po.getId())
po.setCreateTime(existing.getCreateTime()); .set(UserResumeEducation::getSchool, po.getSchool())
po.setUpdateTime(Instant.now()); .set(UserResumeEducation::getMajor, po.getMajor())
educationMapper.updateById(po); .set(UserResumeEducation::getDegree, po.getDegree())
.set(UserResumeEducation::getStudyType, po.getStudyType())
.set(UserResumeEducation::getStartDate, po.getStartDate())
.set(UserResumeEducation::getEndDate, po.getEndDate())
.set(UserResumeEducation::getDescription, po.getDescription(), JSON_TYPE_HANDLER)
.set(UserResumeEducation::getUpdateTime, Instant.now()));
touchResumeUpdateTime(existing.getResumeId()); touchResumeUpdateTime(existing.getResumeId());
} }
@@ -509,12 +525,15 @@ public class UserResumeService {
UserResumeWork existing = workMapper.selectById(po.getId()); UserResumeWork existing = workMapper.selectById(po.getId());
Assert.notNull(existing, "工作经历不存在"); Assert.notNull(existing, "工作经历不存在");
checkResumeOwnership(existing.getResumeId()); checkResumeOwnership(existing.getResumeId());
po.setResumeId(existing.getResumeId()); // 显式set用户可编辑字段(允许清空为null);resumeId/userId/sortOrder/createTime保留原值
po.setUserId(existing.getUserId()); workMapper.update(null, new LambdaUpdateWrapper<UserResumeWork>()
po.setSortOrder(existing.getSortOrder()); .eq(UserResumeWork::getId, po.getId())
po.setCreateTime(existing.getCreateTime()); .set(UserResumeWork::getCompanyName, po.getCompanyName())
po.setUpdateTime(Instant.now()); .set(UserResumeWork::getPosition, po.getPosition())
workMapper.updateById(po); .set(UserResumeWork::getStartDate, po.getStartDate())
.set(UserResumeWork::getEndDate, po.getEndDate())
.set(UserResumeWork::getDescription, po.getDescription(), JSON_TYPE_HANDLER)
.set(UserResumeWork::getUpdateTime, Instant.now()));
touchResumeUpdateTime(existing.getResumeId()); touchResumeUpdateTime(existing.getResumeId());
} }
@@ -527,12 +546,15 @@ public class UserResumeService {
UserResumeInternship existing = internshipMapper.selectById(po.getId()); UserResumeInternship existing = internshipMapper.selectById(po.getId());
Assert.notNull(existing, "实习经历不存在"); Assert.notNull(existing, "实习经历不存在");
checkResumeOwnership(existing.getResumeId()); checkResumeOwnership(existing.getResumeId());
po.setResumeId(existing.getResumeId()); // 显式set用户可编辑字段(允许清空为null);resumeId/userId/sortOrder/createTime保留原值
po.setUserId(existing.getUserId()); internshipMapper.update(null, new LambdaUpdateWrapper<UserResumeInternship>()
po.setSortOrder(existing.getSortOrder()); .eq(UserResumeInternship::getId, po.getId())
po.setCreateTime(existing.getCreateTime()); .set(UserResumeInternship::getCompanyName, po.getCompanyName())
po.setUpdateTime(Instant.now()); .set(UserResumeInternship::getPosition, po.getPosition())
internshipMapper.updateById(po); .set(UserResumeInternship::getStartDate, po.getStartDate())
.set(UserResumeInternship::getEndDate, po.getEndDate())
.set(UserResumeInternship::getDescription, po.getDescription(), JSON_TYPE_HANDLER)
.set(UserResumeInternship::getUpdateTime, Instant.now()));
touchResumeUpdateTime(existing.getResumeId()); touchResumeUpdateTime(existing.getResumeId());
} }
@@ -545,12 +567,16 @@ public class UserResumeService {
UserResumeProject existing = projectMapper.selectById(po.getId()); UserResumeProject existing = projectMapper.selectById(po.getId());
Assert.notNull(existing, "项目经历不存在"); Assert.notNull(existing, "项目经历不存在");
checkResumeOwnership(existing.getResumeId()); checkResumeOwnership(existing.getResumeId());
po.setResumeId(existing.getResumeId()); // 显式set用户可编辑字段(允许清空为null);resumeId/userId/sortOrder/createTime保留原值
po.setUserId(existing.getUserId()); projectMapper.update(null, new LambdaUpdateWrapper<UserResumeProject>()
po.setSortOrder(existing.getSortOrder()); .eq(UserResumeProject::getId, po.getId())
po.setCreateTime(existing.getCreateTime()); .set(UserResumeProject::getCompanyName, po.getCompanyName())
po.setUpdateTime(Instant.now()); .set(UserResumeProject::getProjectName, po.getProjectName())
projectMapper.updateById(po); .set(UserResumeProject::getRole, po.getRole())
.set(UserResumeProject::getStartDate, po.getStartDate())
.set(UserResumeProject::getEndDate, po.getEndDate())
.set(UserResumeProject::getDescription, po.getDescription(), JSON_TYPE_HANDLER)
.set(UserResumeProject::getUpdateTime, Instant.now()));
touchResumeUpdateTime(existing.getResumeId()); touchResumeUpdateTime(existing.getResumeId());
} }
@@ -563,12 +589,14 @@ public class UserResumeService {
UserResumeCompetition existing = competitionMapper.selectById(po.getId()); UserResumeCompetition existing = competitionMapper.selectById(po.getId());
Assert.notNull(existing, "竞赛经历不存在"); Assert.notNull(existing, "竞赛经历不存在");
checkResumeOwnership(existing.getResumeId()); checkResumeOwnership(existing.getResumeId());
po.setResumeId(existing.getResumeId()); // 显式set用户可编辑字段(允许清空为null);resumeId/userId/sortOrder/createTime保留原值
po.setUserId(existing.getUserId()); competitionMapper.update(null, new LambdaUpdateWrapper<UserResumeCompetition>()
po.setSortOrder(existing.getSortOrder()); .eq(UserResumeCompetition::getId, po.getId())
po.setCreateTime(existing.getCreateTime()); .set(UserResumeCompetition::getCompetitionName, po.getCompetitionName())
po.setUpdateTime(Instant.now()); .set(UserResumeCompetition::getAward, po.getAward())
competitionMapper.updateById(po); .set(UserResumeCompetition::getAwardDate, po.getAwardDate())
.set(UserResumeCompetition::getDescription, po.getDescription(), JSON_TYPE_HANDLER)
.set(UserResumeCompetition::getUpdateTime, Instant.now()));
touchResumeUpdateTime(existing.getResumeId()); touchResumeUpdateTime(existing.getResumeId());
} }