ProductCategory获取不到fix

This commit is contained in:
litianxiang
2026-04-29 16:33:23 +08:00
parent 5569da47f7
commit ad2254bc80
3 changed files with 6 additions and 19 deletions

View File

@@ -1,9 +1,7 @@
package com.aida.seller.module.listing.entity;
import com.aida.seller.module.listing.enums.ProductCategoryEnum;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
@@ -17,7 +15,7 @@ import java.util.List;
* 商品实体
*/
@Data
@TableName("seller_listing")
@TableName(value = "seller_listing", autoResultMap = true)
public class ListingEntity implements Serializable {
private static final long serialVersionUID = 1L;
@@ -68,5 +66,5 @@ public class ListingEntity implements Serializable {
/** 商品分类列表 */
@TableField(typeHandler = JacksonTypeHandler.class)
private List<ProductCategoryEnum> productCategory;
private List<String> productCategory;
}

View File

@@ -17,7 +17,9 @@ public enum ProductCategoryEnum {
BLOUSE("blouse", "衬衫"),
DRESS("dress", "连衣裙"),
SKIRT("skirt", "半身裙"),
ACCESSORIES("accessories", "配饰");
OTHERS("others", "其他"),
TOP("top", "上装"),
BOTTOMS("bottoms", "下装");
@JsonValue
private final String code;

View File

@@ -52,13 +52,7 @@ public class ListingServiceImpl extends ServiceImpl<ListingMapper, ListingEntity
BeanUtils.copyProperties(dto, entity);
entity.setSellerId(sellerId);
if (!CollectionUtils.isEmpty(dto.getProductCategory())) {
List<ProductCategoryEnum> categories = dto.getProductCategory().stream()
.map(ProductCategoryEnum::of)
.filter(Objects::nonNull)
.collect(Collectors.toList());
entity.setProductCategory(categories.isEmpty() ? null : categories);
}
if (dto.getDesignFor() != null && DesignForEnum.of(dto.getDesignFor()) == null) {
throw new BusinessException("designFor 只能为 male/female");
@@ -125,13 +119,6 @@ public class ListingServiceImpl extends ServiceImpl<ListingMapper, ListingEntity
ListingSaveDTO dto = new ListingSaveDTO();
BeanUtils.copyProperties(entity, dto);
if (!CollectionUtils.isEmpty(entity.getProductCategory())) {
dto.setProductCategory(
entity.getProductCategory().stream()
.map(ProductCategoryEnum::getCode)
.collect(Collectors.toList()));
}
List<ListingImageEntity> images = listingImageMapper.selectList(
new LambdaQueryWrapper<ListingImageEntity>()
.eq(ListingImageEntity::getListingId, id)