修改bug

This commit is contained in:
zk
2026-03-20 18:59:07 +08:00
parent 28e551285d
commit 7e5171d637
3 changed files with 58 additions and 18 deletions
@@ -10,11 +10,13 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.Instant;
/**
* 求职意向服务
* 主要功能:用户求职意向的查询和保存
* 依赖服务:无
* 使用的表:bg_user_job_intention
* <p>主要功能:用户求职意向的查询和保存</p>
* <p>依赖服务:无</p>
* <p>使用的表:bg_user_job_intention</p>
*
* @author zk
*/
@@ -25,7 +27,7 @@ public class JobIntentionService {
/**
* 查询当前用户的求职意向
* 逻辑:根据userId查询,不存在返回null
* <p>根据userId查询,不存在返回null</p>
*/
public JobIntentionDto getJobIntention() {
Long userId = UserSecurityTool.getUserId();
@@ -40,18 +42,28 @@ public class JobIntentionService {
/**
* 保存/更新求职意向
* 逻辑:先查询是否存在,存在则更新,不存在则新增
* <p>先查询是否存在,存在则更新,不存在则新增</p>
*/
public void saveJobIntention(JobIntentionParam param) {
Long userId = UserSecurityTool.getUserId();
UserJobIntention po = intentionMapper.selectOne(new LambdaQueryWrapper<UserJobIntention>().eq(UserJobIntention::getUserId, userId));
if (po == null) {
po = new UserJobIntention();
po.setUserId(userId);
BeanUtils.copyProperties(param, po);
po.setCategoryIds(param.getCategoryIds() != null ? param.getCategoryIds() : java.util.Collections.emptyList());
po.setRegionCodes(param.getRegionCodes() != null ? param.getRegionCodes() : java.util.Collections.emptyList());
po.setIndustryIds(param.getIndustryIds() != null ? param.getIndustryIds() : java.util.Collections.emptyList());
po.setEmploymentType(param.getEmploymentType());
po.setCreateTime(Instant.now());
po.setUpdateTime(Instant.now());
intentionMapper.insert(po);
} else {
BeanUtils.copyProperties(param, po);
po.setCategoryIds(param.getCategoryIds() != null ? param.getCategoryIds() : java.util.Collections.emptyList());
po.setRegionCodes(param.getRegionCodes() != null ? param.getRegionCodes() : java.util.Collections.emptyList());
po.setIndustryIds(param.getIndustryIds() != null ? param.getIndustryIds() : java.util.Collections.emptyList());
po.setEmploymentType(param.getEmploymentType());
po.setUpdateTime(Instant.now());
intentionMapper.updateById(po);
}
}