修改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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 求职意向服务
|
* 求职意向服务
|
||||||
* 主要功能:用户求职意向的查询和保存
|
* <p>主要功能:用户求职意向的查询和保存</p>
|
||||||
* 依赖服务:无
|
* <p>依赖服务:无</p>
|
||||||
* 使用的表:bg_user_job_intention
|
* <p>使用的表:bg_user_job_intention</p>
|
||||||
*
|
*
|
||||||
* @author zk
|
* @author zk
|
||||||
*/
|
*/
|
||||||
@@ -25,7 +27,7 @@ public class JobIntentionService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询当前用户的求职意向
|
* 查询当前用户的求职意向
|
||||||
* 逻辑:根据userId查询,不存在返回null
|
* <p>根据userId查询,不存在返回null</p>
|
||||||
*/
|
*/
|
||||||
public JobIntentionDto getJobIntention() {
|
public JobIntentionDto getJobIntention() {
|
||||||
Long userId = UserSecurityTool.getUserId();
|
Long userId = UserSecurityTool.getUserId();
|
||||||
@@ -40,18 +42,28 @@ public class JobIntentionService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存/更新求职意向
|
* 保存/更新求职意向
|
||||||
* 逻辑:先查询是否存在,存在则更新,不存在则新增
|
* <p>先查询是否存在,存在则更新,不存在则新增</p>
|
||||||
*/
|
*/
|
||||||
public void saveJobIntention(JobIntentionParam param) {
|
public void saveJobIntention(JobIntentionParam param) {
|
||||||
Long userId = UserSecurityTool.getUserId();
|
Long userId = UserSecurityTool.getUserId();
|
||||||
UserJobIntention po = intentionMapper.selectOne(new LambdaQueryWrapper<UserJobIntention>().eq(UserJobIntention::getUserId, userId));
|
UserJobIntention po = intentionMapper.selectOne(new LambdaQueryWrapper<UserJobIntention>().eq(UserJobIntention::getUserId, userId));
|
||||||
|
|
||||||
if (po == null) {
|
if (po == null) {
|
||||||
po = new UserJobIntention();
|
po = new UserJobIntention();
|
||||||
po.setUserId(userId);
|
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);
|
intentionMapper.insert(po);
|
||||||
} else {
|
} 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);
|
intentionMapper.updateById(po);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,25 @@ public class JacksonConfig {
|
|||||||
private static final JsonSerializer<Long> LONG_SERIALIZER = new JsonSerializer<Long>() {
|
private static final JsonSerializer<Long> LONG_SERIALIZER = new JsonSerializer<Long>() {
|
||||||
@Override
|
@Override
|
||||||
public void serialize(Long value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
public void serialize(Long value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||||
|
if (value == null) {
|
||||||
|
gen.writeNull();
|
||||||
|
} else {
|
||||||
gen.writeString(value.toString());
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final JsonDeserializer<Long> LONG_DESERIALIZER = new JsonDeserializer<Long>() {
|
private static final JsonDeserializer<Long> LONG_DESERIALIZER = new JsonDeserializer<Long>() {
|
||||||
@@ -38,11 +55,16 @@ public class JacksonConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
|
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
|
||||||
return builder
|
ObjectMapper mapper = builder
|
||||||
.serializerByType(Long.class, LONG_SERIALIZER)
|
|
||||||
.serializerByType(long.class, LONG_SERIALIZER)
|
|
||||||
.deserializerByType(Long.class, LONG_DESERIALIZER)
|
.deserializerByType(Long.class, LONG_DESERIALIZER)
|
||||||
.deserializerByType(long.class, LONG_DESERIALIZER)
|
.deserializerByType(long.class, LONG_DESERIALIZER)
|
||||||
.build();
|
.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;
|
package org.jiayunet.pojo.po;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户求职意向表(bg_user_job_intention)
|
* 用户求职意向表(bg_user_job_intention)
|
||||||
@@ -13,7 +16,7 @@ import java.time.Instant;
|
|||||||
* @author zk
|
* @author zk
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@TableName(value = "bg_user_job_intention")
|
@TableName(value = "bg_user_job_intention", autoResultMap = true)
|
||||||
public class UserJobIntention {
|
public class UserJobIntention {
|
||||||
|
|
||||||
@TableId(type = IdType.ASSIGN_ID)
|
@TableId(type = IdType.ASSIGN_ID)
|
||||||
@@ -22,14 +25,17 @@ public class UserJobIntention {
|
|||||||
/** 用户ID */
|
/** 用户ID */
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/** 意向岗位类型ID列表(JSON数组),节点可能为任意级别 */
|
/** 意向岗位类型ID列表,节点可能为任意级别 */
|
||||||
private String categoryIds;
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
|
private List<Long> categoryIds;
|
||||||
|
|
||||||
/** 意向城市编码列表(JSON数组),节点可能为任意级别 */
|
/** 意向城市编码列表,节点可能为任意级别 */
|
||||||
private String regionCodes;
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
|
private List<String> regionCodes;
|
||||||
|
|
||||||
/** 意向行业ID列表(JSON数组),节点可能为任意级别 */
|
/** 意向行业ID列表,节点可能为任意级别 */
|
||||||
private String industryIds;
|
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||||
|
private List<Long> industryIds;
|
||||||
|
|
||||||
/** 工作类型 0=全职 1=实习 */
|
/** 工作类型 0=全职 1=实习 */
|
||||||
private Integer employmentType;
|
private Integer employmentType;
|
||||||
|
|||||||
Reference in New Issue
Block a user