Skip to content

Commit

Permalink
Merge pull request #934 from wangyu096/feature/remove_biz_set_compati…
Browse files Browse the repository at this point in the history
…ble_code

feature: 移除发布业务集引入的兼容代码 #896
  • Loading branch information
wangyu096 authored May 19, 2022
2 parents 8afda3b + aeb5465 commit 9d0bc3e
Show file tree
Hide file tree
Showing 70 changed files with 467 additions and 739 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import brave.Tracer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.tencent.bk.job.common.annotation.DeprecatedAppLogic;
import com.tencent.bk.job.common.constant.HttpRequestSourceEnum;
import com.tencent.bk.job.common.constant.JobCommonHeaders;
import com.tencent.bk.job.common.constant.ResourceScopeTypeEnum;
Expand Down Expand Up @@ -66,8 +65,6 @@
@Component
public class JobCommonInterceptor extends HandlerInterceptorAdapter {
private static final Pattern SCOPE_PATTERN = Pattern.compile("/scope/(\\w+)/(\\d+)");
@DeprecatedAppLogic
private static final Pattern APP_ID_PATTERN = Pattern.compile("/app/(\\d+)");

private final Tracer tracer;

Expand Down Expand Up @@ -197,12 +194,6 @@ private AppResourceScope parseAppResourceScopeFromPath(String requestURI) {
return buildAppResourceScope(resourceScope);
}

// 兼容当前业务ID路径模式
Long appId = parseAppIdFromURI(requestURI);
if (appId != null) {
return buildAppResourceScope(appId);
}

return null;
}

Expand All @@ -215,25 +206,11 @@ private ResourceScope parseResourceScopeFromURI(String requestURI) {
return resourceScope;
}

private Long parseAppIdFromURI(String requestURI) {
Matcher appIdMatcher = APP_ID_PATTERN.matcher(requestURI);
Long appId = null;
if (appIdMatcher.find()) {
appId = Long.valueOf(appIdMatcher.group(1));
}
return appId;
}

private AppResourceScope buildAppResourceScope(ResourceScope resourceScope) {
Long appId = appScopeMappingService.getAppIdByScope(resourceScope);
return new AppResourceScope(appId, resourceScope);
}

private AppResourceScope buildAppResourceScope(Long appId) {
ResourceScope resourceScope = appScopeMappingService.getScopeByAppId(appId);
return new AppResourceScope(appId, resourceScope);
}

private String parseUsernameFromQueryStringOrBody(HttpServletRequest request) {
return parseValueFromQueryStringOrBody(request, "bk_username");
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ public synchronized List<ServiceApplicationDTO> listLocalDBAppsFromCache() {
}

public List<ServiceApplicationDTO> listLocalDBApps() {
val resp = applicationResourceClient.listApps(null, null);
List<ServiceApplicationDTO> apps = resp.getData();
return apps;
val resp = applicationResourceClient.listApps(null);
return resp.getData();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@

public interface ApplicationService {

List<ServiceApplicationDTO> listLocalDBApps(Integer appType);
List<ServiceApplicationDTO> listLocalDBApps();
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public ApplicationServiceImpl(ApplicationResourceClient applicationResourceClien
}

@Override
public List<ServiceApplicationDTO> listLocalDBApps(Integer appType) {
val result = applicationResourceClient.listApps(appType, null);
public List<ServiceApplicationDTO> listLocalDBApps() {
val result = applicationResourceClient.listApps(null);
if (result == null) {
throw new RuntimeException("Job-manage unavailable, please check");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public int updateAnalysisTaskInstanceById(AnalysisTaskInstanceDTO analysisTaskIn
}

public List<ServiceApplicationDTO> getAppInfoList() {
return applicationService.listLocalDBApps(-1);
return applicationService.listLocalDBApps();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package com.tencent.bk.job.crontab.api.web;

import com.tencent.bk.job.common.annotation.DeprecatedAppLogic;
import com.tencent.bk.job.common.annotation.WebAPI;
import com.tencent.bk.job.common.model.Response;
import com.tencent.bk.job.common.model.permission.AuthResultVO;
Expand Down Expand Up @@ -81,23 +80,22 @@ Response<AuthResultVO> checkOperationPermission(
* 检查操作权限
*
* @param username 用户名
* @param appId 业务ID
* @param scopeType 资源范围类型
* @param scopeId 资源范围ID
* @param operation 操作ID
* @param resourceId 资源ID
* @param returnPermissionDetail 是否返回详细的权限信息
* @return
* @return 鉴权结果
*/
@ApiOperation(value = "检查操作权限", produces = "application/json")
@GetMapping("/check")
Response<AuthResultVO> checkOperationPermission(
@ApiParam("用户名,网关自动传入")
@RequestHeader("username") String username,
@DeprecatedAppLogic @ApiParam(value = "业务ID", required = false)
@RequestParam(value = "appId", required = false) Long appId,
@ApiParam(value = "业务范围类型,biz-业务,biz_set-业务集")
@RequestParam(value = "scopeType", required = false) String scopeType,
@ApiParam(value = "范畴ID", required = false)
@RequestParam(value = "scopeId", required = false) String scopeId,
@RequestParam(value = "scopeType") String scopeType,
@ApiParam(value = "资源范围ID", required = true)
@RequestParam(value = "scopeId") String scopeId,
@ApiParam("操作ID,取值为: [cron/create,cron/view,cron/edit,cron/delete,cron/manage")
@RequestParam(value = "operation") String operation,
@ApiParam(value = "资源ID,比如定时任务ID;对于部分不需要资源ID的操作(新建),不需要传参")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
package com.tencent.bk.job.crontab.model;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.tencent.bk.job.common.annotation.CompatibleImplementation;
import com.tencent.bk.job.common.model.vo.UserRoleInfoVO;
import com.tencent.bk.job.common.util.json.LongTimestampSerializer;
import io.swagger.annotations.ApiModel;
Expand All @@ -47,13 +46,6 @@ public class CronJobVO {
@ApiModelProperty("任务 ID")
private Long id;

/**
* 业务 ID
*/
@ApiModelProperty("业务 ID")
@CompatibleImplementation(explain = "为了无损发布保留的历史字段,发布完成需要删除", version = "3.5.1")
private Long appId;

/**
* 资源范围类型
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package com.tencent.bk.job.crontab.model;

import com.tencent.bk.job.common.annotation.DeprecatedAppLogic;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
Expand All @@ -37,11 +36,6 @@ public class OperationPermissionReq {

@ApiModelProperty("资源ID,比如作业ID,定时任务ID;对于部分不需要资源ID的操作(新建),不需要传参")
private String resourceId;

@DeprecatedAppLogic
@ApiModelProperty("业务ID")
private Long appId;

@ApiModelProperty("资源范围类型,biz-cmdb业务,biz_set-cmdb业务集")
private String scopeType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,18 @@ public Response<String> getApplyUrl(String username, OperationPermissionReq req)
@Override
public Response<AuthResultVO> checkOperationPermission(String username, OperationPermissionReq req) {
return checkOperationPermission(
username, req.getAppId(), req.getScopeType(), req.getScopeId(),
username, req.getScopeType(), req.getScopeId(),
req.getOperation(), req.getResourceId(), req.isReturnPermissionDetail());
}

@Override
public Response<AuthResultVO> checkOperationPermission(String username,
Long appId,
String scopeType,
String scopeId,
String operation,
String resourceId,
Boolean returnPermissionDetail) {
AppResourceScope appResourceScope = toAppResourceScope(appId, scopeType, scopeId);
AppResourceScope appResourceScope = new AppResourceScope(scopeType, scopeId, null);
if (StringUtils.isEmpty(operation)) {
return Response.buildCommonFailResp(ErrorCode.ILLEGAL_PARAM);
}
Expand Down Expand Up @@ -105,8 +104,4 @@ public Response<AuthResultVO> checkOperationPermission(String username,
}
return Response.buildSuccessResp(AuthResultVO.fail());
}

private AppResourceScope toAppResourceScope(Long appId, String scopeType, String scopeId) {
return new AppResourceScope(scopeType, scopeId, appId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ public static CronJobVO toVO(CronJobInfoDTO cronJobInfo) {
}
CronJobVO cronJobVO = new CronJobVO();
cronJobVO.setId(cronJobInfo.getId());
cronJobVO.setAppId(cronJobInfo.getAppId());
AppScopeMappingService appScopeMappingService =
ApplicationContextRegister.getBean(AppScopeMappingService.class);
ResourceScope resourceScope = appScopeMappingService.getScopeByAppId(cronJobInfo.getAppId());
Expand Down Expand Up @@ -232,7 +231,6 @@ public static CronJobVO toBasicVO(CronJobInfoDTO cronJobInfo) {
}
CronJobVO cronJobVO = new CronJobVO();
cronJobVO.setId(cronJobInfo.getId());
cronJobVO.setAppId(cronJobInfo.getAppId());
AppScopeMappingService appScopeMappingService =
ApplicationContextRegister.getBean(AppScopeMappingService.class);
ResourceScope resourceScope = appScopeMappingService.getScopeByAppId(cronJobInfo.getAppId());
Expand Down
Loading

0 comments on commit 9d0bc3e

Please sign in to comment.