From 96db6b97ad1868938e92b4a79e37f2622a3fc0e0 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 31 Aug 2022 23:26:17 +0800 Subject: [PATCH] =?UTF-8?q?mall=EF=BC=9A=E8=A7=A3=E5=86=B3=20ProductSkuDO.?= =?UTF-8?q?properties=20=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/dataobject/sku/ProductSkuDO.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java index 6d3d374fc..72daba257 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/sku/ProductSkuDO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.product.dal.dataobject.sku; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; @@ -9,7 +10,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence; 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 com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler; import lombok.*; import java.util.List; @@ -47,7 +48,7 @@ public class ProductSkuDO extends BaseDO { /** * 规格值数组,JSON 格式 */ - @TableField(typeHandler = JacksonTypeHandler.class) + @TableField(typeHandler = PropertyTypeHandler.class) private List properties; /** * 销售价格,单位:分 @@ -113,6 +114,21 @@ public class ProductSkuDO extends BaseDO { } + // TODO @芋艿:可以找一些新的思路 + public static class PropertyTypeHandler extends AbstractJsonTypeHandler { + + @Override + protected Object parse(String json) { + return JsonUtils.parseArray(json, Property.class); + } + + @Override + protected String toJson(Object obj) { + return JsonUtils.toJsonString(obj); + } + + } + // TODO ========== 待定字段:yv ========= // TODO brokerage:一级返佣 // TODO brokerage_two:二级返佣