package com.fs.store.mapper;

import com.fs.store.domain.FsIntegralGoods;
import com.fs.store.param.FsIntegralGoodsListUParam;
import com.fs.store.vo.FsIntegralGoodsListUVO;
import com.fs.store.vo.FsIntegralGoodsListVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 积分商品Mapper接口
 *
 * @author fs
 * @date 2023-11-02
 */
public interface FsIntegralGoodsMapper
{
    /**
     * 查询积分商品
     *
     * @param goodsId 积分商品主键
     * @return 积分商品
     */
    public FsIntegralGoods selectFsIntegralGoodsByGoodsId(Long goodsId);

    /**
     * 查询积分商品列表
     *
     * @param fsIntegralGoods 积分商品
     * @return 积分商品集合
     */
    public List<FsIntegralGoods> selectFsIntegralGoodsList(FsIntegralGoods fsIntegralGoods);

    /**
     * 新增积分商品
     *
     * @param fsIntegralGoods 积分商品
     * @return 结果
     */
    public int insertFsIntegralGoods(FsIntegralGoods fsIntegralGoods);

    /**
     * 修改积分商品
     *
     * @param fsIntegralGoods 积分商品
     * @return 结果
     */
    public int updateFsIntegralGoods(FsIntegralGoods fsIntegralGoods);

    /**
     * 删除积分商品
     *
     * @param goodsId 积分商品主键
     * @return 结果
     */
    public int deleteFsIntegralGoodsByGoodsId(Long goodsId);

    /**
     * 批量删除积分商品
     *
     * @param goodsIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFsIntegralGoodsByGoodsIds(Long[] goodsIds);

    @Select({"<script> select goods_id, img_url, images, goods_name, ot_price, goods_type, status, integral, sort, stock, descs, create_time from fs_integral_goods" +
            "<where>  \n" +
            "            <if test=\"goodsName != null  and goodsName != ''\"> and goods_name like concat('%', #{goodsName}, '%')</if>\n" +
            "            <if test=\"goodsType != null \"> and goods_type = #{goodsType}</if>\n" +
            "            <if test=\"status != null \"> and status = #{status}</if>\n" +
            "            <if test=\"integral != null \"> and integral = #{integral}</if>\n" +
            "        </where> order by sort,goods_id desc"+
            "</script>"})
    List<FsIntegralGoodsListVO> selectFsIntegralGoodsListVO(FsIntegralGoods fsIntegralGoods);
    @Select({"<script> " +
            "select g.goods_id,g.img_url,g.images,g.goods_name,g.ot_price,g.goods_type,g.integral,g.sort  from fs_integral_goods g  " +
            "where g.status=1  " +
            "<if test = 'maps.goodsType != null and maps.goodsType != 0     '> " +
            "and g.goods_type = #{maps.goodsType}  " +
            "</if>" +
            " order by g.goods_id desc "+
            "</script>"})
    List<FsIntegralGoodsListUVO> selectFsIntegralGoodsListUVO(@Param("maps")FsIntegralGoodsListUParam param);
}
