| | |
| | | <?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" property="id" jdbcType="INTEGER" />
|
| | | <result column="name" property="name" jdbcType="VARCHAR" />
|
| | | <result column="rank" property="rank" jdbcType="INTEGER" />
|
| | | <result column="province_code" property="provinceCode" jdbcType="INTEGER" />
|
| | | <result column="city_code" property="cityCode" jdbcType="INTEGER" />
|
| | | <result column="area_code" property="areaCode" jdbcType="INTEGER" />
|
| | | <result column="address" property="address" jdbcType="VARCHAR" />
|
| | | <result column="telephone" property="telephone" jdbcType="VARCHAR" />
|
| | | <result column="email" property="email" jdbcType="VARCHAR" />
|
| | | <result column="is_delete" property="isDelete" jdbcType="CHAR" />
|
| | | <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
|
| | | <result column="expire_time" property="expireTime" jdbcType="TIMESTAMP" />
|
| | | <result column="description" property="description" jdbcType="VARCHAR" />
|
| | | </resultMap>
|
| | | <sql id="Example_Where_Clause" >
|
| | | <where >
|
| | | <foreach collection="oredCriteria" item="criteria" separator="or" >
|
| | | <if test="criteria.valid" >
|
| | | <trim prefix="(" suffix=")" prefixOverrides="and" >
|
| | | <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 collection="criterion.value" item="listItem" open="(" close=")" separator="," >
|
| | | #{listItem}
|
| | | </foreach>
|
| | | </when>
|
| | | </choose>
|
| | | </foreach>
|
| | | </trim>
|
| | | </if>
|
| | | </foreach>
|
| | | </where>
|
| | | </sql>
|
| | | <sql id="Update_By_Example_Where_Clause" >
|
| | | <where >
|
| | | <foreach collection="example.oredCriteria" item="criteria" separator="or" >
|
| | | <if test="criteria.valid" >
|
| | | <trim prefix="(" suffix=")" prefixOverrides="and" >
|
| | | <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 collection="criterion.value" item="listItem" open="(" close=")" 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>
|
| | | <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.moral.entity.OrganizationExample" >
|
| | | select
|
| | | <if test="distinct" >
|
| | | distinct
|
| | | </if>
|
| | | <include refid="Base_Column_List" />
|
| | | from organization
|
| | | <if test="_parameter != null" >
|
| | | <include refid="Example_Where_Clause" />
|
| | | </if>
|
| | | <if test="orderByClause != null" >
|
| | | order by ${orderByClause}
|
| | | </if>
|
| | | </select>
|
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
|
| | | select |
| | | <include refid="Base_Column_List" />
|
| | | from organization
|
| | | where id = #{id,jdbcType=INTEGER}
|
| | | </select>
|
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
|
| | | delete from organization
|
| | | where id = #{id,jdbcType=INTEGER}
|
| | | </delete>
|
| | | <delete id="deleteByExample" parameterType="com.moral.entity.OrganizationExample" >
|
| | | delete from organization
|
| | | <if test="_parameter != null" >
|
| | | <include refid="Example_Where_Clause" />
|
| | | </if>
|
| | | </delete>
|
| | | <insert id="insert" parameterType="com.moral.entity.Organization" >
|
| | | insert into organization (id, name, rank, |
| | | province_code, city_code, area_code, |
| | | address, telephone, email, |
| | | is_delete, create_time, expire_time, |
| | | description)
|
| | | values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{rank,jdbcType=INTEGER}, |
| | | #{provinceCode,jdbcType=INTEGER}, #{cityCode,jdbcType=INTEGER}, #{areaCode,jdbcType=INTEGER}, |
| | | #{address,jdbcType=VARCHAR}, #{telephone,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, |
| | | #{isDelete,jdbcType=CHAR}, #{createTime,jdbcType=TIMESTAMP}, #{expireTime,jdbcType=TIMESTAMP}, |
| | | #{description,jdbcType=VARCHAR})
|
| | | </insert>
|
| | | <insert id="insertSelective" parameterType="com.moral.entity.Organization" >
|
| | | insert into organization
|
| | | <trim prefix="(" suffix=")" suffixOverrides="," >
|
| | | <if test="id != null" >
|
| | | id,
|
| | | </if>
|
| | | <if test="name != null" >
|
| | | name,
|
| | | </if>
|
| | | <if test="rank != null" >
|
| | | rank,
|
| | | </if>
|
| | | <if test="provinceCode != null" >
|
| | | province_code,
|
| | | </if>
|
| | | <if test="cityCode != null" >
|
| | | city_code,
|
| | | </if>
|
| | | <if test="areaCode != null" >
|
| | | area_code,
|
| | | </if>
|
| | | <if test="address != null" >
|
| | | address,
|
| | | </if>
|
| | | <if test="telephone != null" >
|
| | | telephone,
|
| | | </if>
|
| | | <if test="email != null" >
|
| | | email,
|
| | | </if>
|
| | | <if test="isDelete != null" >
|
| | | is_delete,
|
| | | </if>
|
| | | <if test="createTime != null" >
|
| | | create_time,
|
| | | </if>
|
| | | <if test="expireTime != null" >
|
| | | expire_time,
|
| | | </if>
|
| | | <if test="description != null" >
|
| | | description,
|
| | | </if>
|
| | | </trim>
|
| | | <trim prefix="values (" suffix=")" suffixOverrides="," >
|
| | | <if test="id != null" >
|
| | | #{id,jdbcType=INTEGER},
|
| | | </if>
|
| | | <if test="name != null" >
|
| | | #{name,jdbcType=VARCHAR},
|
| | | </if>
|
| | | <if test="rank != null" >
|
| | | #{rank,jdbcType=INTEGER},
|
| | | </if>
|
| | | <if test="provinceCode != null" >
|
| | | #{provinceCode,jdbcType=INTEGER},
|
| | | </if>
|
| | | <if test="cityCode != null" >
|
| | | #{cityCode,jdbcType=INTEGER},
|
| | | </if>
|
| | | <if test="areaCode != null" >
|
| | | #{areaCode,jdbcType=INTEGER},
|
| | | </if>
|
| | | <if test="address != null" >
|
| | | #{address,jdbcType=VARCHAR},
|
| | | </if>
|
| | | <if test="telephone != null" >
|
| | | #{telephone,jdbcType=VARCHAR},
|
| | | </if>
|
| | | <if test="email != null" >
|
| | | #{email,jdbcType=VARCHAR},
|
| | | </if>
|
| | | <if test="isDelete != null" >
|
| | | #{isDelete,jdbcType=CHAR},
|
| | | </if>
|
| | | <if test="createTime != null" >
|
| | | #{createTime,jdbcType=TIMESTAMP},
|
| | | </if>
|
| | | <if test="expireTime != null" >
|
| | | #{expireTime,jdbcType=TIMESTAMP},
|
| | | </if>
|
| | | <if test="description != null" >
|
| | | #{description,jdbcType=VARCHAR},
|
| | | </if>
|
| | | </trim>
|
| | | </insert>
|
| | | <select id="countByExample" parameterType="com.moral.entity.OrganizationExample" resultType="java.lang.Integer" >
|
| | | select count(*) from organization
|
| | | <if test="_parameter != null" >
|
| | | <include refid="Example_Where_Clause" />
|
| | | </if>
|
| | | </select>
|
| | | <update id="updateByExampleSelective" parameterType="map" >
|
| | | update organization
|
| | | <set >
|
| | | <if test="record.id != null" >
|
| | | id = #{record.id,jdbcType=INTEGER},
|
| | | </if>
|
| | | <if test="record.name != null" >
|
| | | name = #{record.name,jdbcType=VARCHAR},
|
| | | </if>
|
| | | <if test="record.rank != null" >
|
| | | rank = #{record.rank,jdbcType=INTEGER},
|
| | | </if>
|
| | | <if test="record.provinceCode != null" >
|
| | | province_code = #{record.provinceCode,jdbcType=INTEGER},
|
| | | </if>
|
| | | <if test="record.cityCode != null" >
|
| | | city_code = #{record.cityCode,jdbcType=INTEGER},
|
| | | </if>
|
| | | <if test="record.areaCode != null" >
|
| | | area_code = #{record.areaCode,jdbcType=INTEGER},
|
| | | </if>
|
| | | <if test="record.address != null" >
|
| | | address = #{record.address,jdbcType=VARCHAR},
|
| | | </if>
|
| | | <if test="record.telephone != null" >
|
| | | telephone = #{record.telephone,jdbcType=VARCHAR},
|
| | | </if>
|
| | | <if test="record.email != null" >
|
| | | email = #{record.email,jdbcType=VARCHAR},
|
| | | </if>
|
| | | <if test="record.isDelete != null" >
|
| | | is_delete = #{record.isDelete,jdbcType=CHAR},
|
| | | </if>
|
| | | <if test="record.createTime != null" >
|
| | | create_time = #{record.createTime,jdbcType=TIMESTAMP},
|
| | | </if>
|
| | | <if test="record.expireTime != null" >
|
| | | expire_time = #{record.expireTime,jdbcType=TIMESTAMP},
|
| | | </if>
|
| | | <if test="record.description != null" >
|
| | | description = #{record.description,jdbcType=VARCHAR},
|
| | | </if>
|
| | | </set>
|
| | | <if test="_parameter != null" >
|
| | | <include refid="Update_By_Example_Where_Clause" />
|
| | | </if>
|
| | | </update>
|
| | | <update id="updateByExample" parameterType="map" >
|
| | | update organization
|
| | | set id = #{record.id,jdbcType=INTEGER},
|
| | | name = #{record.name,jdbcType=VARCHAR},
|
| | | rank = #{record.rank,jdbcType=INTEGER},
|
| | | province_code = #{record.provinceCode,jdbcType=INTEGER},
|
| | | city_code = #{record.cityCode,jdbcType=INTEGER},
|
| | | area_code = #{record.areaCode,jdbcType=INTEGER},
|
| | | address = #{record.address,jdbcType=VARCHAR},
|
| | | telephone = #{record.telephone,jdbcType=VARCHAR},
|
| | | email = #{record.email,jdbcType=VARCHAR},
|
| | | is_delete = #{record.isDelete,jdbcType=CHAR},
|
| | | create_time = #{record.createTime,jdbcType=TIMESTAMP},
|
| | | expire_time = #{record.expireTime,jdbcType=TIMESTAMP},
|
| | | description = #{record.description,jdbcType=VARCHAR}
|
| | | <if test="_parameter != null" >
|
| | | <include refid="Update_By_Example_Where_Clause" />
|
| | | </if>
|
| | | </update>
|
| | | <update id="updateByPrimaryKeySelective" parameterType="com.moral.entity.Organization" >
|
| | | update organization
|
| | | <set >
|
| | | <if test="name != null" >
|
| | | name = #{name,jdbcType=VARCHAR},
|
| | | </if>
|
| | | <if test="rank != null" >
|
| | | rank = #{rank,jdbcType=INTEGER},
|
| | | </if>
|
| | | <if test="provinceCode != null" >
|
| | | province_code = #{provinceCode,jdbcType=INTEGER},
|
| | | </if>
|
| | | <if test="cityCode != null" >
|
| | | city_code = #{cityCode,jdbcType=INTEGER},
|
| | | </if>
|
| | | <if test="areaCode != null" >
|
| | | area_code = #{areaCode,jdbcType=INTEGER},
|
| | | </if>
|
| | | <if test="address != null" >
|
| | | address = #{address,jdbcType=VARCHAR},
|
| | | </if>
|
| | | <if test="telephone != null" >
|
| | | telephone = #{telephone,jdbcType=VARCHAR},
|
| | | </if>
|
| | | <if test="email != null" >
|
| | | email = #{email,jdbcType=VARCHAR},
|
| | | </if>
|
| | | <if test="isDelete != null" >
|
| | | is_delete = #{isDelete,jdbcType=CHAR},
|
| | | </if>
|
| | | <if test="createTime != null" >
|
| | | create_time = #{createTime,jdbcType=TIMESTAMP},
|
| | | </if>
|
| | | <if test="expireTime != null" >
|
| | | expire_time = #{expireTime,jdbcType=TIMESTAMP},
|
| | | </if>
|
| | | <if test="description != null" >
|
| | | description = #{description,jdbcType=VARCHAR},
|
| | | </if>
|
| | | </set>
|
| | | where id = #{id,jdbcType=INTEGER}
|
| | | </update>
|
| | | <update id="updateByPrimaryKey" parameterType="com.moral.entity.Organization" >
|
| | | update organization
|
| | | set name = #{name,jdbcType=VARCHAR},
|
| | | rank = #{rank,jdbcType=INTEGER},
|
| | | province_code = #{provinceCode,jdbcType=INTEGER},
|
| | | city_code = #{cityCode,jdbcType=INTEGER},
|
| | | area_code = #{areaCode,jdbcType=INTEGER},
|
| | | address = #{address,jdbcType=VARCHAR},
|
| | | telephone = #{telephone,jdbcType=VARCHAR},
|
| | | email = #{email,jdbcType=VARCHAR},
|
| | | is_delete = #{isDelete,jdbcType=CHAR},
|
| | | create_time = #{createTime,jdbcType=TIMESTAMP},
|
| | | expire_time = #{expireTime,jdbcType=TIMESTAMP},
|
| | | description = #{description,jdbcType=VARCHAR}
|
| | | where id = #{id,jdbcType=INTEGER}
|
| | | </update>
|
| | | <?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> |
| | | <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> |