<?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.RegisterSchoolMapper">
    
    <resultMap type="RegisterSchool" id="RegisterSchoolResult">
        <result property="id"    column="id"    />
        <result property="openId"    column="open_id"    />
        <result property="schoolName"    column="school_name"    />
        <result property="userName"    column="user_name"    />
        <result property="userPhone"    column="user_phone"    />
        <result property="isPass"    column="is_pass"    />
        <result property="auditId"    column="audit_id"    />
        <result property="auditUser"    column="audit_user"    />
        <result property="opinion"    column="opinion"    />
        <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="selectRegisterSchoolVo">
        select id,open_id, school_name, user_name, user_phone, is_pass,audit_id,audit_user,opinion, create_by, create_time, update_by, update_time, remark from register_school
    </sql>

    <select id="selectRegisterSchoolList" parameterType="RegisterSchool" resultMap="RegisterSchoolResult">
        <include refid="selectRegisterSchoolVo"/>
        <where>
            <if test="openId != null  and openId != ''"> and open_id = #{openId},</if>
            <if test="schoolName != null  and schoolName != ''"> and school_name like concat('%', #{schoolName}, '%')</if>
            <if test="userName != null  and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
            <if test="userPhone != null  and userPhone != ''"> and user_phone = #{userPhone}</if>
            <if test="isPass != null  and isPass != ''"> and is_pass = #{isPass}</if>
            <if test="auditId != null "> and audit_id = #{auditId}</if>
            <if test="auditUser != null  and auditUser != ''"> and audit_user = #{auditUser}</if>
        </where>
    </select>
    
    <select id="selectRegisterSchoolById" parameterType="Long" resultMap="RegisterSchoolResult">
        <include refid="selectRegisterSchoolVo"/>
        where id = #{id}
    </select>
    <select id="selectRegisterSchooByOppenId" resultMap="RegisterSchoolResult" parameterType="java.lang.String">
        <include refid="selectRegisterSchoolVo"/>
        where  open_id = #{openId} limit 1
    </select>

    <insert id="insertRegisterSchool" parameterType="RegisterSchool" useGeneratedKeys="true" keyProperty="id">
        insert into register_school
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="openId != null  and openId != ''">open_id, </if>
            <if test="schoolName != null and schoolName != ''">school_name,</if>
            <if test="userName != null and userName != ''">user_name,</if>
            <if test="userPhone != null">user_phone,</if>
            <if test="isPass != null">is_pass,</if>
            <if test="auditId != null">audit_id,</if>
            <if test="auditUser != null">audit_user,</if>
            <if test="opinion != null">opinion,</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="openId != null  and openId != ''"> #{openId},</if>
            <if test="schoolName != null and schoolName != ''">#{schoolName},</if>
            <if test="userName != null and userName != ''">#{userName},</if>
            <if test="userPhone != null">#{userPhone},</if>
            <if test="isPass != null">#{isPass},</if>
            <if test="auditId != null">#{auditId},</if>
            <if test="auditUser != null">#{auditUser},</if>
            <if test="opinion != null">#{opinion},</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="updateRegisterSchool" parameterType="RegisterSchool">
        update register_school
        <trim prefix="SET" suffixOverrides=",">
            <if test="openId != null  and openId != ''"> open_id = #{openId},</if>
            <if test="schoolName != null and schoolName != ''">school_name = #{schoolName},</if>
            <if test="userName != null and userName != ''">user_name = #{userName},</if>
            <if test="userPhone != null">user_phone = #{userPhone},</if>
            <if test="isPass != null">is_pass = #{isPass},</if>
            <if test="auditId != null">audit_id= #{auditId},</if>
            <if test="auditUser != null">audit_user= #{auditUser},</if>
            <if test="opinion != null">opinion= #{opinion},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</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="deleteRegisterSchoolById" parameterType="Long">
        delete from register_school where id = #{id}
    </delete>

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