hn_cloud_service/hn-czl-service/src/main/resources/mappers/user/OrgMapper.xml

59 lines
2.1 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.hn.bearing.capacity.backstage.manager.dao.OrgDao">
<resultMap id="ZNode" type="com.bonus.hn.bearing.capacity.backstage.manager.entity.ZNode"></resultMap>
<select id="getAll" parameterType="com.bonus.hn.bearing.capacity.backstage.manager.entity.OrgBean" resultMap="ZNode">
SELECT
po.ID AS id,
po.parent_id AS pId ,
po.`org_name` as name
FROM bns_czl_sys_organization po
WHERE
po.is_active = '1'
<if test="companyId!=null and companyId!='' ">
and po.ID =#{companyId}
</if>
</select>
<select id="getCompanyTree" parameterType="com.bonus.hn.bearing.capacity.backstage.manager.entity.OrgBean" resultMap="ZNode">
SELECT
po.ID AS id,
po.parent_id AS pId ,
po.`org_name` as name
FROM bns_czl_sys_organization po
WHERE
po.is_active = '1'
<if test="companyId!=null and companyId!='' ">
and po.ID =#{companyId}
</if>
</select>
<insert id="addOrg" parameterType="com.bonus.hn.bearing.capacity.backstage.manager.entity.OrgBean">
insert into bns_czl_pm_device_type( type_name,pId,IS_ACTIVE,current_day)
values ( #{name},#{parentId},'1',now())
</insert>
<update id="updateOrg" parameterType="com.bonus.hn.bearing.capacity.backstage.manager.entity.OrgBean">
update bns_czl_pm_device_type
<set>
<if test="name != null">
type_name =#{name},
</if>
</set>
where ID = #{id}
</update>
<update id="deleteOrg" parameterType="com.bonus.hn.bearing.capacity.backstage.manager.entity.OrgBean">
update bns_czl_pm_device_type set IS_ACTIVE = 0 WHERE ID = #{id}
</update>
<select id="findCompanyInfo" resultType="com.bonus.hn.bearing.capacity.backstage.manager.entity.OrgBean" parameterType="com.bonus.hn.bearing.capacity.backstage.manager.entity.OrgBean" >
SELECT po.ID as companyId,po.`type_name` as companyName,po.pId as parentId
FROM bns_czl_pm_device_type po
WHERE po.ID = #{id} AND po.IS_ACTIVE = 1
</select>
</mapper>