325 lines
9.2 KiB
XML
325 lines
9.2 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="com.bonus.sys.dao.OrgDao" >
|
|
<resultMap id="BaseResultMap" type="com.bonus.sys.beans.OrgBean" >
|
|
<id column="ID" property="id" jdbcType="INTEGER" />
|
|
<result column="NAME" property="name" jdbcType="VARCHAR" />
|
|
<result column="CODE" property="code" jdbcType="VARCHAR" />
|
|
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
|
|
|
|
<result column="parentName" property="parent.name" />
|
|
<result column="parentCode" property="parent.code" />
|
|
<result column="parentId" property="parent.id" />
|
|
|
|
<result column="PARENT_ID" property="parentId" jdbcType="INTEGER" />
|
|
<result column="IS_ACTIVE" property="isActive" jdbcType="INTEGER" />
|
|
<result column="userName" property="user.name" jdbcType="VARCHAR" />
|
|
<result column="userId" property="user.id" jdbcType="INTEGER" />
|
|
</resultMap>
|
|
|
|
|
|
<select id="findParentOrgById" resultMap="BaseResultMap" parameterType="java.lang.String">
|
|
SELECT
|
|
pop.id AS id,
|
|
pop.NAME AS name
|
|
FROM
|
|
pm_organization po
|
|
LEFT JOIN pm_organization pop on pop.id = po.PARENT_ID
|
|
WHERE
|
|
po.id = #{companyId}
|
|
</select>
|
|
|
|
<select id="findOrgBySelect" resultMap="BaseResultMap" parameterType="com.bonus.sys.beans.OrgBean">
|
|
SELECT
|
|
po.id AS id,
|
|
po.NAME AS name
|
|
FROM
|
|
pm_organization po
|
|
LEFT JOIN pm_organization pop on pop.id = po.PARENT_ID
|
|
where
|
|
pop.id = 33
|
|
</select>
|
|
|
|
<select id="getOrgTree" resultType="com.bonus.sys.beans.ZNode" >
|
|
SELECT
|
|
po.id,
|
|
po.`CODE`,
|
|
po.`NAME`,
|
|
po.PARENT_ID AS pId
|
|
FROM
|
|
pm_organization po
|
|
</select>
|
|
|
|
<select id="findOrgById" resultMap="BaseResultMap" parameterType="com.bonus.sys.beans.OrgBean">
|
|
SELECT
|
|
po.id,
|
|
po.`CODE`,
|
|
po.`NAME`,
|
|
po.PARENT_ID,
|
|
po.DESCRIPTION,
|
|
po.IS_ACTIVE,
|
|
pu.`NAME` AS userName,
|
|
pu.ID AS userId,
|
|
poo.id AS parentId,
|
|
poo.`CODE` AS parentCode,
|
|
poo.`NAME` AS parentName
|
|
FROM
|
|
pm_organization po
|
|
LEFT JOIN pm_user pu ON po.technician = pu.id
|
|
LEFT JOIN pm_organization poo ON poo.id = po.PARENT_ID
|
|
WHERE
|
|
po.id = #{id}
|
|
</select>
|
|
|
|
<select id="checkNameIsExist" resultMap="BaseResultMap" parameterType="com.bonus.sys.beans.OrgBean">
|
|
SELECT
|
|
po.id,
|
|
po.`CODE`,
|
|
po.`NAME`
|
|
FROM
|
|
pm_organization po
|
|
WHERE
|
|
po.`CODE` like #{code}
|
|
AND
|
|
po.`NAME` = #{name}
|
|
</select>
|
|
|
|
<select id="getLastChild" resultMap="BaseResultMap" parameterType="com.bonus.sys.beans.OrgBean">
|
|
select
|
|
po.id,
|
|
po.`CODE`,
|
|
po.`NAME`,
|
|
po.PARENT_ID
|
|
from
|
|
pm_organization po
|
|
where
|
|
po.`CODE` like CONCAT(#{code},'___')
|
|
order by
|
|
po.`CODE` desc
|
|
limit 1
|
|
</select>
|
|
|
|
|
|
<select id="findByPage" parameterType="com.bonus.sys.beans.OrgBean" resultMap="BaseResultMap" >
|
|
SELECT
|
|
po.id,
|
|
po.`CODE`,
|
|
po.`NAME`,
|
|
po.PARENT_ID,
|
|
po.DESCRIPTION,
|
|
po.IS_ACTIVE,
|
|
pu.`NAME` AS userName,
|
|
pu.ID AS userId
|
|
FROM
|
|
pm_organization po
|
|
LEFT JOIN pm_user pu ON po.technician = pu.id
|
|
where
|
|
1 = 1
|
|
<if test="param.keyWord != null and param.keyWord != ''">
|
|
and (
|
|
po.`NAME` like CONCAT('%',#{param.keyWord},'%') or
|
|
po.`CODE` like CONCAT('%',#{param.keyWord},'%') or
|
|
pu.`NAME` like CONCAT('%',#{param.keyWord},'%')
|
|
)
|
|
</if>
|
|
<if test="param.code != null and param.code != ''">
|
|
and po.`CODE` like CONCAT(#{param.code},'%')
|
|
</if>
|
|
ORDER BY po.`CODE`
|
|
</select>
|
|
|
|
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
|
|
select ID,NAME,DESCRIPTION,PARENT_ID,IS_ACTIVE
|
|
from pm_organization
|
|
where ID = #{id,jdbcType=INTEGER}
|
|
</select>
|
|
<delete id="deleteByPrimaryKey" parameterType="com.bonus.sys.beans.OrgBean" >
|
|
delete from pm_organization
|
|
where ID = #{id,jdbcType=INTEGER}
|
|
</delete>
|
|
<insert id="insertBean" parameterType="com.bonus.sys.beans.OrgBean" >
|
|
insert into
|
|
pm_organization
|
|
(ID,
|
|
NAME,
|
|
DESCRIPTION,
|
|
PARENT_ID,
|
|
IS_ACTIVE)
|
|
values (#{id,jdbcType=INTEGER},
|
|
#{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
|
|
#{parentId,jdbcType=INTEGER}, 1)
|
|
<selectKey resultType="int" keyProperty="id" >
|
|
SELECT last_insert_id() as ID;
|
|
</selectKey>
|
|
</insert>
|
|
<insert id="insertSelective" parameterType="com.bonus.sys.beans.OrgBean" >
|
|
insert into pm_organization
|
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
|
<if test="id != null" >
|
|
ID,
|
|
</if>
|
|
<if test="name != null" >
|
|
NAME,
|
|
</if>
|
|
<if test="description != null" >
|
|
DESCRIPTION,
|
|
</if>
|
|
<if test="parentId != null" >
|
|
PARENT_ID,
|
|
</if>
|
|
<if test="isActive != null" >
|
|
IS_ACTIVE,
|
|
</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="description != null" >
|
|
#{description,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="parentId != null" >
|
|
#{parentId,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="isActive != null" >
|
|
#{isActive,jdbcType=INTEGER},
|
|
</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<insert id="insertOrg" parameterType="com.bonus.sys.beans.OrgBean" >
|
|
insert into
|
|
pm_organization
|
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
|
<if test="name != null" >
|
|
NAME,
|
|
</if>
|
|
<if test="description != null" >
|
|
DESCRIPTION,
|
|
</if>
|
|
<if test="parent != null" >
|
|
PARENT_ID,
|
|
</if>
|
|
<if test="isActive != null" >
|
|
IS_ACTIVE,
|
|
</if>
|
|
<if test="user != null" >
|
|
technician,
|
|
</if>
|
|
<if test="code != null" >
|
|
code,
|
|
</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
|
<if test="name != null" >
|
|
#{name,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="description != null" >
|
|
#{description,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="parent != null" >
|
|
#{parent.id,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="isActive != null" >
|
|
#{isActive,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="user != null" >
|
|
#{user.id,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="code != null" >
|
|
#{code,jdbcType=VARCHAR},
|
|
</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateOrg" parameterType="com.bonus.sys.beans.OrgBean" >
|
|
update pm_organization
|
|
<set >
|
|
<if test="name != null" >
|
|
NAME = #{name,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="description != null" >
|
|
DESCRIPTION = #{description,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="parent != null" >
|
|
PARENT_ID = #{parent.id,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="isActive != null" >
|
|
IS_ACTIVE = #{isActive,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="code != null" >
|
|
code = #{code,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="user != null" >
|
|
technician = #{user.id,jdbcType=INTEGER},
|
|
</if>
|
|
</set>
|
|
where ID = #{id,jdbcType=INTEGER}
|
|
</update>
|
|
|
|
<update id="updateByPrimaryKeySelective" parameterType="com.bonus.sys.beans.OrgBean" >
|
|
update pm_organization
|
|
<set >
|
|
<if test="name != null" >
|
|
NAME = #{name,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="description != null" >
|
|
DESCRIPTION = #{description,jdbcType=VARCHAR},
|
|
</if>
|
|
<if test="parentId != null" >
|
|
PARENT_ID = #{parentId,jdbcType=INTEGER},
|
|
</if>
|
|
<if test="isActive != null" >
|
|
IS_ACTIVE = #{isActive,jdbcType=CHAR},
|
|
</if>
|
|
</set>
|
|
where ID = #{id,jdbcType=INTEGER}
|
|
</update>
|
|
<update id="updateByPrimaryKey" parameterType="com.bonus.sys.beans.OrgBean" >
|
|
update pm_organization
|
|
set NAME = #{name,jdbcType=VARCHAR},
|
|
DESCRIPTION = #{description,jdbcType=VARCHAR},
|
|
PARENT_ID = #{parentId,jdbcType=INTEGER},
|
|
IS_ACTIVE = #{isActive,jdbcType=CHAR}
|
|
where ID = #{id,jdbcType=INTEGER}
|
|
</update>
|
|
|
|
<select id="findRepairGroup" parameterType="com.bonus.sys.beans.OrgBean" resultMap="BaseResultMap" >
|
|
SELECT p.ID,p.`NAME`
|
|
FROM pm_organization p
|
|
WHERE p.PARENT_ID = 6
|
|
order by p.ID asc
|
|
</select>
|
|
|
|
<select id="findRepairGroupList" parameterType="com.bonus.sys.beans.OrgBean" resultMap="BaseResultMap" >
|
|
SELECT p.ID,p.`NAME`
|
|
FROM pm_organization p
|
|
WHERE p.PARENT_ID = 5
|
|
order by p.ID
|
|
</select>
|
|
|
|
<select id="getBackGroup" parameterType="com.bonus.sys.beans.OrgBean" resultMap="BaseResultMap" >
|
|
SELECT p.ID,p.`NAME`
|
|
FROM pm_organization p
|
|
WHERE p.PARENT_ID = 6
|
|
order by p.ID asc
|
|
</select>
|
|
|
|
|
|
<select id="checkIsRepairDept" parameterType="java.lang.Integer" resultType="java.lang.Integer" >
|
|
SELECT
|
|
ppo.id
|
|
FROM
|
|
pm_organization po
|
|
LEFT JOIN
|
|
pm_organization ppo
|
|
ON
|
|
ppo.id = po.PARENT_ID
|
|
WHERE
|
|
po.ID = #{0}
|
|
</select>
|
|
|
|
</mapper> |