diff --git a/Knowledge_Test_Go/internal/logic/knowledge/knowledge.go b/Knowledge_Test_Go/internal/logic/knowledge/knowledge.go index 9a6acfa..9927058 100644 --- a/Knowledge_Test_Go/internal/logic/knowledge/knowledge.go +++ b/Knowledge_Test_Go/internal/logic/knowledge/knowledge.go @@ -54,7 +54,7 @@ func (s *sKnowledgeTest) GetCourse(ctx context.Context, req *v1.GetCourseReq) (r Where("a.jwcode = ?", req.Jwcode). Where("c.cr_name IS NOT NULL"). Where("c.cr_name != ''"). - Fields("DISTINCT c.cr_name"). + Fields("DISTINCT c.cr_name"). // DISTINCT去重 Ctx(ctx). Scan(&courses) diff --git a/Knowledge_Test_Go/internal/logic/questionBank/questionBank.go b/Knowledge_Test_Go/internal/logic/questionBank/questionBank.go index dd09517..fdffb7c 100644 --- a/Knowledge_Test_Go/internal/logic/questionBank/questionBank.go +++ b/Knowledge_Test_Go/internal/logic/questionBank/questionBank.go @@ -267,7 +267,7 @@ func (s *sQuestionBank) ExportQuestion(r *ghttp.Request, ctx context.Context, re fileName := "题目数据导出.xlsx" // === 4. 设置表头 === - headers := []string{"序号", "ID", "题干", "选项A", "选项B", "选项C", "选项D", "正确答案", "题目类型", "推荐课程", "引用次数", "错误次数", "错误率"} + headers := []string{"序号", "题干", "选项A", "选项B", "选项C", "选项D", "正确答案", "题目类型", "推荐课程", "引用次数", "错误次数", "错误率"} for i, header := range headers { col := string('A' + i) excelFile.SetCellValue(sheetName, col+"1", header) @@ -277,18 +277,17 @@ func (s *sQuestionBank) ExportQuestion(r *ghttp.Request, ctx context.Context, re rowIndex := 2 for _, question := range result { excelFile.SetCellValue(sheetName, "A"+strconv.Itoa(rowIndex), rowIndex-1) - excelFile.SetCellValue(sheetName, "B"+strconv.Itoa(rowIndex), question.Id) - excelFile.SetCellValue(sheetName, "C"+strconv.Itoa(rowIndex), question.Stem) - excelFile.SetCellValue(sheetName, "D"+strconv.Itoa(rowIndex), question.A) - excelFile.SetCellValue(sheetName, "E"+strconv.Itoa(rowIndex), question.B) - excelFile.SetCellValue(sheetName, "F"+strconv.Itoa(rowIndex), question.C) - excelFile.SetCellValue(sheetName, "G"+strconv.Itoa(rowIndex), question.D) - excelFile.SetCellValue(sheetName, "H"+strconv.Itoa(rowIndex), question.CorrectAnswer) - excelFile.SetCellValue(sheetName, "I"+strconv.Itoa(rowIndex), question.QuestionTypeName) - excelFile.SetCellValue(sheetName, "J"+strconv.Itoa(rowIndex), question.CrName) - excelFile.SetCellValue(sheetName, "K"+strconv.Itoa(rowIndex), question.CitationCount) - excelFile.SetCellValue(sheetName, "L"+strconv.Itoa(rowIndex), question.ErrorCount) - excelFile.SetCellValue(sheetName, "M"+strconv.Itoa(rowIndex), strconv.Itoa(question.ErrorRate)+"%") + excelFile.SetCellValue(sheetName, "B"+strconv.Itoa(rowIndex), question.Stem) + excelFile.SetCellValue(sheetName, "C"+strconv.Itoa(rowIndex), question.A) + excelFile.SetCellValue(sheetName, "D"+strconv.Itoa(rowIndex), question.B) + excelFile.SetCellValue(sheetName, "E"+strconv.Itoa(rowIndex), question.C) + excelFile.SetCellValue(sheetName, "F"+strconv.Itoa(rowIndex), question.D) + excelFile.SetCellValue(sheetName, "G"+strconv.Itoa(rowIndex), question.CorrectAnswer) + excelFile.SetCellValue(sheetName, "H"+strconv.Itoa(rowIndex), question.QuestionTypeName) + excelFile.SetCellValue(sheetName, "I"+strconv.Itoa(rowIndex), question.CrName) + excelFile.SetCellValue(sheetName, "J"+strconv.Itoa(rowIndex), question.CitationCount) + excelFile.SetCellValue(sheetName, "K"+strconv.Itoa(rowIndex), question.ErrorCount) + excelFile.SetCellValue(sheetName, "L"+strconv.Itoa(rowIndex), strconv.Itoa(question.ErrorRate)+"%") rowIndex++ } @@ -312,13 +311,12 @@ func (s *sQuestionBank) ExportQuestion(r *ghttp.Request, ctx context.Context, re excelFile.SetCellStyle(sheetName, "A1", "L"+strconv.Itoa(lastRow), style) // 设置列宽 - excelFile.SetColWidth(sheetName, "B", "B", 10) // ID - excelFile.SetColWidth(sheetName, "C", "C", 40) // 题干 - excelFile.SetColWidth(sheetName, "D", "G", 20) // 选项A-D - excelFile.SetColWidth(sheetName, "H", "H", 12) // 正确答案 - excelFile.SetColWidth(sheetName, "I", "I", 15) // 题目类型 - excelFile.SetColWidth(sheetName, "J", "J", 20) // 推荐课程 - excelFile.SetColWidth(sheetName, "K", "M", 12) // 统计信息 + excelFile.SetColWidth(sheetName, "B", "B", 40) // 题干 + excelFile.SetColWidth(sheetName, "C", "F", 20) // 选项A-D + excelFile.SetColWidth(sheetName, "G", "G", 12) // 正确答案 + excelFile.SetColWidth(sheetName, "H", "H", 15) // 题目类型 + excelFile.SetColWidth(sheetName, "I", "I", 20) // 推荐课程 + excelFile.SetColWidth(sheetName, "J", "L", 12) // 统计信息 // === 7. 输出 Excel 文件 === buffer, err := excelFile.WriteToBuffer() @@ -380,7 +378,7 @@ func (s *sQuestionBank) ExportUserScore(r *ghttp.Request, ctx context.Context, r fileName := "用户成绩导出.xlsx" // === 4. 设置表头 === - headers := []string{"序号", "ID", "用户名", "用户身份", "精网号", "成绩", "创建时间"} + headers := []string{"序号", "用户名", "用户身份", "精网号", "成绩", "创建时间"} for i, header := range headers { col := string('A' + i) excelFile.SetCellValue(sheetName, col+"1", header) @@ -390,12 +388,11 @@ func (s *sQuestionBank) ExportUserScore(r *ghttp.Request, ctx context.Context, r rowIndex := 2 for _, userScore := range result { excelFile.SetCellValue(sheetName, "A"+strconv.Itoa(rowIndex), rowIndex-1) - excelFile.SetCellValue(sheetName, "B"+strconv.Itoa(rowIndex), userScore.Id) - excelFile.SetCellValue(sheetName, "C"+strconv.Itoa(rowIndex), userScore.UserName) - excelFile.SetCellValue(sheetName, "D"+strconv.Itoa(rowIndex), userScore.UserIdentity) - excelFile.SetCellValue(sheetName, "E"+strconv.Itoa(rowIndex), userScore.Jwcode) - excelFile.SetCellValue(sheetName, "F"+strconv.Itoa(rowIndex), userScore.Score) - excelFile.SetCellValue(sheetName, "G"+strconv.Itoa(rowIndex), userScore.CreatedAt) + excelFile.SetCellValue(sheetName, "B"+strconv.Itoa(rowIndex), userScore.UserName) + excelFile.SetCellValue(sheetName, "C"+strconv.Itoa(rowIndex), userScore.UserIdentity) + excelFile.SetCellValue(sheetName, "D"+strconv.Itoa(rowIndex), userScore.Jwcode) + excelFile.SetCellValue(sheetName, "E"+strconv.Itoa(rowIndex), userScore.Score) + excelFile.SetCellValue(sheetName, "F"+strconv.Itoa(rowIndex), userScore.CreatedAt) rowIndex++ } @@ -419,12 +416,11 @@ func (s *sQuestionBank) ExportUserScore(r *ghttp.Request, ctx context.Context, r excelFile.SetCellStyle(sheetName, "A1", "F"+strconv.Itoa(lastRow), style) // 设置列宽 - excelFile.SetColWidth(sheetName, "B", "B", 10) // ID - excelFile.SetColWidth(sheetName, "C", "C", 20) // 用户名 - excelFile.SetColWidth(sheetName, "D", "D", 15) // 用户身份 - excelFile.SetColWidth(sheetName, "E", "E", 15) // 精网号 - excelFile.SetColWidth(sheetName, "F", "F", 10) // 成绩 - excelFile.SetColWidth(sheetName, "G", "G", 20) // 创建时间 + excelFile.SetColWidth(sheetName, "B", "B", 20) // 用户名 + excelFile.SetColWidth(sheetName, "C", "C", 15) // 用户身份 + excelFile.SetColWidth(sheetName, "D", "D", 15) // 精网号 + excelFile.SetColWidth(sheetName, "E", "E", 10) // 成绩 + excelFile.SetColWidth(sheetName, "F", "F", 20) // 创建时间 // === 7. 输出 Excel 文件 === buffer, err := excelFile.WriteToBuffer()