无关风月
2024-11-04 64f7ccb9ef8b5a0618e65cddc14b981c1f108ba3
xinquan-modules/xinquan-system/src/main/resources/mapper/system/SysDeptMapper.xml
@@ -23,8 +23,9 @@
   </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
        from sys_dept d
        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.dept_code,d.remark
      from sys_dept d
    </sql>
    
   <select id="selectDeptList" parameterType="com.xinquan.system.api.domain.SysDept" resultMap="SysDeptResult">
@@ -82,10 +83,33 @@
   
   <select id="checkDeptNameUnique" resultMap="SysDeptResult">
       <include refid="selectDeptVo"/>
      where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
      where dept_code=#{deptCode} and del_flag = '0' limit 1
   </select>
    <insert id="insertDept" parameterType="com.xinquan.system.api.domain.SysDept">
   <select id="checkDeptNameUnique1" resultMap="SysDeptResult">
       <include refid="selectDeptVo"/>
      where dept_code=#{deptCode} and dept_id!=#{deptId} and del_flag = '0' limit 1
   </select>
   <select id="getList" resultType="com.xinquan.system.api.domain.SysDept">
      select d.dept_id as deptId, d.parent_id as parentId,
             d.ancestors, d.dept_name as deptName,
             d.order_num, d.leader,
             d.phone, d.email, d.status,
             d.del_flag, d.create_by, d.create_time AS createTime,d.remark,
      d.update_by as updateBy,
      d.handleName as handleName,
      d.reason,
       d.dept_code as deptCode
      from
                   sys_dept d
      where 1 = 1
      <if test="null != deptName and deptName!=''">
         and (d.dept_code  LIKE CONCAT('%',#{deptName},'%') or d.dept_id  LIKE CONCAT('%',#{deptName},'%'))
      </if>
      and d.del_flag = '0'
   </select>
   <insert id="insertDept" parameterType="com.xinquan.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 +121,8 @@
          <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="remark != null and remark != ''">remark,</if>
          <if test="deptCode != null and deptCode != ''">dept_code,</if>
          create_time
       )values(
          <if test="deptId != null and deptId != 0">#{deptId},</if>
@@ -109,7 +135,10 @@
          <if test="email != null and email != ''">#{email},</if>
          <if test="status != null">#{status},</if>
          <if test="createBy != null and createBy != ''">#{createBy},</if>
          sysdate()
      <if test="remark != null and remark != ''">#{remark},</if>
      <if test="deptCode != null and deptCode != ''">#{deptCode},</if>
      sysdate()
       )
   </insert>
   
@@ -125,6 +154,9 @@
          <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="updateBy != null and updateBy != ''">remark = #{remark},</if>
         <if test="deptCode != null and deptCode != ''">dept_code = #{deptCode},</if>
         <if test="handleName != null and handleName != ''">handleName = #{handleName},</if>
          update_time = sysdate()
       </set>
       where dept_id = #{deptId}