MrShi
2024-11-01 deb4575b72443cf906946a9fb28a557c16556fb9
server/service/src/main/resources/mappers/SystemDataPermissionMapper.xml
@@ -43,5 +43,30 @@
    </where>
    ${orderByClause}
  </select>
  <select id="selectUserList" resultMap="SystemDataPermissionListVO">
    SELECT
    sdp.`ID`, sdp.`BUSINESS_CODE`, sdp.`ROLE_ID`, sdp.`TYPE`, sdp.`CUSTOM_DATA`, sdp.`DISABLED`, sdp.`REMARK`, sdp.DISABLED, sdp.`CREATE_TIME`, sdp.`UPDATE_TIME`,
    role.`ID` AS ROLE_ID, role.`CODE` AS ROLE_CODE, role.`NAME` AS ROLE_NAME,
    create_user.ID CREATE_USER_ID, create_user.`USERNAME` CREATE_USER_NAME,
    update_user.ID UPDETE_USER_ID, update_user.`USERNAME` UPDATE_USER_NAME
    FROM SYSTEM_DATA_PERMISSION sdp
    INNER JOIN `SYSTEM_ROLE` role ON role.ID = sdp.ROLE_ID
    LEFT JOIN `SYSTEM_USER` create_user ON create_user.ID = sdp.CREATE_USER
    LEFT JOIN `SYSTEM_USER` update_user ON update_user.ID = sdp.UPDATE_USER
    <where>
      sdp.DELETED = 0
      <if test="dto.businessCode != null and dto.businessCode != ''">
        AND sdp.`BUSINESS_CODE` = #{dto.businessCode}
      </if>
      <if test="dto.roleId != null">
        AND role.`ID` =  #{dto.roleId}
      </if>
      <if test="dto.type != null">
        AND sdp.`TYPE` =  #{dto.type}
      </if>
      <if test="userId != null">
        AND exists (select sr.id from system_user_role sr where sr.role_id=sdp.role_id and sr.user_id=#{userId} and sr.deleted=0)
      </if>
    </where>
  </select>
</mapper>