<?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.winsun.mapper.SchoolMapper">


    <select id="querySchoolMap" parameterType="String" resultType="HashMap">
        select * from hhr_school where sub_name = #{subName} and  school_name = #{schoolName}
    </select>

    <select id="selectHhrSchool" resultType="com.winsun.bean.Schools">
        select hus.user_id userId,hs.* FROM hhr_user_school hus LEFT JOIN  hhr_school hs
        on hs.id = hus.school_id
    </select>

    <select id="selectForId" resultType="java.lang.Integer">
        select id from  hhr_school where  id = #{schoolId};
    </select>
    <select id="selectByHeHuorenId" resultType="java.util.Map">
        select hs.* from hhr_school hs join hhr_user_school hus on hs.id = hus.school_id where hus.user_id = #{hehuorenId}
    </select>


    <insert id="insertSchoolMap">
        INSERT INTO hhr_school
        (sub_name,school_name,status,bandproduct_id,net_id,lzgh,lz_user,network_code,network_name,app_id,app_key)
        VALUES (#{a},#{b},0,#{c},#{d},#{e},#{f},#{g},#{h},#{i},#{j})
    </insert>
    <update id="updateSchoolMap">
        update hhr_school set
        <if test="c != null and c != ''">
            bandproduct_id = #{c},
        </if>
        <if test="d != null and d != ''">
            net_id = #{d},
        </if>
        <if test="e != null and e != ''">
            lzgh = #{e},
        </if>
        <if test="f != null and f != ''">
            lz_user = #{f},
        </if>
        <if test="g != null and g != ''">
            network_code = #{g},
        </if>
        <if test="h != null and h != ''">
            network_name = #{h},
        </if>
        <if test="i != null and i != ''">
            app_id = #{i},
        </if>
        <if test="j != null and j != ''">
            app_key = #{j},
        </if>
        sub_name = #{a},school_name = #{b}
        where
        sub_name = #{a}
        and
        school_name = #{b}
    </update>


    <insert id="insertNetworkInfo">
        INSERT INTO hhr_network_info (area_name,school_name,network_code,network_name)
        VALUES (#{a},#{b},#{e},#{f})
    </insert>
</mapper>
