<?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.CpsUsrApplyMapper">

    <resultMap type="com.ruoyi.system.domain.CpsUsrApply" id="CpsUsrApplyResult">
        <result property="id"    column="id"    />
        <result property="usrName"    column="usr_name"    />
        <result property="tel"    column="tel"    />
        <result property="orgUnitName"    column="org_unit_name"    />
        <result property="uniLevel"    column="uni_level"    />
        <result property="email"    column="email"    />
        <result property="usrType"    column="usr_type"    />
        <result property="conferenceFlag"    column="conference_flag"    />
        <result property="conferenceRel"    column="conference_rel"    />
        <result property="applyType"    column="apply_type"    />
        <result property="reviewState"    column="review_state"    />
        <result property="reviewMsg"    column="review_msg"    />
        <result property="usrWechatId"    column="usr_wechat_id"    />
        <result property="contentId"    column="content_id"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectCpsUsrApplyVo">
        select id, usr_name, tel, org_unit_name, uni_level, email, usr_type, conference_flag, conference_rel, apply_type, review_state, review_msg, usr_wechat_id, content_id, update_time, create_time, create_by, update_by from cps_usr_apply
    </sql>

    <select id="selectCpsUsrApplyList" parameterType="com.ruoyi.system.domain.CpsUsrApply" resultMap="CpsUsrApplyResult">
        <include refid="selectCpsUsrApplyVo"/>
        <where>
            <if test="usrName != null  and usrName != ''"> and usr_name like concat('%', #{usrName}, '%')</if>
            <if test="tel != null  and tel != ''"> and tel = #{tel}</if>
            <if test="orgUnitName != null  and orgUnitName != ''"> and org_unit_name like concat('%', #{orgUnitName}, '%')</if>
            <if test="uniLevel != null  and uniLevel != ''"> and uni_levle = #{uniLevel}</if>
            <if test="usrType != null  and usrType != ''"> and usr_type = #{usrType}</if>
            <if test="conferenceFlag != null  and conferenceFlag != ''"> and conference_flag = #{conferenceFlag}</if>
            <if test="applyType != null  and applyType != ''"> and apply_type = #{applyType}</if>
            <if test="reviewState != null  and reviewState != ''"> and review_state = #{reviewState}</if>
        </where>
    </select>

    <select id="selectCpsUsrApplyById" parameterType="Long" resultMap="CpsUsrApplyResult">
        <include refid="selectCpsUsrApplyVo"/>
        where id = #{id}
    </select>

    <insert id="insertCpsUsrApply" parameterType="com.ruoyi.system.domain.CpsUsrApply" useGeneratedKeys="true" keyProperty="id">
        insert into cps_usr_apply
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="usrName != null">usr_name,</if>
            <if test="tel != null">tel,</if>
            <if test="orgUnitName != null">org_unit_name,</if>
            <if test="uniLevel != null">uni_level,</if>
            <if test="email != null">email,</if>
            <if test="usrType != null">usr_type,</if>
            <if test="conferenceFlag != null">conference_flag,</if>
            <if test="conferenceRel != null">conference_rel,</if>
            <if test="applyType != null">apply_type,</if>
            <if test="reviewState != null">review_state,</if>
            <if test="reviewMsg != null">review_msg,</if>
            <if test="usrWechatId != null">usr_wechat_id,</if>
            <if test="contentId != null">content_id,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="usrName != null">#{usrName},</if>
            <if test="tel != null">#{tel},</if>
            <if test="orgUnitName != null">#{orgUnitName},</if>
            <if test="uniLevel != null">#{uniLevel},</if>
            <if test="email != null">#{email},</if>
            <if test="usrType != null">#{usrType},</if>
            <if test="conferenceFlag != null">#{conferenceFlag},</if>
            <if test="conferenceRel != null">#{conferenceRel},</if>
            <if test="applyType != null">#{applyType},</if>
            <if test="reviewState != null">#{reviewState},</if>
            <if test="reviewMsg != null">#{reviewMsg},</if>
            <if test="usrWechatId != null">#{usrWechatId},</if>
            <if test="contentId != null">#{contentId},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
         </trim>
    </insert>

    <update id="updateCpsUsrApply" parameterType="com.ruoyi.system.domain.CpsUsrApply">
        update cps_usr_apply
        <trim prefix="SET" suffixOverrides=",">
            <if test="usrName != null">usr_name = #{usrName},</if>
            <if test="tel != null">tel = #{tel},</if>
            <if test="orgUnitName != null">org_unit_name = #{orgUnitName},</if>
            <if test="uniLevel != null">uni_level = #{uniLevel},</if>
            <if test="email != null">email = #{email},</if>
            <if test="usrType != null">usr_type = #{usrType},</if>
            <if test="conferenceFlag != null">conference_flag = #{conferenceFlag},</if>
            <if test="conferenceRel != null">conference_rel = #{conferenceRel},</if>
            <if test="applyType != null">apply_type = #{applyType},</if>
            <if test="reviewState != null">review_state = #{reviewState},</if>
            <if test="reviewMsg != null">review_msg = #{reviewMsg},</if>
            <if test="usrWechatId != null">usr_wechat_id = #{usrWechatId},</if>
            <if test="contentId != null">content_id = #{contentId},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCpsUsrApplyById" parameterType="Long">
        delete from cps_usr_apply where id = #{id}
    </delete>

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