<?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.yuanchu.mom.mapper.DepartmentLimsMapper">
|
|
<resultMap id="BaseResultMap" type="com.yuanchu.mom.pojo.DepartmentLims">
|
<id property="id" column="id" jdbcType="INTEGER"/>
|
<result property="name" column="name" jdbcType="VARCHAR"/>
|
<result property="fatherId" column="father_id" jdbcType="INTEGER"/>
|
<result property="createUser" column="create_user" jdbcType="INTEGER"/>
|
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
<result property="updateUser" column="update_user" jdbcType="INTEGER"/>
|
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
</resultMap>
|
|
<select id="selectDepartment" resultType="com.yuanchu.mom.dto.DepartmentDto">
|
SELECT id, name, father_id
|
FROM department_lims
|
</select>
|
|
<select id="selectSonById" resultType="java.lang.Integer">
|
SELECT au.id
|
FROM (SELECT * FROM department_lims WHERE father_id IS NOT NULL) au,
|
(SELECT @father_id := #{id}) pd
|
WHERE FIND_IN_SET(father_id, @father_id) > 0
|
AND @father_id := concat(@father_id, ',', id)
|
UNION
|
SELECT id
|
FROM department_lims
|
WHERE id = #{id}
|
ORDER BY id
|
</select>
|
</mapper>
|