From 9b22520851140d5010e04a2b53b74893530569b8 Mon Sep 17 00:00:00 2001 From: "jiaji.H" Date: Wed, 11 Mar 2026 18:38:30 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Updata=EF=BC=9A=E6=9B=B4=E6=96=B0sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/dao/questionnaire_survey.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/dao/questionnaire_survey.go b/internal/dao/questionnaire_survey.go index 0aee32b..a206c42 100644 --- a/internal/dao/questionnaire_survey.go +++ b/internal/dao/questionnaire_survey.go @@ -2,6 +2,7 @@ package dao import ( "encoding/json" + "errors" "micro-bundle/internal/model" "micro-bundle/pb/bundle" "micro-bundle/pkg/app" @@ -9,6 +10,7 @@ import ( "time" "github.com/google/uuid" + "gorm.io/gorm" ) func SendQuestionnaireSurvey(req *bundle.SendQuestionnaireSurveyRequest) (resp *bundle.SendQuestionnaireSurveyResponse, err error) { @@ -36,6 +38,9 @@ func SendQuestionnaireSurvey(req *bundle.SendQuestionnaireSurveyRequest) (resp * Where("user_tel = ? and deleted_at is null", req.UserTel). First(&questionnaireInfo).Error if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + resp.Status = 0 + } return resp, err } if questionnaireInfo.UserId != 0 { From 14609d29cae65207ef11479cdf29fe330f6f2b42 Mon Sep 17 00:00:00 2001 From: "jiaji.H" Date: Wed, 11 Mar 2026 18:39:10 +0800 Subject: [PATCH 2/2] Updata --- internal/dao/questionnaire_survey.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/dao/questionnaire_survey.go b/internal/dao/questionnaire_survey.go index a206c42..1e7a99b 100644 --- a/internal/dao/questionnaire_survey.go +++ b/internal/dao/questionnaire_survey.go @@ -107,6 +107,9 @@ func GetQuestionnaireSurveyInfo(req *bundle.GetQuestionnaireSurveyInfoRequest) ( Order("created_at desc"). First(&questionnaireInfo).Error if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return nil, errors.New("问卷信息不存在") + } return data, err } return data, nil