no message
This commit is contained in:
31
docs/databus-client使用说明.md
Normal file
31
docs/databus-client使用说明.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Databus Client 使用说明
|
||||
|
||||
databus client 最主要用于调用基于http协议的第三方接口时需要记录调用日志到 databus 的情况, 通过databus client 调用第三方接口会将调用日志记录到databus的访问日志中
|
||||
|
||||
# 使用方法
|
||||
1. 添加依赖:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.zt.plat</groupId>
|
||||
<artifactId>zt-module-databus-client</artifactId>
|
||||
<version>3.0.47-SNAPSHOT</version>
|
||||
</dependency>
|
||||
```
|
||||
2. 注入 DatabusClient
|
||||
```java
|
||||
@Resource
|
||||
private DatabusClient databusClient;
|
||||
```
|
||||
3. 方法说明
|
||||
* get(...) : 发送 get 请求
|
||||
* post(...): 发送 post 请求
|
||||
* put(...): 发送 put 请求
|
||||
* delete(...): 发送 delete 请求
|
||||
* doRequest(...): 发送自定义请求
|
||||
4. 方法参数说明(由于所有方法参数都是一样的,所以在此统一说明)
|
||||
* String urlString: 请求的 http 接口地址(get/delete请求不需要带url参数)
|
||||
* Map<String, Object> data: 请求的参数(post/put方法会转换为json提交, get/delete会拼接到url上)
|
||||
* Map<String, String> headers: 请求头信息
|
||||
* String appId: databus 的appid
|
||||
* String authToken: databus 的访问令牌
|
||||
* Method method: doRequest 方法独有,如果要使用 get/post/put/delete 之外的方法,请使用doRequest方法并通过method参数指定
|
||||
@@ -96,7 +96,6 @@ public class DeptDataPermissionRule implements DataPermissionRule {
|
||||
/**
|
||||
* 基于用户的表字段配置
|
||||
* 一般情况下,每个表的部门编号字段是 dept_id,通过该配置自定义。
|
||||
* key:表名
|
||||
* value:字段名
|
||||
*/
|
||||
private final Map<String, String> userColumns = new HashMap<>();
|
||||
@@ -262,7 +261,11 @@ public class DeptDataPermissionRule implements DataPermissionRule {
|
||||
if (Boolean.FALSE.equals(self)) {
|
||||
return null;
|
||||
}
|
||||
String columnName = userColumns.get(tableName);
|
||||
String userColumnsKey = tableName;
|
||||
if (StrUtil.isNotBlank(workCode)) {
|
||||
userColumnsKey = userColumnsKey + "_work_code";
|
||||
}
|
||||
String columnName = userColumns.get(userColumnsKey);
|
||||
if (StrUtil.isEmpty(columnName)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<groupId>com.zt.plat</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>zt-module-databus-server-client</artifactId>
|
||||
<artifactId>zt-module-databus-client</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
|
||||
@@ -7,7 +7,6 @@ import cn.hutool.http.Method;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.util.security.CryptoSignatureUtils;
|
||||
import com.zt.plat.module.databus.api.dto.ApiAccessLogCreateReq;
|
||||
import com.zt.plat.module.databus.api.provider.DatabusAccessLogProviderApi;
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
@@ -56,4 +56,9 @@ public interface PermissionApi extends PermissionCommonApi {
|
||||
@Parameter(name = "userId", description = "用户编号", example = "1", required = true)
|
||||
CommonResult<DataScopeEnum> getUserDataPermissionLevel(@RequestParam("userId") Long userId);
|
||||
|
||||
@GetMapping(PREFIX + "/get")
|
||||
@Operation(summary = "通过用户 ID 查询用户是否为超级管理员")
|
||||
@Parameter(name = "id", description = "用户编号", example = "1", required = true)
|
||||
CommonResult<Boolean> isSuperAdmin(@RequestParam("id") Long id);
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||
import com.zt.plat.module.system.api.permission.dto.*;
|
||||
import com.zt.plat.module.system.controller.admin.permission.vo.permission.PermissionAssignRoleDataScopeReqVO;
|
||||
import com.zt.plat.module.system.controller.admin.permission.vo.permission.PermissionAssignUserRoleReqVO;
|
||||
import com.zt.plat.module.system.dal.dataobject.user.AdminUserDO;
|
||||
import com.zt.plat.module.system.enums.permission.DataScopeEnum;
|
||||
import com.zt.plat.module.system.service.permission.PermissionService;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
@@ -90,4 +91,9 @@ public class PermissionApiImpl implements PermissionApi {
|
||||
public CommonResult<DeptDataPermissionRespDTO> getDeptDataPermissionWithRoleCodes(Long userId, String roleCodes) {
|
||||
return success(permissionService.getDeptDataPermissionWithRoleCodes(userId, roleCodes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> isSuperAdmin(Long id) {
|
||||
return success(permissionService.isSuperAdmin(id));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ public class DataPermissionConfiguration {
|
||||
rule.addDeptColumn(DeptDO.class, "id");
|
||||
// user
|
||||
rule.addUserColumn(AdminUserDO.class, "id");
|
||||
rule.addUserColumn("system_users_work_code", "workcode");
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -189,4 +189,12 @@ public interface PermissionService {
|
||||
*/
|
||||
Set<RoleMenuDO> getByRoleIdAndMenuIds(Set<Long> roleIds, Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据用户ID判断用户是否是超级管理员
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
Boolean isSuperAdmin(Long userId);
|
||||
|
||||
}
|
||||
|
||||
@@ -559,5 +559,11 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isSuperAdmin(Long userId) {
|
||||
Set<Long> userRoleIds = getUserRoleIdListByUserId(userId);
|
||||
return roleService.hasAnySuperAdmin(userRoleIds);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user