From 5b0347a811a6c948defb5320e71c43173280dfc2 Mon Sep 17 00:00:00 2001
From: xufenglei <xufenglei>
Date: Tue, 06 Feb 2018 10:30:31 +0800
Subject: [PATCH] 更新

---
 src/main/resources/mapper/OrganizationMapper.xml |  102 ++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 89 insertions(+), 13 deletions(-)

diff --git a/src/main/resources/mapper/OrganizationMapper.xml b/src/main/resources/mapper/OrganizationMapper.xml
index b05b312..1e58531 100644
--- a/src/main/resources/mapper/OrganizationMapper.xml
+++ b/src/main/resources/mapper/OrganizationMapper.xml
@@ -1,21 +1,97 @@
-<?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">
+<?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">
-	<select id="getOrganizationsByAreaName" resultType="com.moral.entity.Organization">
+  <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="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" />
+      </association>
+  </resultMap>
+  <sql id="Example_Where_Clause">
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    id, name, rank, province_code, city_code, area_code, address, telephone, email, is_delete, 
+    create_time, expire_time, description
+  </sql>
+   <sql id="Relation_Province_City_Area_List">
+       are.area_name, cti.city_name, pro.province_name
+  </sql>
+  <select id="selectWithAreaNameByExample" parameterType="tk.mybatis.mapper.entity.Example" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+      organization.*
+      ,
+      <include refid="Relation_Province_City_Area_List" />
+      from organization
+      left join area are on organization.area_code = are.area_code
+      left join city cti on organization.city_code = cti.city_code
+      left join province pro on organization.province_code = pro.province_code
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+  </select>
+  	<select id="getOrganizationsByAreaName" resultType="com.moral.entity.Organization">
 		SELECT
-			o.* 
+			o.*
 		FROM
 			organization o,
-			area a 
-		<if test="cityName != null">
-			,city c 
-		</if>
+			area a
+		<if test="cityName != null">
+			,city c
+		</if>
 		WHERE
-			o.area_code = a.area_code 
+			o.area_code = a.area_code
 			AND a.area_name = #{areaName}
-		<if test="cityName != null">
-			AND c.city_name = #{cityName}
-			AND o.city_code = c.city_code
-		</if>
+		<if test="cityName != null">
+			AND c.city_name = #{cityName}
+			AND o.city_code = c.city_code
+		</if>
 	</select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0