Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: tenant adapter #829

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public interface RequestContextAdapter {

<T> void queryWrapperTenantAdapt(QueryWrapper<T> queryWrapper, String tenant, String workspace);

void tenantAdapt(String tenant, String workspace);

<T> void queryWrapperTenantAdapt(QueryWrapper<T> queryWrapper, String tenant);

<T> void queryWrapperWorkspaceAdapt(QueryWrapper<T> queryWrapper, String workspace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ public <T> void queryWrapperTenantAdapt(QueryWrapper<T> queryWrapper, String ten
}
}

@Override
public void tenantAdapt(String tenant, String workspace) {

}

@Override
public <T> void queryWrapperTenantAdapt(QueryWrapper<T> queryWrapper, String tenant) {
if (queryWrapper != null && StringUtils.isNotBlank(tenant)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public interface AlertGroupService extends IService<AlarmGroup> {

Boolean updateById(AlarmGroupDTO alarmGroupDTO);

AlarmGroupDTO queryById(Long id, String tenant);

AlarmGroupDTO queryById(Long id, String tenant, String workspace);

List<AlarmGroupDTO> getListByUserLike(String userId, String tenant);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public List<AlarmMetric> queryByMetric(String metric, String tenant, String work

@Override
public List<AlarmMetric> queryByRuleId(Long ruleId, String tenant, String workspace) {
this.requestContextAdapter.tenantAdapt(tenant, workspace);
QueryWrapper<AlarmMetric> wrapper = new QueryWrapper<>();
wrapper.eq("deleted", 0);
if (StringUtils.isNotBlank(tenant)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ public MonitorPageResult<AlarmDingDingRobotDTO> getListByPage(
AlarmDingDingRobot alarmDingDingRobot =
alarmDingDingRobotConverter.dtoToDO(pageRequest.getTarget());

wrapper.eq("tenant", alarmDingDingRobot.getTenant());
if (StringUtils.isNotEmpty(alarmDingDingRobot.getWorkspace())) {
wrapper.eq("workspace", alarmDingDingRobot.getWorkspace());
}
requestContextAdapter.queryWrapperTenantAdapt(wrapper, alarmDingDingRobot.getTenant(),
alarmDingDingRobot.getWorkspace());

if (null != alarmDingDingRobot.getId()) {
wrapper.eq("id", alarmDingDingRobot.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ public Boolean updateById(AlarmGroupDTO alarmGroupDTO) {
return this.updateById(alarmGroup);
}

@Override
public AlarmGroupDTO queryById(Long id, String tenant) {
return queryById(id, tenant, requestContextAdapter.getWorkspace(true));
}

@Override
public AlarmGroupDTO queryById(Long id, String tenant, String workspace) {
QueryWrapper<AlarmGroup> wrapper = new QueryWrapper<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void checkParameter() {
public void doManage() {

AlarmGroupDTO item = alarmGroupService.queryById(alarmGroup.getId(),
RequestContext.getContext().ms.getTenant());
RequestContext.getContext().ms.getTenant(), requestContextAdapter.getWorkspace(true));
if (null == item) {
throw new MonitorException("cannot find record: " + alarmGroup.getId());
}
Expand Down Expand Up @@ -233,8 +233,8 @@ public void checkParameter() {
@Override
public void doManage() {

AlarmGroupDTO save =
alarmGroupService.queryById(id, RequestContext.getContext().ms.getTenant());
AlarmGroupDTO save = alarmGroupService.queryById(id,
RequestContext.getContext().ms.getTenant(), requestContextAdapter.getWorkspace(true));
JsonResult.createSuccessResult(result, save);
}
});
Expand All @@ -256,7 +256,8 @@ public void checkParameter() {
public void doManage() {
MonitorScope ms = RequestContext.getContext().ms;
boolean rtn = false;
AlarmGroupDTO alarmGroup = alarmGroupService.queryById(id, ms.getTenant());
AlarmGroupDTO alarmGroup = alarmGroupService.queryById(id, ms.getTenant(),
requestContextAdapter.getWorkspace(true));
if (alarmGroup != null && StringUtils.equals(alarmGroup.getTenant(), ms.getTenant())) {
rtn = alarmGroupService.removeById(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public void checkParameter() {
@Override
public void doManage() {
MonitorScope ms = RequestContext.getContext().ms;
AlertNotifyRecordDTO save = alertNotifyRecordService.queryByHistoryDetailId(historyDetailId,
ms.getTenant(), ms.getWorkspace());
AlertNotifyRecordDTO save =
alertNotifyRecordService.queryByHistoryDetailId(historyDetailId, tenant(), workspace());
JsonResult.createSuccessResult(result, save);
}
});
Expand All @@ -69,12 +69,13 @@ public void checkParameter() {

@Override
public void doManage() {
MonitorScope ms = RequestContext.getContext().ms;
if (null != ms && !StringUtils.isEmpty(ms.tenant)) {
pageRequest.getTarget().setTenant(ms.tenant);
String tenant = tenant();
String workspace = workspace();
if (StringUtils.isNotEmpty(tenant)) {
pageRequest.getTarget().setTenant(tenant);
}
if (null != ms && !StringUtils.isEmpty(ms.workspace)) {
pageRequest.getTarget().setWorkspace(ms.workspace);
if (StringUtils.isNotEmpty(workspace)) {
pageRequest.getTarget().setWorkspace(workspace);
}
JsonResult.createSuccessResult(result, alertNotifyRecordService.getListByPage(pageRequest));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public class AlarmRuleLevelAuthorizationChecker extends AbstractQueryChecker
"max", "count", "none", "SUM", "AVG", "MIX", "MAX", "COUNT", "NONE"));
private static final Set<String> metricTypes =
new HashSet<>(Arrays.asList("app", "cache", "log", "oss", "trace", "system", "metric",
"service", "function", "pg", "mongodb", "db", "miniProgram"));
"service", "function", "pg", "mongodb", "db", "miniProgram", "mysql"));
private static final Set<String> products = new HashSet<>(Arrays.asList("JVM", "Function",
"OceanBase", "Tbase", "PortCheck", "System", "MiniProgram", "Spanner", "IoT"));

Expand Down
Loading