Skip to content

Commit

Permalink
Merge pull request #2577 from actiontech/feat-i18n-dev1-ce
Browse files Browse the repository at this point in the history
Feat i18n dev1 ce
  • Loading branch information
ColdWaterLW authored Sep 6, 2024
2 parents 93a06db + 289484a commit e7afe89
Show file tree
Hide file tree
Showing 158 changed files with 13,157 additions and 2,489 deletions.
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ RPM_BUILD_IMAGE ?= rpmbuild/centos7
## Static Parameter, should not be overwrite
GOBIN = ${shell pwd}/bin
PARSER_PATH = ${shell pwd}/vendor/github.com/pingcap/parser
LOCALE_PATH = ${shell pwd}/sqle/locale
PLUGIN_LOCALE_PATH = ${shell pwd}/sqle/driver/mysql/plocale

## Arm Build
ARM_CGO_BUILD_FLAG =
Expand All @@ -70,6 +72,23 @@ ifeq ($(EDITION)_$(GOARCH),ee_arm64)
endif

default: install

######################################## i18n ##########################################################
install_i18n_tool:
GOBIN=$(GOBIN) go install -v github.com/nicksnyder/go-i18n/v2/goi18n@latest

extract_i18n:
cd ${LOCALE_PATH} && $(GOBIN)/goi18n extract -sourceLanguage zh
cd ${PLUGIN_LOCALE_PATH} && $(GOBIN)/goi18n extract -sourceLanguage zh

start_trans_i18n:
cd ${LOCALE_PATH} && touch translate.en.toml && $(GOBIN)/goi18n merge -sourceLanguage=zh active.*.toml
cd ${PLUGIN_LOCALE_PATH} && touch translate.en.toml && $(GOBIN)/goi18n merge -sourceLanguage=zh active.*.toml

end_trans_i18n:
cd ${LOCALE_PATH} && $(GOBIN)/goi18n merge active.en.toml translate.en.toml && rm -rf translate.en.toml
cd ${PLUGIN_LOCALE_PATH} && $(GOBIN)/goi18n merge active.en.toml translate.en.toml && rm -rf translate.en.toml

######################################## Code Check ####################################################
## Static Code Analysis
vet: swagger
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ 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
golang.org/x/text v0.13.0
github.com/nicksnyder/go-i18n/v2 v2.4.0
golang.org/x/text v0.14.0
gorm.io/driver/mysql v1.4.7
gorm.io/gorm v1.24.3
)
Expand Down
9 changes: 6 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
Expand Down Expand Up @@ -630,6 +631,8 @@ github.com/ngaut/pools v0.0.0-20180318154953-b7bc8c42aac7/go.mod h1:iWMfgwqYW+e8
github.com/ngaut/sync2 v0.0.0-20141008032647-7a24ed77b2ef h1:K0Fn+DoFqNqktdZtdV3bPQ/0cuYh2H4rkg0tytX/07k=
github.com/ngaut/sync2 v0.0.0-20141008032647-7a24ed77b2ef/go.mod h1:7WjlapSfwQyo6LNmIvEWzsW1hbBQfpUO4JWnuQRmva8=
github.com/nicksnyder/go-i18n v1.10.0/go.mod h1:HrK7VCrbOvQoUAQ7Vpy7i87N7JZZZ7R2xBGjv0j365Q=
github.com/nicksnyder/go-i18n/v2 v2.4.0 h1:3IcvPOAvnCKwNm0TB0dLDTuawWEj+ax/RERNC+diLMM=
github.com/nicksnyder/go-i18n/v2 v2.4.0/go.mod h1:nxYSZE9M0bf3Y70gPQjN9ha7XNHX7gMc814+6wVyEI4=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
Expand Down Expand Up @@ -1141,8 +1144,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
5 changes: 3 additions & 2 deletions sqle/api/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/actiontech/dms/pkg/dms-common/api/accesstoken"
dmsV1 "github.com/actiontech/dms/pkg/dms-common/api/dms/v1"
jwtPkg "github.com/actiontech/dms/pkg/dms-common/api/jwt"
"github.com/actiontech/sqle/sqle/locale"

// "github.com/actiontech/sqle/sqle/api/cloudbeaver_wrapper"
"github.com/actiontech/sqle/sqle/api/controller"
Expand Down Expand Up @@ -107,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(), sqleMiddleware.OperationLogRecord(), accesstoken.CheckLatestAccessToken(controller.GetDMSServerAddress(), jwtPkg.GetTokenDetailFromContextWithOldJwt))
v1Router.Use(sqleMiddleware.JWTTokenAdapter(), sqleMiddleware.JWTWithConfig(dmsV1.JwtSigningKey), sqleMiddleware.VerifyUserIsDisabled(), locale.EchoMiddlewareI18nByAcceptLanguage(), sqleMiddleware.OperationLogRecord(), accesstoken.CheckLatestAccessToken(controller.GetDMSServerAddress(), jwtPkg.GetTokenDetailFromContextWithOldJwt))
v2Router := e.Group(apiV2)
v2Router.Use(sqleMiddleware.JWTTokenAdapter(), sqleMiddleware.JWTWithConfig(dmsV1.JwtSigningKey), sqleMiddleware.VerifyUserIsDisabled(), sqleMiddleware.OperationLogRecord(), accesstoken.CheckLatestAccessToken(controller.GetDMSServerAddress(), jwtPkg.GetTokenDetailFromContextWithOldJwt))
v2Router.Use(sqleMiddleware.JWTTokenAdapter(), sqleMiddleware.JWTWithConfig(dmsV1.JwtSigningKey), sqleMiddleware.VerifyUserIsDisabled(), locale.EchoMiddlewareI18nByAcceptLanguage(), sqleMiddleware.OperationLogRecord(), accesstoken.CheckLatestAccessToken(controller.GetDMSServerAddress(), jwtPkg.GetTokenDetailFromContextWithOldJwt))

// v1 admin api, just admin user can access.
{
Expand Down
139 changes: 94 additions & 45 deletions sqle/api/controller/v1/audit_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/actiontech/sqle/sqle/driver"
driverV2 "github.com/actiontech/sqle/sqle/driver/v2"
"github.com/actiontech/sqle/sqle/errors"
"github.com/actiontech/sqle/sqle/locale"
"github.com/actiontech/sqle/sqle/log"
"github.com/actiontech/sqle/sqle/model"
"github.com/actiontech/sqle/sqle/notification"
Expand Down Expand Up @@ -49,19 +50,38 @@ type GetAuditPlanMetasResV1 struct {
}

type AuditPlanMetaV1 struct {
Type string `json:"audit_plan_type"`
Desc string `json:"audit_plan_type_desc"`
InstanceType string `json:"instance_type"`
Params []AuditPlanParamResV1 `json:"audit_plan_params,omitempty"`
HighPriorityConditions []HighPriorityCondition `json:"high_priority_conditions"`
Type string `json:"audit_plan_type"`
Desc string `json:"audit_plan_type_desc"`
InstanceType string `json:"instance_type"`
Params []AuditPlanParamResV1 `json:"audit_plan_params,omitempty"`
HighPriorityConditions []HighPriorityConditionResV1 `json:"high_priority_conditions"`
}

type HighPriorityConditionResV1 struct {
Key string `json:"key"`
Desc string `json:"desc"`
Value string `json:"value"`
Type string `json:"type" enums:"string,int,bool,password"`
EnumsValues []EnumsValueResV1 `json:"enums_value"`
Operator OperatorResV1 `json:"operator"`
}

type OperatorResV1 struct {
Value string `json:"operator_value"`
EnumsValue []EnumsValueResV1 `json:"operator_enums_value"`
}

type EnumsValueResV1 struct {
Value string `json:"value"`
Desc string `json:"desc"`
}

type AuditPlanParamResV1 struct {
Key string `json:"key"`
Desc string `json:"desc"`
Value string `json:"value"`
Type string `json:"type" enums:"string,int,bool,password"`
EnumsValues []params.EnumsValue `json:"enums_value"`
Key string `json:"key"`
Desc string `json:"desc"`
Value string `json:"value"`
Type string `json:"type" enums:"string,int,bool,password"`
EnumsValues []EnumsValueResV1 `json:"enums_value"`
}

type HighPriorityCondition struct {
Expand All @@ -78,10 +98,10 @@ type Operator struct {
EnumsValue []params.EnumsValue `json:"operator_enums_value"`
}

func ConvertAuditPlanMetaWithInstanceIdToRes(meta auditplan.Meta, instanceId string) AuditPlanMetaV1 {
func ConvertAuditPlanMetaWithInstanceIdToRes(ctx context.Context, meta auditplan.Meta, instanceId string) AuditPlanMetaV1 {
res := AuditPlanMetaV1{
Type: meta.Type,
Desc: meta.Desc,
Desc: locale.ShouldLocalizeMsg(ctx, meta.Desc),
InstanceType: meta.InstanceType,
}
if meta.Params != nil && len(meta.Params()) > 0 {
Expand All @@ -93,27 +113,27 @@ func ConvertAuditPlanMetaWithInstanceIdToRes(meta auditplan.Meta, instanceId str
}
paramsRes = append(paramsRes, AuditPlanParamResV1{
Key: p.Key,
Desc: p.Desc,
Desc: p.GetDesc(locale.GetLangTagFromCtx(ctx)),
Type: string(p.Type),
Value: val,
EnumsValues: p.Enums,
EnumsValues: ConvertEnumsValuesToRes(ctx, p.Enums),
})
}
res.Params = paramsRes
}
// 高优先级参数
if len(meta.HighPriorityParams) > 0 {
highPriorityparamsRes := make([]HighPriorityCondition, 0, len(meta.HighPriorityParams))
highPriorityparamsRes := make([]HighPriorityConditionResV1, 0, len(meta.HighPriorityParams))
for _, hpc := range meta.HighPriorityParams {
highPriorityparamsRes = append(highPriorityparamsRes, HighPriorityCondition{
highPriorityparamsRes = append(highPriorityparamsRes, HighPriorityConditionResV1{
Key: hpc.Key,
Desc: hpc.Desc,
Desc: hpc.GetDesc(locale.GetLangTagFromCtx(ctx)),
Type: string(hpc.Type),
Value: hpc.Value,
EnumsValues: hpc.Enums,
Operator: Operator{
EnumsValues: ConvertEnumsValuesToRes(ctx, hpc.Enums),
Operator: OperatorResV1{
string(hpc.Operator.Value),
hpc.Operator.EnumsValue,
ConvertEnumsValuesToRes(ctx, hpc.Operator.EnumsValue),
},
})
}
Expand All @@ -122,10 +142,10 @@ func ConvertAuditPlanMetaWithInstanceIdToRes(meta auditplan.Meta, instanceId str
return res
}

func ConvertAuditPlanMetaToRes(meta auditplan.Meta) AuditPlanMetaV1 {
func ConvertAuditPlanMetaToRes(ctx context.Context, meta auditplan.Meta) AuditPlanMetaV1 {
res := AuditPlanMetaV1{
Type: meta.Type,
Desc: meta.Desc,
Desc: locale.ShouldLocalizeMsg(ctx, meta.Desc),
InstanceType: meta.InstanceType,
}
if meta.Params != nil && len(meta.Params()) > 0 {
Expand All @@ -137,10 +157,10 @@ func ConvertAuditPlanMetaToRes(meta auditplan.Meta) AuditPlanMetaV1 {
}
paramRes := AuditPlanParamResV1{
Key: p.Key,
Desc: p.Desc,
Desc: p.GetDesc(locale.GetLangTagFromCtx(ctx)),
Type: string(p.Type),
Value: val,
EnumsValues: p.Enums,
EnumsValues: ConvertEnumsValuesToRes(ctx, p.Enums),
}
paramsRes = append(paramsRes, paramRes)
}
Expand All @@ -149,6 +169,27 @@ func ConvertAuditPlanMetaToRes(meta auditplan.Meta) AuditPlanMetaV1 {
return res
}

func ConvertEnumsValuesToRes(ctx context.Context, ems []params.EnumsValue) []EnumsValueResV1 {
if ems == nil {
return nil
}
res := make([]EnumsValueResV1, 0, len(ems))
for _, em := range ems {
res = append(res, ConvertEnumsValueToRes(ctx, em))
}
return res
}

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

// @Summary 获取扫描任务元信息
// @Description get audit plan metas
// @Id getAuditPlanMetasV1
Expand All @@ -169,7 +210,7 @@ func GetAuditPlanMetas(c echo.Context) error {
if req.FilterInstanceType == nil ||
meta.InstanceType == auditplan.InstanceTypeAll ||
meta.InstanceType == *req.FilterInstanceType {
metas = append(metas, ConvertAuditPlanMetaWithInstanceIdToRes(meta, req.FilterInstanceID))
metas = append(metas, ConvertAuditPlanMetaWithInstanceIdToRes(c.Request().Context(), meta, req.FilterInstanceID))
}
}
return c.JSON(http.StatusOK, &GetAuditPlanMetasResV1{
Expand Down Expand Up @@ -202,7 +243,7 @@ func GetAuditPlanTypes(c echo.Context) error {
for _, meta := range auditplan.Metas {
auditPlanTypesV1 = append(auditPlanTypesV1, AuditPlanTypesV1{
Type: meta.Type,
Desc: meta.Desc,
Desc: locale.ShouldLocalizeMsg(c.Request().Context(), meta.Desc),
InstanceType: meta.InstanceType,
})
}
Expand Down Expand Up @@ -340,7 +381,7 @@ func CreateAuditPlan(c echo.Context) error {
return controller.JSONBaseErrorReq(c, err)
}
if !canCreateAuditPlan {
return controller.JSONBaseErrorReq(c, errors.NewUserNotPermissionError(model.GetOperationCodeDesc(uint(model.OP_AUDIT_PLAN_SAVE))))
return controller.JSONBaseErrorReq(c, errors.NewUserNotPermissionError(model.GetOperationCodeDesc(c.Request().Context(), uint(model.OP_AUDIT_PLAN_SAVE))))
}
} else {
instanceType = req.InstanceType
Expand Down Expand Up @@ -649,7 +690,7 @@ func GetAuditPlans(c echo.Context) error {
InstanceDatabase: ap.InstanceDatabase,
RuleTemplateName: ap.RuleTemplateName.String,
Token: ap.Token,
Meta: ConvertAuditPlanMetaToRes(meta),
Meta: ConvertAuditPlanMetaToRes(c.Request().Context(), meta),
}
}
return c.JSON(http.StatusOK, &GetAuditPlansResV1{
Expand Down Expand Up @@ -704,7 +745,7 @@ func GetAuditPlan(c echo.Context) error {
InstanceDatabase: ap.InstanceDatabase,
RuleTemplateName: ap.RuleTemplateName,
Token: ap.Token,
Meta: ConvertAuditPlanMetaToRes(meta),
Meta: ConvertAuditPlanMetaToRes(c.Request().Context(), meta),
},
})
}
Expand Down Expand Up @@ -1383,7 +1424,7 @@ func GetAuditPlanSQLs(c echo.Context) error {
for _, v := range head {
res.Head = append(res.Head, AuditPlanSQLHeadV1{
Name: v.Name,
Desc: v.Desc,
Desc: locale.ShouldLocalizeMsg(c.Request().Context(), v.Desc),
Type: v.Type,
})
}
Expand Down Expand Up @@ -1463,7 +1504,7 @@ func GetAuditPlanReportSQLsV1(c echo.Context) error {
for i, auditPlanReportSQL := range auditPlanReportSQLs {
auditPlanReportSQLsResV1[i] = AuditPlanReportSQLResV1{
SQL: auditPlanReportSQL.SQL,
AuditResult: auditPlanReportSQL.AuditResults.String(),
AuditResult: auditPlanReportSQL.AuditResults.String(c.Request().Context()),
Number: auditPlanReportSQL.Number,
}
}
Expand All @@ -1474,10 +1515,13 @@ func GetAuditPlanReportSQLsV1(c echo.Context) error {
})
}

func spliceAuditResults(auditResults []model.AuditResult) string {
func spliceAuditResults(ctx context.Context, auditResults []model.AuditResult) string {
lang := locale.GetLangTagFromCtx(ctx)
results := []string{}
for _, auditResult := range auditResults {
results = append(results, fmt.Sprintf("[%v]%v", auditResult.Level, auditResult.Message))
results = append(results,
fmt.Sprintf("[%v]%v", auditResult.Level, auditResult.GetAuditMsgByLangTag(lang)),
)
}
return strings.Join(results, "\n")
}
Expand Down Expand Up @@ -1517,16 +1561,17 @@ func ExportAuditPlanReportV1(c echo.Context) error {
return controller.JSONBaseErrorReq(c, fmt.Errorf("the audit plan corresponding to the report was not found"))
}

ctx := c.Request().Context()
baseInfo := [][]string{
{"扫描任务名称", auditPlanName},
{"报告生成时间", reportInfo.CreatedAt.Format("2006/01/02 15:04")},
{"审核结果评分", strconv.FormatInt(int64(reportInfo.Score), 10)},
{"审核通过率", fmt.Sprintf("%v%%", reportInfo.PassRate*100)},
{"所属项目", projectName},
{"扫描任务创建人", dms.GetUserNameWithDelTag(reportInfo.AuditPlan.CreateUserID)},
{"扫描任务类型", reportInfo.AuditPlan.Type},
{"数据库类型", reportInfo.AuditPlan.DBType},
{"审核的数据库", reportInfo.AuditPlan.InstanceDatabase},
{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},
}
err = csvWriter.WriteAll(baseInfo)
if err != nil {
Expand All @@ -1539,14 +1584,18 @@ func ExportAuditPlanReportV1(c echo.Context) error {
return controller.JSONBaseErrorReq(c, err)
}

err = csvWriter.Write([]string{"编号", "SQL", "审核结果"})
err = csvWriter.Write([]string{
locale.ShouldLocalizeMsg(ctx, locale.APExportNumber), // 编号
"SQL",
locale.ShouldLocalizeMsg(ctx, locale.APExportAuditResult), // 审核结果
})
if err != nil {
return controller.JSONBaseErrorReq(c, err)
}

sqlInfo := [][]string{}
for idx, sql := range reportInfo.AuditPlanReportSQLs {
sqlInfo = append(sqlInfo, []string{strconv.Itoa(idx + 1), sql.SQL, spliceAuditResults(sql.AuditResults)})
sqlInfo = append(sqlInfo, []string{strconv.Itoa(idx + 1), sql.SQL, spliceAuditResults(ctx, sql.AuditResults)})
}

err = csvWriter.WriteAll(sqlInfo)
Expand All @@ -1556,7 +1605,7 @@ func ExportAuditPlanReportV1(c echo.Context) error {

csvWriter.Flush()

fileName := fmt.Sprintf("扫描任务报告_%s_%s.csv", auditPlanName, time.Now().Format("20060102150405"))
fileName := fmt.Sprintf("audit_plan_report_%s_%s.csv", auditPlanName, time.Now().Format("20060102150405"))
c.Response().Header().Set(echo.HeaderContentDisposition, mime.FormatMediaType("attachment", map[string]string{
"filename": fileName,
}))
Expand Down
Loading

0 comments on commit e7afe89

Please sign in to comment.