<?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="MdeSchoolInfoMapper">
    
	<sql id="mdeSchoolInfoColumns">
		a.school_id AS "schoolId",
		a.school_name_cn AS "schoolNameCn",
		a.school_name_en AS "schoolNameEn",
		a.school_province AS "schoolProvince",
		a.school_city AS "schoolCity",
		a.international AS "international",
		a.sort AS "sort",
		a.version_no AS "versionNo",
		a.remarks AS "remarks",
		a.del_flag AS "delFlag",
		a.create_by AS "createBy.id",
		a.create_date AS "createDate",
		a.update_by AS "updateBy.id",
		a.update_date AS "updateDate"
	</sql>
	<sql id="mdeSchoolInfoJoins"></sql>
	
	<select id="get" resultType="com.wechat.model.dbEntity.MdeSchoolInfo">
		SELECT 
			<include refid="mdeSchoolInfoColumns"/>
		FROM mde_school_info a
		<include refid="mdeSchoolInfoJoins"/>
		WHERE a.school_id = #{id} 
	</select>
	
	<select id="getSchoolList" resultType="com.wechat.model.responseDto.LVResp">
		SELECT
			case #{lang} 
				when 'en' then case a.school_name_en when null then a.school_name_cn when '' then a.school_name_cn else a.school_name_en end 
				else a.school_name_cn 
			end as label,
			a.school_id as value
		FROM mde_school_info a
		WHERE a.del_flag=0
		order by a.school_name_cn, a.school_name_en
	</select>
	
	
	<insert id="insert">
		INSERT INTO mde_school_info(
			school_id,
			school_name_cn,
			school_name_en,
			school_province,
			school_city,
			international,
			sort,
			version_no,
			remarks,
			del_flag,
			create_by,
			create_date,
			update_by,
			update_date
		) VALUES (
			#{schoolId},
			#{schoolNameCn},
			#{schoolNameEn},
			#{schoolProvince},
			#{schoolCity},
			#{international},
			#{sort},
			#{versionNo},
			#{remarks},
			#{delFlag},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate}
		)
	</insert>
	
	<update id="update">
		UPDATE mde_school_info SET 	
			school_id = #{schoolId},
			school_name_cn = #{schoolNameCn},
			school_name_en = #{schoolNameEn},
			school_province = #{schoolProvince},
			school_city = #{schoolCity},
			international = #{international},
			sort = #{sort},
			version_no = #{versionNo},
			remarks = #{remarks},
			update_by = #{updateBy.id},
			update_date = #{updateDate}
		WHERE school_id = #{schoolId}
	</update>
	
	<update id="delete">
		UPDATE mde_school_info SET 
			del_flag = #{DEL_FLAG_DELETE}
		WHERE school_id = #{schoolId}
	</update>
	
</mapper>