package com.gree.mall.miniapp.commonmapper;

import com.baomidou.mybatisplus.annotation.SqlParser;
import com.gree.mall.miniapp.bean.goods.GoodsCategoryBean;
import com.gree.mall.miniapp.bean.goods.GoodsCategoryBean;
import com.gree.mall.miniapp.plus.entity.GoodsCategory;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CustomGoodsCategoryMapper {

    @Select("<script>" +
            "SELECT " +
            "category_id AS categoryId, " +
            "name AS name, " +
            "status AS status, " +
            "img_url AS imgUrl, " +
            "goods_num AS goodsNum, " +
            "level AS level, " +
            "parent_id AS parentId, " +
            "sort_num AS sortNum, " +
            "create_time AS createTime " +
            "FROM goods_category " +
            "WHERE " +
            "del_flag = 0 " +
            "<if test='level != null'>AND level = #{level}</if> " +
            "<if test='status != null'>AND status = #{status}</if> " +
            " order by sort_num"+
            "</script>")
    @Results({
            @Result(
                    property = "children",
                    column = "categoryId",
                    many = @Many(select = "com.gree.mall.miniapp.commonmapper.CustomGoodsCategoryMapper.findChildrenByCategoryId")
            )
    })
    List<GoodsCategoryBean> list(@Param("level") Integer level, @Param("status") Boolean status);




}
