package shop.alien.mapper.second;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import shop.alien.entity.second.SecondGoodsRecord;
import shop.alien.entity.second.vo.SecondGoodsVo;

import java.util.List;

public interface SecondGoodsRecordMapper extends BaseMapper<SecondGoodsRecord> {
    @Select("SELECT " +
            "sg.*, " +
            "sgc1.category_name as categoryOneName, " +
            "sgc2.category_name as categoryTwoName " +
            "FROM second_goods_record sg " +
            "LEFT JOIN second_goods_category sgc1 " +
            "on sg.category_one_id = sgc1.id " +
            "LEFT JOIN second_goods_category sgc2 " +
            "on sg.category_two_id = sgc2.id " +
            "${ew.customSqlSegment}")
    List<SecondGoodsRecord> selectdminGoodsList(@Param(Constants.WRAPPER) QueryWrapper<SecondGoodsRecord> queryWrapper);

    @Select("SELECT " +
            "sg.*, " +
            "sgc1.category_name as categoryOneName, " +
            "sgc2.category_name as categoryTwoName " +
            "FROM second_goods_record sg " +
            "LEFT JOIN second_goods_category sgc1 " +
            "on sg.category_one_id = sgc1.id " +
            "LEFT JOIN second_goods_category sgc2 " +
            "on sg.category_two_id = sgc2.id " +
            "${ew.customSqlSegment}")
    SecondGoodsRecord selectGoodsRecordById(@Param(Constants.WRAPPER) QueryWrapper<SecondGoodsRecord> queryWrapper);
}