liujie
2025-05-09 3627366f9016271d29c663e1da9a22c547126756
springcloud_k8s_panzhihuazhihuishequ/service_sangeshenbian/src/main/resources/mapper/SystemUserMapper.xml
@@ -6,22 +6,17 @@
   
   <select id="list" resultType="com.panzhihua.sangeshenbian.warpper.SystemUserListVo">
      select
      select distinct
         a.id,
         a.name,
         a.phone,
         IF(a.four_department_id is not null, e.`name`, IF(a.three_department_id is not null, d.`name`, IF(a.two_department_id is not null, c.`name`, b.`name`))) as departmentName,
         f.`name` as systemPostName,
         g.`name` as systemRoleName,
         a.account_level as accountLevel,
         a.`status`
      from sgsb_system_user a
      left join sgsb_department b on (a.one_department_id = b.id)
      left join sgsb_department c on (a.two_department_id = c.id)
      left join sgsb_department d on (a.three_department_id = d.id)
      left join sgsb_department e on (a.four_department_id = e.id)
      left join sgsb_system_post f on (a.system_post_id = f.id)
      left join sgsb_system_role g on (a.system_role_id = g.id)
      left join sgsb_system_user_level h on (a.id = h.system_user_id)
      where a.`status` != 3
      <if test="null != query.name and '' != query.name">
         and a.name like CONCAT('%', #{query.name}, '%')
@@ -29,26 +24,47 @@
      <if test="null != query.phone and '' != query.phone">
         and a.phone like CONCAT('%', #{query.phone}, '%')
      </if>
      <if test="null != query.departmentId">
         and (a.one_department_id = #{query.departmentId} or a.two_department_id = #{query.departmentId} or a.three_department_id = #{query.departmentId} or a.four_department_id = #{query.departmentId})
      </if>
      <if test="null != query.systemRoleId">
         and a.system_role_id = #{query.systemRoleId}
      </if>
      <if test="null != user.accountLevel and 2 == user.accountLevel">
         and a.account_level >= #{user.accountLevel} and a.districts_code = #{user.districtsCode}
      <if test="null != query.accountLevel and 2 == query.accountLevel and query.type==2 and query.code != null and query.code !=''  ">
         and h.level >= #{query.accountLevel} and h.districts_code = #{query.code}
      </if>
      <if test="null != user.accountLevel and 3 == user.accountLevel">
         and a.account_level >= #{user.accountLevel} and a.street_id = #{user.streetId}
      <if test="null != query.accountLevel and 2 == query.accountLevel and query.type==2 and query.code == null">
         and h.level >= #{query.accountLevel}
      </if>
      <if test="null != user.accountLevel and 4 == user.accountLevel">
         and a.account_level >= #{user.accountLevel} and a.community_id = #{user.communityId}
      <if test="null != query.accountLevel and 2 == query.accountLevel and query.type==1 and query.code != null and query.code !=''">
         and h.level = #{query.accountLevel} and h.districts_code = #{query.code}
      </if>
      <if test="null != query.accountLevel and 2 == query.accountLevel and query.type==1 and query.code == null ">
         and h.level = #{query.accountLevel}
      </if>
      <if test="null != query.accountLevel and 3 == query.accountLevel and query.type==2 and query.code != null and query.code !=''">
         and h.level >= #{query.accountLevel} and h.street_id = #{query.code}
      </if>
      <if test="null != query.accountLevel and 3 == query.accountLevel and query.type==2 and query.code == null">
         and h.level >= #{query.accountLevel}
      </if>
      <if test="null != query.accountLevel and 3 == query.accountLevel and query.type==1 and query.code != null and query.code !=''">
         and h.level = #{query.accountLevel} and h.street_id = #{query.code}
      </if>
      <if test="null != query.accountLevel and 3 == query.accountLevel and query.type==1 and query.code == null">
         and h.level = #{query.accountLevel}
      </if>
      <if test="null != query.accountLevel and 4 == query.accountLevel and query.type==2 and query.code != null and query.code !=''">
         and h.level >= #{query.accountLevel} and h.community_id = #{query.code}
      </if>
      <if test="null != query.accountLevel and 4 == query.accountLevel and query.type==2 and query.code == null">
         and h.level >= #{query.accountLevel}
      </if>
      <if test="null != query.accountLevel and 4 == query.accountLevel and query.type==1 and query.code != null and query.code !=''">
         and h.level = #{query.accountLevel} and h.community_id = #{query.code}
      </if>
      <if test="null != query.accountLevel and 4 == query.accountLevel and query.type==1 and query.code == null">
         and h.level = #{query.accountLevel}
      </if>
      <if test="null != user.accountLevel and 5 == user.accountLevel">
         and a.id = 0
      </if>
      <if test="null != query.accountLevel">
         and a.account_level = #{query.accountLevel}
      </if>
      order by a.create_time desc
   </select>