商品模块代码提交

This commit is contained in:
Tankaikai
2025-02-18 15:17:45 +08:00
parent 78d7c32638
commit f8658d3386
3 changed files with 16 additions and 9 deletions

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONWriter;
import com.czg.enums.DeleteEnum;
import com.czg.enums.YesNoEnum;
import com.czg.exception.CzgException;
@@ -124,13 +125,14 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
}
Product entity = BeanUtil.copyProperties(dto, Product.class);
entity.setImages(JSON.toJSONString(dto.getImages()));
entity.setImages(JSON.toJSONString(dto.getImages(), JSONWriter.Feature.WriteMapNullValue));
entity.setGroupSnap("[]");
//套餐
if (ProductTypeEnum.PACKAGE.value().equals(dto.getType())) {
//套餐内容
if (CollUtil.isNotEmpty(dto.getProGroupVo())) {
entity.setGroupSnap(JSON.toJSONString(dto.getProGroupVo()));
String groupSnap = JSON.toJSONString(dto.getProGroupVo(), JSONWriter.Feature.WriteMapNullValue);
entity.setGroupSnap(groupSnap);
}
}
entity.setIsDel(DeleteEnum.NORMAL.value());
@@ -163,13 +165,13 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
throw new CzgException("商品已存在");
}
Product entity = BeanUtil.copyProperties(dto, Product.class);
entity.setImages(JSON.toJSONString(dto.getImages()));
entity.setImages(JSON.toJSONString(dto.getImages(), JSONWriter.Feature.WriteMapNullValue));
entity.setGroupSnap("[]");
//套餐
if (ProductTypeEnum.PACKAGE.value().equals(dto.getType())) {
//套餐内容
if (CollUtil.isNotEmpty(dto.getProGroupVo())) {
entity.setGroupSnap(JSON.toJSONString(dto.getProGroupVo()));
entity.setGroupSnap(JSON.toJSONString(dto.getProGroupVo(), JSONWriter.Feature.WriteMapNullValue));
}
}
entity.setIsDel(DeleteEnum.NORMAL.value());