sfd
2025-05-26 2a64b537e8e3bce9ce030585a3da17d48379c0ad
aps-modules/aps-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.aps.system.mapper.SysDeptMapper">
   <resultMap type="SysDept" id="SysDeptResult">
   <resultMap type="com.aps.system.api.domain.SysDept" id="SysDeptResult">
      <id     property="deptId"     column="dept_id"     />
      <result property="parentId"   column="parent_id"   />
      <result property="ancestors"  column="ancestors"   />
@@ -20,14 +20,17 @@
      <result property="createTime" column="create_time" />
      <result property="updateBy"   column="update_by"   />
      <result property="updateTime" column="update_time" />
      <result property="orgCode"    column="org_code"      />
   </resultMap>
   
   <sql id="selectDeptVo">
        select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
        select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,
               d.del_flag, d.create_by, d.create_time ,
               d.org_code
        from sys_dept d
    </sql>
    
   <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
   <select id="selectDeptList" parameterType="com.aps.system.api.domain.SysDept" resultMap="SysDeptResult">
        <include refid="selectDeptVo"/>
        where d.del_flag = '0'
      <if test="deptId != null and deptId != 0">
@@ -37,7 +40,7 @@
         AND parent_id = #{parentId}
      </if>
      <if test="deptName != null and deptName != ''">
         AND dept_name like concat('%', #{deptName}, '%')
         AND dept_name like '%' || #{deptName} '%'
      </if>
      <if test="status != null and status != ''">
         AND status = #{status}
@@ -85,7 +88,7 @@
      where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
   </select>
    
    <insert id="insertDept" parameterType="SysDept">
    <insert id="insertDept" parameterType="com.aps.system.api.domain.SysDept">
       insert into sys_dept(
          <if test="deptId != null and deptId != 0">dept_id,</if>
          <if test="parentId != null and parentId != 0">parent_id,</if>
@@ -97,6 +100,7 @@
          <if test="email != null and email != ''">email,</if>
          <if test="status != null">status,</if>
          <if test="createBy != null and createBy != ''">create_by,</if>
         <if test="orgCode != null and orgCode != ''">org_code,</if>
          create_time
       )values(
          <if test="deptId != null and deptId != 0">#{deptId},</if>
@@ -109,11 +113,12 @@
          <if test="email != null and email != ''">#{email},</if>
          <if test="status != null">#{status},</if>
          <if test="createBy != null and createBy != ''">#{createBy},</if>
         <if test="orgCode != null and orgCode != ''">#{orgCode},</if>
          now()
       )
   </insert>
   
   <update id="updateDept" parameterType="SysDept">
   <update id="updateDept" parameterType="com.aps.system.api.domain.SysDept">
       update sys_dept
       <set>
          <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
@@ -125,6 +130,7 @@
          <if test="email != null">email = #{email},</if>
          <if test="status != null and status != ''">status = #{status},</if>
          <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
         <if test="orgCode != null and orgCode != ''">org_code = #{orgCode},</if>
          update_time = now()
       </set>
       where dept_id = #{deptId}
@@ -153,5 +159,13 @@
   <delete id="deleteDeptById" parameterType="Long">
      update sys_dept set del_flag = '2' where dept_id = #{deptId}
   </delete>
   <select id="selectDeptListByIdList" parameterType="Long" resultMap="SysDeptResult">
      <include refid="selectDeptVo"/>
      where d.del_flag = '0' and dept_id in
      <foreach collection="deptIdList" item="deptId" open="(" separator="," close=")">
         #{deptId}
      </foreach>
      order by d.parent_id, d.order_num
   </select>
</mapper>