|
@@ -8,9 +8,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
<id property="deptId" column="dept_id" />
|
|
<id property="deptId" column="dept_id" />
|
|
|
<result property="parentId" column="parent_id" />
|
|
<result property="parentId" column="parent_id" />
|
|
|
<result property="ancestors" column="ancestors" />
|
|
<result property="ancestors" column="ancestors" />
|
|
|
|
|
+ <result property="provinceCode" column="province_code" />
|
|
|
|
|
+ <result property="provinceName" column="province_name" />
|
|
|
<result property="deptName" column="dept_name" />
|
|
<result property="deptName" column="dept_name" />
|
|
|
<result property="cityCode" column="city_code" />
|
|
<result property="cityCode" column="city_code" />
|
|
|
<result property="cityName" column="city_name" />
|
|
<result property="cityName" column="city_name" />
|
|
|
|
|
+ <result property="districtCode" column="district_code" />
|
|
|
|
|
+ <result property="districtName" column="district_name" />
|
|
|
<result property="orderNum" column="order_num" />
|
|
<result property="orderNum" column="order_num" />
|
|
|
<result property="leader" column="leader" />
|
|
<result property="leader" column="leader" />
|
|
|
<result property="phone" column="phone" />
|
|
<result property="phone" column="phone" />
|
|
@@ -25,7 +29,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
</resultMap>
|
|
</resultMap>
|
|
|
|
|
|
|
|
<sql id="selectDeptVo">
|
|
<sql id="selectDeptVo">
|
|
|
- select d.dept_id, d.parent_id, d.ancestors, d.dept_name,d.city_code,d.city_name, d.order_num, d.leader, d.phone, d.email, d.status, d.is_delete, d.create_by, d.create_time
|
|
|
|
|
|
|
+ select d.dept_id, d.parent_id, d.ancestors, d.province_code, d.province_name, d.dept_name,
|
|
|
|
|
+ d.city_code, d.city_name, d.district_code, d.district_name, d.order_num, d.leader,
|
|
|
|
|
+ d.phone, d.email, d.status, d.is_delete, d.create_by, d.create_time
|
|
|
from sys_dept d
|
|
from sys_dept d
|
|
|
</sql>
|
|
</sql>
|
|
|
|
|
|
|
@@ -72,6 +78,53 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
order by d.parent_id, d.order_num
|
|
order by d.parent_id, d.order_num
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
|
|
+ <!-- 按省市查询部门平铺列表,包含顶级部门 -->
|
|
|
|
|
+ <select id="selectDeptFlatListByRegion" resultMap="SysDeptResult">
|
|
|
|
|
+ <include refid="selectDeptVo"/>
|
|
|
|
|
+ <where>
|
|
|
|
|
+ d.is_delete = 0
|
|
|
|
|
+ AND (
|
|
|
|
|
+ d.parent_id = 0
|
|
|
|
|
+ <if test="(dept.provinceCode != null and dept.provinceCode != '')
|
|
|
|
|
+ or (dept.provinceName != null and dept.provinceName != '')
|
|
|
|
|
+ or (dept.cityCode != null and dept.cityCode != '')
|
|
|
|
|
+ or (dept.cityName != null and dept.cityName != '')">
|
|
|
|
|
+ OR (
|
|
|
|
|
+ 1 = 1
|
|
|
|
|
+ <if test="dept.provinceCode != null and dept.provinceCode != ''">
|
|
|
|
|
+ AND d.province_code = #{dept.provinceCode}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="dept.provinceName != null and dept.provinceName != ''">
|
|
|
|
|
+ AND d.province_name = #{dept.provinceName}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="dept.cityCode != null and dept.cityCode != ''">
|
|
|
|
|
+ AND d.city_code = #{dept.cityCode}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ <if test="dept.cityName != null and dept.cityName != ''">
|
|
|
|
|
+ AND d.city_name = #{dept.cityName}
|
|
|
|
|
+ </if>
|
|
|
|
|
+ )
|
|
|
|
|
+ </if>
|
|
|
|
|
+ )
|
|
|
|
|
+ </where>
|
|
|
|
|
+ order by d.parent_id, d.order_num, d.dept_id
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 查询城市列表 -->
|
|
|
|
|
+ <select id="selectCityList" resultType="com.ylx.system.domain.vo.SysDeptCityVo">
|
|
|
|
|
+ select distinct
|
|
|
|
|
+ d.city_code as cityCode,
|
|
|
|
|
+ d.city_name as cityName
|
|
|
|
|
+ from sys_dept d
|
|
|
|
|
+ where d.is_delete = 0
|
|
|
|
|
+ and d.status = '0'
|
|
|
|
|
+ and d.city_code is not null
|
|
|
|
|
+ and d.city_code != ''
|
|
|
|
|
+ and d.city_name is not null
|
|
|
|
|
+ and d.city_name != ''
|
|
|
|
|
+ order by d.city_code, d.city_name
|
|
|
|
|
+ </select>
|
|
|
|
|
+
|
|
|
<select id="selectDeptListByRoleId" resultType="Long">
|
|
<select id="selectDeptListByRoleId" resultType="Long">
|
|
|
select d.dept_id
|
|
select d.dept_id
|
|
|
from sys_dept d
|
|
from sys_dept d
|
|
@@ -114,39 +167,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
where dept_name=#{deptName} and parent_id = #{parentId} and is_delete = 0 limit 1
|
|
where dept_name=#{deptName} and parent_id = #{parentId} and is_delete = 0 limit 1
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
- <!-- 新增部门 -->
|
|
|
|
|
- <insert id="insertDept" parameterType="SysDept">
|
|
|
|
|
- insert into sys_dept(
|
|
|
|
|
- <if test="deptId != null and deptId != 0">dept_id,</if>
|
|
|
|
|
- <if test="parentId != null and parentId != 0">parent_id,</if>
|
|
|
|
|
- <if test="deptName != null and deptName != ''">dept_name,</if>
|
|
|
|
|
- <if test="cityCode != null and cityCode != ''">city_code,</if>
|
|
|
|
|
- <if test="cityName != null and cityName != ''">city_name,</if>
|
|
|
|
|
- <if test="ancestors != null and ancestors != ''">ancestors,</if>
|
|
|
|
|
- <if test="orderNum != null">order_num,</if>
|
|
|
|
|
- <if test="leader != null and leader != ''">leader,</if>
|
|
|
|
|
- <if test="phone != null and phone != ''">phone,</if>
|
|
|
|
|
- <if test="email != null and email != ''">email,</if>
|
|
|
|
|
- <if test="status != null">status,</if>
|
|
|
|
|
- <if test="createBy != null and createBy != ''">create_by,</if>
|
|
|
|
|
- create_time
|
|
|
|
|
- )values(
|
|
|
|
|
- <if test="deptId != null and deptId != 0">#{deptId},</if>
|
|
|
|
|
- <if test="parentId != null and parentId != 0">#{parentId},</if>
|
|
|
|
|
- <if test="deptName != null and deptName != ''">#{deptName},</if>
|
|
|
|
|
- <if test="cityCode != null and cityCode != ''">#{cityCode},</if>
|
|
|
|
|
- <if test="cityName != null and cityName != ''">#{cityName},</if>
|
|
|
|
|
- <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
|
|
|
|
|
- <if test="orderNum != null">#{orderNum},</if>
|
|
|
|
|
- <if test="leader != null and leader != ''">#{leader},</if>
|
|
|
|
|
- <if test="phone != null and phone != ''">#{phone},</if>
|
|
|
|
|
- <if test="email != null and email != ''">#{email},</if>
|
|
|
|
|
- <if test="status != null">#{status},</if>
|
|
|
|
|
- <if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
|
|
|
- sysdate()
|
|
|
|
|
- )
|
|
|
|
|
- </insert>
|
|
|
|
|
-
|
|
|
|
|
<update id="updateDept" parameterType="SysDept">
|
|
<update id="updateDept" parameterType="SysDept">
|
|
|
update sys_dept
|
|
update sys_dept
|
|
|
<set>
|
|
<set>
|