48 lines
1.7 KiB
XML
48 lines
1.7 KiB
XML
<?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="SystemDeptMapper">
|
|
|
|
<resultMap type="Dept" id="DeptResult">
|
|
<id property="deptId" column="dept_id" />
|
|
<result property="parentId" column="parent_id" />
|
|
<result property="deptName" column="dept_name" />
|
|
<result property="orderNum" column="order_num" />
|
|
<result property="status" column="status" />
|
|
<result property="parentName" column="parent_name" />
|
|
</resultMap>
|
|
|
|
<select id="selectDeptAll" resultMap="DeptResult">
|
|
select * from sys_dept
|
|
</select>
|
|
|
|
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
|
|
select count(*) from sys_user where dept_id = #{deptId}
|
|
</select>
|
|
|
|
<select id="selectDeptCount" parameterType="Dept" resultType="int">
|
|
select count(*) from sys_dept
|
|
<where>
|
|
<if test="deptId != null and deptId != 0"> and dept_id = #{deptId} </if>
|
|
<if test="parentId != null and parentId != 0"> and parent_id = #{parentId} </if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectDeptById" parameterType="Long" resultMap="DeptResult">
|
|
select t.dept_id, t.parent_id, t.dept_name, t.order_num, t.status,
|
|
(select dept_name from sys_dept where dept_id = t.parent_id) parent_name
|
|
from sys_dept t
|
|
where dept_id = #{deptId}
|
|
</select>
|
|
|
|
<insert id="saveDept" parameterType="Dept">
|
|
replace into sys_dept(dept_id, parent_id, dept_name, order_num, status)
|
|
values (#{deptId}, #{parentId}, #{deptName}, #{orderNum}, #{status})
|
|
</insert>
|
|
|
|
<delete id="deleteDeptById" parameterType="Long">
|
|
delete from sys_dept where dept_id = #{deptId}
|
|
</delete>
|
|
|
|
</mapper> |