diff --git a/services/chore/internal/dao/answerUser.go b/services/chore/internal/dao/answerUser.go index 1d669e2..13cd28a 100644 --- a/services/chore/internal/dao/answerUser.go +++ b/services/chore/internal/dao/answerUser.go @@ -1,6 +1,7 @@ package dao type UserAnswer struct { - Id int `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` + Id int64 `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` Answer uint8 `gorm:"column:answer;type:tinyint(1);default:2;comment:答题状态,1为答完, 2为未答" json:"answer"` + UserId int64 `gorm:"column:user_id;type:int(11);comment:用户ID" json:"user_id"` } diff --git a/services/chore/internal/logic/apiAnswerSaveLogic.go b/services/chore/internal/logic/apiAnswerSaveLogic.go index 58b09af..9f59f45 100644 --- a/services/chore/internal/logic/apiAnswerSaveLogic.go +++ b/services/chore/internal/logic/apiAnswerSaveLogic.go @@ -43,7 +43,14 @@ func (l *ApiAnswerSaveLogic) ApiAnswerSave(in *chore.EmptyReq) (*chore.Response, return l.fail(utils.Fail) } if info.Id < utils.NumberOne { - return l.fail(utils.SetError(utils.ErrorNotFund, "用户不存在")) + info.Answer = utils.StatusOk + info.UserId = adminInfo.ID + err = model.AnswerUserModel{}.Init().Create(&info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail) + } + return l.ok(info.Id) } info.Answer = utils.StatusOk