👎 处理product的list json
This commit is contained in:
+23
-23
@@ -21,28 +21,28 @@ public class YudaoCacheAutoConfiguration {
|
|||||||
*
|
*
|
||||||
* 参考 org.springframework.boot.autoconfigure.cache.RedisCacheConfiguration 的 createConfiguration 方法
|
* 参考 org.springframework.boot.autoconfigure.cache.RedisCacheConfiguration 的 createConfiguration 方法
|
||||||
*/
|
*/
|
||||||
@Bean
|
// @Bean
|
||||||
@Primary
|
// @Primary
|
||||||
public RedisCacheConfiguration redisCacheConfiguration(CacheProperties cacheProperties) {
|
// public RedisCacheConfiguration redisCacheConfiguration(CacheProperties cacheProperties) {
|
||||||
// 设置使用 JSON 序列化方式
|
// // 设置使用 JSON 序列化方式
|
||||||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
|
// RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig();
|
||||||
config = config.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(RedisSerializer.json()));
|
// config = config.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(RedisSerializer.json()));
|
||||||
|
//
|
||||||
// 设置 CacheProperties.Redis 的属性
|
// // 设置 CacheProperties.Redis 的属性
|
||||||
CacheProperties.Redis redisProperties = cacheProperties.getRedis();
|
// CacheProperties.Redis redisProperties = cacheProperties.getRedis();
|
||||||
if (redisProperties.getTimeToLive() != null) {
|
// if (redisProperties.getTimeToLive() != null) {
|
||||||
config = config.entryTtl(redisProperties.getTimeToLive());
|
// config = config.entryTtl(redisProperties.getTimeToLive());
|
||||||
}
|
// }
|
||||||
if (redisProperties.getKeyPrefix() != null) {
|
// if (redisProperties.getKeyPrefix() != null) {
|
||||||
config = config.prefixCacheNameWith(redisProperties.getKeyPrefix());
|
// config = config.prefixCacheNameWith(redisProperties.getKeyPrefix());
|
||||||
}
|
// }
|
||||||
if (!redisProperties.isCacheNullValues()) {
|
// if (!redisProperties.isCacheNullValues()) {
|
||||||
config = config.disableCachingNullValues();
|
// config = config.disableCachingNullValues();
|
||||||
}
|
// }
|
||||||
if (!redisProperties.isUseKeyPrefix()) {
|
// if (!redisProperties.isUseKeyPrefix()) {
|
||||||
config = config.disableKeyPrefix();
|
// config = config.disableKeyPrefix();
|
||||||
}
|
// }
|
||||||
return config;
|
// return config;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import java.io.File;
|
|||||||
"${yudao.info.base-package}.server", "${yudao.info.base-package}.module",
|
"${yudao.info.base-package}.server", "${yudao.info.base-package}.module",
|
||||||
"co.yixiang", "com.zsw.erp"
|
"co.yixiang", "com.zsw.erp"
|
||||||
})
|
})
|
||||||
@EnableDubbo
|
//@EnableDubbo
|
||||||
public class YudaoServerApplication {
|
public class YudaoServerApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ spring:
|
|||||||
|
|
||||||
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
|
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
|
||||||
redis:
|
redis:
|
||||||
host: 192.168.10.250 # 地址
|
host: 127.0.0.1 # 地址
|
||||||
port: 6379 # 端口
|
port: 6379 # 端口
|
||||||
database: 0 # 数据库索引
|
database: 0 # 数据库索引
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package co.yixiang.config;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
// 世纪的handler
|
||||||
|
public class SsjListHandler extends JacksonTypeHandler {
|
||||||
|
|
||||||
|
private Class<?> type;
|
||||||
|
|
||||||
|
public SsjListHandler(Class<?> type) {
|
||||||
|
super(type);
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<?> parse(String json) {
|
||||||
|
// return super.parse(json);
|
||||||
|
return JSONUtil.toList(json,type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String toJson(Object obj) {
|
||||||
|
return super.toJson(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ package co.yixiang.modules.product.domain;
|
|||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
import cn.hutool.core.bean.copier.CopyOptions;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDomain;
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDomain;
|
||||||
|
import co.yixiang.config.SsjListHandler;
|
||||||
import co.yixiang.modules.category.domain.YxStoreCategory;
|
import co.yixiang.modules.category.domain.YxStoreCategory;
|
||||||
import co.yixiang.modules.evaluation.domain.EditableTabs;
|
import co.yixiang.modules.evaluation.domain.EditableTabs;
|
||||||
import co.yixiang.modules.product.service.dto.Parameter;
|
import co.yixiang.modules.product.service.dto.Parameter;
|
||||||
@@ -39,7 +40,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@TableName(value = "yx_store_product",autoResultMap = true)
|
@TableName(value = "yx_store_product",autoResultMap = true,resultMap = "co.yixiang.modules.product.service.mapper.StoreProductMapper.resultMap")
|
||||||
@Builder
|
@Builder
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@@ -76,7 +77,7 @@ public class YxStoreProduct extends BaseDomain {
|
|||||||
private String storeName;
|
private String storeName;
|
||||||
|
|
||||||
/**价保和无理由退款等配置**/
|
/**价保和无理由退款等配置**/
|
||||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
@TableField(typeHandler = SsjListHandler.class)
|
||||||
private List<EditableTabs> config;
|
private List<EditableTabs> config;
|
||||||
|
|
||||||
/** 商品简介 */
|
/** 商品简介 */
|
||||||
@@ -188,7 +189,7 @@ public class YxStoreProduct extends BaseDomain {
|
|||||||
|
|
||||||
/** 商品参数 */
|
/** 商品参数 */
|
||||||
@ApiModelProperty(value = "商品参数")
|
@ApiModelProperty(value = "商品参数")
|
||||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
@TableField(typeHandler = SsjListHandler.class)
|
||||||
private List<Parameter> parameter;
|
private List<Parameter> parameter;
|
||||||
|
|
||||||
/** 是否包邮 */
|
/** 是否包邮 */
|
||||||
|
|||||||
+2
-1
@@ -73,6 +73,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import com.qiniu.util.StringUtils;
|
import com.qiniu.util.StringUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -91,6 +92,7 @@ import java.util.stream.Collectors;
|
|||||||
* @date 2020-05-12
|
* @date 2020-05-12
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
||||||
public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMapper, YxStoreProduct> implements YxStoreProductService {
|
public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMapper, YxStoreProduct> implements YxStoreProductService {
|
||||||
|
|
||||||
@@ -340,7 +342,6 @@ public class YxStoreProductServiceImpl extends BaseServiceImpl<StoreProductMappe
|
|||||||
wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
wrapper.eq(YxStoreProduct::getIsShow, ShopCommonEnum.SHOW_1.getValue())
|
||||||
.eq(YxStoreProduct::getId, id);
|
.eq(YxStoreProduct::getId, id);
|
||||||
YxStoreProduct storeProduct = storeProductMapper.selectOne(wrapper);
|
YxStoreProduct storeProduct = storeProductMapper.selectOne(wrapper);
|
||||||
|
|
||||||
if (ObjectUtil.isNull(storeProduct)) {
|
if (ObjectUtil.isNull(storeProduct)) {
|
||||||
throw new ErrorRequestException("商品不存在或已下架");
|
throw new ErrorRequestException("商品不存在或已下架");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="co.yixiang.modules.product.service.mapper.StoreProductMapper">
|
||||||
|
|
||||||
|
<resultMap id="resultMap" type="co.yixiang.modules.product.domain.YxStoreProduct">
|
||||||
|
<result property="config" column="config" typeHandler="co.yixiang.config.SsjListHandler" javaType="co.yixiang.modules.evaluation.domain.EditableTabs"/>
|
||||||
|
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user