hd_real_name/target/classes/mappers/manager/OrgMapper.xml

95 lines
2.8 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.gzrn.rnbmw.manager.dao.OrgDao">
<resultMap id="ZNode" type="com.bonus.gzrn.rnbmw.manager.entity.ZNode"></resultMap>
<delete id="deleteTeamType">
update bm_sub_team_type set IS_ACTIVE = '0' WHERE ID = #{id}
</delete>
<select id="getAll" parameterType="com.bonus.gzrn.rnbmw.manager.entity.OrgBean" resultMap="ZNode">
SELECT
po.ID AS id,
po.PARENT_ID AS pId ,
po.COMPANY_ID as companyId,
po.`NAME` as name
FROM
pm_organization po
LEFT JOIN pm_company pc on po.COMPANY_ID = pc.ID
WHERE
po.is_active = '1'
<if test="companyId!=null and companyId!='' ">
and pc.ID =#{companyId}
</if>
</select>
<select id="getTeamTypeList" parameterType="com.bonus.gzrn.rnbmw.manager.entity.OrgBean" resultMap="ZNode">
SELECT
bstt.ID AS id,bstt.`NAME` AS name,'0' AS pId,'0' AS companyId
FROM bm_sub_team_type bstt
WHERE bstt.IS_ACTIVE = '1'
</select>
<select id="getTeamNumByType" resultType="int">
SELECT count(1) from bm_sub_team WHERE IS_ACTIVE = '1' and team_type_id = #{id}
</select>
<select id="getCompanyTree" parameterType="com.bonus.gzrn.rnbmw.manager.entity.OrgBean" resultMap="ZNode">
SELECT
ID AS id,
PARENT_ID AS pId ,
`NAME` as name,
COMPANY_ID as companyId
FROM
pm_organization
WHERE
is_active = '1'
<if test="companyId!=null and companyId!='' and companyId!='0' ">
and COMPANY_ID = #{companyId}
</if>
</select>
<insert id="addOrg" parameterType="com.bonus.gzrn.rnbmw.manager.entity.OrgBean">
insert into pm_organization( NAME,PARENT_ID,IS_ACTIVE,TYPE,update_time,COMPANY_ID)
values ( #{name},#{parentId},'1',#{type},now(),#{companyId})
</insert>
<insert id="addTeamType">
insert into bm_sub_team_type(NAME) values (#{name})
</insert>
<update id="updateOrg" parameterType="com.bonus.gzrn.rnbmw.manager.entity.OrgBean">
update pm_organization
<set>
<if test="name != null">
NAME =#{name},
</if>
</set>
where ID = #{id}
</update>
<update id="deleteOrg" parameterType="com.bonus.gzrn.rnbmw.manager.entity.OrgBean">
update pm_organization set IS_ACTIVE = 0 WHERE ID = #{id}
</update>
<update id="updateTeamType">
update bm_sub_team_type
<set>
<if test="name != null">
NAME =#{name},
</if>
</set>
where ID = #{id}
</update>
<select id="findCompanyInfo" resultType="com.bonus.gzrn.rnbmw.manager.entity.OrgBean" parameterType="com.bonus.gzrn.rnbmw.manager.entity.OrgBean" >
SELECT po.ID as companyId,po.`NAME` as companyName,po.PARENT_ID as parentId
FROM pm_organization po
WHERE po.ID = #{id} AND po.IS_ACTIVE = 1
</select>
</mapper>