package chat import ( "confrontation-training/global" "confrontation-training/models/chat" ) type AnswerService struct { } func (a *AnswerService) CreateNewAnswer(param models.CreateAnswer) (models.Answer, int64) { answer := models.Answer{ Answer: param.Answer, QuestionId: param.QuestionId, NextQuestionId: param.NextQuestionId, } count := global.Db.Create(&answer).RowsAffected return answer, count } func (a *AnswerService) FindAnswerByQuestionId(id uint8) ([]models.Answer, int64) { answerList := make([]models.Answer, 0) count := global.Db.Where(" question_id = ?", id).Find(&answerList).RowsAffected return answerList, count }