<?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.SysApplicationCaseMapper">
    <resultMap type="SysApplicationCase" id="SysApplicationCaseResult">
        <id property="id" column="id" />
        <result property="caseName" column="case_name" />
        <result property="thumbnail" column="thumbnail" />
        <result property="introduction" column="introduction" />
        <result property="applicationField" column="application_field" />
        <result property="applicationUnit" column="application_unit" />
        <result property="publishTime" column="publish_time" />
        <result property="publisher" column="publisher" />
        <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="selectSysApplicationCaseVo">
        select id, case_name, thumbnail, introduction, application_field, application_unit, publish_time, publisher, sort, status, create_by, create_time, update_by, update_time, remark
        from sys_application_case
    </sql>

    <select id="selectSysApplicationCaseList" parameterType="SysApplicationCase" resultMap="SysApplicationCaseResult">
        <include refid="selectSysApplicationCaseVo" />
        <where>
            <if test="caseName != null and caseName != ''">
                AND case_name like concat('%', #{caseName}, '%')
            </if>
            <if test="applicationField != null and applicationField != ''">
                AND application_field = #{applicationField}
            </if>
            <if test="publisher != null and publisher != ''">
                AND publisher = #{publisher}
            </if>
            <if test="params.beginTime != null and params.beginTime != ''">
                AND date_format(publish_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
            </if>
            <if test="params.endTime != null and params.endTime != ''">
                AND date_format(publish_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="selectSysApplicationCaseById" parameterType="Long" resultMap="SysApplicationCaseResult">
        <include refid="selectSysApplicationCaseVo" />
        where id = #{id}
    </select>

    <insert id="insertSysApplicationCase" parameterType="SysApplicationCase" useGeneratedKeys="true" keyProperty="id">
        insert into sys_application_case
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="caseName != null and caseName != ''">case_name,</if>
            <if test="thumbnail != null">thumbnail,</if>
            <if test="introduction != null">introduction,</if>
            <if test="applicationField != null">application_field,</if>
            <if test="applicationUnit != null">application_unit,</if>
            <if test="publishTime != null">publish_time,</if>
            <if test="publisher != null">publisher,</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="caseName != null and caseName != ''">#{caseName},</if>
            <if test="thumbnail != null">#{thumbnail},</if>
            <if test="introduction != null">#{introduction},</if>
            <if test="applicationField != null">#{applicationField},</if>
            <if test="applicationUnit != null">#{applicationUnit},</if>
            <if test="publishTime != null">#{publishTime},</if>
            <if test="publisher != null">#{publisher},</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="updateSysApplicationCase" parameterType="SysApplicationCase">
        update sys_application_case
        <trim prefix="set" suffixOverrides=",">
            <if test="caseName != null and caseName != ''">case_name = #{caseName},</if>
            <if test="thumbnail != null">thumbnail = #{thumbnail},</if>
            <if test="introduction != null">introduction = #{introduction},</if>
            <if test="applicationField != null">application_field = #{applicationField},</if>
            <if test="applicationUnit != null">application_unit = #{applicationUnit},</if>
            <if test="publishTime != null">publish_time = #{publishTime},</if>
            <if test="publisher != null">publisher = #{publisher},</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="deleteSysApplicationCaseById" parameterType="Long">
        delete from sys_application_case where id = #{id}
    </delete>

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