answer.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package question
  2. import (
  3. errmsg "confrontation-training/err"
  4. "confrontation-training/models"
  5. "confrontation-training/response"
  6. "confrontation-training/service"
  7. "github.com/gin-gonic/gin"
  8. )
  9. type AnswerService struct {
  10. service.AnswerService
  11. }
  12. func GteAnswerService() *AnswerService {
  13. return &AnswerService{}
  14. }
  15. // CreateAnswer
  16. // PingExample confrontation-training
  17. // @Summary 录入答案
  18. // @Schemes
  19. // @Description 录入答案
  20. // @Tags 问答管理
  21. // @Param q body string true "questionNo:问题编号;NextQuestionNo:下一个问题编号;answer:答案"
  22. // @Accept json
  23. // @Produce json
  24. // @Success 200 {string} string "ok"
  25. // @Router /v1/chat/create/answer [post]
  26. func (a *AnswerService) CreateAnswer(c *gin.Context) {
  27. var param models.CreateAnswer
  28. err := c.ShouldBindJSON(&param)
  29. if err != nil {
  30. panic(err)
  31. return
  32. }
  33. answer, count := a.CreateNewAnswer(param)
  34. if count == 0 {
  35. response.Failed(errmsg.AnswerCreateFailed, c)
  36. } else {
  37. response.Success(errmsg.CreateSuccess, answer, c)
  38. }
  39. return
  40. }
  41. //GetAnswer
  42. // PingExample confrontation-training
  43. // @Summary 查询答案
  44. // @Schemes
  45. // @Description 查询答案
  46. // @Tags 问答管理
  47. // @Param id query uint8 false "id:问题主键"
  48. // @Accept json
  49. // @Produce json
  50. // @Success 200 {string} string "ok"
  51. // @Router /v1/chat/get/question [get]
  52. func (a *AnswerService) GetAnswer(c *gin.Context) {
  53. var id uint8
  54. err := c.ShouldBind(&id)
  55. if err != nil {
  56. return
  57. }
  58. }