👎 处理product的list json
This commit is contained in:
@@ -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.copier.CopyOptions;
|
||||
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.evaluation.domain.EditableTabs;
|
||||
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
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@@ -76,7 +77,7 @@ public class YxStoreProduct extends BaseDomain {
|
||||
private String storeName;
|
||||
|
||||
/**价保和无理由退款等配置**/
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
@TableField(typeHandler = SsjListHandler.class)
|
||||
private List<EditableTabs> config;
|
||||
|
||||
/** 商品简介 */
|
||||
@@ -188,7 +189,7 @@ public class YxStoreProduct extends BaseDomain {
|
||||
|
||||
/** 商品参数 */
|
||||
@ApiModelProperty(value = "商品参数")
|
||||
@TableField(typeHandler = JacksonTypeHandler.class)
|
||||
@TableField(typeHandler = SsjListHandler.class)
|
||||
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.github.pagehelper.PageInfo;
|
||||
import com.qiniu.util.StringUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -91,6 +92,7 @@ import java.util.stream.Collectors;
|
||||
* @date 2020-05-12
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
||||
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())
|
||||
.eq(YxStoreProduct::getId, id);
|
||||
YxStoreProduct storeProduct = storeProductMapper.selectOne(wrapper);
|
||||
|
||||
if (ObjectUtil.isNull(storeProduct)) {
|
||||
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