<?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.jarvis.mapper.PrdErrorTipMapper">
    
    <resultMap type="PrdErrorTip" id="PrdErrorTipResult">
        <result property="id"           column="id"           />
        <result property="errCode"      column="err_code"     />
        <result property="errSubCode"   column="err_sub_code" />
        <result property="errMsg"       column="err_msg"      />
        <result property="content"      column="content"      />
        <result property="status"       column="status"       />
        <result property="createTime"   column="create_time"  />
        <result property="updateTime"   column="update_time"  />
    </resultMap>

    <sql id="selectPrdErrorTipVo">
        select id, err_code, err_sub_code, err_msg, content, status, create_time, update_time
        from prd_error_tip
    </sql>

    <select id="selectPrdErrorTipList" parameterType="PrdErrorTip" resultMap="PrdErrorTipResult">
        <include refid="selectPrdErrorTipVo"/>
        <where>  
            <if test="errCode != null  and errCode != ''"> and err_code = #{errCode}</if>
            <if test="errSubCode != null  and errSubCode != ''"> and err_sub_code = #{errSubCode}</if>
            <if test="errMsg != null  and errMsg != ''"> and err_msg like concat('%', #{errMsg}, '%')</if>
            <if test="content != null  and content != ''"> and content like concat('%', #{content}, '%')</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
        order by create_time desc
    </select>
    
    <select id="selectPrdErrorTipById" parameterType="Long" resultMap="PrdErrorTipResult">
        <include refid="selectPrdErrorTipVo"/>
        where id = #{id}
    </select>

    <select id="selectPrdErrorTipByCode" resultMap="PrdErrorTipResult">
        <include refid="selectPrdErrorTipVo"/>
        where err_code = #{errCode} and err_sub_code = #{errSubCode} and status = 1
    </select>
        
    <insert id="insertPrdErrorTip" parameterType="PrdErrorTip" useGeneratedKeys="true" keyProperty="id">
        insert into prd_error_tip
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="errCode != null and errCode != ''">err_code,</if>
            <if test="errSubCode != null and errSubCode != ''">err_sub_code,</if>
            <if test="errMsg != null and errMsg != ''">err_msg,</if>
            <if test="content != null and content != ''">content,</if>
            <if test="status != null">status,</if>
            create_time,
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="errCode != null and errCode != ''">#{errCode},</if>
            <if test="errSubCode != null and errSubCode != ''">#{errSubCode},</if>
            <if test="errMsg != null and errMsg != ''">#{errMsg},</if>
            <if test="content != null and content != ''">#{content},</if>
            <if test="status != null">#{status},</if>
            sysdate(),
        </trim>
    </insert>

    <update id="updatePrdErrorTip" parameterType="PrdErrorTip">
        update prd_error_tip
        <trim prefix="SET" suffixOverrides=",">
            <if test="errCode != null and errCode != ''">err_code = #{errCode},</if>
            <if test="errSubCode != null and errSubCode != ''">err_sub_code = #{errSubCode},</if>
            <if test="errMsg != null and errMsg != ''">err_msg = #{errMsg},</if>
            <if test="content != null and content != ''">content = #{content},</if>
            <if test="status != null">status = #{status},</if>
            update_time = sysdate(),
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePrdErrorTipById" parameterType="Long">
        delete from prd_error_tip where id = #{id}
    </delete>

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