From 730288aba8acd39f00a4fa42df9310a392aa3d37 Mon Sep 17 00:00:00 2001 From: jsonwan Date: Mon, 6 Sep 2021 20:30:47 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=8F=90=E4=BE=9BJOB=E7=9A=84=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=8B=93=E6=89=91=5Fbk=5Fiam=5Fpath=5F=20=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E6=9D=83=E9=99=90=E4=B8=AD=E5=BF=83=E6=8E=A8=E8=8D=90?= =?UTF-8?q?=E7=B2=BE=E5=87=86=E5=BA=A6=20#181?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../commons/common-iam/libs/iam-sdk-1.0.0.jar | Bin 113589 -> 115097 bytes .../iam/service/BaseIamCallbackService.java | 70 ++++++++++ .../IamDashBoardViewCallbackResourceImpl.java | 106 ++++++-------- .../iam/impl/IamCallbackControllerImpl.java | 111 ++++++++------- .../bk/job/crontab/dao/CronJobDAO.java | 8 ++ .../job/crontab/dao/impl/CronJobDAOImpl.java | 21 ++- .../job/crontab/service/CronJobService.java | 16 +++ .../service/impl/CronJobServiceImpl.java | 36 ++++- .../execute/dao/impl/TaskInstanceDAOImpl.java | 15 +- .../IamFileSourceCallbackResourceImpl.java | 119 ++++++++-------- .../impl/IamAccountCallbackResourceImpl.java | 114 +++++++--------- .../IamPublicScriptCallbackResourceImpl.java | 14 +- .../impl/IamScriptCallbackResourceImpl.java | 14 +- .../iam/impl/IamTagCallbackResourceImpl.java | 68 ++++----- .../impl/IamTaskPlanCallbackResourceImpl.java | 100 +++++++------- .../IamTaskTemplateCallbackResourceImpl.java | 103 +++++++------- .../api/iam/impl/ScriptCallbackHelper.java | 129 +++++++++--------- 17 files changed, 582 insertions(+), 462 deletions(-) create mode 100644 src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/service/BaseIamCallbackService.java diff --git a/src/backend/commons/common-iam/libs/iam-sd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=Mluri>CYki`XdB7hX zSrM8u-Xd`8Itm_)b7h@D?$jD7#%!#Mxv>_Zux@L9Y^nl^jXAQ^9?c0 zAX^;hk4g?wk_}?8vlgh6hd<+G3wE3pHst^%4Q0^MJQoRQR1GFzH_p{aQpp^Z3{(Rd zm{JWU;ywufTk_)&ighMx+Q}mEa^yvHG_f`O7I`ZDOG0f`ZZ*Oq^Q%G5;8<}U;$rOv zN*tgzMjP#9bfu~1U+gpoi{VlMP{m3iXjc$>CFJhX0h+L0AaqBq5n|i5Xa&5qNuLv5 z2fKz%XJ(?j9MP3970Ii16h8@X9qU9JRSA_BG5{b?HA^K-)Xp&%mrU%#y+H5KFqz^GdQjY1@X>{ldEsv9n2jvXM;5I`EG`YCpgfpY2iS0a9Z<%$ed>^v z1?zr_=x0UYY>cxzvZ9aXv$=?sbsH(DE*!TRC>f6(>A60k%Z?y;75XQ-qcJwoYDHUs z;(ydA2O|fiN&SI8)ImMl1oP{G5snmh9XE_(Oh}Ie(Hos)NtEP8 z_^6IsBbWf6H3*acj>NzQI@ALWwSyZ%pNqmvfAAtw^p75+`066i!?Ca%kvKY5L~M#r zwCUcmxLv6BFHvt8jiiFU3lk6Q$8gxtD7;1wC?m@cP+V=O)&w-MfqyKr-+x8bn29cg cXqWFvp$$Yd0ghZS5lq}PAc$+J=$MHA18h?%&Hw-a diff --git a/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/service/BaseIamCallbackService.java b/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/service/BaseIamCallbackService.java new file mode 100644 index 0000000000..f74385a571 --- /dev/null +++ b/src/backend/commons/common-iam/src/main/java/com/tencent/bk/job/common/iam/service/BaseIamCallbackService.java @@ -0,0 +1,70 @@ +package com.tencent.bk.job.common.iam.service; + +import com.tencent.bk.sdk.iam.constants.CommonResponseCode; +import com.tencent.bk.sdk.iam.dto.callback.request.CallbackRequestDTO; +import com.tencent.bk.sdk.iam.dto.callback.response.CallbackBaseResponseDTO; +import com.tencent.bk.sdk.iam.dto.callback.response.ListAttributeResponseDTO; +import com.tencent.bk.sdk.iam.dto.callback.response.ListAttributeValueResponseDTO; +import com.tencent.bk.sdk.iam.dto.callback.response.ListInstanceByPolicyResponseDTO; +import com.tencent.bk.sdk.iam.dto.callback.response.ListInstanceResponseDTO; +import com.tencent.bk.sdk.iam.dto.callback.response.SearchInstanceResponseDTO; +import lombok.extern.slf4j.Slf4j; + +@Slf4j +public abstract class BaseIamCallbackService { + + public CallbackBaseResponseDTO getFailResp(Long code, String message) { + CallbackBaseResponseDTO respDTO = new CallbackBaseResponseDTO(); + respDTO.setCode(code); + respDTO.setMessage(message); + return respDTO; + } + + public CallbackBaseResponseDTO getNotFoundResp(String message) { + return getFailResp(CommonResponseCode.NOT_FOUND, message); + } + + public CallbackBaseResponseDTO getNotFoundRespById(String id) { + String msg = String.format("cannot find resource by id %d, may be deleted", id); + log.warn(msg); + return getNotFoundResp(msg); + } + + protected abstract ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest); + + protected abstract SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest); + + protected abstract CallbackBaseResponseDTO fetchInstanceResp(CallbackRequestDTO callbackRequest); + + public CallbackBaseResponseDTO baseCallback(CallbackRequestDTO callbackRequest) { + CallbackBaseResponseDTO response; + switch (callbackRequest.getMethod()) { + case LIST_INSTANCE: + response = listInstanceResp(callbackRequest); + break; + case FETCH_INSTANCE_INFO: + response = fetchInstanceResp(callbackRequest); + break; + case LIST_ATTRIBUTE: + response = new ListAttributeResponseDTO(); + response.setCode(0L); + break; + case LIST_ATTRIBUTE_VALUE: + response = new ListAttributeValueResponseDTO(); + response.setCode(0L); + break; + case LIST_INSTANCE_BY_POLICY: + response = new ListInstanceByPolicyResponseDTO(); + response.setCode(0L); + break; + case SEARCH_INSTANCE: + response = searchInstanceResp(callbackRequest); + break; + default: + log.error("Unknown callback method!|{}|{}|{}|{}", callbackRequest.getMethod(), + callbackRequest.getType(), callbackRequest.getFilter(), callbackRequest.getPage()); + response = new CallbackBaseResponseDTO(); + } + return response; + } +} diff --git a/src/backend/job-analysis/service-job-analysis/src/main/java/com/tencent/bk/job/analysis/api/iam/impl/IamDashBoardViewCallbackResourceImpl.java b/src/backend/job-analysis/service-job-analysis/src/main/java/com/tencent/bk/job/analysis/api/iam/impl/IamDashBoardViewCallbackResourceImpl.java index a8fde51385..7b793aa217 100644 --- a/src/backend/job-analysis/service-job-analysis/src/main/java/com/tencent/bk/job/analysis/api/iam/impl/IamDashBoardViewCallbackResourceImpl.java +++ b/src/backend/job-analysis/service-job-analysis/src/main/java/com/tencent/bk/job/analysis/api/iam/impl/IamDashBoardViewCallbackResourceImpl.java @@ -26,15 +26,15 @@ import com.tencent.bk.job.analysis.api.iam.IamDashBoardViewCallbackResource; import com.tencent.bk.job.analysis.consts.AnalysisConsts; +import com.tencent.bk.job.common.iam.constant.ResourceId; +import com.tencent.bk.job.common.iam.service.BaseIamCallbackService; +import com.tencent.bk.sdk.iam.dto.PathInfoDTO; import com.tencent.bk.sdk.iam.dto.callback.request.CallbackRequestDTO; import com.tencent.bk.sdk.iam.dto.callback.request.IamSearchCondition; import com.tencent.bk.sdk.iam.dto.callback.response.BaseDataResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.CallbackBaseResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.FetchInstanceInfoResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.InstanceInfoDTO; -import com.tencent.bk.sdk.iam.dto.callback.response.ListAttributeResponseDTO; -import com.tencent.bk.sdk.iam.dto.callback.response.ListAttributeValueResponseDTO; -import com.tencent.bk.sdk.iam.dto.callback.response.ListInstanceByPolicyResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.ListInstanceResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.SearchInstanceResponseDTO; import lombok.extern.slf4j.Slf4j; @@ -46,13 +46,15 @@ @RestController @Slf4j -public class IamDashBoardViewCallbackResourceImpl implements IamDashBoardViewCallbackResource { +public class IamDashBoardViewCallbackResourceImpl extends BaseIamCallbackService + implements IamDashBoardViewCallbackResource { @Autowired public IamDashBoardViewCallbackResourceImpl() { } - private ListInstanceResponseDTO listInstanceResp() { + @Override + protected ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest) { List instanceInfoList = new ArrayList<>(); // TODO:当前只有全局视图,待后续视图功能开发后更新这里 InstanceInfoDTO tmpInstanceInfo = new InstanceInfoDTO(); @@ -69,10 +71,11 @@ private ListInstanceResponseDTO listInstanceResp() { return instanceResponse; } - private SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { + @Override + protected SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { SearchInstanceResponseDTO instanceResponse = new SearchInstanceResponseDTO(); String keyword = callbackRequest.getFilter().getKeyword(); - if (AnalysisConsts.GLOBAL_DASHBOARD_VIEW_NAME.contains(keyword)) { + if (keyword == null || AnalysisConsts.GLOBAL_DASHBOARD_VIEW_NAME.contains(keyword)) { List instanceInfoList = new ArrayList<>(); InstanceInfoDTO tmpInstanceInfo = new InstanceInfoDTO(); tmpInstanceInfo.setId(AnalysisConsts.GLOBAL_DASHBOARD_VIEW_ID); @@ -95,66 +98,41 @@ private SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callback } @Override - public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { - CallbackBaseResponseDTO response; + protected CallbackBaseResponseDTO fetchInstanceResp( + CallbackRequestDTO callbackRequest + ) { IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); - switch (callbackRequest.getMethod()) { - case LIST_INSTANCE: - response = listInstanceResp(); - break; - case FETCH_INSTANCE_INFO: - log.debug("Fetch instance info request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); - - List instanceAttributeInfoList = new ArrayList<>(); - for (String instanceId : searchCondition.getIdList()) { - try { - InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); - instanceInfo.setId(instanceId); - if (AnalysisConsts.GLOBAL_DASHBOARD_VIEW_ID.equals(instanceId)) { - instanceInfo.setDisplayName(AnalysisConsts.GLOBAL_DASHBOARD_VIEW_NAME); - } else { - instanceInfo.setDisplayName("Unknown(may be deleted)"); - log.warn("Unexpected dashBoardViewId:{} passed by iam", instanceId); - } - instanceAttributeInfoList.add(instanceInfo); - } catch (NumberFormatException e) { - log.error("Parse object id failed!|{}", instanceId, e); - } + List instanceAttributeInfoList = new ArrayList<>(); + for (String instanceId : searchCondition.getIdList()) { + try { + if (!AnalysisConsts.GLOBAL_DASHBOARD_VIEW_ID.equals(instanceId)) { + return getNotFoundRespById(instanceId); } + // 拓扑路径构建 + List path = new ArrayList<>(); + PathInfoDTO rootNode = new PathInfoDTO(); + rootNode.setType(ResourceId.DASHBOARD_VIEW); + rootNode.setId(AnalysisConsts.GLOBAL_DASHBOARD_VIEW_ID); + path.add(rootNode); + // 实例组装 + InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); + instanceInfo.setId(instanceId); + instanceInfo.setDisplayName(AnalysisConsts.GLOBAL_DASHBOARD_VIEW_NAME); + instanceInfo.setPath(path); + instanceAttributeInfoList.add(instanceInfo); + } catch (NumberFormatException e) { + log.error("Parse object id failed!|{}", instanceId, e); + } + } - FetchInstanceInfoResponseDTO fetchInstanceInfoResponse = new FetchInstanceInfoResponseDTO(); - fetchInstanceInfoResponse.setCode(0L); - fetchInstanceInfoResponse.setData(instanceAttributeInfoList); + FetchInstanceInfoResponseDTO fetchInstanceInfoResponse = new FetchInstanceInfoResponseDTO(); + fetchInstanceInfoResponse.setCode(0L); + fetchInstanceInfoResponse.setData(instanceAttributeInfoList); + return fetchInstanceInfoResponse; + } - response = fetchInstanceInfoResponse; - break; - case LIST_ATTRIBUTE: - log.debug("List attribute request!|{}|{}|{}", callbackRequest.getType(), callbackRequest.getFilter(), - callbackRequest.getPage()); - response = new ListAttributeResponseDTO(); - response.setCode(0L); - break; - case LIST_ATTRIBUTE_VALUE: - log.debug("List attribute value request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); - response = new ListAttributeValueResponseDTO(); - response.setCode(0L); - break; - case LIST_INSTANCE_BY_POLICY: - log.debug("List instance by policy request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); - response = new ListInstanceByPolicyResponseDTO(); - response.setCode(0L); - break; - case SEARCH_INSTANCE: - response = searchInstanceResp(callbackRequest); - break; - default: - log.error("Unknown callback method!|{}|{}|{}|{}", callbackRequest.getMethod(), - callbackRequest.getType(), callbackRequest.getFilter(), callbackRequest.getPage()); - response = new CallbackBaseResponseDTO(); - } - return response; + @Override + public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { + return baseCallback(callbackRequest); } } diff --git a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/iam/impl/IamCallbackControllerImpl.java b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/iam/impl/IamCallbackControllerImpl.java index 70ba83918e..516d559082 100644 --- a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/iam/impl/IamCallbackControllerImpl.java +++ b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/api/iam/impl/IamCallbackControllerImpl.java @@ -24,20 +24,20 @@ package com.tencent.bk.job.crontab.api.iam.impl; +import com.tencent.bk.job.common.iam.constant.ResourceId; +import com.tencent.bk.job.common.iam.service.BaseIamCallbackService; import com.tencent.bk.job.common.iam.util.IamRespUtil; import com.tencent.bk.job.common.model.BaseSearchCondition; import com.tencent.bk.job.common.model.PageData; import com.tencent.bk.job.crontab.api.iam.IamCallbackController; import com.tencent.bk.job.crontab.model.dto.CronJobInfoDTO; import com.tencent.bk.job.crontab.service.CronJobService; +import com.tencent.bk.sdk.iam.dto.PathInfoDTO; import com.tencent.bk.sdk.iam.dto.callback.request.CallbackRequestDTO; import com.tencent.bk.sdk.iam.dto.callback.request.IamSearchCondition; import com.tencent.bk.sdk.iam.dto.callback.response.CallbackBaseResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.FetchInstanceInfoResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.InstanceInfoDTO; -import com.tencent.bk.sdk.iam.dto.callback.response.ListAttributeResponseDTO; -import com.tencent.bk.sdk.iam.dto.callback.response.ListAttributeValueResponseDTO; -import com.tencent.bk.sdk.iam.dto.callback.response.ListInstanceByPolicyResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.ListInstanceResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.SearchInstanceResponseDTO; import lombok.extern.slf4j.Slf4j; @@ -47,13 +47,11 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; -/** - * @since 23/3/2020 11:20 - */ @Slf4j @RestController -public class IamCallbackControllerImpl implements IamCallbackController { +public class IamCallbackControllerImpl extends BaseIamCallbackService implements IamCallbackController { private final CronJobService cronJobService; @@ -80,7 +78,8 @@ private InstanceInfoDTO convert(CronJobInfoDTO cronJobInfo) { return instanceInfo; } - private SearchInstanceResponseDTO searchInstanceResp( + @Override + protected SearchInstanceResponseDTO searchInstanceResp( CallbackRequestDTO callbackRequest ) { Pair basicQueryCond = getBasicQueryCondition(callbackRequest); @@ -94,7 +93,8 @@ private SearchInstanceResponseDTO searchInstanceResp( return IamRespUtil.getSearchInstanceRespFromPageData(cronJobInfoPageData, this::convert); } - private ListInstanceResponseDTO listInstanceResp( + @Override + protected ListInstanceResponseDTO listInstanceResp( CallbackRequestDTO callbackRequest ) { Pair basicQueryCond = getBasicQueryCondition(callbackRequest); @@ -108,53 +108,52 @@ private ListInstanceResponseDTO listInstanceResp( } @Override - public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { - CallbackBaseResponseDTO response; - switch (callbackRequest.getMethod()) { - case LIST_INSTANCE: - response = listInstanceResp(callbackRequest); - break; - case FETCH_INSTANCE_INFO: - IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); - List instanceAttributeInfoList = new ArrayList<>(); - for (String instanceId : searchCondition.getIdList()) { - try { - long id = Long.parseLong(instanceId); - InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); - instanceInfo.setId(instanceId); - instanceInfo.setDisplayName(cronJobService.getCronJobNameById(id)); - instanceAttributeInfoList.add(instanceInfo); - } catch (NumberFormatException e) { - log.error("Parse object id failed!|{}", instanceId, e); - } - } - - FetchInstanceInfoResponseDTO fetchInstanceInfoResponse = new FetchInstanceInfoResponseDTO(); - fetchInstanceInfoResponse.setCode(0L); - fetchInstanceInfoResponse.setData(instanceAttributeInfoList); - - response = fetchInstanceInfoResponse; - break; - case LIST_ATTRIBUTE: - response = new ListAttributeResponseDTO(); - response.setCode(0L); - break; - case LIST_ATTRIBUTE_VALUE: - response = new ListAttributeValueResponseDTO(); - response.setCode(0L); - break; - case LIST_INSTANCE_BY_POLICY: - response = new ListInstanceByPolicyResponseDTO(); - response.setCode(0L); - break; - case SEARCH_INSTANCE: - response = searchInstanceResp(callbackRequest); - break; - default: - log.error("Unknown callback method!|{}|{}|{}|{}", callbackRequest.getMethod(), - callbackRequest.getType(), callbackRequest.getFilter(), callbackRequest.getPage()); - response = new CallbackBaseResponseDTO(); + protected CallbackBaseResponseDTO fetchInstanceResp( + CallbackRequestDTO callbackRequest + ) { + IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); + List instanceAttributeInfoList = new ArrayList<>(); + List cronJobIdList = new ArrayList<>(); + for (String instanceId : searchCondition.getIdList()) { + try { + long id = Long.parseLong(instanceId); + cronJobIdList.add(id); + } catch (NumberFormatException e) { + log.error("Parse object id failed!|{}", instanceId, e); + } } - return response; + Map cronJobInfoMap = cronJobService.getCronJobInfoMapByIds(cronJobIdList); + for (Long id : cronJobIdList) { + CronJobInfoDTO cronJobInfoDTO = cronJobInfoMap.get(id); + if (cronJobInfoDTO == null) { + return getNotFoundRespById(id.toString()); + } + // 拓扑路径构建 + List path = new ArrayList<>(); + PathInfoDTO rootNode = new PathInfoDTO(); + rootNode.setType(ResourceId.APP); + rootNode.setId(cronJobInfoDTO.getAppId().toString()); + PathInfoDTO cronJobNode = new PathInfoDTO(); + cronJobNode.setType(ResourceId.CRON); + cronJobNode.setId(cronJobInfoDTO.getId().toString()); + rootNode.setChild(cronJobNode); + path.add(rootNode); + // 实例组装 + InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); + instanceInfo.setId(id.toString()); + instanceInfo.setDisplayName(cronJobInfoDTO.getName()); + instanceInfo.setPath(path); + instanceAttributeInfoList.add(instanceInfo); + } + + FetchInstanceInfoResponseDTO fetchInstanceInfoResponse = new FetchInstanceInfoResponseDTO(); + fetchInstanceInfoResponse.setCode(0L); + fetchInstanceInfoResponse.setData(instanceAttributeInfoList); + return fetchInstanceInfoResponse; + } + + @Override + public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { + return baseCallback(callbackRequest); } } diff --git a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/dao/CronJobDAO.java b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/dao/CronJobDAO.java index 842d4bf42f..218936c7e6 100644 --- a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/dao/CronJobDAO.java +++ b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/dao/CronJobDAO.java @@ -53,6 +53,14 @@ PageData listPageCronJobsByCondition(CronJobInfoDTO cronJobCondi */ CronJobInfoDTO getCronJobById(long cronJobId); + /** + * 根据定时任务 IDs 查询定时任务信息 + * + * @param cronJobIdList 定时任务 IDs + * @return 定时任务信息 + */ + List getCronJobByIds(List cronJobIdList); + /** * 根据定时任务 ID 查询定时任务信息 * diff --git a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/dao/impl/CronJobDAOImpl.java b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/dao/impl/CronJobDAOImpl.java index a87679e204..cb501a1ede 100644 --- a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/dao/impl/CronJobDAOImpl.java +++ b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/dao/impl/CronJobDAOImpl.java @@ -37,7 +37,14 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; -import org.jooq.*; +import org.jooq.Condition; +import org.jooq.DSLContext; +import org.jooq.OrderField; +import org.jooq.Record1; +import org.jooq.Record21; +import org.jooq.Result; +import org.jooq.TableField; +import org.jooq.UpdateSetMoreStep; import org.jooq.generated.tables.CronJob; import org.jooq.generated.tables.records.CronJobRecord; import org.jooq.types.UByte; @@ -172,6 +179,14 @@ public CronJobInfoDTO getCronJobById(long cronJobId) { return getCronJobByConditions(conditions); } + @Override + public List getCronJobByIds(List cronJobIdList) { + List conditions = new ArrayList<>(); + conditions.add(TABLE.ID.in(cronJobIdList.parallelStream().map(ULong::valueOf).collect(Collectors.toList()))); + conditions.add(TABLE.IS_DELETED.equal(UByte.valueOf(0))); + return fetchData(conditions); + } + @Override public CronJobInfoDTO getCronJobById(long appId, long cronJobId) { List conditions = new ArrayList<>(); @@ -389,7 +404,7 @@ public boolean isExistAnyAppCronJob(Long appId) { return context.fetchExists(TABLE, conditions); } - private List fetchData(List conditions) { + private List fetchData(Collection conditions) { Result> records = context @@ -401,7 +416,7 @@ private List fetchData(List conditions) { .from(TABLE).where(conditions).fetch(); List cronJobInfoList = new ArrayList<>(); - if (records != null && records.size() >= 1) { + if (records.size() >= 1) { records.map(record -> cronJobInfoList.add(convertToCronJobDTO(record))); } return cronJobInfoList; diff --git a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/CronJobService.java b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/CronJobService.java index ed92058fba..341433178f 100644 --- a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/CronJobService.java +++ b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/CronJobService.java @@ -57,6 +57,22 @@ PageData listPageCronJobInfos(CronJobInfoDTO cronJobCondition, */ CronJobInfoDTO getCronJobInfoById(Long cronJobId); + /** + * 根据 IDs 查询定时任务信息,按照传入的id顺序返回结果 + * + * @param cronJobIdList 定时任务 IDs + * @return 定时任务信息 + */ + List getOrderedCronJobInfoByIds(List cronJobIdList); + + /** + * 根据 IDs 查询定时任务信息,返回Map + * + * @param cronJobIdList 定时任务 IDs + * @return 定时任务信息 + */ + Map getCronJobInfoMapByIds(List cronJobIdList); + /** * 根据 ID 查询定时任务信息 * diff --git a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/impl/CronJobServiceImpl.java b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/impl/CronJobServiceImpl.java index d42b1bfdb6..2204d0a537 100644 --- a/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/impl/CronJobServiceImpl.java +++ b/src/backend/job-crontab/service-job-crontab/src/main/java/com/tencent/bk/job/crontab/service/impl/CronJobServiceImpl.java @@ -47,7 +47,11 @@ import com.tencent.bk.job.crontab.service.ExecuteTaskService; import com.tencent.bk.job.crontab.service.TaskExecuteResultService; import com.tencent.bk.job.crontab.service.TaskPlanService; -import com.tencent.bk.job.crontab.timer.*; +import com.tencent.bk.job.crontab.timer.AbstractQuartzTaskHandler; +import com.tencent.bk.job.crontab.timer.QuartzJob; +import com.tencent.bk.job.crontab.timer.QuartzJobBuilder; +import com.tencent.bk.job.crontab.timer.QuartzTrigger; +import com.tencent.bk.job.crontab.timer.QuartzTriggerBuilder; import com.tencent.bk.job.crontab.timer.executor.InnerJobExecutor; import com.tencent.bk.job.crontab.timer.executor.NotifyJobExecutor; import com.tencent.bk.job.crontab.timer.executor.SimpleJobExecutor; @@ -67,7 +71,12 @@ import java.sql.Date; import java.time.Instant; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -122,6 +131,29 @@ public CronJobInfoDTO getCronJobInfoById(Long cronJobId) { return cronJobDAO.getCronJobById(cronJobId); } + @Override + public List getOrderedCronJobInfoByIds(List cronJobIdList) { + Map map = getCronJobInfoMapByIds(cronJobIdList); + List cronJobInfoDTOList = new ArrayList<>(); + for (Long id : cronJobIdList) { + CronJobInfoDTO cronJobInfoDTO = map.get(id); + if (cronJobInfoDTO != null) { + cronJobInfoDTOList.add(cronJobInfoDTO); + } + } + return cronJobInfoDTOList; + } + + @Override + public Map getCronJobInfoMapByIds(List cronJobIdList) { + List cronJobInfoDTOList = cronJobDAO.getCronJobByIds(cronJobIdList); + Map map = new HashMap<>(); + for (CronJobInfoDTO cronJobInfoDTO : cronJobInfoDTOList) { + map.put(cronJobInfoDTO.getId(), cronJobInfoDTO); + } + return map; + } + @Override public CronJobInfoDTO getCronJobInfoById(Long appId, Long cronJobId) { return cronJobDAO.getCronJobById(appId, cronJobId); diff --git a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/dao/impl/TaskInstanceDAOImpl.java b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/dao/impl/TaskInstanceDAOImpl.java index 063d932d90..b8760d50ff 100644 --- a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/dao/impl/TaskInstanceDAOImpl.java +++ b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/dao/impl/TaskInstanceDAOImpl.java @@ -33,9 +33,18 @@ import com.tencent.bk.job.execute.dao.TaskInstanceDAO; import com.tencent.bk.job.execute.model.TaskInstanceDTO; import com.tencent.bk.job.execute.model.TaskInstanceQuery; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import org.jooq.*; +import org.jooq.Condition; +import org.jooq.DSLContext; +import org.jooq.Record; +import org.jooq.Record1; +import org.jooq.Result; +import org.jooq.SelectSeekStep1; +import org.jooq.SortField; +import org.jooq.UpdateSetMoreStep; +import org.jooq.conf.ParamType; import org.jooq.generated.tables.GseTaskIpLog; import org.jooq.generated.tables.StepInstance; import org.jooq.generated.tables.TaskInstance; @@ -52,6 +61,7 @@ /** * 作业执行实例DAO */ +@Slf4j @Repository public class TaskInstanceDAOImpl implements TaskInstanceDAO { private static final TaskInstance TABLE = TaskInstance.TASK_INSTANCE; @@ -363,6 +373,9 @@ public List listLatestCronTaskInstance(long appId, Long cronTas .from(TABLE.useIndex("idx_app_cron")) .where(conditions) .orderBy(TABLE.CREATE_TIME.desc()); + if(log.isDebugEnabled()) { + log.debug("SQL=", select.getSQL(ParamType.INLINED)); + } Result result; if (limit != null && limit > 0) { result = select.limit(0, limit.intValue()).fetch(); diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/iam/IamFileSourceCallbackResourceImpl.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/iam/IamFileSourceCallbackResourceImpl.java index b9daa5364c..304eaaa45a 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/iam/IamFileSourceCallbackResourceImpl.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/iam/IamFileSourceCallbackResourceImpl.java @@ -24,18 +24,18 @@ package com.tencent.bk.job.file_gateway.api.iam; +import com.tencent.bk.job.common.iam.constant.ResourceId; +import com.tencent.bk.job.common.iam.service.BaseIamCallbackService; import com.tencent.bk.job.common.iam.util.IamRespUtil; import com.tencent.bk.job.common.model.PageData; import com.tencent.bk.job.file_gateway.model.dto.FileSourceDTO; import com.tencent.bk.job.file_gateway.service.FileSourceService; +import com.tencent.bk.sdk.iam.dto.PathInfoDTO; import com.tencent.bk.sdk.iam.dto.callback.request.CallbackRequestDTO; import com.tencent.bk.sdk.iam.dto.callback.request.IamSearchCondition; import com.tencent.bk.sdk.iam.dto.callback.response.CallbackBaseResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.FetchInstanceInfoResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.InstanceInfoDTO; -import com.tencent.bk.sdk.iam.dto.callback.response.ListAttributeResponseDTO; -import com.tencent.bk.sdk.iam.dto.callback.response.ListAttributeValueResponseDTO; -import com.tencent.bk.sdk.iam.dto.callback.response.ListInstanceByPolicyResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.ListInstanceResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.SearchInstanceResponseDTO; import lombok.Data; @@ -49,7 +49,8 @@ @RestController @Slf4j -public class IamFileSourceCallbackResourceImpl implements IamFileSourceCallbackResource { +public class IamFileSourceCallbackResourceImpl extends BaseIamCallbackService + implements IamFileSourceCallbackResource { private final FileSourceService fileSourceService; @@ -103,7 +104,15 @@ private FileSourceSearchCondition getSearchCondition(CallbackRequestDTO callback ); } - private ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest) { + private InstanceInfoDTO convert(FileSourceDTO fileSourceDTO) { + InstanceInfoDTO tmpInstanceInfo = new InstanceInfoDTO(); + tmpInstanceInfo.setId(fileSourceDTO.getId().toString()); + tmpInstanceInfo.setDisplayName(fileSourceDTO.getAlias()); + return tmpInstanceInfo; + } + + @Override + protected ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest) { FileSourceSearchCondition searchCondition = getSearchCondition(callbackRequest); List fileSourceDTOList = fileSourceService.listWorkTableFileSource( @@ -124,14 +133,8 @@ private ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequ return IamRespUtil.getListInstanceRespFromPageData(fileSourceDTOPageData, this::convert); } - private InstanceInfoDTO convert(FileSourceDTO fileSourceDTO) { - InstanceInfoDTO tmpInstanceInfo = new InstanceInfoDTO(); - tmpInstanceInfo.setId(fileSourceDTO.getId().toString()); - tmpInstanceInfo.setDisplayName(fileSourceDTO.getAlias()); - return tmpInstanceInfo; - } - - private SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { + @Override + protected SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { FileSourceSearchCondition searchCondition = getSearchCondition(callbackRequest); List fileSourceDTOList = fileSourceService.listWorkTableFileSource( @@ -155,59 +158,47 @@ private SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callback } @Override - public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { - CallbackBaseResponseDTO response; + protected CallbackBaseResponseDTO fetchInstanceResp( + CallbackRequestDTO callbackRequest + ) { IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); - switch (callbackRequest.getMethod()) { - case LIST_INSTANCE: - response = listInstanceResp(callbackRequest); - break; - case FETCH_INSTANCE_INFO: - List instanceAttributeInfoList = new ArrayList<>(); - for (String instanceId : searchCondition.getIdList()) { - try { - InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); - instanceInfo.setId(instanceId); - // 文件源详情查询实现 - FileSourceDTO fileSourceDTO = fileSourceService.getFileSourceById(Integer.parseInt(instanceId)); - if (fileSourceDTO == null) { - instanceInfo.setDisplayName("Unknown(may be deleted)"); - log.warn("Unexpected fileSourceId:{} passed by iam", instanceId); - } else { - instanceInfo.setDisplayName(fileSourceDTO.getAlias()); - } - instanceAttributeInfoList.add(instanceInfo); - } catch (NumberFormatException e) { - log.error("Parse object id failed!|{}", instanceId, e); - } + List instanceAttributeInfoList = new ArrayList<>(); + for (String instanceId : searchCondition.getIdList()) { + try { + // 文件源详情查询实现 + FileSourceDTO fileSourceDTO = fileSourceService.getFileSourceById(Integer.parseInt(instanceId)); + if (fileSourceDTO == null) { + return getNotFoundRespById(instanceId); } - - FetchInstanceInfoResponseDTO fetchInstanceInfoResponse = new FetchInstanceInfoResponseDTO(); - fetchInstanceInfoResponse.setCode(0L); - fetchInstanceInfoResponse.setData(instanceAttributeInfoList); - - response = fetchInstanceInfoResponse; - break; - case LIST_ATTRIBUTE: - response = new ListAttributeResponseDTO(); - response.setCode(0L); - break; - case LIST_ATTRIBUTE_VALUE: - response = new ListAttributeValueResponseDTO(); - response.setCode(0L); - break; - case LIST_INSTANCE_BY_POLICY: - response = new ListInstanceByPolicyResponseDTO(); - response.setCode(0L); - break; - case SEARCH_INSTANCE: - response = searchInstanceResp(callbackRequest); - break; - default: - log.error("Unknown callback method!|{}|{}|{}|{}", callbackRequest.getMethod(), - callbackRequest.getType(), callbackRequest.getFilter(), callbackRequest.getPage()); - response = new CallbackBaseResponseDTO(); + // 拓扑路径构建 + List path = new ArrayList<>(); + PathInfoDTO rootNode = new PathInfoDTO(); + rootNode.setType(ResourceId.APP); + rootNode.setId(fileSourceDTO.getAppId().toString()); + PathInfoDTO fileSourceNode = new PathInfoDTO(); + fileSourceNode.setType(ResourceId.FILE_SOURCE); + fileSourceNode.setId(fileSourceDTO.getId().toString()); + rootNode.setChild(fileSourceNode); + path.add(rootNode); + // 实例组装 + InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); + instanceInfo.setId(instanceId); + instanceInfo.setDisplayName(fileSourceDTO.getAlias()); + instanceInfo.setPath(path); + instanceAttributeInfoList.add(instanceInfo); + } catch (NumberFormatException e) { + log.error("Parse object id failed!|{}", instanceId, e); + } } - return response; + + FetchInstanceInfoResponseDTO fetchInstanceInfoResponse = new FetchInstanceInfoResponseDTO(); + fetchInstanceInfoResponse.setCode(0L); + fetchInstanceInfoResponse.setData(instanceAttributeInfoList); + return fetchInstanceInfoResponse; + } + + @Override + public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { + return baseCallback(callbackRequest); } } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamAccountCallbackResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamAccountCallbackResourceImpl.java index 020a251dc1..9c7ebcc51e 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamAccountCallbackResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamAccountCallbackResourceImpl.java @@ -24,20 +24,20 @@ package com.tencent.bk.job.manage.api.iam.impl; +import com.tencent.bk.job.common.iam.constant.ResourceId; +import com.tencent.bk.job.common.iam.service.BaseIamCallbackService; import com.tencent.bk.job.common.iam.util.IamRespUtil; import com.tencent.bk.job.common.model.BaseSearchCondition; import com.tencent.bk.job.common.model.PageData; import com.tencent.bk.job.manage.api.iam.IamAccountCallbackResource; import com.tencent.bk.job.manage.model.dto.AccountDTO; import com.tencent.bk.job.manage.service.AccountService; +import com.tencent.bk.sdk.iam.dto.PathInfoDTO; import com.tencent.bk.sdk.iam.dto.callback.request.CallbackRequestDTO; import com.tencent.bk.sdk.iam.dto.callback.request.IamSearchCondition; import com.tencent.bk.sdk.iam.dto.callback.response.CallbackBaseResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.FetchInstanceInfoResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.InstanceInfoDTO; -import com.tencent.bk.sdk.iam.dto.callback.response.ListAttributeResponseDTO; -import com.tencent.bk.sdk.iam.dto.callback.response.ListAttributeValueResponseDTO; -import com.tencent.bk.sdk.iam.dto.callback.response.ListInstanceByPolicyResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.ListInstanceResponseDTO; import com.tencent.bk.sdk.iam.dto.callback.response.SearchInstanceResponseDTO; import lombok.extern.slf4j.Slf4j; @@ -50,9 +50,14 @@ @RestController @Slf4j -public class IamAccountCallbackResourceImpl implements IamAccountCallbackResource { +public class IamAccountCallbackResourceImpl extends BaseIamCallbackService implements IamAccountCallbackResource { private final AccountService accountService; + @Autowired + public IamAccountCallbackResourceImpl(AccountService accountService) { + this.accountService = accountService; + } + private Pair getBasicQueryCondition(CallbackRequestDTO callbackRequest) { IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); BaseSearchCondition baseSearchCondition = new BaseSearchCondition(); @@ -71,7 +76,8 @@ private InstanceInfoDTO convert(AccountDTO accountDTO) { return instanceInfo; } - private ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest) { + @Override + protected ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest) { Pair basicQueryCond = getBasicQueryCondition(callbackRequest); AccountDTO accountQuery = basicQueryCond.getLeft(); @@ -82,7 +88,8 @@ private ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequ return IamRespUtil.getListInstanceRespFromPageData(accountDTOPageData, this::convert); } - private SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { + @Override + protected SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { Pair basicQueryCond = getBasicQueryCondition(callbackRequest); AccountDTO accountQuery = basicQueryCond.getLeft(); @@ -95,65 +102,48 @@ private SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callback return IamRespUtil.getSearchInstanceRespFromPageData(accountDTOPageData, this::convert); } - @Autowired - public IamAccountCallbackResourceImpl(AccountService accountService) { - this.accountService = accountService; + @Override + protected CallbackBaseResponseDTO fetchInstanceResp( + CallbackRequestDTO callbackRequest + ) { + IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); + List instanceAttributeInfoList = new ArrayList<>(); + for (String instanceId : searchCondition.getIdList()) { + try { + long id = Long.parseLong(instanceId); + AccountDTO accountDTO = accountService.getAccountById(id); + if (accountDTO == null) { + return getNotFoundRespById(instanceId); + } + // 拓扑路径构建 + List path = new ArrayList<>(); + PathInfoDTO rootNode = new PathInfoDTO(); + rootNode.setType(ResourceId.APP); + rootNode.setId(accountDTO.getAppId().toString()); + PathInfoDTO accountNode = new PathInfoDTO(); + accountNode.setType(ResourceId.ACCOUNT); + accountNode.setId(accountDTO.getId().toString()); + rootNode.setChild(accountNode); + path.add(rootNode); + // 实例组装 + InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); + instanceInfo.setId(instanceId); + instanceInfo.setDisplayName(accountDTO.getAlias()); + instanceInfo.setPath(path); + instanceAttributeInfoList.add(instanceInfo); + } catch (NumberFormatException e) { + log.error("Parse object id failed!|{}", instanceId, e); + } + } + + FetchInstanceInfoResponseDTO fetchInstanceInfoResponse = new FetchInstanceInfoResponseDTO(); + fetchInstanceInfoResponse.setCode(0L); + fetchInstanceInfoResponse.setData(instanceAttributeInfoList); + return fetchInstanceInfoResponse; } @Override public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { - CallbackBaseResponseDTO response; - switch (callbackRequest.getMethod()) { - case LIST_INSTANCE: - response = listInstanceResp(callbackRequest); - break; - case FETCH_INSTANCE_INFO: - IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); - List instanceAttributeInfoList = new ArrayList<>(); - for (String instanceId : searchCondition.getIdList()) { - try { - long id = Long.parseLong(instanceId); - InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); - instanceInfo.setId(instanceId); - AccountDTO accountDTO = accountService.getAccountById(id); - if (accountDTO != null) { - instanceInfo.setDisplayName(accountDTO.getAlias()); - } else { - instanceInfo.setDisplayName("Unknown(may be deleted)"); - log.warn("Unexpected accountId:{} passed by iam", id); - } - instanceAttributeInfoList.add(instanceInfo); - } catch (NumberFormatException e) { - log.error("Parse object id failed!|{}", instanceId, e); - } - } - - FetchInstanceInfoResponseDTO fetchInstanceInfoResponse = new FetchInstanceInfoResponseDTO(); - fetchInstanceInfoResponse.setCode(0L); - fetchInstanceInfoResponse.setData(instanceAttributeInfoList); - - response = fetchInstanceInfoResponse; - break; - case LIST_ATTRIBUTE: - response = new ListAttributeResponseDTO(); - response.setCode(0L); - break; - case LIST_ATTRIBUTE_VALUE: - response = new ListAttributeValueResponseDTO(); - response.setCode(0L); - break; - case LIST_INSTANCE_BY_POLICY: - response = new ListInstanceByPolicyResponseDTO(); - response.setCode(0L); - break; - case SEARCH_INSTANCE: - response = searchInstanceResp(callbackRequest); - break; - default: - log.error("Unknown callback method!|{}|{}|{}|{}", callbackRequest.getMethod(), - callbackRequest.getType(), callbackRequest.getFilter(), callbackRequest.getPage()); - response = new CallbackBaseResponseDTO(); - } - return response; + return baseCallback(callbackRequest); } } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamPublicScriptCallbackResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamPublicScriptCallbackResourceImpl.java index d717edebad..7b3a9612bc 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamPublicScriptCallbackResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamPublicScriptCallbackResourceImpl.java @@ -43,10 +43,20 @@ public class IamPublicScriptCallbackResourceImpl implements IamPublicScriptCallb @Autowired public IamPublicScriptCallbackResourceImpl(ScriptService scriptService) { - this.scriptCallbackHelper = new ScriptCallbackHelper(scriptService, this::getBasicQueryCondition); + this.scriptCallbackHelper = new ScriptCallbackHelper(scriptService, new ScriptCallbackHelper.IGetBasicInfo() { + @Override + public Pair getBasicQueryCondition(CallbackRequestDTO callbackRequest) { + return getBasicQueryConditionImpl(callbackRequest); + } + + @Override + public boolean isPublicScript() { + return true; + } + }); } - private Pair getBasicQueryCondition(CallbackRequestDTO callbackRequest) { + private Pair getBasicQueryConditionImpl(CallbackRequestDTO callbackRequest) { IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); BaseSearchCondition baseSearchCondition = new BaseSearchCondition(); baseSearchCondition.setStart(searchCondition.getStart().intValue()); diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamScriptCallbackResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamScriptCallbackResourceImpl.java index 1a599a5a59..e5c4dd645d 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamScriptCallbackResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamScriptCallbackResourceImpl.java @@ -43,10 +43,20 @@ public class IamScriptCallbackResourceImpl implements IamScriptCallbackResource @Autowired public IamScriptCallbackResourceImpl(ScriptService scriptService) { - this.scriptCallbackHelper = new ScriptCallbackHelper(scriptService, this::getBasicQueryCondition); + this.scriptCallbackHelper = new ScriptCallbackHelper(scriptService, new ScriptCallbackHelper.IGetBasicInfo() { + @Override + public Pair getBasicQueryCondition(CallbackRequestDTO callbackRequest) { + return getBasicQueryConditionImpl(callbackRequest); + } + + @Override + public boolean isPublicScript() { + return false; + } + }); } - private Pair getBasicQueryCondition(CallbackRequestDTO callbackRequest) { + private Pair getBasicQueryConditionImpl(CallbackRequestDTO callbackRequest) { IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); BaseSearchCondition baseSearchCondition = new BaseSearchCondition(); baseSearchCondition.setStart(searchCondition.getStart().intValue()); diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTagCallbackResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTagCallbackResourceImpl.java index b481823e8d..0f5ec5beec 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTagCallbackResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTagCallbackResourceImpl.java @@ -24,12 +24,15 @@ package com.tencent.bk.job.manage.api.iam.impl; +import com.tencent.bk.job.common.iam.constant.ResourceId; +import com.tencent.bk.job.common.iam.service.BaseIamCallbackService; import com.tencent.bk.job.common.iam.util.IamRespUtil; import com.tencent.bk.job.common.model.BaseSearchCondition; import com.tencent.bk.job.common.model.PageData; import com.tencent.bk.job.manage.api.iam.IamTagCallbackResource; import com.tencent.bk.job.manage.model.dto.TagDTO; import com.tencent.bk.job.manage.service.TagService; +import com.tencent.bk.sdk.iam.dto.PathInfoDTO; import com.tencent.bk.sdk.iam.dto.callback.request.CallbackRequestDTO; import com.tencent.bk.sdk.iam.dto.callback.request.IamSearchCondition; import com.tencent.bk.sdk.iam.dto.callback.response.CallbackBaseResponseDTO; @@ -50,7 +53,7 @@ @RestController @Slf4j -public class IamTagCallbackResourceImpl implements IamTagCallbackResource { +public class IamTagCallbackResourceImpl extends BaseIamCallbackService implements IamTagCallbackResource { private final TagService tagService; @Autowired @@ -76,7 +79,8 @@ private InstanceInfoDTO convert(TagDTO tagDTO) { return instanceInfo; } - private SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { + @Override + protected SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { Pair basicQueryCond = getBasicQueryCondition(callbackRequest); TagDTO tagQuery = basicQueryCond.getLeft(); @@ -88,7 +92,8 @@ private SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callback return IamRespUtil.getSearchInstanceRespFromPageData(tagDTOPageData, this::convert); } - private ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest) { + @Override + protected ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest) { Pair basicQueryCond = getBasicQueryCondition(callbackRequest); TagDTO tagQuery = basicQueryCond.getLeft(); @@ -98,21 +103,32 @@ private ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequ return IamRespUtil.getListInstanceRespFromPageData(tagDTOPageData, this::convert); } - private FetchInstanceInfoResponseDTO fetchInstanceResp(CallbackRequestDTO callbackRequest) { + @Override + protected CallbackBaseResponseDTO fetchInstanceResp(CallbackRequestDTO callbackRequest) { IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); List instanceAttributeInfoList = new ArrayList<>(); for (String instanceId : searchCondition.getIdList()) { try { Long tagId = Long.parseLong(instanceId); - InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); - instanceInfo.setId(instanceId); TagDTO tagDTO = tagService.getTagInfoById(tagId); - if (tagDTO != null) { - instanceInfo.setDisplayName(tagDTO.getName()); - } else { - instanceInfo.setDisplayName("Unknown(may be deleted)"); - log.warn("Unexpected tagId:{} passed by iam", instanceId); + if (tagDTO == null) { + return getNotFoundRespById(instanceId); } + // 拓扑路径构建 + List path = new ArrayList<>(); + PathInfoDTO rootNode = new PathInfoDTO(); + rootNode.setType(ResourceId.APP); + rootNode.setId(tagDTO.getAppId().toString()); + PathInfoDTO tagNode = new PathInfoDTO(); + tagNode.setType(ResourceId.TAG); + tagNode.setId(tagDTO.getId().toString()); + rootNode.setChild(tagNode); + path.add(rootNode); + // 实例组装 + InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); + instanceInfo.setId(instanceId); + instanceInfo.setDisplayName(tagDTO.getName()); + instanceInfo.setPath(path); instanceAttributeInfoList.add(instanceInfo); } catch (NumberFormatException e) { log.error("Parse object id failed!|{}", instanceId, e); @@ -127,34 +143,6 @@ private FetchInstanceInfoResponseDTO fetchInstanceResp(CallbackRequestDTO callba @Override public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { - CallbackBaseResponseDTO response; - switch (callbackRequest.getMethod()) { - case LIST_INSTANCE: - response = listInstanceResp(callbackRequest); - break; - case FETCH_INSTANCE_INFO: - response = fetchInstanceResp(callbackRequest); - break; - case LIST_ATTRIBUTE: - response = new ListAttributeResponseDTO(); - response.setCode(0L); - break; - case LIST_ATTRIBUTE_VALUE: - response = new ListAttributeValueResponseDTO(); - response.setCode(0L); - break; - case LIST_INSTANCE_BY_POLICY: - response = new ListInstanceByPolicyResponseDTO(); - response.setCode(0L); - break; - case SEARCH_INSTANCE: - response = searchInstanceResp(callbackRequest); - break; - default: - log.error("Unknown callback method!|{}|{}|{}|{}", callbackRequest.getMethod(), - callbackRequest.getType(), callbackRequest.getFilter(), callbackRequest.getPage()); - response = new CallbackBaseResponseDTO(); - } - return response; + return baseCallback(callbackRequest); } } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskPlanCallbackResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskPlanCallbackResourceImpl.java index a435fa0733..c04a771486 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskPlanCallbackResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskPlanCallbackResourceImpl.java @@ -24,6 +24,8 @@ package com.tencent.bk.job.manage.api.iam.impl; +import com.tencent.bk.job.common.iam.constant.ResourceId; +import com.tencent.bk.job.common.iam.service.BaseIamCallbackService; import com.tencent.bk.job.common.iam.util.IamRespUtil; import com.tencent.bk.job.common.model.BaseSearchCondition; import com.tencent.bk.job.common.model.PageData; @@ -31,6 +33,7 @@ import com.tencent.bk.job.manage.model.dto.TaskPlanQueryDTO; import com.tencent.bk.job.manage.model.dto.task.TaskPlanInfoDTO; import com.tencent.bk.job.manage.service.plan.TaskPlanService; +import com.tencent.bk.sdk.iam.dto.PathInfoDTO; import com.tencent.bk.sdk.iam.dto.callback.request.CallbackRequestDTO; import com.tencent.bk.sdk.iam.dto.callback.request.IamSearchCondition; import com.tencent.bk.sdk.iam.dto.callback.response.CallbackBaseResponseDTO; @@ -51,7 +54,8 @@ @Slf4j @RestController -public class IamTaskPlanCallbackResourceImpl implements IamTaskPlanCallbackResource { +public class IamTaskPlanCallbackResourceImpl extends BaseIamCallbackService + implements IamTaskPlanCallbackResource { private final TaskPlanService planService; @@ -78,7 +82,8 @@ private Pair getBasicQueryCondition(Callb return Pair.of(planQuery, baseSearchCondition); } - public ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest) { + @Override + protected ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest) { Pair basicQueryCond = getBasicQueryCondition(callbackRequest); @@ -90,7 +95,8 @@ public ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackReque return IamRespUtil.getListInstanceRespFromPageData(planDTOPageData, this::convert); } - public SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { + @Override + protected SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { Pair basicQueryCond = getBasicQueryCondition(callbackRequest); @@ -105,53 +111,51 @@ public SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackR } @Override - public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { - CallbackBaseResponseDTO response; + protected CallbackBaseResponseDTO fetchInstanceResp( + CallbackRequestDTO callbackRequest + ) { IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); - switch (callbackRequest.getMethod()) { - case LIST_INSTANCE: - response = listInstanceResp(callbackRequest); - break; - case FETCH_INSTANCE_INFO: - List instanceAttributeInfoList = new ArrayList<>(); - for (String instanceId : searchCondition.getIdList()) { - try { - long id = Long.parseLong(instanceId); - InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); - instanceInfo.setId(instanceId); - instanceInfo.setDisplayName(planService.getPlanName(id)); - instanceAttributeInfoList.add(instanceInfo); - } catch (NumberFormatException e) { - log.error("Parse object id failed!|{}", instanceId, e); - } + List instanceAttributeInfoList = new ArrayList<>(); + for (String instanceId : searchCondition.getIdList()) { + try { + long id = Long.parseLong(instanceId); + TaskPlanInfoDTO planInfoDTO = planService.getTaskPlanById(id); + if (planInfoDTO == null) { + return getNotFoundRespById(instanceId); } - - FetchInstanceInfoResponseDTO fetchInstanceInfoResponse = new FetchInstanceInfoResponseDTO(); - fetchInstanceInfoResponse.setCode(0L); - fetchInstanceInfoResponse.setData(instanceAttributeInfoList); - - response = fetchInstanceInfoResponse; - break; - case LIST_ATTRIBUTE: - response = new ListAttributeResponseDTO(); - response.setCode(0L); - break; - case LIST_ATTRIBUTE_VALUE: - response = new ListAttributeValueResponseDTO(); - response.setCode(0L); - break; - case LIST_INSTANCE_BY_POLICY: - response = new ListInstanceByPolicyResponseDTO(); - response.setCode(0L); - break; - case SEARCH_INSTANCE: - response = searchInstanceResp(callbackRequest); - break; - default: - log.error("Unknown callback method!|{}|{}|{}|{}", callbackRequest.getMethod(), - callbackRequest.getType(), callbackRequest.getFilter(), callbackRequest.getPage()); - response = new CallbackBaseResponseDTO(); + // 拓扑路径构建 + List path = new ArrayList<>(); + PathInfoDTO rootNode = new PathInfoDTO(); + rootNode.setType(ResourceId.APP); + rootNode.setId(planInfoDTO.getAppId().toString()); + PathInfoDTO templateNode = new PathInfoDTO(); + templateNode.setType(ResourceId.TEMPLATE); + templateNode.setId(planInfoDTO.getTemplateId().toString()); + rootNode.setChild(templateNode); + PathInfoDTO planNode = new PathInfoDTO(); + planNode.setType(ResourceId.PLAN); + planNode.setId(planInfoDTO.getId().toString()); + templateNode.setChild(planNode); + path.add(rootNode); + // 实例组装 + InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); + instanceInfo.setId(instanceId); + instanceInfo.setDisplayName(planInfoDTO.getName()); + instanceInfo.setPath(path); + instanceAttributeInfoList.add(instanceInfo); + } catch (NumberFormatException e) { + log.error("Parse object id failed!|{}", instanceId, e); + } } - return response; + FetchInstanceInfoResponseDTO fetchInstanceInfoResponse = new FetchInstanceInfoResponseDTO(); + fetchInstanceInfoResponse.setCode(0L); + fetchInstanceInfoResponse.setData(instanceAttributeInfoList); + + return fetchInstanceInfoResponse; + } + + @Override + public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { + return baseCallback(callbackRequest); } } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskTemplateCallbackResourceImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskTemplateCallbackResourceImpl.java index 3cbf3eaca0..b46db57849 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskTemplateCallbackResourceImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/IamTaskTemplateCallbackResourceImpl.java @@ -24,12 +24,15 @@ package com.tencent.bk.job.manage.api.iam.impl; +import com.tencent.bk.job.common.iam.constant.ResourceId; +import com.tencent.bk.job.common.iam.service.BaseIamCallbackService; import com.tencent.bk.job.common.iam.util.IamRespUtil; import com.tencent.bk.job.common.model.BaseSearchCondition; import com.tencent.bk.job.common.model.PageData; import com.tencent.bk.job.manage.api.iam.IamTaskTemplateCallbackResource; import com.tencent.bk.job.manage.model.dto.task.TaskTemplateInfoDTO; import com.tencent.bk.job.manage.service.template.TaskTemplateService; +import com.tencent.bk.sdk.iam.dto.PathInfoDTO; import com.tencent.bk.sdk.iam.dto.callback.request.CallbackRequestDTO; import com.tencent.bk.sdk.iam.dto.callback.request.IamSearchCondition; import com.tencent.bk.sdk.iam.dto.callback.response.CallbackBaseResponseDTO; @@ -50,7 +53,8 @@ @Slf4j @RestController -public class IamTaskTemplateCallbackResourceImpl implements IamTaskTemplateCallbackResource { +public class IamTaskTemplateCallbackResourceImpl extends BaseIamCallbackService + implements IamTaskTemplateCallbackResource { private final TaskTemplateService templateService; @@ -77,19 +81,24 @@ private Pair getBasicQueryCondition(Ca return Pair.of(templateQuery, baseSearchCondition); } - public ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest) { + @Override + protected ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest) { Pair basicQueryCond = getBasicQueryCondition(callbackRequest); TaskTemplateInfoDTO templateQuery = basicQueryCond.getLeft(); BaseSearchCondition baseSearchCondition = basicQueryCond.getRight(); - PageData templateDTOPageData = templateService.listPageTaskTemplatesBasicInfo(templateQuery, - baseSearchCondition, null); + PageData templateDTOPageData = templateService.listPageTaskTemplatesBasicInfo( + templateQuery, + baseSearchCondition, + null + ); return IamRespUtil.getListInstanceRespFromPageData(templateDTOPageData, this::convert); } - public SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { + @Override + protected SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { Pair basicQueryCond = getBasicQueryCondition(callbackRequest); @@ -104,53 +113,47 @@ public SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackR } @Override - public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { - CallbackBaseResponseDTO response; + protected CallbackBaseResponseDTO fetchInstanceResp( + CallbackRequestDTO callbackRequest + ) { IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); - switch (callbackRequest.getMethod()) { - case LIST_INSTANCE: - response = listInstanceResp(callbackRequest); - break; - case FETCH_INSTANCE_INFO: - List instanceAttributeInfoList = new ArrayList<>(); - for (String instanceId : searchCondition.getIdList()) { - try { - long id = Long.parseLong(instanceId); - InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); - instanceInfo.setId(instanceId); - instanceInfo.setDisplayName(templateService.getTemplateName(id)); - instanceAttributeInfoList.add(instanceInfo); - } catch (NumberFormatException e) { - log.error("Parse object id failed!|{}", instanceId, e); - } + List instanceAttributeInfoList = new ArrayList<>(); + for (String instanceId : searchCondition.getIdList()) { + try { + long id = Long.parseLong(instanceId); + TaskTemplateInfoDTO templateInfoDTO = templateService.getTaskTemplateBasicInfoById(id); + if (templateInfoDTO == null) { + return getNotFoundRespById(instanceId); } - - FetchInstanceInfoResponseDTO fetchInstanceInfoResponse = new FetchInstanceInfoResponseDTO(); - fetchInstanceInfoResponse.setCode(0L); - fetchInstanceInfoResponse.setData(instanceAttributeInfoList); - - response = fetchInstanceInfoResponse; - break; - case LIST_ATTRIBUTE: - response = new ListAttributeResponseDTO(); - response.setCode(0L); - break; - case LIST_ATTRIBUTE_VALUE: - response = new ListAttributeValueResponseDTO(); - response.setCode(0L); - break; - case LIST_INSTANCE_BY_POLICY: - response = new ListInstanceByPolicyResponseDTO(); - response.setCode(0L); - break; - case SEARCH_INSTANCE: - response = searchInstanceResp(callbackRequest); - break; - default: - log.error("Unknown callback method!|{}|{}|{}|{}", callbackRequest.getMethod(), - callbackRequest.getType(), callbackRequest.getFilter(), callbackRequest.getPage()); - response = new CallbackBaseResponseDTO(); + // 拓扑路径构建 + List path = new ArrayList<>(); + PathInfoDTO rootNode = new PathInfoDTO(); + rootNode.setType(ResourceId.APP); + rootNode.setId(templateInfoDTO.getAppId().toString()); + PathInfoDTO templateNode = new PathInfoDTO(); + templateNode.setType(ResourceId.TEMPLATE); + templateNode.setId(templateInfoDTO.getId().toString()); + rootNode.setChild(templateNode); + path.add(rootNode); + // 实例组装 + InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); + instanceInfo.setId(instanceId); + instanceInfo.setDisplayName(templateInfoDTO.getName()); + instanceInfo.setPath(path); + instanceAttributeInfoList.add(instanceInfo); + } catch (NumberFormatException e) { + log.error("Parse object id failed!|{}", instanceId, e); + } } - return response; + + FetchInstanceInfoResponseDTO fetchInstanceInfoResponse = new FetchInstanceInfoResponseDTO(); + fetchInstanceInfoResponse.setCode(0L); + fetchInstanceInfoResponse.setData(instanceAttributeInfoList); + return fetchInstanceInfoResponse; + } + + @Override + public CallbackBaseResponseDTO callback(CallbackRequestDTO callbackRequest) { + return baseCallback(callbackRequest); } } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/ScriptCallbackHelper.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/ScriptCallbackHelper.java index 13c552cfe7..3377fe0bcd 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/ScriptCallbackHelper.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/iam/impl/ScriptCallbackHelper.java @@ -1,11 +1,14 @@ package com.tencent.bk.job.manage.api.iam.impl; +import com.tencent.bk.job.common.iam.constant.ResourceId; +import com.tencent.bk.job.common.iam.service.BaseIamCallbackService; import com.tencent.bk.job.common.iam.util.IamRespUtil; import com.tencent.bk.job.common.model.BaseSearchCondition; import com.tencent.bk.job.common.model.PageData; import com.tencent.bk.job.manage.model.dto.ScriptDTO; import com.tencent.bk.job.manage.model.dto.ScriptQueryDTO; import com.tencent.bk.job.manage.service.ScriptService; +import com.tencent.bk.sdk.iam.dto.PathInfoDTO; import com.tencent.bk.sdk.iam.dto.callback.request.CallbackRequestDTO; import com.tencent.bk.sdk.iam.dto.callback.request.IamSearchCondition; import com.tencent.bk.sdk.iam.dto.callback.response.CallbackBaseResponseDTO; @@ -23,20 +26,22 @@ import java.util.List; @Slf4j -public class ScriptCallbackHelper { +public class ScriptCallbackHelper extends BaseIamCallbackService { private ScriptService scriptService; - private IGetBasicQueryCondition basicQueryInterface; + private IGetBasicInfo basicInfoInterface; public ScriptCallbackHelper( ScriptService scriptService, - IGetBasicQueryCondition basicQueryInterface + IGetBasicInfo basicInfoInterface ) { this.scriptService = scriptService; - this.basicQueryInterface = basicQueryInterface; + this.basicInfoInterface = basicInfoInterface; } - public interface IGetBasicQueryCondition { + public interface IGetBasicInfo { Pair getBasicQueryCondition(CallbackRequestDTO callbackRequest); + + boolean isPublicScript(); } @@ -47,9 +52,10 @@ private InstanceInfoDTO convert(ScriptDTO script) { return instanceInfo; } - public ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest) { + @Override + protected ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackRequest) { Pair basicQueryCond = - basicQueryInterface.getBasicQueryCondition(callbackRequest); + basicInfoInterface.getBasicQueryCondition(callbackRequest); ScriptQueryDTO scriptQuery = basicQueryCond.getLeft(); BaseSearchCondition baseSearchCondition = basicQueryCond.getRight(); @@ -59,10 +65,11 @@ public ListInstanceResponseDTO listInstanceResp(CallbackRequestDTO callbackReque return IamRespUtil.getListInstanceRespFromPageData(accountDTOPageData, this::convert); } - public SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { + @Override + protected SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackRequest) { Pair basicQueryCond = - basicQueryInterface.getBasicQueryCondition(callbackRequest); + basicInfoInterface.getBasicQueryCondition(callbackRequest); ScriptQueryDTO scriptQuery = basicQueryCond.getLeft(); BaseSearchCondition baseSearchCondition = basicQueryCond.getRight(); @@ -73,67 +80,53 @@ public SearchInstanceResponseDTO searchInstanceResp(CallbackRequestDTO callbackR return IamRespUtil.getSearchInstanceRespFromPageData(accountDTOPageData, this::convert); } - public CallbackBaseResponseDTO doCallback(CallbackRequestDTO callbackRequest){ - CallbackBaseResponseDTO response; + @Override + protected CallbackBaseResponseDTO fetchInstanceResp( + CallbackRequestDTO callbackRequest + ) { IamSearchCondition searchCondition = IamSearchCondition.fromReq(callbackRequest); - switch (callbackRequest.getMethod()) { - case LIST_INSTANCE: - response = listInstanceResp(callbackRequest); - break; - case FETCH_INSTANCE_INFO: - log.debug("Fetch instance info request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); - - List instanceAttributeInfoList = new ArrayList<>(); - for (String instanceId : searchCondition.getIdList()) { - try { - InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); - instanceInfo.setId(instanceId); - ScriptDTO scriptDTO = scriptService.getScriptByScriptId(instanceId); - if (scriptDTO != null) { - instanceInfo.setDisplayName(scriptDTO.getName()); - } else { - instanceInfo.setDisplayName("Unknown(may be deleted)"); - log.warn("Unexpected scriptId:{} passed by iam", instanceId); - } - instanceAttributeInfoList.add(instanceInfo); - } catch (NumberFormatException e) { - log.error("Parse object id failed!|{}", instanceId, e); - } + List instanceAttributeInfoList = new ArrayList<>(); + for (String instanceId : searchCondition.getIdList()) { + try { + ScriptDTO scriptDTO = scriptService.getScriptByScriptId(instanceId); + if (scriptDTO == null) { + return getNotFoundRespById(instanceId); } - - FetchInstanceInfoResponseDTO fetchInstanceInfoResponse = new FetchInstanceInfoResponseDTO(); - fetchInstanceInfoResponse.setCode(0L); - fetchInstanceInfoResponse.setData(instanceAttributeInfoList); - - response = fetchInstanceInfoResponse; - break; - case LIST_ATTRIBUTE: - log.debug("List attribute request!|{}|{}|{}", callbackRequest.getType(), callbackRequest.getFilter(), - callbackRequest.getPage()); - response = new ListAttributeResponseDTO(); - response.setCode(0L); - break; - case LIST_ATTRIBUTE_VALUE: - log.debug("List attribute value request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); - response = new ListAttributeValueResponseDTO(); - response.setCode(0L); - break; - case LIST_INSTANCE_BY_POLICY: - log.debug("List instance by policy request!|{}|{}|{}", callbackRequest.getType(), - callbackRequest.getFilter(), callbackRequest.getPage()); - response = new ListInstanceByPolicyResponseDTO(); - response.setCode(0L); - break; - case SEARCH_INSTANCE: - response = searchInstanceResp(callbackRequest); - break; - default: - log.error("Unknown callback method!|{}|{}|{}|{}", callbackRequest.getMethod(), - callbackRequest.getType(), callbackRequest.getFilter(), callbackRequest.getPage()); - response = new CallbackBaseResponseDTO(); + // 拓扑路径构建 + List path = new ArrayList<>(); + PathInfoDTO rootNode = new PathInfoDTO(); + if (basicInfoInterface.isPublicScript()) { + // 公共脚本 + rootNode.setType(ResourceId.PUBLIC_SCRIPT); + rootNode.setId(scriptDTO.getId()); + } else { + // 业务脚本 + rootNode.setType(ResourceId.APP); + rootNode.setId(scriptDTO.getAppId().toString()); + PathInfoDTO scriptNode = new PathInfoDTO(); + scriptNode.setType(ResourceId.SCRIPT); + scriptNode.setId(scriptDTO.getId()); + rootNode.setChild(scriptNode); + } + path.add(rootNode); + // 实例组装 + InstanceInfoDTO instanceInfo = new InstanceInfoDTO(); + instanceInfo.setId(instanceId); + instanceInfo.setDisplayName(scriptDTO.getName()); + instanceInfo.setPath(path); + instanceAttributeInfoList.add(instanceInfo); + } catch (NumberFormatException e) { + log.error("Parse object id failed!|{}", instanceId, e); + } } - return response; + + FetchInstanceInfoResponseDTO fetchInstanceInfoResponse = new FetchInstanceInfoResponseDTO(); + fetchInstanceInfoResponse.setCode(0L); + fetchInstanceInfoResponse.setData(instanceAttributeInfoList); + return fetchInstanceInfoResponse; + } + + public CallbackBaseResponseDTO doCallback(CallbackRequestDTO callbackRequest) { + return baseCallback(callbackRequest); } }