<?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.abuwx.mapper.InfoContentMapper">

    <resultMap type="InfoContent" id="InfoContentResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="categoryId"    column="category_id"    />
        <result property="source"    column="source"    />
        <result property="checkStatus"    column="check_status"    />
        <result property="checkResult"    column="check_result"    />
        <result property="publishStatus"    column="publish_status"    />
        <result property="publishTime"    column="publish_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="content"    column="content"    />
        <result property="banner"    column="banner"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="cancelTime"    column="cancel_time"    />
    </resultMap>

    <sql id="selectInfoContentVo">
        select id, title, category_id, source, check_status, check_result, publish_status, publish_time, create_time, update_time, remark, content, banner, create_by, update_by, cancel_time from info_content
    </sql>

    <select id="selectInfoContentList" parameterType="InfoContent" resultMap="InfoContentResult">
        <include refid="selectInfoContentVo"/>
        <where>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="categoryId != null "> and category_id = #{categoryId}</if>
            <if test="source != null  and source != ''"> and source = #{source}</if>
            <if test="checkStatus != null  and checkStatus != ''"> and check_status = #{checkStatus}</if>
            <if test="checkResult != null  and checkResult != ''"> and check_result = #{checkResult}</if>
            <if test="publishStatus != null  and publishStatus != ''"> and publish_status = #{publishStatus}</if>
            <if test="publishTime != null "> and publish_time = #{publishTime}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="banner != null  and banner != ''"> and banner = #{banner}</if>
            <if test="cancelTime != null "> and cancel_time = #{cancelTime}</if>
        </where>
    </select>

    <select id="selectInfoContentById" parameterType="Long" resultMap="InfoContentResult">
        <include refid="selectInfoContentVo"/>
        where id = #{id}
    </select>

    <select id="selectInfoContentVoList" parameterType="InfoContent" resultType="com.ruoyi.abuwx.vo.InfoContentVo">
        select a.id, a.title, a.category_id as categoryId, a.source, a.check_status as checkStatus, a.check_result as checkResult,
        a.publish_status as publishStatus, a.publish_time as publishTime, a.create_time as createTime,
        a.update_time as updateTime, a.remark, a.content, a.banner,
        a.create_by as createBy, a.update_by as updateBy, a.cancel_time as cancelTime, b.name as categoryName
        from info_content a left join info_category b on a.category_id = b.id
        <where>
            <if test="title != null  and title != ''"> and a.title like concat('%',#{title},'%')</if>
            <if test="categoryId != null "> and a.category_id = #{categoryId}</if>
            <if test="source != null  and source != ''"> and a.source = #{source}</if>
            <if test="checkStatus != null  and checkStatus != ''"> and a.check_status = #{checkStatus}</if>
            <if test="checkResult != null  and checkResult != ''"> and a.check_result = #{checkResult}</if>
            <if test="publishStatus != null  and publishStatus != ''"> and a.publish_status = #{publishStatus}</if>
            <if test="publishTime != null "> and a.publish_time = #{publishTime}</if>
            <if test="content != null  and content != ''"> and a.content = #{content}</if>
            <if test="banner != null  and banner != ''"> and a.banner = #{banner}</if>
            <if test="cancelTime != null "> and a.cancel_time = #{cancelTime}</if>
            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
                and date_format(a.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
            </if>
            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
                and date_format(a.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
            </if>
            <if test="params.beginupdateTime != null and params.beginupdateTime != ''"><!-- 开始时间检索 -->
                and date_format(a.update_time,'%y%m%d') &gt;= date_format(#{params.beginupdateTime},'%y%m%d')
            </if>
            <if test="params.endupdateTime != null and params.endupdateTime != ''"><!-- 结束时间检索 -->
                and date_format(a.update_time,'%y%m%d') &lt;= date_format(#{params.endupdateTime},'%y%m%d')
            </if>
        </where>
    </select>

    <insert id="insertInfoContent" parameterType="InfoContent" useGeneratedKeys="true" keyProperty="id">
        insert into info_content
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,</if>
            <if test="categoryId != null">category_id,</if>
            <if test="source != null">source,</if>
            <if test="checkStatus != null">check_status,</if>
            <if test="checkResult != null">check_result,</if>
            <if test="publishStatus != null">publish_status,</if>
            <if test="publishTime != null">publish_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="content != null">content,</if>
            <if test="banner != null">banner,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="cancelTime != null">cancel_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},</if>
            <if test="categoryId != null">#{categoryId},</if>
            <if test="source != null">#{source},</if>
            <if test="checkStatus != null">#{checkStatus},</if>
            <if test="checkResult != null">#{checkResult},</if>
            <if test="publishStatus != null">#{publishStatus},</if>
            <if test="publishTime != null">#{publishTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="content != null">#{content},</if>
            <if test="banner != null">#{banner},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="cancelTime != null">#{cancelTime},</if>
         </trim>
    </insert>

    <update id="updateInfoContent" parameterType="InfoContent">
        update info_content
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="categoryId != null">category_id = #{categoryId},</if>
            <if test="source != null">source = #{source},</if>
            <if test="checkStatus != null">check_status = #{checkStatus},</if>
            <if test="checkResult != null">check_result = #{checkResult},</if>
            <if test="publishStatus != null">publish_status = #{publishStatus},</if>
            <if test="publishTime != null">publish_time = #{publishTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="content != null">content = #{content},</if>
            <if test="banner != null">banner = #{banner},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="cancelTime != null">cancel_time = #{cancelTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteInfoContentById" parameterType="Long">
        delete from info_content where id = #{id}
    </delete>

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

</mapper>
