Browse Source

refactor package question 2 chat

zzf 1 year ago
parent
commit
8394ec3354
4 changed files with 13 additions and 13 deletions
  1. 2 2
      api/chat/answer.go
  2. 4 4
      api/chat/question.go
  3. 5 5
      initialize/router.go
  4. 2 2
      models/question.go

+ 2 - 2
api/question/answer.go → api/chat/answer.go

@@ -1,4 +1,4 @@
-package question
+package chat
 
 import (
 	errmsg "confrontation-training/err"
@@ -53,7 +53,7 @@ func (a *AnswerService) CreateAnswer(c *gin.Context) {
 // @Accept json
 // @Produce json
 // @Success 200 {string} string "ok"
-// @Router /v1/chat/get/question [get]
+// @Router /v1/chat/get/chat [get]
 func (a *AnswerService) GetAnswer(c *gin.Context) {
 
 	var id uint8

+ 4 - 4
api/question/question.go → api/chat/question.go

@@ -1,4 +1,4 @@
-package question
+package chat
 
 import (
 	errmsg "confrontation-training/err"
@@ -27,7 +27,7 @@ func GetQuestionService() *QuestionService {
 // @Accept json
 // @Produce json
 // @Success 200 {string} string "ok"
-// @Router /v1/chat/get/question [get]
+// @Router /v1/chat/get/chat [get]
 func (q *QuestionService) GetQuestion(c *gin.Context) {
 	var id uint8
 	if err := c.ShouldBind(&id); err != nil {
@@ -53,11 +53,11 @@ func (q *QuestionService) GetQuestion(c *gin.Context) {
 // @Schemes
 // @Description 录入问题
 // @Tags 问答管理
-// @Param q body string true "question:问题;nextQuestionNo:下一个问题编号:如果此编号不为空,则说明此问题为陈述,没有答案信息;questionType:题目类型:0选择题;1填空题"
+// @Param q body string true "chat:问题;nextQuestionNo:下一个问题编号:如果此编号不为空,则说明此问题为陈述,没有答案信息;questionType:题目类型:0选择题;1填空题"
 // @Accept json
 // @Produce json
 // @Success 200 {string} string "ok"
-// @Router /v1/chat/create/question [post]
+// @Router /v1/chat/create/chat [post]
 func (q *QuestionService) CreateQuestion(c *gin.Context) {
 	var param models.CreateQuestion
 	if err := c.ShouldBindJSON(&param); err != nil {

+ 5 - 5
initialize/router.go

@@ -1,8 +1,8 @@
 package initialize
 
 import (
+	"confrontation-training/api/chat"
 	"confrontation-training/api/gateway"
-	"confrontation-training/api/question"
 	"confrontation-training/global"
 	_ "confrontation-training/global"
 	"confrontation-training/middleware"
@@ -55,10 +55,10 @@ func Router() {
 	device.GET("/:mac/stop/trans/", gateway.StopTrans)
 	device.GET("/:mac/stop/collect/", gateway.StopCollect)
 	device.GET("/:mac/disconnect/", gateway.Disconnect)
-	chat := v1.Group("/chat")
-	chat.GET("/get/question/", question.GetQuestionService().GetQuestion)
-	chat.POST("/create/question/", question.GetQuestionService().CreateQuestion)
-	chat.GET("/get/answer/", question.GteAnswerService().CreateAnswer)
+	chats := v1.Group("/chat")
+	chats.GET("/get/chat/", chat.GetQuestionService().GetQuestion)
+	chats.POST("/create/chat/", chat.GetQuestionService().CreateQuestion)
+	chats.GET("/get/answer/", chat.GteAnswerService().CreateAnswer)
 
 	//
 	//record := v1.Group("/record")

+ 2 - 2
models/question.go

@@ -4,13 +4,13 @@ import "gorm.io/gorm"
 
 type Question struct {
 	gorm.Model
-	Question       string `gorm:"question type:varchar(100) not null comment '问题'"`
+	Question       string `gorm:"chat type:varchar(100) not null comment '问题'"`
 	NextQuestionId *uint8 `gorm:"next_question_id comment '下一个问题编号:如果此编号不为空,则说明此问题为陈述,没有答案信息'"`
 	QuestionType   *uint8 `gorm:"question_type not null default '0' comment '题目类型:0选择题;1填空题'"`
 }
 
 type CreateQuestion struct {
-	Question       string `json:"question" binding:"required"`
+	Question       string `json:"chat" binding:"required"`
 	NextQuestionId *uint8 `json:"nextQuestionId"`
 	QuestionType   *uint8 `json:"questionType" binding:"required,gte=0" `
 }