You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func NormalizeExportFormat(format *ExportFormat) ExportFormat {
- if format == nil {+ if format == nil || *format == "" {
return CsvExportFormat
}
return *format
}
Suggestion importance[1-10]: 7
__
Why: The suggestion adds an extra condition to handle empty string inputs, ensuring that even when a non-nil pointer holds an empty value the default CsvExportFormat is returned. This is a minor but useful enhancement to improve robustness.
Why: This suggestion addresses a potential bug in the sheet creation and deletion logic in NewExcelBuilder, replacing hardcoded "Sheet1" with the current active sheet to avoid inadvertently deleting a needed sheet.
func NormalizeExportFormat(format interface{}) string {
var formatStr string
switch v := format.(type) {
case string:
formatStr = v
case *string:
if v != nil {
formatStr = *v
}
default:
- return "csv"+ return "excel"
}
if formatStr == "" {
- return "csv"+ return "excel"
}
formatStr = strings.ToLower(formatStr)
if formatStr != "csv" && formatStr != "excel" {
- return "csv"+ return "excel"
}
return formatStr
}
Suggestion importance[1-10]: 6
__
Why: The suggestion improves consistency by changing the default export format from "csv" to "excel" in NormalizeExportFormat, aligning it with the behavior expected in the controller, though its impact is relatively minor.
Why: The suggestion replaces the creation and deletion of "Sheet1" with renaming the default active sheet, which simplifies the initialization logic and avoids potential issues. The improvement correctly targets the lines 24-40 in the new hunk.
Why: The suggestion improves the Excel sheet initialization by avoiding redundant operations that might lead to data loss or confusion, and it provides a clearer approach using the default sheet, though the impact is relatively moderate.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
assign in @LordofAvernus
关联的 issue
#3198
描述你的变更
确认项(pr提交后操作)
Tip
请在指定复审人之前,确认并完成以下事项,完成后✅
not_compatibleneed_update_docDescription
添加 export_format 参数支持 CSV 与 Excel 导出
更新 SQL、工单、SQL管控 API 接口
新增 ExcelBuilder 工具自适应列宽
更新文档及依赖配置
Diagram Walkthrough
File Walkthrough
5 files
更新 SQL 导出接口支持 CSV/Excel 格式更新工单导出接口支持 CSV/Excel 格式更新 SQL 管控导出接口支持 CSV/Excel 格式新增 ExcelBuilder 实现 Excel 文件构建新增数据导出方法支持 CSV 与 Excel 格式3 files
更新 swagger 文档导出描述支持 CSV/Excel 格式更新 swagger.json 中导出描述更新 swagger.yaml 中导出描述2 files
引入 excelize 模块依赖更新更新依赖校验文件信息