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

feat: turbo后台信息国际化 #86 #92

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
476eaf5
feat: turbo后台信息国际化 #86
eazence Jun 27, 2023
ae5dd5f
feat: turbo后台信息国际化-调整i18n工具类 #86
eazence Jun 28, 2023
58c2bce
feat: turbo后台信息国际化-适配无法翻译的未知字段 #86
eazence Jun 28, 2023
a545e7d
feat: turbo后台信息国际化-调整国际化参数优先级cookie > header > param #86
eazence Jun 28, 2023
5c1cc86
feat: turbo后台信息国际化 #86
eazence Jun 28, 2023
c14c8b0
feat: turbo后台信息国际化 #86
eazence Jun 28, 2023
d9ebc9b
feat: turbo后台信息国际化 #86
eazence Jul 4, 2023
9620818
feat: turbo后台信息国际化 #86
eazence Jul 5, 2023
463364f
feat: turbo后台信息国际化 #86
eazence Jul 5, 2023
6bf0225
feat: turbo后台信息国际化 #86
eazence Jul 5, 2023
8cb548b
feat: turbo后台信息国际化-异常错误信息国际化 #86
eazence Jul 7, 2023
352b238
feat: turbo后台信息国际化-异常错误信息国际化 #86
eazence Jul 7, 2023
7856749
feat: turbo后台信息国际化-配置异常错误信息国际化 #86
eazence Jul 10, 2023
f5106a2
feat: turbo后台信息国际化-异常错误信息国际化 #86
eazence Jul 11, 2023
5e0d7cd
feat: turbo后台信息国际化 #86
eazence Jul 11, 2023
98ecbb8
feat: turbo后台信息国际化 #86
eazence Jul 12, 2023
d0cb614
feat: turbo后台信息国际化 #86
eazence Jul 12, 2023
439016a
feat: turbo后台信息国际化 #86
eazence Aug 18, 2023
284bae8
feat: turbo后台信息国际化 #86
eazence Aug 18, 2023
b0567fa
feat: turbo后台信息国际化 #86
eazence Aug 21, 2023
0a9427d
feat: turbo后台信息国际化 #86
eazence Aug 22, 2023
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
@@ -0,0 +1,11 @@
package com.tencent.devops.turbo.enums

enum class EnumEngineType(private val engineCode: String) {
DISTTASK_CC("disttask-cc"),
DISTTASK_UE4("disttask-ue4"),
DISTTCC("distcc");

fun getEngineCode(): String {
return this.engineCode
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import javax.validation.constraints.NotEmpty
@ApiModel("编译加速模式请求数据模型")
data class TurboEngineConfigModel(
@ApiModelProperty("编译加速模式代码")
@get:NotBlank(message = "模板代码不能为空", groups = [TurboEngineConfigGroup.Create::class])
@get:NotBlank(message = "{bizError.engineCodeNotBlank}", groups = [TurboEngineConfigGroup.Create::class])
val engineCode: String?,
@ApiModelProperty("编译加速模式名字")
@get:NotBlank(message = "模板名字不能为空", groups = [TurboEngineConfigGroup.Create::class, TurboEngineConfigGroup.Update::class])
@get:NotBlank(message = "{bizError.engineNameNotBlank}", groups = [TurboEngineConfigGroup.Create::class, TurboEngineConfigGroup.Update::class])
val engineName: String?,
@ApiModelProperty("描述")
val desc: String?,
@ApiModelProperty("spel表达式")
@get:NotBlank(message = "计算表达式不能为空", groups = [TurboEngineConfigGroup.Create::class, TurboEngineConfigGroup.Update::class])
@get:NotBlank(message = "{bizError.expressionNotBlank}", groups = [TurboEngineConfigGroup.Create::class, TurboEngineConfigGroup.Update::class])
val spelExpression: String?,
@ApiModelProperty("spel参数映射")
val spelParamMap: Map<String, Any?>?,
Expand All @@ -28,7 +28,7 @@ data class TurboEngineConfigModel(
val userManual: String? = null,
@ApiModelProperty("文档链接指引")
val docUrl: String? = null,
@get:NotEmpty(message = "编译加速历史显示字段值不能为空", groups = [TurboEngineConfigGroup.Create::class, TurboEngineConfigGroup.Update::class])
@get:NotEmpty(message = "{bizError.displayFieldsNotEmpty}", groups = [TurboEngineConfigGroup.Create::class, TurboEngineConfigGroup.Update::class])
@ApiModelProperty("编译加速历史显示字段值")
val displayFields: List<TurboDisplayFieldModel>? = null,
@ApiModelProperty("是否推荐")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import javax.validation.constraints.NotBlank
data class TurboEngineConfigPriorityModel(
@ApiModelProperty("引擎代码")
@get:NotBlank(
message = "请先选择加速模式!"
message = "{bizError.engineCodeNotSelect}"
)
val engineCode: String,
@ApiModelProperty("优先级序号")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ import javax.validation.constraints.NotBlank
@ApiModel("运行编译加速插件时入参")
data class TurboPlanInstanceModel(
@ApiModelProperty("项目id")
@get:NotBlank(message = "项目id不能为空")
@get:NotBlank(message = "{bizError.projectIdNotBlank}")
val projectId: String?,
@ApiModelProperty("编译加速方案id")
@get:NotBlank(message = "编译加速方案id不能为空")
@get:NotBlank(message = "{bizError.turboPlanIdNotBlank}")
val turboPlanId: String?,
@ApiModelProperty("流水线id")
@get:NotBlank(message = "流水线id不能为空")
@get:NotBlank(message = "{bizError.pipelineIdNotBlank}")
val pipelineId: String?,
@ApiModelProperty("流水线元素id")
@get:NotBlank(message = "流水线元素id不能为空")
@get:NotBlank(message = "{bizError.pipelineElementIdNotBlank}")
val pipelineElementId: String?,
@ApiModelProperty("流水线名称")
val pipelineName: String? = null,
@ApiModelProperty("流水线构建id")
@get:NotBlank(message = "流水线构建id不能为空")
@get:NotBlank(message = "{bizError.buildIdNotBlank}")
val buildId: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull
data class TurboPlanModel(
@ApiModelProperty("蓝盾项目id")
@get:NotBlank(
message = "项目id不能为空",
message = "{bizError.projectIdNotBlank}",
groups = [
TurboPlanGroup.Create::class,
TurboPlanGroup.UpdateDetail::class
Expand All @@ -20,7 +20,7 @@ data class TurboPlanModel(
val projectId: String?,
@ApiModelProperty("加速方案名称")
@get:NotBlank(
message = "方案名称不能为空",
message = "{bizError.planNameNotBlank}",
groups = [
TurboPlanGroup.Create::class,
TurboPlanGroup.UpdateDetail::class,
Expand All @@ -30,7 +30,7 @@ data class TurboPlanModel(
val planName: String?,
@ApiModelProperty("蓝盾模板代码")
@get:NotBlank(
message = "请先选择加速模式!",
message = "{bizError.engineCodeNotSelect}",
groups = [
TurboPlanGroup.Create::class,
TurboPlanGroup.UpdateWhiteList::class,
Expand All @@ -42,14 +42,14 @@ data class TurboPlanModel(
val desc: String?,
@ApiModelProperty("配置参数值")
@get:NotNull(
message = "参数不能为空",
message = "{bizError.configParamNotNull}",
groups = [
TurboPlanGroup.UpdateParam::class,
TurboPlanGroup.UpdateAll::class
]
)
@get:NotEmpty(
message = "参数不能为空",
message = "{bizError.configParamNotEmpty}",
groups = [
TurboPlanGroup.UpdateParam::class,
TurboPlanGroup.UpdateAll::class
Expand All @@ -58,15 +58,15 @@ data class TurboPlanModel(
val configParam: Map<String, Any>?,
@ApiModelProperty("白名单")
@get:NotBlank(
message = "白名单不能为空",
message = "{bizError.whiteListNotBlank}",
groups = [
TurboPlanGroup.UpdateWhiteList::class
]
)
val whiteList: String?,
@ApiModelProperty("开启状态")
@get:NotNull(
message = "状态不能为空",
message = "{bizError.openStatusNotNull}",
groups = [
TurboPlanGroup.UpdateDetail::class,
TurboPlanGroup.UpdateAll::class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import javax.validation.constraints.NotBlank
data class TurboRecordModel(
@ApiModelProperty("项目id")
@get:NotBlank(
message = "项目id不能为空",
message = "{bizError.projectIdNotBlank}",
groups = [
TurboRecordGroup.OpenApi::class
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.tencent.devops.turbo.controller

import com.tencent.devops.api.pojo.Response
import com.tencent.devops.common.api.exception.TurboException
import com.tencent.devops.common.api.exception.code.IS_NOT_ADMIN_MEMBER
import com.tencent.devops.common.api.exception.UnauthorizedErrorException
import com.tencent.devops.common.api.pojo.Page
import com.tencent.devops.common.util.constants.NO_ADMIN_MEMBER_MESSAGE
import com.tencent.devops.turbo.api.IServiceTurboController
import com.tencent.devops.turbo.pojo.TurboRecordModel
import com.tencent.devops.turbo.service.TurboAuthService
Expand Down Expand Up @@ -34,7 +32,7 @@ class ServiceTurboController @Autowired constructor(
): Response<Page<TurboPlanStatRowVO>> {
// 判断是否是管理员
if (!turboAuthService.getAuthResult(projectId, userId)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw UnauthorizedErrorException()
}
return Response.success(
turboPlanService.getTurboPlanByProjectIdAndCreatedDate(projectId, startTime, endTime, pageNum, pageSize))
Expand All @@ -51,7 +49,7 @@ class ServiceTurboController @Autowired constructor(
): Response<Page<TurboRecordHistoryVO>> {
// 判断是否是管理员
if (!turboAuthService.getAuthResult(projectId, userId)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw UnauthorizedErrorException()
}
return Response.success(
turboRecordService.getTurboRecordHistoryList(pageNum, pageSize, sortField, sortType, turboRecordModel))
Expand All @@ -64,7 +62,7 @@ class ServiceTurboController @Autowired constructor(
): Response<TurboPlanDetailVO> {
// 判断是否是管理员
if (!turboAuthService.getAuthResult(projectId, userId)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw UnauthorizedErrorException()
}
return Response.success(turboPlanService.getTurboPlanDetailByPlanId(planId))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.tencent.devops.turbo.controller

import com.tencent.devops.common.api.exception.TurboException
import com.tencent.devops.common.api.exception.code.IS_NOT_ADMIN_MEMBER
import com.tencent.devops.common.util.constants.NO_ADMIN_MEMBER_MESSAGE
import com.tencent.devops.common.api.exception.UnauthorizedErrorException
import com.tencent.devops.turbo.api.IUserCustomScheduleTaskController
import com.tencent.devops.turbo.pojo.CustomScheduleJobModel
import com.tencent.devops.turbo.service.CustomScheduleJobService
Expand All @@ -23,14 +21,14 @@ class UserCustomScheduleTaskController @Autowired constructor(
customScheduleJobModel: CustomScheduleJobModel
): Boolean {
if (!turboAuthService.validatePlatformMember(projectId, user)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw UnauthorizedErrorException()
}
return customScheduleJobService.customScheduledJobAdd(customScheduleJobModel)
}

override fun triggerCustomScheduleJob(user: String, projectId: String, jobName: String): String? {
if (!turboAuthService.getAuthResult(projectId, user)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw UnauthorizedErrorException()
}
return customScheduleJobService.trigger(jobName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.tencent.devops.turbo.controller
import com.tencent.devops.api.pojo.Response
import com.tencent.devops.common.api.exception.TurboException
import com.tencent.devops.common.api.exception.code.IS_NOT_ADMIN_MEMBER
import com.tencent.devops.common.util.constants.NO_ADMIN_MEMBER_MESSAGE
import com.tencent.devops.turbo.api.IUserTurboDaySummaryController
import com.tencent.devops.turbo.service.TurboAuthService
import com.tencent.devops.turbo.service.TurboSummaryService
Expand All @@ -23,7 +22,7 @@ class UserTurboDaySummaryController @Autowired constructor(
override fun getOverviewStatRowData(projectId: String, user: String): Response<TurboOverviewStatRowVO> {
// 判断是否是管理员
if (!turboAuthService.getAuthResult(projectId, user)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = "")
}
return Response.success(turboSummaryService.getOverviewStatRowData(projectId))
}
Expand All @@ -38,7 +37,7 @@ class UserTurboDaySummaryController @Autowired constructor(
): Response<List<TurboOverviewTrendVO>> {
// 判断是否是管理员
if (!turboAuthService.getAuthResult(projectId, user)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = "")
}
return Response.success(turboSummaryService.getTimeConsumingTrendData(dateType, projectId))
}
Expand All @@ -53,7 +52,7 @@ class UserTurboDaySummaryController @Autowired constructor(
): Response<List<TurboOverviewTrendVO>> {
// 判断是否是管理员
if (!turboAuthService.getAuthResult(projectId, user)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = "")
}
return Response.success(turboSummaryService.getCompileNumberTrendData(dateType, projectId))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.tencent.devops.turbo.controller

import com.tencent.devops.api.pojo.Response
import com.tencent.devops.common.api.exception.TurboException
import com.tencent.devops.common.api.exception.code.IS_NOT_ADMIN_MEMBER
import com.tencent.devops.common.api.exception.UnauthorizedErrorException
import com.tencent.devops.common.api.pojo.Page
import com.tencent.devops.common.util.constants.NO_ADMIN_MEMBER_MESSAGE
import com.tencent.devops.turbo.api.IUserTurboPlanController
import com.tencent.devops.turbo.pojo.TurboPlanModel
import com.tencent.devops.turbo.service.TurboAuthService
Expand All @@ -25,39 +23,39 @@ class UserTurboPlanController @Autowired constructor(
override fun addNewTurboPlan(turboPlanModel: TurboPlanModel, projectId: String, user: String): Response<String?> {
// 判断是否是管理员
if (!turboAuthService.getAuthResult(projectId, user)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw UnauthorizedErrorException()
}
return Response.success(turboPlanService.addNewTurboPlan(turboPlanModel, user))
}

override fun getTurboPlanStatRowData(projectId: String, pageNum: Int?, pageSize: Int?, user: String): Response<TurboPlanPageVO> {
// 判断是否是管理员
if (!turboAuthService.getAuthResult(projectId, user)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw UnauthorizedErrorException()
}
return Response.success(turboPlanService.getTurboPlanStatRowData(projectId, pageNum, pageSize))
}

override fun getTurboPlanDetailByPlanId(planId: String, projectId: String, user: String): Response<TurboPlanDetailVO> {
// 判断是否是管理员
if (!turboAuthService.getAuthResult(projectId, user)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw UnauthorizedErrorException()
}
return Response.success(turboPlanService.getTurboPlanDetailByPlanId(planId))
}

override fun putTurboPlanDetailNameAndOpenStatus(turboPlanModel: TurboPlanModel, planId: String, user: String, projectId: String): Response<Boolean> {
// 判断是否是管理员
if (!turboAuthService.getAuthResult(projectId, user)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw UnauthorizedErrorException()
}
return Response.success(turboPlanService.putTurboPlanDetailNameAndOpenStatus(turboPlanModel, planId, user))
}

override fun putTurboPlanConfigParam(turboPlanModel: TurboPlanModel, planId: String, user: String, projectId: String): Response<Boolean> {
// 判断是否是管理员
if (!turboAuthService.getAuthResult(projectId, user)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw UnauthorizedErrorException()
}
return Response.success(turboPlanService.putTurboPlanConfigParam(turboPlanModel, planId, user))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package com.tencent.devops.turbo.controller

import com.tencent.devops.api.pojo.Response
import com.tencent.devops.common.api.exception.TurboException
import com.tencent.devops.common.api.exception.code.IS_NOT_ADMIN_MEMBER
import com.tencent.devops.common.api.exception.UnauthorizedErrorException
import com.tencent.devops.common.api.exception.code.TURBO_PARAM_INVALID
import com.tencent.devops.common.api.pojo.Page
import com.tencent.devops.common.util.constants.NO_ADMIN_MEMBER_MESSAGE
import com.tencent.devops.common.web.utils.I18NUtil
import com.tencent.devops.turbo.api.IUserTurboRecordController
import com.tencent.devops.turbo.enums.EnumDistccTaskStatus
import com.tencent.devops.turbo.pojo.TurboRecordModel
Expand Down Expand Up @@ -44,7 +44,7 @@ class UserTurboRecordController @Autowired constructor(
): Response<Page<TurboRecordHistoryVO>> {
// 判断是否是管理员
if (!turboAuthService.getAuthResult(projectId, user)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw UnauthorizedErrorException()
}
return Response.success(turboRecordService.getTurboRecordHistoryList(pageNum, pageSize, sortField, sortType, turboRecordModel))
}
Expand All @@ -56,7 +56,8 @@ class UserTurboRecordController @Autowired constructor(
planInfo = turboPlanService.getByProjectId(projectId).associate { it.id!! to it.planName },
pipelineInfo = turboPlanInstanceList.filter { !it.pipelineId.isNullOrBlank() }.associate { it.pipelineId!! to it.pipelineName },
clientIpInfo = turboPlanInstanceList.filter { !it.clientIp.isNullOrBlank() }.distinctBy { it.clientIp }.map { it.clientIp!! },
statusInfo = EnumDistccTaskStatus.values().associate { it.getTBSStatus() to it.getStatusName() }
statusInfo = EnumDistccTaskStatus.values().associate { it.getTBSStatus() to (I18NUtil
.getMessage("taskStatus.${it.getTBSStatus()}") ?: it.getStatusName()) }
)
)
}
Expand All @@ -70,7 +71,7 @@ class UserTurboRecordController @Autowired constructor(
override fun getTurboDisplayInfoById(turboRecordId: String, projectId: String, user: String): Response<TurboRecordDisplayVO> {
// 判断是否是管理员
if (!turboAuthService.getAuthResult(projectId, user)) {
throw TurboException(errorCode = IS_NOT_ADMIN_MEMBER, errorMessage = NO_ADMIN_MEMBER_MESSAGE)
throw UnauthorizedErrorException()
}

val turboRecordEntity = turboRecordService.findByRecordId(turboRecordId)
Expand Down
Loading