package com.seer.teach.mall.convert;

import com.seer.teach.mall.entity.GoodsEntity;
import com.seer.teach.mall.entity.GoodsLogEntity;
import com.seer.teach.mall.entity.GoodsSpecificationEntity;
import com.seer.teach.mall.request.GoodsReq;
import com.seer.teach.mall.request.GoodsSpecificationReq;
import com.seer.teach.mall.response.GoodLogsResp;
import com.seer.teach.mall.response.GoodsDetailsResp;
import com.seer.teach.mall.response.GoodsResp;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface GoodConverter {

    GoodConverter INSTANCE = Mappers.getMapper(GoodConverter.class);

    GoodsResp one(GoodsEntity good);

    @Mapping(source = "specList", target = "specifications")
    GoodsResp one(GoodsEntity good,List<GoodsSpecificationEntity> specList);

    GoodsDetailsResp detail(GoodsEntity good);

    List<GoodsResp> list(List<GoodsEntity> goods);

    GoodsEntity toEntity(GoodsReq req);

    List<GoodsSpecificationEntity> toSpecificationEntityList(List<GoodsSpecificationReq> req);

    GoodLogsResp toGoodsLogEntity(GoodsLogEntity goodsLogEntity);

    List<GoodLogsResp> toGoodsLogEntityList(List<GoodsLogEntity> goodsLogEntityList);

}