Skip to content

Commit

Permalink
feat: 增加查询文件源与凭证详情的ApiGW接口 TencentBlueKing#2830
Browse files Browse the repository at this point in the history
  • Loading branch information
liuliaozhong committed Apr 9, 2024
1 parent ff632d5 commit b07d11e
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

package com.tencent.bk.job.file_gateway.api.inner;

import com.tencent.bk.job.common.annotation.CompatibleImplementation;
import com.tencent.bk.job.common.annotation.InternalAPI;
import com.tencent.bk.job.common.constant.CompatibleType;
import com.tencent.bk.job.common.model.InternalResponse;
import com.tentent.bk.job.common.api.feign.annotation.SmartFeignClient;
import io.swagger.annotations.Api;
Expand All @@ -44,6 +46,14 @@ InternalResponse<Integer> getFileSourceIdByCode(
@ApiParam(value = "Job业务ID", required = true) @PathVariable("appId") Long appId,
@ApiParam(value = "文件源标识", required = true) @PathVariable("code") String code);

@Deprecated
@CompatibleImplementation(name = "fileSourceId", deprecatedVersion = "3.9.x", type = CompatibleType.DEPLOY,
explain = "文件源标识仅在appId下唯一,发布完成后可删除")
@ApiOperation(value = "获取文件源ID", produces = "application/json")
@GetMapping("/service/fileSource/getFileSourceIdByCode/codes/{code}")
InternalResponse<Integer> getFileSourceIdByCode(
@ApiParam(value = "文件源标识", required = true) @PathVariable("code") String code);

@ApiOperation(value = "判断是否存在文件源引用了指定凭证", produces = "application/json")
@GetMapping("/service/app/{appId}/fileSource/existsFileSourceUsingCredential/credentialIds/{credentialId}")
InternalResponse<Boolean> existsFileSourceUsingCredential(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ public InternalResponse<Integer> getFileSourceIdByCode(Long appId, String code)
return InternalResponse.buildSuccessResp(fileSourceDTO.getId());
}

@Override
public InternalResponse<Integer> getFileSourceIdByCode(String code) {
FileSourceDTO fileSourceDTO = fileSourceService.getFileSourceByCode(code);
if (null == fileSourceDTO) {
throw new NotFoundException(ErrorCode.FAIL_TO_FIND_FILE_SOURCE_BY_CODE, new String[]{code});
}
return InternalResponse.buildSuccessResp(fileSourceDTO.getId());
}

@Override
public InternalResponse<Boolean> existsFileSourceUsingCredential(Long appId, String credentialId) {
boolean result = fileSourceService.existsFileSourceUsingCredential(appId, credentialId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

package com.tencent.bk.job.file_gateway.dao.filesource;

import com.tencent.bk.job.common.annotation.CompatibleImplementation;
import com.tencent.bk.job.common.constant.CompatibleType;
import com.tencent.bk.job.file_gateway.model.dto.FileSourceBasicInfoDTO;
import com.tencent.bk.job.file_gateway.model.dto.FileSourceDTO;

Expand All @@ -45,6 +47,11 @@ public interface FileSourceDAO {

List<FileSourceBasicInfoDTO> listFileSourceByIds(Collection<Integer> ids);

@Deprecated
@CompatibleImplementation(name = "fileSourceId", deprecatedVersion = "3.9.x", type = CompatibleType.DEPLOY,
explain = "文件源标识仅在appId下唯一,发布完成后可删除")
FileSourceDTO getFileSourceByCode(String code);

FileSourceDTO getFileSourceByCode(Long appId, String code);

Integer countAvailableLikeFileSource(Long appId, String credentialId, String alias);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ public List<FileSourceBasicInfoDTO> listFileSourceByIds(Collection<Integer> ids)
return records.map(this::convertRecordToBasicInfoDto);
}

@Override
public FileSourceDTO getFileSourceByCode(String code) {
val record = dslContext.selectFrom(defaultTable)
.where(defaultTable.CODE.eq(code))
.fetchOne();
if (record == null) {
return null;
} else {
return convertRecordToDto(record);
}
}

@Override
public FileSourceDTO getFileSourceByCode(Long appId, String code) {
val record = dslContext.selectFrom(defaultTable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

package com.tencent.bk.job.file_gateway.service;

import com.tencent.bk.job.common.annotation.CompatibleImplementation;
import com.tencent.bk.job.common.constant.CompatibleType;
import com.tencent.bk.job.file_gateway.model.dto.FileSourceBasicInfoDTO;
import com.tencent.bk.job.file_gateway.model.dto.FileSourceDTO;
import com.tencent.bk.job.file_gateway.model.dto.FileSourceTypeDTO;
Expand Down Expand Up @@ -90,6 +92,11 @@ List<FileSourceDTO> listWorkTableFileSource(

List<FileSourceBasicInfoDTO> listFileSourceByIds(Collection<Integer> ids);

@Deprecated
@CompatibleImplementation(name = "fileSourceId", deprecatedVersion = "3.9.x", type = CompatibleType.DEPLOY,
explain = "文件源标识仅在appId下唯一,发布完成后可删除")
FileSourceDTO getFileSourceByCode(String code);

FileSourceDTO getFileSourceByCode(Long appId, String code);

List<FileSourceStaticParam> getFileSourceParams(Long appId, String fileSourceTypeCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ public List<FileSourceBasicInfoDTO> listFileSourceByIds(Collection<Integer> ids)
return fileSourceDAO.listFileSourceByIds(ids);
}

@Override
public FileSourceDTO getFileSourceByCode(String code) {
return fileSourceDAO.getFileSourceByCode(code);
}

@Override
public FileSourceDTO getFileSourceByCode(Long appId, String code) {
return fileSourceDAO.getFileSourceByCode(appId, code);
Expand Down

0 comments on commit b07d11e

Please sign in to comment.