package com.wzj.soopin.goods.domain.bo;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wzj.soopin.goods.domain.entity.ProductCategory;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * @author fxh
 */
@Data
@Schema(description = "商品分类 查询 对象")
public class ProductCategoryBo {

    @Schema(description = "上级分类的编号：0表示一级分类 精确匹配")
    private Long parentId;

    @Schema(description = "NAME 模糊匹配")
    private String nameLike;

    @Schema(description = "分类级别：0->1级；1->2级 精确匹配")
    private Integer level;

    @Schema(description = "显示状态：0->不显示；1->显示 精确匹配")
    private Integer showStatus;

    @Schema(description = "SORT 精确匹配")
    private Integer sort;

    @Schema(description = "图标 精确匹配")
    private String icon;

    public Wrapper<ProductCategory> toWrapper() {
        return new LambdaQueryWrapper<ProductCategory>()
            .eq(parentId != null, ProductCategory::getParentId, parentId)
            .eq(level != null, ProductCategory::getLevel, level)
            .eq(showStatus != null, ProductCategory::getShowStatus, showStatus)
            .eq(sort != null, ProductCategory::getSort, sort)
            .eq(icon != null && !icon.isEmpty(), ProductCategory::getIcon, icon)
            .like(nameLike != null && !nameLike.isEmpty(), ProductCategory::getName, nameLike);
    }
}
