<?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.business.mapper.TpParabarDetailMapper">
    
    <resultMap type="TpParabarDetail" id="TpParabarDetailResult">
        <id property="id"    column="id"    />
        <result property="parabarId"    column="parabar_id"    />
        <result property="parabarDetailName"    column="parabar_detail_name"    />
        <result property="parabarDetailNameUS"    column="parabar_detail_nameUS"    />
        <result property="parabarDetailNameRU"    column="parabar_detail_nameRU"    />
        <result property="parabarDetailNameES"    column="parabar_detail_nameES"    />
        <result property="sortNumber"    column="sort_number"    />
        <result property="status"    column="status"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <resultMap type="TpParabarDetail" id="TpParabarDetailResultForList" extends="TpParabarDetailResult">
        <result property="file"    column="file"    />
        <result property="fileId"    column="fileId"  />
    </resultMap>

    <sql id="selectTpParabarDetailVo">
        select id, parabar_id, parabar_detail_name, parabar_detail_nameUS, parabar_detail_nameRU, parabar_detail_nameES, sort_number, status, del_flag, create_time, create_by, update_time, update_by, remark from tp_parabar_detail
    </sql>

    <select id="selectTpParabarDetailList" parameterType="TpParabarDetail" resultMap="TpParabarDetailResult">
        SELECT
            distinct
        t1.id,
        t1.parabar_id,
        t1.parabar_detail_name,
        t1.parabar_detail_nameUS,
        t1.parabar_detail_nameRU,
        t1.parabar_detail_nameES,
        t1.sort_number,
        t1.STATUS,
        t1.del_flag,
        t1.create_time,
        t1.create_by,
        t1.update_time,
        t1.update_by,
        t1.remark
        FROM
        tp_parabar_detail  t1
        <where>
            t1.del_flag = 0
            <if test="parabarId != null "> and parabar_id = #{parabarId}</if>
            <if test="parabarDetailName != null  and parabarDetailName != ''"> and parabar_detail_name like concat('%', #{parabarDetailName}, '%')</if>
            <if test="parabarDetailNameUS != null  and parabarDetailNameUS != ''"> and parabar_detail_nameUS = #{parabarDetailNameUS}</if>
            <if test="parabarDetailNameRU != null  and parabarDetailNameRU != ''"> and parabar_detail_nameRU = #{parabarDetailNameRU}</if>
            <if test="parabarDetailNameES != null  and parabarDetailNameES != ''"> and parabar_detail_nameES = #{parabarDetailNameES}</if>
            <if test="sortNumber != null  and sortNumber != ''"> and sort_number = #{sortNumber}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectTpParabarDetailById" parameterType="Long" resultMap="TpParabarDetailResult">
        <include refid="selectTpParabarDetailVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTpParabarDetail" parameterType="TpParabarDetail" useGeneratedKeys="true" keyProperty="id">
        insert into tp_parabar_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="parabarId != null">parabar_id,</if>
            <if test="parabarDetailName != null">parabar_detail_name,</if>
            <if test="parabarDetailNameUS != null">parabar_detail_nameUS,</if>
            <if test="parabarDetailNameRU != null">parabar_detail_nameRU,</if>
            <if test="parabarDetailNameES != null">parabar_detail_nameES,</if>
            <if test="sortNumber != null">sort_number,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="parabarId != null">#{parabarId},</if>
            <if test="parabarDetailName != null">#{parabarDetailName},</if>
            <if test="parabarDetailNameUS != null">#{parabarDetailNameUS},</if>
            <if test="parabarDetailNameRU != null">#{parabarDetailNameRU},</if>
            <if test="parabarDetailNameES != null">#{parabarDetailNameES},</if>
            <if test="sortNumber != null">#{sortNumber},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTpParabarDetail" parameterType="TpParabarDetail">
        update tp_parabar_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="parabarId != null">parabar_id = #{parabarId},</if>
            <if test="parabarDetailName != null">parabar_detail_name = #{parabarDetailName},</if>
            <if test="parabarDetailNameUS != null">parabar_detail_nameUS = #{parabarDetailNameUS},</if>
            <if test="parabarDetailNameRU != null">parabar_detail_nameRU = #{parabarDetailNameRU},</if>
            <if test="parabarDetailNameES != null">parabar_detail_nameES = #{parabarDetailNameES},</if>
            <if test="sortNumber != null">sort_number = #{sortNumber},</if>
            <if test="status != null">status = #{status},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTpParabarDetailById" parameterType="Long">
        update tp_parabar_detail set  del_flag = 1  where id = #{id}
    </delete>

    <delete id="deleteTpParabarDetailByParabarId" parameterType="Long">
        delete from tp_parabar_detail  where parabar_id = #{parabarId}
    </delete>

    <delete id="softDeleteTpParabarDetailByParabarId" parameterType="Long">
        update tp_parabar_detail set  del_flag = 1 where parabar_id  in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <delete id="deleteTpParabarDetailByIds" parameterType="String">
        update tp_parabar_detail set  del_flag = 1  where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>