<?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.nuvole.four.mapper.SysOrgMapper">
|
<resultMap id="BaseResultMap" type="com.nuvole.four.domain.SysOrg">
|
<id column="id" jdbcType="BIGINT" property="id" />
|
<result column="name" jdbcType="VARCHAR" property="name" />
|
<result column="org_code" jdbcType="VARCHAR" property="orgCode" />
|
<result column="user_org_code" jdbcType="VARCHAR" property="userOrgCode" />
|
<result column="pid" jdbcType="BIGINT" property="pid" />
|
<result column="lv" jdbcType="INTEGER" property="lv" />
|
<result column="sort_no" jdbcType="INTEGER" property="sortNo" />
|
<result column="state" jdbcType="INTEGER" property="state" />
|
<result column="note" jdbcType="VARCHAR" property="note" />
|
<result column="lon" jdbcType="VARCHAR" property="lon" />
|
<result column="lat" jdbcType="VARCHAR" property="lat" />
|
<result column="phone" jdbcType="VARCHAR" property="phone" />
|
<result column="open_time" jdbcType="VARCHAR" property="openTime" />
|
<result column="address" jdbcType="VARCHAR" property="address" />
|
</resultMap>
|
<resultMap id="xqMap" type="HashMap">
|
<result column="id" property="key" jdbcType="BIGINT"/>
|
<result column="name" property="value" jdbcType="VARCHAR" />
|
</resultMap>
|
<sql id="Base_Column_List">
|
id, name, org_code, user_org_code, pid, lv, sort_no, state, note, lon, lat,phone,open_time, address
|
</sql>
|
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List" />
|
from sys_org
|
where id = #{id,jdbcType=BIGINT}
|
</select>
|
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
|
delete from sys_org
|
where id = #{id,jdbcType=BIGINT}
|
</delete>
|
<insert id="insert" parameterType="com.nuvole.four.domain.SysOrg">
|
insert into sys_org (id, name, org_code,
|
user_org_code, pid, lv,
|
sort_no, state, note,
|
lon, lat,phone,open_time, address)
|
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{orgCode,jdbcType=VARCHAR},
|
#{userOrgCode,jdbcType=VARCHAR}, #{pid,jdbcType=BIGINT}, #{lv,jdbcType=INTEGER},
|
#{sortNo,jdbcType=INTEGER}, #{state,jdbcType=INTEGER}, #{note,jdbcType=VARCHAR},
|
#{lon,jdbcType=VARCHAR}, #{lat,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, #{openTime,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR})
|
</insert>
|
<insert id="insertSelective" parameterType="com.nuvole.four.domain.SysOrg">
|
insert into sys_org
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="id != null">
|
id,
|
</if>
|
<if test="name != null">
|
name,
|
</if>
|
<if test="orgCode != null">
|
org_code,
|
</if>
|
<if test="userOrgCode != null">
|
user_org_code,
|
</if>
|
<if test="pid != null">
|
pid,
|
</if>
|
<if test="lv != null">
|
lv,
|
</if>
|
<if test="sortNo != null">
|
sort_no,
|
</if>
|
<if test="state != null">
|
state,
|
</if>
|
<if test="note != null">
|
note,
|
</if>
|
<if test="lon != null">
|
lon,
|
</if>
|
<if test="lat != null">
|
lat,
|
</if>
|
<if test="phone != null">
|
phone,
|
</if>
|
<if test="openTime != null">
|
open_time,
|
</if>
|
<if test="address != null">
|
address,
|
</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<if test="id != null">
|
#{id,jdbcType=BIGINT},
|
</if>
|
<if test="name != null">
|
#{name,jdbcType=VARCHAR},
|
</if>
|
<if test="orgCode != null">
|
#{orgCode,jdbcType=VARCHAR},
|
</if>
|
<if test="userOrgCode != null">
|
#{userOrgCode,jdbcType=VARCHAR},
|
</if>
|
<if test="pid != null">
|
#{pid,jdbcType=BIGINT},
|
</if>
|
<if test="lv != null">
|
#{lv,jdbcType=INTEGER},
|
</if>
|
<if test="sortNo != null">
|
#{sortNo,jdbcType=INTEGER},
|
</if>
|
<if test="state != null">
|
#{state,jdbcType=INTEGER},
|
</if>
|
<if test="note != null">
|
#{note,jdbcType=VARCHAR},
|
</if>
|
<if test="lon != null">
|
#{lon,jdbcType=VARCHAR},
|
</if>
|
<if test="lat != null">
|
#{lat,jdbcType=VARCHAR},
|
</if>
|
<if test="phone != null">
|
#{phone,jdbcType=VARCHAR},
|
</if> <if test="openTime != null">
|
#{openTime,jdbcType=VARCHAR},
|
</if> <if test="address != null">
|
#{address,jdbcType=VARCHAR},
|
</if>
|
</trim>
|
</insert>
|
<update id="updateByPrimaryKeySelective" parameterType="com.nuvole.four.domain.SysOrg">
|
update sys_org
|
<set>
|
<if test="name != null">
|
name = #{name,jdbcType=VARCHAR},
|
</if>
|
<if test="orgCode != null">
|
org_code = #{orgCode,jdbcType=VARCHAR},
|
</if>
|
<if test="userOrgCode != null">
|
user_org_code = #{userOrgCode,jdbcType=VARCHAR},
|
</if>
|
<if test="pid != null">
|
pid = #{pid,jdbcType=BIGINT},
|
</if>
|
<if test="lv != null">
|
lv = #{lv,jdbcType=INTEGER},
|
</if>
|
<if test="sortNo != null">
|
sort_no = #{sortNo,jdbcType=INTEGER},
|
</if>
|
<if test="state != null">
|
state = #{state,jdbcType=INTEGER},
|
</if>
|
<if test="note != null">
|
note = #{note,jdbcType=VARCHAR},
|
</if>
|
<if test="lon != null">
|
lon = #{lon,jdbcType=VARCHAR},
|
</if>
|
<if test="lat != null">
|
lat = #{lat,jdbcType=VARCHAR},
|
</if>
|
<if test="phone != null">
|
phone = #{phone,jdbcType=VARCHAR},
|
</if>
|
<if test="openTime != null">
|
open_time = #{openTime,jdbcType=VARCHAR},
|
</if>
|
<if test="address != null">
|
address = #{address,jdbcType=VARCHAR},
|
</if>
|
</set>
|
where id = #{id,jdbcType=BIGINT}
|
</update>
|
<update id="updateByPrimaryKey" parameterType="com.nuvole.four.domain.SysOrg">
|
update sys_org
|
set name = #{name,jdbcType=VARCHAR},
|
org_code = #{orgCode,jdbcType=VARCHAR},
|
user_org_code = #{userOrgCode,jdbcType=VARCHAR},
|
pid = #{pid,jdbcType=BIGINT},
|
lv = #{lv,jdbcType=INTEGER},
|
sort_no = #{sortNo,jdbcType=INTEGER},
|
state = #{state,jdbcType=INTEGER},
|
note = #{note,jdbcType=VARCHAR},
|
lon = #{lon,jdbcType=VARCHAR},
|
lat = #{lat,jdbcType=VARCHAR},
|
phone = #{phone,jdbcType=VARCHAR},
|
open_time = #{openTime,jdbcType=VARCHAR},
|
address = #{address,jdbcType=VARCHAR}
|
where id = #{id,jdbcType=BIGINT}
|
</update>
|
|
|
<select id="selectAll" parameterType="map" resultMap="BaseResultMap">
|
select <include refid="Base_Column_List" /> from sys_org
|
<where>
|
<choose>
|
<when test="pid != null">
|
and pid = #{pid}
|
</when>
|
<otherwise>
|
<if test="id != null">
|
and id = #{id}
|
</if>
|
</otherwise>
|
</choose>
|
<if test="name!=null and name!=''">
|
and name like CONCAT('%',#{name},'%')
|
</if>
|
<if test="userOrgCode!=null and userOrgCode!=''">
|
and user_org_code like CONCAT(CONCAT('%',#{userOrgCode},'%'))
|
</if>
|
<if test="state!=null">
|
and state = #{state}
|
</if>
|
</where>
|
</select>
|
|
<select id="selectAllOfMap" parameterType="map" resultType="map">
|
select <include refid="Base_Column_List" /> from sys_org
|
</select>
|
|
|
<select id="getOrgByCode" parameterType="string" resultMap="BaseResultMap">
|
select <include refid="Base_Column_List"></include>
|
from sys_org
|
where org_code=#{code}
|
</select>
|
<select id="getBranchByOrgCode" resultType="map">
|
select (SELECT COUNT(u.id) from sys_user u where u.org_id = org.id
|
<if test="userType != null">
|
and user_type = #{userType}
|
</if>
|
) managerNum,
|
org.id as id,
|
org.name as name,
|
org.org_code as orgCode,
|
org.user_org_code as userOrgCode,
|
org.pid as pid,
|
org.lv as lv,
|
org.sort_no as sortNo,
|
org.state as state,
|
org.note as note,
|
org.lon as lon,
|
org.lat as lat,
|
org.phone as phone,
|
org.open_time as openTime,
|
org.address as address
|
from sys_org org
|
LEFT JOIN sys_org o2 on o2.id = org.pid
|
LEFT JOIN sys_org o1 on o1.id = o2.pid
|
where org.lv=3
|
<if test="code !=null and code !=''">
|
and org.org_code like CONCAT( #{code},'%')
|
</if>
|
<if test="keyText !=null and keyText !=''">
|
and (
|
org.address like concat('%',#{keyText},'%')
|
or org.`name` like concat('%',#{keyText},'%')
|
or o1.`name` like concat('%',#{keyText},'%')
|
or o2.`name` like concat('%',#{keyText},'%')
|
)
|
</if>
|
</select>
|
|
<select id="selectOrgByCode" parameterType="string" resultMap="BaseResultMap">
|
select
|
<include refid="Base_Column_List"/>
|
from sys_org where user_org_code = #{code}
|
</select>
|
|
<insert id="batchImportOrg" parameterType="list">
|
insert into sys_org
|
(id,name,org_code,user_org_code,pid,lv,sort_no,state,note)
|
values
|
<foreach collection="list" index="i" item="n" separator=",">
|
(
|
#{n.id},
|
#{n.name},
|
#{n.orgCode},
|
#{n.userOrgCode},
|
#{n.pid},
|
#{n.lv},
|
#{n.sortNo},
|
#{n.state},
|
#{n.note}
|
)
|
</foreach>
|
</insert>
|
<select id="getListForRoleUser" parameterType="map" resultMap="BaseResultMap">
|
select <include refid="Base_Column_List"></include>
|
from sys_org
|
|
<where>
|
and state = 1
|
<choose>
|
<when test="pid != null">
|
and pid = #{pid}
|
</when>
|
<otherwise>
|
and id = #{orgId}
|
</otherwise>
|
</choose>
|
</where>
|
</select>
|
<!-- 此方法为机构级联选择期公用方法,慎重修改 -->
|
<select id="getOrgForSelector" parameterType="long" resultMap="BaseResultMap">
|
select <include refid="Base_Column_List"/>
|
from sys_org
|
<where>
|
and state = 1
|
<if test="pid != null">
|
and pid = #{pid}
|
</if>
|
<if test="rootId != null">
|
and id = #{rootId}
|
</if>
|
<if test="pid == null and rootId==null">
|
and pid = 0
|
</if>
|
</where>
|
order by sort_no
|
</select>
|
|
<select id="getByOrgCode" parameterType="com.nuvole.four.domain.SysOrg" resultType="integer">
|
select count(id) from sys_org
|
<where>
|
<if test="userOrgCode != null">
|
and user_org_code = #{userOrgCode}
|
</if>
|
<if test="id != null">
|
and id != #{id}
|
</if>
|
</where>
|
</select>
|
|
</mapper>
|