hsun 2 жил өмнө
parent
commit
417fde755f

+ 1 - 1
controller/community/question.go

@@ -25,7 +25,7 @@ import (
 // @Param chart_permission_id	query int false "品种权限ID"
 // @Param reply_status			query int false "回复状态 0-全部 2-待回答 3-已回答"
 // @Param replier_user_id		query int false "回复人ID"
-// @Success 200 {object} respond.CommunityQuestionList
+// @Success 200 {object} []respond.CommunityQuestionItem
 // @failure 400 {string} string "获取失败"
 // @Router /question/list [get]
 func QuestionList(c *gin.Context) {

+ 7 - 15
docs/docs.go

@@ -1218,7 +1218,10 @@ var doc = `{
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/response.CommunityQuestionList"
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/response.CommunityQuestionItem"
+                            }
                         }
                     },
                     "400": {
@@ -2596,6 +2599,9 @@ var doc = `{
                 "is_top": {
                     "type": "integer"
                 },
+                "permission_info": {
+                    "$ref": "#/definitions/response.PermissionCheckInfo"
+                },
                 "question_content": {
                     "type": "string"
                 },
@@ -2616,20 +2622,6 @@ var doc = `{
                 }
             }
         },
-        "response.CommunityQuestionList": {
-            "type": "object",
-            "properties": {
-                "permissionInfo": {
-                    "$ref": "#/definitions/response.PermissionCheckInfo"
-                },
-                "questionList": {
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/response.CommunityQuestionItem"
-                    }
-                }
-            }
-        },
         "response.CommunityReplyTotal": {
             "type": "object",
             "properties": {

+ 7 - 15
docs/swagger.json

@@ -1204,7 +1204,10 @@
                     "200": {
                         "description": "OK",
                         "schema": {
-                            "$ref": "#/definitions/response.CommunityQuestionList"
+                            "type": "array",
+                            "items": {
+                                "$ref": "#/definitions/response.CommunityQuestionItem"
+                            }
                         }
                     },
                     "400": {
@@ -2582,6 +2585,9 @@
                 "is_top": {
                     "type": "integer"
                 },
+                "permission_info": {
+                    "$ref": "#/definitions/response.PermissionCheckInfo"
+                },
                 "question_content": {
                     "type": "string"
                 },
@@ -2602,20 +2608,6 @@
                 }
             }
         },
-        "response.CommunityQuestionList": {
-            "type": "object",
-            "properties": {
-                "permissionInfo": {
-                    "$ref": "#/definitions/response.PermissionCheckInfo"
-                },
-                "questionList": {
-                    "type": "array",
-                    "items": {
-                        "$ref": "#/definitions/response.CommunityQuestionItem"
-                    }
-                }
-            }
-        },
         "response.CommunityReplyTotal": {
             "type": "object",
             "properties": {

+ 5 - 10
docs/swagger.yaml

@@ -516,6 +516,8 @@ definitions:
         type: integer
       is_top:
         type: integer
+      permission_info:
+        $ref: '#/definitions/response.PermissionCheckInfo'
       question_content:
         type: string
       replier_avatar:
@@ -529,15 +531,6 @@ definitions:
       user_id:
         type: integer
     type: object
-  response.CommunityQuestionList:
-    properties:
-      permissionInfo:
-        $ref: '#/definitions/response.PermissionCheckInfo'
-      questionList:
-        items:
-          $ref: '#/definitions/response.CommunityQuestionItem'
-        type: array
-    type: object
   response.CommunityReplyTotal:
     properties:
       replied:
@@ -1576,7 +1569,9 @@ paths:
         "200":
           description: OK
           schema:
-            $ref: '#/definitions/response.CommunityQuestionList'
+            items:
+              $ref: '#/definitions/response.CommunityQuestionItem'
+            type: array
         "400":
           description: 获取失败
           schema:

+ 0 - 5
models/response/community.go

@@ -1,10 +1,5 @@
 package response
 
-type CommunityQuestionList struct {
-	QuestionList   []*CommunityQuestionItem
-	//PermissionInfo PermissionCheckInfo
-}
-
 type CommunityQuestionItem struct {
 	CommunityQuestionID int                           `json:"community_question_id"`
 	UserId              int                           `json:"user_id"`

+ 3 - 6
services/community/question.go

@@ -16,7 +16,7 @@ import (
 )
 
 // GetQuestionList 获取问答列表
-func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStatus, replierUserId int, userInfo user.UserInfo) (resp *response.CommunityQuestionList, err error) {
+func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStatus, replierUserId int, userInfo user.UserInfo) (resp []*response.CommunityQuestionItem, err error) {
 	condition := make(map[string]interface{})
 	condition["is_deleted ="] = 0
 	// 用户身份
@@ -75,8 +75,7 @@ func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStat
 	}
 
 	userId := int(userInfo.UserID)
-	resp = new(response.CommunityQuestionList)
-	respList := make([]*response.CommunityQuestionItem, 0)
+	resp = make([]*response.CommunityQuestionItem, 0)
 	for _, v := range questionList {
 		audios := make([]*response.CommunityQuestionAudioItem, 0)
 		for _, a := range audioList {
@@ -114,10 +113,8 @@ func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStat
 		if !isAdmin && item.IsRead == 0 && item.UserId == userId {
 			item.IsTop = 1
 		}
-		respList = append(respList, item)
+		resp = append(resp, item)
 	}
-	resp.QuestionList = respList
-	//resp.PermissionInfo = permissionInfo
 	return
 }