AddAnswer add answer
(ctx context.Context, answer *entity.Answer)
| 65 | |
| 66 | // AddAnswer add answer |
| 67 | func (ar *answerRepo) AddAnswer(ctx context.Context, answer *entity.Answer) (err error) { |
| 68 | answer.QuestionID = uid.DeShortID(answer.QuestionID) |
| 69 | ID, err := ar.uniqueIDRepo.GenUniqueIDStr(ctx, answer.TableName()) |
| 70 | if err != nil { |
| 71 | return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack() |
| 72 | } |
| 73 | answer.ID = ID |
| 74 | _, err = ar.data.DB.Context(ctx).Insert(answer) |
| 75 | |
| 76 | if err != nil { |
| 77 | return errors.InternalServer(reason.DatabaseError).WithError(err).WithStack() |
| 78 | } |
| 79 | if handler.GetEnableShortID(ctx) { |
| 80 | answer.ID = uid.EnShortID(answer.ID) |
| 81 | answer.QuestionID = uid.EnShortID(answer.QuestionID) |
| 82 | } |
| 83 | _ = ar.updateSearch(ctx, answer.ID) |
| 84 | return nil |
| 85 | } |
| 86 | |
| 87 | // RemoveAnswer delete answer |
| 88 | func (ar *answerRepo) RemoveAnswer(ctx context.Context, answerID string) (err error) { |
nothing calls this directly
no test coverage detected