<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.project.benyi.mapper.BySchoolNewsMapper">

    <resultMap type="BySchoolNews" id="BySchoolNewsResult">
        <result property="id" column="id"/>
        <result property="title" column="title"/>
        <result property="imgurl" column="imgurl"/>
        <result property="abstractcontent" column="abstractcontent"/>
        <result property="type" column="type"/>
        <result property="content" column="content"/>
        <result property="isdel" column="isdel"/>
        <result property="createuserid" column="createuserid"/>
        <result property="createTime" column="create_time"/>
        <result property="deptId" column="dept_id"/>
        <result property="istop" column="istop"/>
        <result property="ischeck" column="ischeck"/>
        <result property="checkuserid" column="checkuserid"/>
        <result property="checkTime" column="check_time"/>
        <result property="istb" column="istb"/>
    </resultMap>

    <sql id="selectBySchoolNewsVo">
        select d.id, d.title, d.imgurl, d.abstractcontent, d.type, d.content, d.isdel, d.createuserid, d.create_time, d.dept_id, d.istop, d.ischeck, d.checkuserid, d.check_time, d.istb from by_school_news d
    </sql>

    <select id="selectBySchoolNewsList" parameterType="BySchoolNews" resultMap="BySchoolNewsResult">
        <include refid="selectBySchoolNewsVo"/>
        <where>
            d.isdel = 'N'
            <if test="title != null  and title != ''">and d.title like concat('%', #{title}, '%')</if>
            <if test="imgurl != null  and imgurl != ''">and d.imgurl = #{imgurl}</if>
            <if test="abstractcontent != null  and abstractcontent != ''">and d.abstractcontent = #{abstractcontent}</if>
            <if test="type != null  and type != ''">and d.type = #{type}</if>
            <if test="content != null  and content != ''">and d.content = #{content}</if>
            <if test="createuserid != null ">and d.createuserid = #{createuserid}</if>
            <if test="deptId != null ">and d.dept_id = #{deptId}</if>
            <if test="istop != null  and istop != ''">and d.istop = #{istop}</if>
            <if test="ischeck != null  and ischeck != ''">and d.ischeck = #{ischeck}</if>
            <if test="checkuserid != null ">and d.checkuserid = #{checkuserid}</if>
            <if test="checkTime != null ">and d.check_time = #{checkTime}</if>
            <if test="istb != null and istb != ''">and d.istb = #{istb}</if>
        </where>
        <!-- 数据范围过滤 -->
        ${dataScope}
    </select>

    <select id="selectAllBySchoolNewsList" parameterType="BySchoolNews" resultMap="BySchoolNewsResult">
        <include refid="selectBySchoolNewsVo"/>
        <where>
            d.isdel = 'N'
            <if test="title != null  and title != ''">and d.title like concat('%', #{title}, '%')</if>
            <if test="imgurl != null  and imgurl != ''">and d.imgurl = #{imgurl}</if>
            <if test="abstractcontent != null  and abstractcontent != ''">and d.abstractcontent = #{abstractcontent}</if>
            <if test="type != null  and type != ''">and d.type = #{type}</if>
            <if test="content != null  and content != ''">and d.content = #{content}</if>
            <if test="createuserid != null ">and d.createuserid = #{createuserid}</if>
            <if test="deptId != null ">and d.dept_id = #{deptId}</if>
            <if test="istop != null  and istop != ''">and d.istop = #{istop}</if>
            <if test="ischeck != null  and ischeck != ''">and d.ischeck = #{ischeck}</if>
            <if test="checkuserid != null ">and d.checkuserid = #{checkuserid}</if>
            <if test="checkTime != null ">and d.check_time = #{checkTime}</if>
            <if test="istb != null and istb != ''">and d.istb = #{istb}</if>
        </where>
    </select>

    <select id="selectBySchoolNewsById" parameterType="Long" resultMap="BySchoolNewsResult">
        <include refid="selectBySchoolNewsVo"/>
        where d.id = #{id}
    </select>

    <insert id="insertBySchoolNews" parameterType="BySchoolNews" useGeneratedKeys="true" keyProperty="id">
        insert into by_school_news
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null  and title != ''">title,</if>
            <if test="imgurl != null  and imgurl != ''">imgurl,</if>
            <if test="abstractcontent != null  and abstractcontent != ''">abstractcontent,</if>
            <if test="type != null  and type != ''">type,</if>
            <if test="content != null  and content != ''">content,</if>
            <if test="isdel != null  and isdel != ''">isdel,</if>
            <if test="createuserid != null ">createuserid,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="deptId != null ">dept_id,</if>
            <if test="istop != null  and istop != ''">istop,</if>
            <if test="ischeck != null  and ischeck != ''">ischeck,</if>
            <if test="checkuserid != null ">checkuserid,</if>
            <if test="checkTime != null ">check_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null  and title != ''">#{title},</if>
            <if test="imgurl != null  and imgurl != ''">#{imgurl},</if>
            <if test="abstractcontent != null  and abstractcontent != ''">#{abstractcontent},</if>
            <if test="type != null  and type != ''">#{type},</if>
            <if test="content != null  and content != ''">#{content},</if>
            <if test="isdel != null  and isdel != ''">#{isdel},</if>
            <if test="createuserid != null ">#{createuserid},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="deptId != null ">#{deptId},</if>
            <if test="istop != null  and istop != ''">#{istop},</if>
            <if test="ischeck != null  and ischeck != ''">#{ischeck},</if>
            <if test="checkuserid != null ">#{checkuserid},</if>
            <if test="checkTime != null ">#{checkTime},</if>
        </trim>
    </insert>

    <update id="updateBySchoolNews" parameterType="BySchoolNews">
        update by_school_news
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null  and title != ''">title = #{title},</if>
            <if test="imgurl != null  and imgurl != ''">imgurl = #{imgurl},</if>
            <if test="abstractcontent != null  and abstractcontent != ''">abstractcontent = #{abstractcontent},</if>
            <if test="type != null  and type != ''">type = #{type},</if>
            <if test="content != null  and content != ''">content = #{content},</if>
            <if test="isdel != null  and isdel != ''">isdel = #{isdel},</if>
            <if test="createuserid != null ">createuserid = #{createuserid},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="deptId != null ">dept_id = #{deptId},</if>
            <if test="istop != null  and istop != ''">istop = #{istop},</if>
            <if test="ischeck != null  and ischeck != ''">ischeck = #{ischeck},</if>
            <if test="checkuserid != null ">checkuserid = #{checkuserid},</if>
            <if test="checkTime != null ">check_time = #{checkTime},</if>
            <if test="istb != null  and istb != ''">istb = #{istb},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBySchoolNewsById" parameterType="Long">
        delete from by_school_news where id = #{id}
    </delete>

    <delete id="deleteBySchoolNewsByIds" parameterType="String">
        delete from by_school_news where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

</mapper>