From 495fc39c94e7532b46773fa788617e3d865816b6 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Fri, 29 Nov 2024 13:44:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BA=86=E9=94=99=E5=88=AB?= =?UTF-8?q?=E5=AD=97=E5=AD=97=E5=85=B81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/controller/ErrorWord.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/api/controller/ErrorWord.go b/api/controller/ErrorWord.go index 0155f59..df9c3e8 100644 --- a/api/controller/ErrorWord.go +++ b/api/controller/ErrorWord.go @@ -1,6 +1,7 @@ package controller import ( + "fmt" "github.com/gin-gonic/gin" "knowledge/api/dao" "knowledge/api/dto" @@ -10,6 +11,8 @@ import ( "knowledge/global" "knowledge/utils" "strconv" + "strings" + "time" ) type BaseErrorWord struct{} @@ -176,6 +179,7 @@ func (r *BaseErrorWord) OperationErrorWord(c *gin.Context) { } }() + var questionIds []string for _, question := range questions { questionName := utils.ReplaceString(question.QuestionName, baseErrorWord.WordOld, baseErrorWord.WordNew) questionAnswer := utils.ReplaceString(question.QuestionAnswer, baseErrorWord.WordOld, baseErrorWord.WordNew) @@ -201,6 +205,21 @@ func (r *BaseErrorWord) OperationErrorWord(c *gin.Context) { responses.FailWithMessage(err.Error(), c) return } + + // 记录操作id + questionIds = append(questionIds, fmt.Sprintf("%d", question.QuestionId)) + } + } + + if len(questionIds) > 0 { + datas := make(map[string]interface{}) + datas["question_ids"] = strings.Join(questionIds, ",") + datas["operation_time"] = time.Now().Format("2006-01-02 15:04:05") + err = baseErrorWordDao.EditBaseErrorWordById(tx, baseErrorWord.WordId, datas) + if err != nil { + tx.Rollback() + responses.FailWithMessage(err.Error(), c) + return } }