diff --git a/client-api/src/main/java/org/jiayunet/service/JobIntentionService.java b/client-api/src/main/java/org/jiayunet/service/JobIntentionService.java
index 71e5a00..78f0728 100644
--- a/client-api/src/main/java/org/jiayunet/service/JobIntentionService.java
+++ b/client-api/src/main/java/org/jiayunet/service/JobIntentionService.java
@@ -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
+ *
主要功能:用户求职意向的查询和保存
+ * 依赖服务:无
+ * 使用的表:bg_user_job_intention
*
* @author zk
*/
@@ -25,7 +27,7 @@ public class JobIntentionService {
/**
* 查询当前用户的求职意向
- * 逻辑:根据userId查询,不存在返回null
+ * 根据userId查询,不存在返回null
*/
public JobIntentionDto getJobIntention() {
Long userId = UserSecurityTool.getUserId();
@@ -40,18 +42,28 @@ public class JobIntentionService {
/**
* 保存/更新求职意向
- * 逻辑:先查询是否存在,存在则更新,不存在则新增
+ * 先查询是否存在,存在则更新,不存在则新增
*/
public void saveJobIntention(JobIntentionParam param) {
Long userId = UserSecurityTool.getUserId();
UserJobIntention po = intentionMapper.selectOne(new LambdaQueryWrapper().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);
}
}
diff --git a/common/src/main/java/org/jiayunet/config/JacksonConfig.java b/common/src/main/java/org/jiayunet/config/JacksonConfig.java
index ae26be7..679e571 100644
--- a/common/src/main/java/org/jiayunet/config/JacksonConfig.java
+++ b/common/src/main/java/org/jiayunet/config/JacksonConfig.java
@@ -24,7 +24,24 @@ public class JacksonConfig {
private static final JsonSerializer LONG_SERIALIZER = new JsonSerializer() {
@Override
public void serialize(Long value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
- gen.writeString(value.toString());
+ if (value == null) {
+ gen.writeNull();
+ } else {
+ gen.writeString(value.toString());
+ }
+ }
+ };
+
+ private static final JsonSerializer