Skip to content

Commit

Permalink
Merge pull request #2604 from actiontech/feat-i18n-dev2-ce
Browse files Browse the repository at this point in the history
Feat i18n dev2 ce
  • Loading branch information
ColdWaterLW authored Sep 13, 2024
2 parents 7386b1d + cdd770a commit 2ed1893
Show file tree
Hide file tree
Showing 72 changed files with 760 additions and 767 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/DATA-DOG/go-sqlmock v1.5.0
github.com/Masterminds/semver/v3 v3.1.1
github.com/actiontech/dms v0.0.0-20240830025931-20d313b918e8
github.com/actiontech/dms v0.0.0-20240912110939-20f9825907f5
github.com/actiontech/java-sql-extractor v0.0.0-20231103015812-cdd5fc040f62
github.com/actiontech/mybatis-mapper-2-sql v0.5.1-0.20240806065717-29cde7000ef5
github.com/agiledragon/gomonkey v2.0.2+incompatible
Expand Down Expand Up @@ -65,7 +65,6 @@ require (
)

require (
github.com/BurntSushi/toml v1.3.2
github.com/aliyun/credentials-go v1.1.2
github.com/hashicorp/go-version v1.7.0
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.69
Expand All @@ -77,6 +76,7 @@ require (

require (
dario.cat/mergo v1.0.0 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdc
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ=
github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
github.com/actiontech/dms v0.0.0-20240830025931-20d313b918e8 h1:l5arXsG/J+z6k72JMy3J2eOXG/S9oJ/saoEpnT5K5Vg=
github.com/actiontech/dms v0.0.0-20240830025931-20d313b918e8/go.mod h1:6puFXgN9RWM/28xTntH++kiNgmCOQbjiYt5K58qmSo0=
github.com/actiontech/dms v0.0.0-20240912110939-20f9825907f5 h1:OyCu5gBcM8G9Pp5kTGXACOO6Tr6Nfp1vFhE6ULQUZKc=
github.com/actiontech/dms v0.0.0-20240912110939-20f9825907f5/go.mod h1:Jm+tDoBYmX8R8zqgPJRq1NwZXdxO/F+HxVRJVF65WXA=
github.com/actiontech/java-sql-extractor v0.0.0-20231103015812-cdd5fc040f62 h1:JM7WnLzlvXOGE90KKd+aigi+qUDS+U5dLwQMNpTKZxE=
github.com/actiontech/java-sql-extractor v0.0.0-20231103015812-cdd5fc040f62/go.mod h1:adDZHhAf2LRMx2h0JzofPXn12x2XlyQjVE116KXquwo=
github.com/actiontech/mybatis-mapper-2-sql v0.5.1-0.20240806065717-29cde7000ef5 h1:vyQVrkYPzUV9d7gSvOWoezwWMTiC4jc3f3Hpianefq0=
Expand Down
4 changes: 2 additions & 2 deletions sqle/api/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ func StartApi(net *gracenet.Net, exitChan chan struct{}, config *config.SqleOpti
})

v1Router := e.Group(apiV1)
v1Router.Use(sqleMiddleware.JWTTokenAdapter(), sqleMiddleware.JWTWithConfig(dmsV1.JwtSigningKey), sqleMiddleware.VerifyUserIsDisabled(), locale.EchoMiddlewareI18nByAcceptLanguage(), sqleMiddleware.OperationLogRecord(), accesstoken.CheckLatestAccessToken(controller.GetDMSServerAddress(), jwtPkg.GetTokenDetailFromContextWithOldJwt))
v1Router.Use(sqleMiddleware.JWTTokenAdapter(), sqleMiddleware.JWTWithConfig(dmsV1.JwtSigningKey), sqleMiddleware.VerifyUserIsDisabled(), locale.Bundle.EchoMiddlewareByAcceptLanguage(), sqleMiddleware.OperationLogRecord(), accesstoken.CheckLatestAccessToken(controller.GetDMSServerAddress(), jwtPkg.GetTokenDetailFromContextWithOldJwt))
v2Router := e.Group(apiV2)
v2Router.Use(sqleMiddleware.JWTTokenAdapter(), sqleMiddleware.JWTWithConfig(dmsV1.JwtSigningKey), sqleMiddleware.VerifyUserIsDisabled(), locale.EchoMiddlewareI18nByAcceptLanguage(), sqleMiddleware.OperationLogRecord(), accesstoken.CheckLatestAccessToken(controller.GetDMSServerAddress(), jwtPkg.GetTokenDetailFromContextWithOldJwt))
v2Router.Use(sqleMiddleware.JWTTokenAdapter(), sqleMiddleware.JWTWithConfig(dmsV1.JwtSigningKey), sqleMiddleware.VerifyUserIsDisabled(), locale.Bundle.EchoMiddlewareByAcceptLanguage(), sqleMiddleware.OperationLogRecord(), accesstoken.CheckLatestAccessToken(controller.GetDMSServerAddress(), jwtPkg.GetTokenDetailFromContextWithOldJwt))

// v1 admin api, just admin user can access.
{
Expand Down
43 changes: 22 additions & 21 deletions sqle/api/controller/v1/audit_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

v1 "github.com/actiontech/dms/pkg/dms-common/api/dms/v1"
dmsCommonJwt "github.com/actiontech/dms/pkg/dms-common/api/jwt"
"github.com/actiontech/dms/pkg/dms-common/i18nPkg"
"github.com/actiontech/sqle/sqle/api/controller"
"github.com/actiontech/sqle/sqle/common"
dms "github.com/actiontech/sqle/sqle/dms"
Expand Down Expand Up @@ -101,7 +102,7 @@ type Operator struct {
func ConvertAuditPlanMetaWithInstanceIdToRes(ctx context.Context, meta auditplan.Meta, instanceId string) AuditPlanMetaV1 {
res := AuditPlanMetaV1{
Type: meta.Type,
Desc: locale.ShouldLocalizeMsg(ctx, meta.Desc),
Desc: locale.Bundle.LocalizeMsgByCtx(ctx, meta.Desc),
InstanceType: meta.InstanceType,
}
if meta.Params != nil && len(meta.Params()) > 0 {
Expand All @@ -113,7 +114,7 @@ func ConvertAuditPlanMetaWithInstanceIdToRes(ctx context.Context, meta auditplan
}
paramsRes = append(paramsRes, AuditPlanParamResV1{
Key: p.Key,
Desc: p.GetDesc(locale.GetLangTagFromCtx(ctx)),
Desc: p.GetDesc(locale.Bundle.GetLangTagFromCtx(ctx)),
Type: string(p.Type),
Value: val,
EnumsValues: ConvertEnumsValuesToRes(ctx, p.Enums),
Expand All @@ -127,7 +128,7 @@ func ConvertAuditPlanMetaWithInstanceIdToRes(ctx context.Context, meta auditplan
for _, hpc := range meta.HighPriorityParams {
highPriorityparamsRes = append(highPriorityparamsRes, HighPriorityConditionResV1{
Key: hpc.Key,
Desc: hpc.GetDesc(locale.GetLangTagFromCtx(ctx)),
Desc: hpc.GetDesc(locale.Bundle.GetLangTagFromCtx(ctx)),
Type: string(hpc.Type),
Value: hpc.Value,
EnumsValues: ConvertEnumsValuesToRes(ctx, hpc.Enums),
Expand All @@ -145,7 +146,7 @@ func ConvertAuditPlanMetaWithInstanceIdToRes(ctx context.Context, meta auditplan
func ConvertAuditPlanMetaToRes(ctx context.Context, meta auditplan.Meta) AuditPlanMetaV1 {
res := AuditPlanMetaV1{
Type: meta.Type,
Desc: locale.ShouldLocalizeMsg(ctx, meta.Desc),
Desc: locale.Bundle.LocalizeMsgByCtx(ctx, meta.Desc),
InstanceType: meta.InstanceType,
}
if meta.Params != nil && len(meta.Params()) > 0 {
Expand All @@ -157,7 +158,7 @@ func ConvertAuditPlanMetaToRes(ctx context.Context, meta auditplan.Meta) AuditPl
}
paramRes := AuditPlanParamResV1{
Key: p.Key,
Desc: p.GetDesc(locale.GetLangTagFromCtx(ctx)),
Desc: p.GetDesc(locale.Bundle.GetLangTagFromCtx(ctx)),
Type: string(p.Type),
Value: val,
EnumsValues: ConvertEnumsValuesToRes(ctx, p.Enums),
Expand All @@ -182,11 +183,11 @@ func ConvertEnumsValuesToRes(ctx context.Context, ems []params.EnumsValue) []Enu

func ConvertEnumsValueToRes(ctx context.Context, ems params.EnumsValue) EnumsValueResV1 {
if ems.Desc != "" {
ems.I18nDesc.SetStrInLang(locale.DefaultLang, ems.Desc)
ems.I18nDesc.SetStrInLang(i18nPkg.DefaultLang, ems.Desc)
}
return EnumsValueResV1{
Value: ems.Value,
Desc: ems.I18nDesc.GetStrInLang(locale.GetLangTagFromCtx(ctx)),
Desc: ems.I18nDesc.GetStrInLang(locale.Bundle.GetLangTagFromCtx(ctx)),
}
}

Expand Down Expand Up @@ -243,7 +244,7 @@ func GetAuditPlanTypes(c echo.Context) error {
for _, meta := range auditplan.Metas {
auditPlanTypesV1 = append(auditPlanTypesV1, AuditPlanTypesV1{
Type: meta.Type,
Desc: locale.ShouldLocalizeMsg(c.Request().Context(), meta.Desc),
Desc: locale.Bundle.LocalizeMsgByCtx(c.Request().Context(), meta.Desc),
InstanceType: meta.InstanceType,
})
}
Expand Down Expand Up @@ -1424,7 +1425,7 @@ func GetAuditPlanSQLs(c echo.Context) error {
for _, v := range head {
res.Head = append(res.Head, AuditPlanSQLHeadV1{
Name: v.Name,
Desc: locale.ShouldLocalizeMsg(c.Request().Context(), v.Desc),
Desc: locale.Bundle.LocalizeMsgByCtx(c.Request().Context(), v.Desc),
Type: v.Type,
})
}
Expand Down Expand Up @@ -1516,7 +1517,7 @@ func GetAuditPlanReportSQLsV1(c echo.Context) error {
}

func spliceAuditResults(ctx context.Context, auditResults []model.AuditResult) string {
lang := locale.GetLangTagFromCtx(ctx)
lang := locale.Bundle.GetLangTagFromCtx(ctx)
results := []string{}
for _, auditResult := range auditResults {
results = append(results,
Expand Down Expand Up @@ -1563,15 +1564,15 @@ func ExportAuditPlanReportV1(c echo.Context) error {

ctx := c.Request().Context()
baseInfo := [][]string{
{locale.ShouldLocalizeMsg(ctx, locale.APExportTaskName), auditPlanName},
{locale.ShouldLocalizeMsg(ctx, locale.APExportGenerationTime), reportInfo.CreatedAt.Format("2006/01/02 15:04")},
{locale.ShouldLocalizeMsg(ctx, locale.APExportResultRating), strconv.FormatInt(int64(reportInfo.Score), 10)},
{locale.ShouldLocalizeMsg(ctx, locale.APExportApprovalRate), fmt.Sprintf("%v%%", reportInfo.PassRate*100)},
{locale.ShouldLocalizeMsg(ctx, locale.APExportBelongingProject), projectName},
{locale.ShouldLocalizeMsg(ctx, locale.APExportCreator), dms.GetUserNameWithDelTag(reportInfo.AuditPlan.CreateUserID)},
{locale.ShouldLocalizeMsg(ctx, locale.APExportType), reportInfo.AuditPlan.Type},
{locale.ShouldLocalizeMsg(ctx, locale.APExportDbType), reportInfo.AuditPlan.DBType},
{locale.ShouldLocalizeMsg(ctx, locale.APExportDatabase), reportInfo.AuditPlan.InstanceDatabase},
{locale.Bundle.LocalizeMsgByCtx(ctx, locale.APExportTaskName), auditPlanName},
{locale.Bundle.LocalizeMsgByCtx(ctx, locale.APExportGenerationTime), reportInfo.CreatedAt.Format("2006/01/02 15:04")},
{locale.Bundle.LocalizeMsgByCtx(ctx, locale.APExportResultRating), strconv.FormatInt(int64(reportInfo.Score), 10)},
{locale.Bundle.LocalizeMsgByCtx(ctx, locale.APExportApprovalRate), fmt.Sprintf("%v%%", reportInfo.PassRate*100)},
{locale.Bundle.LocalizeMsgByCtx(ctx, locale.APExportBelongingProject), projectName},
{locale.Bundle.LocalizeMsgByCtx(ctx, locale.APExportCreator), dms.GetUserNameWithDelTag(reportInfo.AuditPlan.CreateUserID)},
{locale.Bundle.LocalizeMsgByCtx(ctx, locale.APExportType), reportInfo.AuditPlan.Type},
{locale.Bundle.LocalizeMsgByCtx(ctx, locale.APExportDbType), reportInfo.AuditPlan.DBType},
{locale.Bundle.LocalizeMsgByCtx(ctx, locale.APExportDatabase), reportInfo.AuditPlan.InstanceDatabase},
}
err = csvWriter.WriteAll(baseInfo)
if err != nil {
Expand All @@ -1585,9 +1586,9 @@ func ExportAuditPlanReportV1(c echo.Context) error {
}

err = csvWriter.Write([]string{
locale.ShouldLocalizeMsg(ctx, locale.APExportNumber), // 编号
locale.Bundle.LocalizeMsgByCtx(ctx, locale.APExportNumber), // 编号
"SQL",
locale.ShouldLocalizeMsg(ctx, locale.APExportAuditResult), // 审核结果
locale.Bundle.LocalizeMsgByCtx(ctx, locale.APExportAuditResult), // 审核结果
})
if err != nil {
return controller.JSONBaseErrorReq(c, err)
Expand Down
18 changes: 9 additions & 9 deletions sqle/api/controller/v1/instance_audit_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ func ConvertAuditPlanTypeToResByID(ctx context.Context, id string) (AuditPlanTyp
if meta.Type == auditPlan.Type {
return AuditPlanTypeResBase{
AuditPlanType: auditPlan.Type,
AuditPlanTypeDesc: locale.ShouldLocalizeMsg(ctx, meta.Desc),
AuditPlanTypeDesc: locale.Bundle.LocalizeMsgByCtx(ctx, meta.Desc),
AuditPlanId: auditPlan.ID,
}, nil
}
Expand All @@ -577,7 +577,7 @@ func ConvertAuditPlanTypeToRes(ctx context.Context, id uint, auditPlanType strin
if meta.Type == auditPlanType {
return AuditPlanTypeResBase{
AuditPlanType: auditPlanType,
AuditPlanTypeDesc: locale.ShouldLocalizeMsg(ctx, meta.Desc),
AuditPlanTypeDesc: locale.Bundle.LocalizeMsgByCtx(ctx, meta.Desc),
AuditPlanId: id,
}
}
Expand Down Expand Up @@ -670,7 +670,7 @@ func ConvertAuditPlansToRes(ctx context.Context, auditPlans []*model.AuditPlanV2
}
paramRes := AuditPlanParamResV1{
Key: p.Key,
Desc: p.GetDesc(locale.GetLangTagFromCtx(ctx)),
Desc: p.GetDesc(locale.Bundle.GetLangTagFromCtx(ctx)),
Type: string(p.Type),
Value: val,
}
Expand All @@ -688,7 +688,7 @@ func ConvertAuditPlansToRes(ctx context.Context, auditPlans []*model.AuditPlanV2
}
highParamRes := HighPriorityCondition{
Key: metaHpp.Key,
Desc: metaHpp.GetDesc(locale.GetLangTagFromCtx(ctx)),
Desc: metaHpp.GetDesc(locale.Bundle.GetLangTagFromCtx(ctx)),
Value: hpp.Value,
Type: string(metaHpp.Type),
Operator: Operator{
Expand Down Expand Up @@ -1002,7 +1002,7 @@ func GetInstanceAuditPlanSQLs(c echo.Context) error {
for _, v := range head {
res.Head = append(res.Head, AuditPlanSQLHeadV1{
Name: v.Name,
Desc: locale.ShouldLocalizeMsg(c.Request().Context(), v.Desc),
Desc: locale.Bundle.LocalizeMsgByCtx(c.Request().Context(), v.Desc),
Type: v.Type,
})
}
Expand Down Expand Up @@ -1096,15 +1096,15 @@ func GetInstanceAuditPlanSQLMeta(c echo.Context) error {
for _, v := range head {
data.Head = append(data.Head, AuditPlanSQLHeadV1{
Name: v.Name,
Desc: locale.ShouldLocalizeMsg(ctx, v.Desc),
Desc: locale.Bundle.LocalizeMsgByCtx(ctx, v.Desc),
Type: v.Type,
Sortable: v.Sortable,
})
}
for _, v := range filter {
data.FilterMetaList = append(data.FilterMetaList, FilterMeta{
Name: v.Name,
Desc: locale.ShouldLocalizeMsg(ctx, v.Desc),
Desc: locale.Bundle.LocalizeMsgByCtx(ctx, v.Desc),
FilterInputType: string(v.FilterInputType),
FilterOpType: string(v.FilterOpType),
FilterTips: ConvertFilterTipsToRes(v.FilterTips),
Expand Down Expand Up @@ -1262,7 +1262,7 @@ func GetInstanceAuditPlanSQLExport(c echo.Context) error {
csvWriter := csv.NewWriter(buff)
toWrite := make([]string, len(head))
for col, h := range head {
toWrite[col] = locale.ShouldLocalizeMsg(c.Request().Context(), h.Desc)
toWrite[col] = locale.Bundle.LocalizeMsgByCtx(c.Request().Context(), h.Desc)
}
if err = csvWriter.Write(toWrite); err != nil {
return controller.JSONBaseErrorReq(c, err)
Expand Down Expand Up @@ -1358,7 +1358,7 @@ func GetAuditPlanSqlAnalysisData(c echo.Context) error {

return c.JSON(http.StatusOK, &GetSqlManageSqlAnalysisResp{
BaseRes: controller.NewBaseReq(nil),
Data: convertSQLAnalysisResultToRes(res, originSQL.SqlText),
Data: convertSQLAnalysisResultToRes(c.Request().Context(), res, originSQL.SqlText),
})
}

Expand Down
10 changes: 5 additions & 5 deletions sqle/api/controller/v1/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ func convertDefaultRuleTemplatesToRes(ctx context.Context, ruleTemplates []*mode
for _, ruleTemplate := range ruleTemplates {
ruleTemplateReq := RuleTemplateResV1{
Name: ruleTemplate.Name,
Desc: locale.ShouldLocalizeMsg(ctx, locale.DefaultRuleTemplatesDesc),
Desc: locale.Bundle.LocalizeMsgByCtx(ctx, locale.DefaultRuleTemplatesDesc),
DBType: ruleTemplate.DBType,
}
ruleTemplatesReq = append(ruleTemplatesReq, ruleTemplateReq)
Expand Down Expand Up @@ -485,7 +485,7 @@ type RuleParamResV1 struct {
}

func convertRuleToRes(ctx context.Context, rule *model.Rule) RuleResV1 {
lang := locale.GetLangTagFromCtx(ctx)
lang := locale.Bundle.GetLangTagFromCtx(ctx)
if rule.I18nRuleInfo == nil {
rule.I18nRuleInfo = make(driverV2.I18nRuleInfo) // avoid panic
}
Expand All @@ -506,7 +506,7 @@ func convertRuleToRes(ctx context.Context, rule *model.Rule) RuleResV1 {
for _, p := range params {
paramRes := RuleParamResV1{
Key: p.Key,
Desc: p.GetDesc(locale.GetLangTagFromCtx(ctx)),
Desc: p.GetDesc(locale.Bundle.GetLangTagFromCtx(ctx)),
Type: string(p.Type),
Value: rule.Params.GetParam(p.Key).Value,
}
Expand Down Expand Up @@ -1327,7 +1327,7 @@ func exportRuleTemplateFile(c echo.Context, projectID string, ruleTemplateName s
return controller.JSONBaseErrorReq(c, ErrRuleTemplateNotExist)
}

lang := locale.GetLangTagFromCtx(c.Request().Context())
lang := locale.Bundle.GetLangTagFromCtx(c.Request().Context())

// 补充缺失的信息(规则说明等描述信息)
ruleNames := []string{}
Expand Down Expand Up @@ -1367,7 +1367,7 @@ func exportRuleTemplateFile(c echo.Context, projectID string, ruleTemplateName s
r.Params = append(r.Params, RuleParamResV1{
Key: param.Key,
Value: param.Value,
Desc: param.GetDesc(locale.GetLangTagFromCtx(c.Request().Context())),
Desc: param.GetDesc(locale.Bundle.GetLangTagFromCtx(c.Request().Context())),
Type: string(param.Type),
})
}
Expand Down
4 changes: 2 additions & 2 deletions sqle/api/controller/v1/sql_audit_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -883,8 +883,8 @@ func GetSQLAuditRecordTagTipsV1(c echo.Context) error {
return c.JSON(http.StatusOK, &GetSQLAuditRecordTagTipsResV1{
BaseRes: controller.BaseRes{},
Tags: []string{
locale.ShouldLocalizeMsg(c.Request().Context(), locale.AuditRecordTagFull), // 全量
locale.ShouldLocalizeMsg(c.Request().Context(), locale.AuditRecordTagIncrement), // 增量
locale.Bundle.LocalizeMsgByCtx(c.Request().Context(), locale.AuditRecordTagFull), // 全量
locale.Bundle.LocalizeMsgByCtx(c.Request().Context(), locale.AuditRecordTagIncrement), // 增量
},
})
}
11 changes: 7 additions & 4 deletions sqle/api/controller/v1/sql_manage.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package v1

import (
"context"

"github.com/actiontech/sqle/sqle/api/controller"
"github.com/actiontech/sqle/sqle/locale"
"github.com/labstack/echo/v4"
)

Expand Down Expand Up @@ -233,7 +236,7 @@ func GetSqlManageSqlAnalysisV1(c echo.Context) error {
return getSqlManageSqlAnalysisV1(c)
}

func convertSQLAnalysisResultToRes(res *AnalysisResult, rawSQL string) *SqlAnalysis {
func convertSQLAnalysisResultToRes(ctx context.Context, res *AnalysisResult, rawSQL string) *SqlAnalysis {
data := &SqlAnalysis{}

// explain
Expand All @@ -251,7 +254,7 @@ func convertSQLAnalysisResultToRes(res *AnalysisResult, rawSQL string) *SqlAnaly
for i := range res.ExplainResult.ClassicResult.Columns {
col := res.ExplainResult.ClassicResult.Columns[i]
classicResult.Head[i].FieldName = col.Name
classicResult.Head[i].Desc = col.Desc
classicResult.Head[i].Desc = col.I18nDesc.GetStrInLang(locale.Bundle.GetLangTagFromCtx(ctx))
}

// rows
Expand Down Expand Up @@ -293,7 +296,7 @@ func convertSQLAnalysisResultToRes(res *AnalysisResult, rawSQL string) *SqlAnaly
for j := range tableMetaColumnsInfo.Columns {
col := tableMetaColumnsInfo.Columns[j]
tableMetaColumnData.Head[j].FieldName = col.Name
tableMetaColumnData.Head[j].Desc = col.Desc
tableMetaColumnData.Head[j].Desc = col.I18nDesc.GetStrInLang(locale.Bundle.GetLangTagFromCtx(ctx))
}

for j := range tableMetaColumnsInfo.Rows {
Expand All @@ -307,7 +310,7 @@ func convertSQLAnalysisResultToRes(res *AnalysisResult, rawSQL string) *SqlAnaly
tableMetaIndexData := tableMetaItemsData[i].Indexes
for j := range tableMetaIndexInfo.Columns {
tableMetaIndexData.Head[j].FieldName = tableMetaIndexInfo.Columns[j].Name
tableMetaIndexData.Head[j].Desc = tableMetaIndexInfo.Columns[j].Desc
tableMetaIndexData.Head[j].Desc = tableMetaIndexInfo.Columns[j].I18nDesc.GetStrInLang(locale.Bundle.GetLangTagFromCtx(ctx))
}

for j := range tableMetaIndexInfo.Rows {
Expand Down
4 changes: 2 additions & 2 deletions sqle/api/controller/v1/statistic.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func GetLicenseUsageV1(c echo.Context) error {
Data: &LicenseUsageV1{
UsersUsage: LicenseUsageItem{
ResourceType: "user",
ResourceTypeDesc: locale.ShouldLocalizeMsg(c.Request().Context(), locale.StatisticResourceTypeUser),
ResourceTypeDesc: locale.Bundle.LocalizeMsgByCtx(c.Request().Context(), locale.StatisticResourceTypeUser),
Used: 0,
Limit: 0,
IsLimited: false,
Expand Down Expand Up @@ -680,7 +680,7 @@ func StatisticAuditPlanV1(c echo.Context) error {
newAuditPlanCount := &AuditPlanCount{
Count: dBTypeAuditPlanCounts[i].AuditPlanCount,
Type: dBTypeAuditPlanCounts[i].Type,
Desc: locale.ShouldLocalizeMsg(c.Request().Context(), meta.Desc),
Desc: locale.Bundle.LocalizeMsgByCtx(c.Request().Context(), meta.Desc),
}
dbTypeAuditPlanCountSliceMap[dbType] = append(auditPlanCountSlice, newAuditPlanCount)
}
Expand Down
Loading

0 comments on commit 2ed1893

Please sign in to comment.