修改bug
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,24 @@ public class JacksonConfig {
|
||||
private static final JsonSerializer<Long> LONG_SERIALIZER = new JsonSerializer<Long>() {
|
||||
@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<Object> NUMBER_TO_STRING_SERIALIZER = new JsonSerializer<Object>() {
|
||||
@Override
|
||||
public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
if (value == null) {
|
||||
gen.writeNull();
|
||||
} else if (value instanceof Number) {
|
||||
gen.writeString(String.valueOf(((Number) value).longValue()));
|
||||
} else {
|
||||
gen.writeString(value.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -38,11 +55,16 @@ public class JacksonConfig {
|
||||
|
||||
@Bean
|
||||
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
|
||||
return builder
|
||||
.serializerByType(Long.class, LONG_SERIALIZER)
|
||||
.serializerByType(long.class, LONG_SERIALIZER)
|
||||
ObjectMapper mapper = builder
|
||||
.deserializerByType(Long.class, LONG_DESERIALIZER)
|
||||
.deserializerByType(long.class, LONG_DESERIALIZER)
|
||||
.build();
|
||||
|
||||
// 使用兼容 Number 类型的序列化器
|
||||
mapper.registerModule(new com.fasterxml.jackson.databind.module.SimpleModule()
|
||||
.addSerializer(Long.class, NUMBER_TO_STRING_SERIALIZER)
|
||||
.addSerializer(long.class, NUMBER_TO_STRING_SERIALIZER));
|
||||
|
||||
return mapper;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package org.jiayunet.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户求职意向表(bg_user_job_intention)
|
||||
@@ -13,7 +16,7 @@ import java.time.Instant;
|
||||
* @author zk
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "bg_user_job_intention")
|
||||
@TableName(value = "bg_user_job_intention", autoResultMap = true)
|
||||
public class UserJobIntention {
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@@ -22,14 +25,17 @@ public class UserJobIntention {
|
||||
/** 用户ID */
|
||||
private Long userId;
|
||||
|
||||
/** 意向岗位类型ID列表(JSON数组),节点可能为任意级别 */
|
||||
private String categoryIds;
|
||||
/** 意向岗位类型ID列表,节点可能为任意级别 */
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<Long> categoryIds;
|
||||
|
||||
/** 意向城市编码列表(JSON数组),节点可能为任意级别 */
|
||||
private String regionCodes;
|
||||
/** 意向城市编码列表,节点可能为任意级别 */
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<String> regionCodes;
|
||||
|
||||
/** 意向行业ID列表(JSON数组),节点可能为任意级别 */
|
||||
private String industryIds;
|
||||
/** 意向行业ID列表,节点可能为任意级别 */
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
private List<Long> industryIds;
|
||||
|
||||
/** 工作类型 0=全职 1=实习 */
|
||||
private Integer employmentType;
|
||||
|
||||
Reference in New Issue
Block a user