package com.org.web.honor.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.org.web.honor.domain.BcHonorShow;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BcHonorShowMapper extends BaseMapper<BcHonorShow> {

    @Select("<script>" +
            "select * " +
            "from bc_honor_show " +
            "where is_delete = 0 "+

            " <if test = 'title != null and title != \"\"'> " +
            "  and title like concat('%', #{title}, '%') " +
            " </if> " +

            " order by if_top desc,create_time desc " +
            "</script>")
    List<BcHonorShow> queryList(BcHonorShow params);

    // 置顶
    @Update("<script>" +
            "update bc_honor_show " +
            "set if_top = #{ifTop} " +
            "where 1 = 1 " +
            "  <if test = \"id != null \"> " +
            "    AND id = #{id}  " +
            "  </if>"  +
            "</script>")
    void setTop(@Param("id") Long id, @Param("ifTop") Integer ifTop);

}
