ganzi-api/inventory-dao/src/main/resources/mapper/ent/EntPostMapper.xml
2023-03-20 09:25:09 +08:00

80 lines
3.6 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.rzyc.mapper.ent.EntPostMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.rzyc.model.ent.EntPost">
<id column="post_id" property="postId" />
<result column="enterprise_id" property="enterpriseId" />
<result column="name" property="name" />
<result column="parent_id" property="parentId" />
<result column="post_path" property="postPath" />
<result column="parent_name" property="parentName" />
<result column="post_level" property="postLevel" />
<result column="completion_rate" property="completionRate" />
<result column="create_time" property="createTime" />
<result column="create_by" property="createBy" />
<result column="modify_time" property="modifyTime" />
<result column="modify_by" property="modifyBy" />
<result column="subordinates" property="subordinates"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
post_id, enterprise_id, name, parent_id, post_path, parent_name, post_level, completion_rate, create_time, create_by, modify_time, modify_by
</sql>
<select id="selectEntUserTree" resultMap="BaseResultMap">
select * from ent_post
where enterprise_id = #{enterpriseId} and del_state = 1
<if test="null != postId and '' != postId">
and post_path like concat('%',#{postId},'%')
</if>
order by post_level,sort asc
</select>
<update id="updateEntPost">
update ent_post set name = #{data.name},parent_id = #{data.parentId},post_path = #{data.postPath},parent_name = #{data.parentName},post_level = #{data.postLevel},
modify_time = #{data.modifyTime} , modify_by = #{data.modifyBy}
where post_id = #{data.postId} and enterprise_id = #{data.enterpriseId}
</update>
<insert id="insertEntPost">
insert into ent_post (post_id,enterprise_id,name,parent_id,post_path,parent_name,post_level,completion_rate,subordinates,create_time,create_by)
values(#{data.postId},#{data.enterpriseId},#{data.name},#{data.parentId},#{data.postPath},#{data.parentName},#{data.postLevel},#{data.completionRate},#{data.subordinates},
#{data.createTime},#{data.createBy})
</insert>
<select id="getParentPost" resultMap="BaseResultMap">
select ep2.* from ent_post ep inner join ent_post ep2 on ep2.post_id = ep.parent_id where ep.post_id = #{postId} and ep.del_state = 1
</select>
<delete id="deletePostOfLegalPerson">
delete from ent_post where `name` = #{legalPerson} and enterprise_id = #{enterpriseId}
</delete>
<update id="deleteEntPost">
update ent_post set del_state = #{delState} where post_id = #{postId}
</update>
<select id="selectNoDutyPost" resultType="com.rzyc.model.ent.EntPost">
select ep.* from ent_post ep left join ent_post_duty epd on epd.post_id = ep.post_id where epd.post_id is null
</select>
<insert id="insertEntPostBatch">
insert into ent_post (post_id,enterprise_id,`name`,post_path,create_time,public_post_id)values
<foreach collection="list" item="list" separator=",">
(#{list.uuid},
#{sysEnterpriseId},
#{list.publicPostName},
#{list.publicPostPath},
#{list.createTime},
#{list.publicPostId})
</foreach>
</insert>
</mapper>