package com.fs.store.mapper;

import java.util.List;
import com.fs.store.domain.FsStoreProductRelation;
import com.fs.store.param.FsStoreProductRelationParam;
import com.fs.store.param.FsStoreProductRelationQueryParam;
import com.fs.store.vo.FsStoreProductRelationQueryVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 商品点赞和收藏Mapper接口
 * 
 * @author fs
 * @date 2022-03-15
 */
public interface FsStoreProductRelationMapper 
{
    /**
     * 查询商品点赞和收藏
     * 
     * @param id 商品点赞和收藏ID
     * @return 商品点赞和收藏
     */
    public FsStoreProductRelation selectFsStoreProductRelationById(Long id);

    /**
     * 查询商品点赞和收藏列表
     * 
     * @param fsStoreProductRelation 商品点赞和收藏
     * @return 商品点赞和收藏集合
     */
    public List<FsStoreProductRelation> selectFsStoreProductRelationList(FsStoreProductRelation fsStoreProductRelation);

    /**
     * 新增商品点赞和收藏
     * 
     * @param fsStoreProductRelation 商品点赞和收藏
     * @return 结果
     */
    public int insertFsStoreProductRelation(FsStoreProductRelation fsStoreProductRelation);

    /**
     * 修改商品点赞和收藏
     * 
     * @param fsStoreProductRelation 商品点赞和收藏
     * @return 结果
     */
    public int updateFsStoreProductRelation(FsStoreProductRelation fsStoreProductRelation);

    /**
     * 删除商品点赞和收藏
     * 
     * @param id 商品点赞和收藏ID
     * @return 结果
     */
    public int deleteFsStoreProductRelationById(Long id);

    /**
     * 批量删除商品点赞和收藏
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteFsStoreProductRelationByIds(Long[] ids);



    @Select({"<script> " +
            "select p.image,p.product_name,p.price,r.*   from fs_store_product_relation r left join  fs_store_product p  on p.product_id=r.product_id   " +
            "where r.is_del=0 " +
            "<if test = 'maps.userId != null    '> " +
            "and r.user_id =#{maps.userId} " +
            "</if>" +
            " order by update_time desc "+
            "</script>"})
    List<FsStoreProductRelationQueryVO> selectFsStoreProductRelationListVOQuery(@Param("maps") FsStoreProductRelationQueryParam param);
    @Select({"<script> " +
            "select p.image,p.product_name,p.price,r.*,u.nickname,u.phone   from fs_store_product_relation r left join  fs_store_product p  on p.product_id=r.product_id left join fs_user u on u.user_id=r.user_id   " +
            "where r.is_del=0 " +
            "<if test = 'maps.userId != null    '> " +
            "and r.user_id =#{maps.userId} " +
            "</if>" +
            "<if test = 'maps.phone != null and maps.phone != \"\"    '> " +
            "and u.phone =#{maps.phone} " +
            "</if>" +
            "<if test = 'maps.productName != null and maps.productName != \"\"    '> " +
            "and p.product_name =#{maps.productName} " +
            "</if>" +
            " order by update_time desc "+
            "</script>"})
    List<FsStoreProductRelationQueryVO> selectFsStoreProductRelationListVO(@Param("maps") FsStoreProductRelationParam param);
}
