package org.dromara.zhishu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.*;
import org.dromara.zhishu.domain.ShopGoodsPublished;
import org.dromara.zhishu.domain.ShopGoodsRejection;
import org.dromara.zhishu.domain.bo.ShopGoodsPublishedBo;

import java.util.List;

@Mapper
public interface ShopGoodsRejectionMapper extends BaseMapper<ShopGoodsRejection> {


    // 插入数据
    @Insert("INSERT INTO shop_goods_rejection (shop_goods_id, shop_id, platform_id, create_time, rejection_reason,tenant_id,isbn,platform_type,shop_goods_img,goods_type,offshelf_time,sync_flag) " +
            "VALUES (#{shopGoodsId}, #{shopId}, #{platformId}, #{createTime}, #{rejectionReason},#{tenantId},#{isbn},#{platformType},#{shopGoodsImg},#{goodsType},#{offshelfTime},#{syncFlag} )")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(ShopGoodsRejection shopGoodsRejection);

    // 根据ID删除
    @Delete("DELETE FROM shop_goods_rejection WHERE id = #{id}")
    int deleteById(Long id);

    // 根据ID更新
    @Update("UPDATE shop_goods_rejection SET " +
            "shop_goods_id = #{shopGoodsId}, " +
            "shop_id = #{shopId}, " +
            "platform_id = #{platformId}, " +
            "rejection_reason = #{rejectionReason} " +
            "WHERE id = #{id}")
    int update(ShopGoodsRejection shopGoodsRejection);

    // 根据ID查询
    @Select("SELECT * FROM shop_goods_rejection WHERE id = #{id}")
    ShopGoodsRejection selectById(Long id);

    // 查询所有
    @Select("SELECT * FROM shop_goods_rejection ORDER BY create_time DESC")
    List<ShopGoodsRejection> selectAll();

    // 根据店铺ID查询
    @Select("SELECT * FROM shop_goods_rejection WHERE shop_id = #{shopId} ORDER BY create_time DESC")
    List<ShopGoodsRejection> selectByShopId(String shopId);

    // 根据平台商品ID查询
    @Select("SELECT * FROM shop_goods_rejection WHERE platform_id = #{platformId} ORDER BY create_time DESC")
    List<ShopGoodsRejection> selectByPlatformId(String platformId);

    // 动态查询（使用XML配置）
    List<ShopGoodsRejection> selectByCondition(ShopGoodsRejection condition);

    // 分页查询
    public Page<ShopGoodsRejection> selectByConditionWithPage(@Param("page") Page<ShopGoodsRejection> page, @Param("bo") ShopGoodsRejection bo);

    // 统计总数
    int countByCondition(ShopGoodsRejection condition);

}
