Skip to content

Commit

Permalink
pref:插件国际化properties文件value值支持引入文件 TencentBlueKing#9366
Browse files Browse the repository at this point in the history
  • Loading branch information
yjieliang committed Oct 8, 2023
1 parent 4be6c77 commit aad7bed
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@
package com.tencent.devops.artifactory.api.service

import com.tencent.devops.artifactory.pojo.enums.FileChannelTypeEnum
import com.tencent.devops.artifactory.pojo.enums.FileTypeEnum
import com.tencent.devops.common.api.auth.AUTH_HEADER_USER_ID
import com.tencent.devops.common.api.pojo.Result
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import org.glassfish.jersey.media.multipart.FormDataContentDisposition
import org.glassfish.jersey.media.multipart.FormDataParam
import java.io.InputStream
import javax.servlet.http.HttpServletResponse
import javax.ws.rs.Consumes
Expand All @@ -46,6 +45,8 @@ import javax.ws.rs.Produces
import javax.ws.rs.QueryParam
import javax.ws.rs.core.Context
import javax.ws.rs.core.MediaType
import org.glassfish.jersey.media.multipart.FormDataContentDisposition
import org.glassfish.jersey.media.multipart.FormDataParam

/**
* 注意,此类用了MULTIPART_FORM_DATA,导致Feign会有问题,不要直接用Feign去调用。
Expand Down Expand Up @@ -78,7 +79,10 @@ interface ServiceFileResource {
fileChannelType: FileChannelTypeEnum = FileChannelTypeEnum.SERVICE,
@ApiParam("是否为插件logo", required = false)
@QueryParam("logo")
logo: Boolean? = false
logo: Boolean? = false,
@ApiParam("文件类型", required = false)
@QueryParam("fileType")
fileType: FileTypeEnum? = null
): Result<String?>

@ApiOperation("下载文件")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ package com.tencent.devops.artifactory.resources

import com.tencent.devops.artifactory.api.service.ServiceFileResource
import com.tencent.devops.artifactory.pojo.enums.FileChannelTypeEnum
import com.tencent.devops.artifactory.pojo.enums.FileTypeEnum
import com.tencent.devops.artifactory.service.ArchiveFileService
import com.tencent.devops.common.api.pojo.Result
import com.tencent.devops.common.web.RestResource
import org.glassfish.jersey.media.multipart.FormDataContentDisposition
import org.springframework.beans.factory.annotation.Autowired
import java.io.InputStream
import javax.servlet.http.HttpServletResponse
import org.glassfish.jersey.media.multipart.FormDataContentDisposition
import org.springframework.beans.factory.annotation.Autowired

@RestResource
class ServiceFileResourceImpl @Autowired constructor(private val archiveFileService: ArchiveFileService) :
Expand All @@ -47,15 +48,17 @@ class ServiceFileResourceImpl @Autowired constructor(private val archiveFileServ
disposition: FormDataContentDisposition,
projectCode: String?,
fileChannelType: FileChannelTypeEnum,
logo: Boolean?
logo: Boolean?,
fileType: FileTypeEnum?
): Result<String?> {
val url = archiveFileService.uploadFile(
userId = userId,
inputStream = inputStream,
disposition = disposition,
projectId = projectCode,
fileChannelType = fileChannelType,
logo = logo
logo = logo,
fileType = fileType
)
return Result(url)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,11 @@ object CommonUtils {
file: File,
fileChannelType: String,
logo: Boolean = false,
language: String
language: String,
fileType: String? = null
): Result<String?> {
val serviceUrl = "$serviceUrlPrefix/service/artifactories/file/upload" +
"?userId=$userId&fileChannelType=$fileChannelType&logo=$logo"
"?userId=$userId&fileChannelType=$fileChannelType&logo=$logo" + fileType?.let { "&fileType=$fileType" }
logger.info("the serviceUrl is:$serviceUrl")
OkhttpUtils.uploadFile(serviceUrl, file).use { response ->
val responseContent = response.body!!.string()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ package com.tencent.devops.store.service.common.impl

import com.tencent.devops.artifactory.api.service.ServiceFileResource
import com.tencent.devops.artifactory.pojo.enums.FileChannelTypeEnum
import com.tencent.devops.artifactory.pojo.enums.FileTypeEnum
import com.tencent.devops.common.api.constant.CommonMessageCode
import com.tencent.devops.common.api.pojo.Result
import com.tencent.devops.common.api.util.OkhttpUtils
Expand All @@ -52,7 +53,8 @@ class SampleStoreFileServiceImpl : StoreFileService() {
client: Client,
fileDirPath: String,
logoFlag: Boolean,
result: MutableMap<String, String>
result: MutableMap<String, String>,
fileType: FileTypeEnum?
): Map<String, String> {
pathList.forEach { path ->
val file = File("$fileDirPath${fileSeparator}$path")
Expand All @@ -65,7 +67,8 @@ class SampleStoreFileServiceImpl : StoreFileService() {
file = file,
logo = logoFlag,
fileChannelType = FileChannelTypeEnum.WEB_SHOW.name,
language = I18nUtil.getLanguage(I18nUtil.getRequestUserId())
language = I18nUtil.getLanguage(I18nUtil.getRequestUserId()),
fileType = fileType?.fileType
).data
fileUrl?.let { result[path] = fileUrl }
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/
package com.tencent.devops.store.service.common

import com.tencent.devops.artifactory.pojo.enums.FileTypeEnum
import com.tencent.devops.common.api.pojo.Result
import com.tencent.devops.common.client.Client
import com.tencent.devops.store.utils.AtomReleaseTxtAnalysisUtil
Expand Down Expand Up @@ -94,7 +95,8 @@ abstract class StoreFileService {
pathList = pathList,
client = client,
fileDirPath = fileDirPath,
result = result
result = result,
fileType = FileTypeEnum.BK_STATIC
)
return AtomReleaseTxtAnalysisUtil.filePathReplace(uploadFileToPathResult.toMutableMap(), descriptionText)
}
Expand All @@ -105,7 +107,8 @@ abstract class StoreFileService {
client: Client,
fileDirPath: String,
logoFlag: Boolean = false,
result: MutableMap<String, String>
result: MutableMap<String, String>,
fileType: FileTypeEnum?
): Map<String, String>

abstract fun serviceArchiveAtomFile(
Expand Down

0 comments on commit aad7bed

Please sign in to comment.