<?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.moral.mapper.OrganizationMapper">
|
<resultMap id="BaseResultMap" type="com.moral.entity.Organization">
|
<id column="id" jdbcType="INTEGER" property="id"/>
|
<result column="name" jdbcType="VARCHAR" property="name"/>
|
<result column="rank" jdbcType="INTEGER" property="rank"/>
|
<result column="province_code" jdbcType="INTEGER" property="provinceCode"/>
|
<result column="city_code" jdbcType="INTEGER" property="cityCode"/>
|
<result column="area_code" jdbcType="INTEGER" property="areaCode"/>
|
<result column="town_code" jdbcType="BIGINT" property="townCode"/>
|
<result column="village_code" jdbcType="BIGINT" property="villageCode"/>
|
<result column="address" jdbcType="VARCHAR" property="address"/>
|
<result column="telephone" jdbcType="VARCHAR" property="telephone"/>
|
<result column="email" jdbcType="VARCHAR" property="email"/>
|
<result column="is_delete" jdbcType="CHAR" property="isDelete"/>
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
|
<result column="expire_time" jdbcType="TIMESTAMP" property="expireTime"/>
|
<result column="description" jdbcType="VARCHAR" property="description"/>
|
<!-- 与省市县一对一的关系 -->
|
<association property="areaNames" javaType="com.moral.entity.AreaNames">
|
<result column="province_name" property="provinceName" jdbcType="VARCHAR"/>
|
<result column="city_name" property="cityName" jdbcType="VARCHAR"/>
|
<result column="area_name" property="areaName" jdbcType="VARCHAR"/>
|
<result column="town_name" property="townName" jdbcType="VARCHAR"/>
|
<result column="village_name" property="villageName" jdbcType="VARCHAR"/>
|
</association>
|
</resultMap>
|
|
|
<select id="getOrganizationByMac" resultMap="BaseResultMap">
|
SELECT *
|
FROM organization o
|
<if test="provinceCode != null" >
|
,province p
|
</if>
|
<if test="cityCode != null" >
|
,city c
|
</if>
|
<if test="areaCode != null" >
|
,area a
|
</if>
|
<if test="townCode != null" >
|
,town t
|
</if>
|
<if test="villageCode != null" >
|
,village v
|
</if>
|
<where>
|
<if test="provinceCode != null" >
|
AND o.province_code = p.province_code
|
</if>
|
<if test="cityCode != null" >
|
AND o.city_code = c.city_code
|
</if>
|
<if test="areaCode != null" >
|
AND o.area_code = a.area_code
|
</if>
|
<if test="townCode != null" >
|
AND o.town_code = t.town_code
|
</if>
|
<if test="villageCode != null" >
|
AND o.village_code = v.village_code
|
</if>
|
AND o.id =
|
(select org.id
|
from organization org,
|
monitor_point m,
|
device d
|
where m.id = d.monitor_point_id
|
and m.organization_id = org.id
|
AND d.mac = #{mac})
|
</where>
|
</select>
|
|
<select id="getOrganizationInfoByMac" resultMap="BaseResultMap">
|
select org.*
|
from organization org,
|
monitor_point m,
|
device d
|
where m.id = d.monitor_point_id
|
and m.organization_id = org.id
|
and d.mac = #{mac}
|
</select>
|
|
</mapper>
|