From 00e38ff225eb948f5234934afc01aa54c94e0de6 Mon Sep 17 00:00:00 2001
From: 于紫祥_1901 <email@yuzixiang_1910>
Date: Sat, 10 Oct 2020 11:29:36 +0800
Subject: [PATCH] update

---
 src/main/resources/mapper/OrganizationMapper.xml |  127 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 115 insertions(+), 12 deletions(-)

diff --git a/src/main/resources/mapper/OrganizationMapper.xml b/src/main/resources/mapper/OrganizationMapper.xml
index cfbdada..3450060 100644
--- a/src/main/resources/mapper/OrganizationMapper.xml
+++ b/src/main/resources/mapper/OrganizationMapper.xml
@@ -1,14 +1,117 @@
-<?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">
-		SELECT
-			o.* 
-		FROM
-			organization o,
-			area a 
-		WHERE
-			o.area_code = a.area_code 
-		AND a.area_name = #{areaName}
-	</select>
+    <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>
+    <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,tow.town_name,vil.village_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 village vil on organization.village_code = vil.village_code
+        left join town tow on organization.town_code = tow.town_code
+        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.*
+        FROM
+        organization o,
+        area a
+        <if test="cityName != null">
+			,city c
+		</if>
+        WHERE
+        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>
+    </select>
+    <select id="selectLowerOrgIds" resultType="java.lang.Integer">
+            call proc_lowerOrgIds_GetByOrgId(#{orgId,jdbcType=INTEGER});
+    </select>
+
+    <select id="getOrganizationList" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from organization
+        where is_delete=0
+        <if test="organizationName != 'null'">
+            and name like concat('%',#{organizationName},'%')
+        </if>
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0