<?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.interfaces.mapper.MdModelPargroupMapper">

    <resultMap type="com.ruoyi.interfaces.domain.MdModelPargroup" id="MdModelPargroupResult">
        <result property="mgid"    column="MGID"    />
        <result property="mdid"    column="MDID"    />
        <result property="parGroupCode"    column="PAR_GROUP_CODE"    />
        <result property="parGroupName"    column="PAR_GROUP_NAME"    />
        <result property="parGroupSort"    column="PAR_GROUP_SORT"    />
        <result property="parGroupNote"    column="PAR_GROUP_NOTE"    />
        <result property="createby"    column="CREATEBY"    />
        <result property="modifyby"    column="MODIFYBY"    />
    </resultMap>

    <sql id="selectMdModelPargroupVo">
        select MGID, MDID, PAR_GROUP_CODE, PAR_GROUP_NAME, PAR_GROUP_SORT, PAR_GROUP_NOTE, CREATEBY, MODIFYBY from md_model_pargroup
    </sql>

    <select id="selectMdModelPargroupList" parameterType="com.ruoyi.interfaces.domain.MdModelPargroup" resultMap="MdModelPargroupResult">
        <include refid="selectMdModelPargroupVo"/>
        <where>
            <if test="parGroupCode != null  and parGroupCode != ''"> and PAR_GROUP_CODE = #{parGroupCode}</if>
            <if test="parGroupNote != null  and parGroupNote != ''"> and PAR_GROUP_NOTE = #{parGroupNote}</if>
            <if test="createby != null "> and CREATEBY = #{createby}</if>
            <if test="modifyby != null "> and MODIFYBY = #{modifyby}</if>
        </where>
    </select>

    <select id="selectMdModelPargroupByMgid" parameterType="Integer" resultMap="MdModelPargroupResult">
        <include refid="selectMdModelPargroupVo"/>
        where MGID = #{mgid}
    </select>

    <insert id="insertMdModelPargroup" parameterType="com.ruoyi.interfaces.domain.MdModelPargroup" useGeneratedKeys="true" keyProperty="mgid">
        insert into md_model_pargroup
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="mdid != null">MDID,</if>
            <if test="parGroupCode != null">PAR_GROUP_CODE,</if>
            <if test="parGroupName != null">PAR_GROUP_NAME,</if>
            <if test="parGroupSort != null">PAR_GROUP_SORT,</if>
            <if test="parGroupNote != null">PAR_GROUP_NOTE,</if>
            <if test="createby != null">CREATEBY,</if>
            <if test="modifyby != null">MODIFYBY,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="mdid != null">#{mdid},</if>
            <if test="parGroupCode != null">#{parGroupCode},</if>
            <if test="parGroupName != null">#{parGroupName},</if>
            <if test="parGroupSort != null">#{parGroupSort},</if>
            <if test="parGroupNote != null">#{parGroupNote},</if>
            <if test="createby != null">#{createby},</if>
            <if test="modifyby != null">#{modifyby},</if>
        </trim>
    </insert>

    <update id="updateMdModelPargroup" parameterType="com.ruoyi.interfaces.domain.MdModelPargroup">
        update md_model_pargroup
        <trim prefix="SET" suffixOverrides=",">
            <if test="mdid != null">MDID = #{mdid},</if>
            <if test="parGroupCode != null">PAR_GROUP_CODE = #{parGroupCode},</if>
            <if test="parGroupName != null">PAR_GROUP_NAME = #{parGroupName},</if>
            <if test="parGroupSort != null">PAR_GROUP_SORT = #{parGroupSort},</if>
            <if test="parGroupNote != null">PAR_GROUP_NOTE = #{parGroupNote},</if>
            <if test="createby != null">CREATEBY = #{createby},</if>
            <if test="modifyby != null">MODIFYBY = #{modifyby},</if>
        </trim>
        where MGID = #{mgid}
    </update>

    <delete id="deleteMdModelPargroupByMgid" parameterType="Integer">
        delete from md_model_pargroup where MGID = #{mgid}
    </delete>

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