<?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.system.mapper.SysSdgsat1CaseMapper">
    <resultMap type="SysSdgsat1Case" id="SysSdgsat1CaseResult">
        <id property="id" column="id" />
        <result property="title" column="title" />
        <result property="coverImage" column="cover_image" />
        <result property="summary" column="summary" />
        <result property="content" column="content" />
        <result property="applicationField" column="application_field" />
        <result property="sort" column="sort" />
        <result property="status" column="status" />
        <result property="createBy" column="create_by" />
        <result property="createTime" column="create_time" />
        <result property="updateBy" column="update_by" />
        <result property="updateTime" column="update_time" />
        <result property="remark" column="remark" />
    </resultMap>

    <sql id="selectSysSdgsat1CaseVo">
        select id, title, cover_image, summary, content, application_field, sort, status, create_by, create_time, update_by, update_time, remark
        from sys_sdgsat1_case
    </sql>

    <select id="selectSysSdgsat1CaseList" parameterType="SysSdgsat1Case" resultMap="SysSdgsat1CaseResult">
        <include refid="selectSysSdgsat1CaseVo" />
        <where>
            <if test="title != null and title != ''">
                AND title like concat('%', #{title}, '%')
            </if>
            <if test="applicationField != null and applicationField != ''">
                AND application_field = #{applicationField}
            </if>
            <if test="createBy != null and createBy != ''">
                AND create_by = #{createBy}
            </if>
            <if test="params.beginTime != null and params.beginTime != ''">
                AND date_format(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(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
            </if>
            <if test="status != null and status != ''">
                AND status = #{status}
            </if>
        </where>
        order by sort asc, create_time desc
    </select>

    <select id="selectSysSdgsat1CaseById" parameterType="Long" resultMap="SysSdgsat1CaseResult">
        <include refid="selectSysSdgsat1CaseVo" />
        where id = #{id}
    </select>

    <insert id="insertSysSdgsat1Case" parameterType="SysSdgsat1Case" useGeneratedKeys="true" keyProperty="id">
        insert into sys_sdgsat1_case
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null and title != ''">title,</if>
            <if test="coverImage != null">cover_image,</if>
            <if test="summary != null">summary,</if>
            <if test="content != null">content,</if>
            <if test="applicationField != null">application_field,</if>
            <if test="sort != null">sort,</if>
            <if test="status != null">status,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null and title != ''">#{title},</if>
            <if test="coverImage != null">#{coverImage},</if>
            <if test="summary != null">#{summary},</if>
            <if test="content != null">#{content},</if>
            <if test="applicationField != null">#{applicationField},</if>
            <if test="sort != null">#{sort},</if>
            <if test="status != null">#{status},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <update id="updateSysSdgsat1Case" parameterType="SysSdgsat1Case">
        update sys_sdgsat1_case
        <trim prefix="set" suffixOverrides=",">
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="coverImage != null">cover_image = #{coverImage},</if>
            <if test="summary != null">summary = #{summary},</if>
            <if test="content != null">content = #{content},</if>
            <if test="applicationField != null">application_field = #{applicationField},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="status != null">status = #{status},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysSdgsat1CaseById" parameterType="Long">
        delete from sys_sdgsat1_case where id = #{id}
    </delete>

    <delete id="deleteSysSdgsat1CaseByIds" parameterType="Long">
        delete from sys_sdgsat1_case where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
