feat: add comments to categorize apis for swagger (#389)

Signed-off-by: Товарищ программист <2962928213@qq.com>
This commit is contained in:
Товарищ программист 2021-12-06 18:27:23 +08:00 committed by GitHub
parent c6f1d1f2a5
commit 3132649d62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 1438 additions and 695 deletions

View File

@ -46,6 +46,7 @@ func InitAuthConfig() {
// @Param state QueryString string true "The state"
// @Success 200 {object} controllers.api_controller.Response The Response object
// @router /signin [post]
// @Tag Account API
func (c *ApiController) Signin() {
code := c.Input().Get("code")
state := c.Input().Get("state")
@ -76,6 +77,7 @@ func (c *ApiController) Signin() {
// @Description sign out the current member
// @Success 200 {object} controllers.api_controller.Response The Response object
// @router /signout [post]
// @Tag Account API
func (c *ApiController) Signout() {
claims := c.GetSessionClaims()
if claims != nil {
@ -95,6 +97,7 @@ func (c *ApiController) Signout() {
// @Description Get current account
// @Success 200 {object} controllers.api_controller.Response The Response object
// @router /get-account [get]
// @Tag Account API
func (c *ApiController) GetAccount() {
if c.RequireSignedIn() {
return

View File

@ -24,6 +24,9 @@ import (
"github.com/casdoor/casdoor-go-sdk/auth"
)
// @Tag Balance API
// @Title AddThanks
// @router /add-thanks [post]
func (c *ApiController) AddThanks() {
if c.RequireSignedIn() {
return
@ -102,6 +105,9 @@ func (c *ApiController) AddThanks() {
}
}
// @Tag Balance API
// @Title GetConsumptionRecord
// @router /get-consumption-record [get]
func (c *ApiController) GetConsumptionRecord() {
username := c.GetSessionUsername()
limitStr := c.Input().Get("limit")
@ -125,6 +131,9 @@ func (c *ApiController) GetConsumptionRecord() {
c.ResponseOk(res, num)
}
// @Tag Balance API
// @Title GetCheckinBonus
// @router /get-checkin-bonus [get]
func (c *ApiController) GetCheckinBonus() {
if c.RequireSignedIn() {
return
@ -170,6 +179,9 @@ func (c *ApiController) GetCheckinBonus() {
c.ResponseOk(bonus)
}
// @router /get-checkin-bonus-status [get]
// @Tag Balance API
// @Title GetCheckinBonusStatus
func (c *ApiController) GetCheckinBonusStatus() {
if c.RequireSignedIn() {
return

View File

@ -21,6 +21,9 @@ import (
"github.com/casbin/casnode/util"
)
// @router /add-favorites [post]
// @Tag Favorite API
// @Title AddFavorites
func (c *ApiController) AddFavorites() {
objectId := c.Input().Get("id")
favoritesTypeStr := c.Input().Get("type")
@ -79,6 +82,9 @@ func (c *ApiController) AddFavorites() {
c.ServeJSON()
}
// @router /delete-favorites [post]
// @Tag Favorite API
// @Title DeleteFavorites
func (c *ApiController) DeleteFavorites() {
memberId := c.GetSessionUsername()
objectId := c.Input().Get("id")
@ -114,6 +120,9 @@ func (c *ApiController) DeleteFavorites() {
c.ServeJSON()
}
// @router /get-favorites-status [get]
// @Tag Favorite API
// @Title GetFavoritesStatus
func (c *ApiController) GetFavoritesStatus() {
memberId := c.GetSessionUsername()
objectId := c.Input().Get("id")
@ -132,6 +141,9 @@ func (c *ApiController) GetFavoritesStatus() {
c.ServeJSON()
}
// @router /get-favorites [get]
// @Tag Favorite API
// @Title GetFavorites
func (c *ApiController) GetFavorites() {
memberId := c.GetSessionUsername()
favoritesTypeStr := c.Input().Get("type")
@ -176,6 +188,9 @@ func (c *ApiController) GetFavorites() {
c.ServeJSON()
}
// @router /get-account-favorite-num [get]
// @Tag Favorite API
// @Title GetAccountFavoriteNum
func (c *ApiController) GetAccountFavoriteNum() {
memberId := c.GetSessionUsername()

View File

@ -191,6 +191,9 @@ func (c *ApiController) UpdateFileDescribe() {
c.ServeJSON()
}
// @Title UploadFile
// @Tag File API
// @router /upload-file [post]
func (c *ApiController) UploadFile() {
if c.RequireSignedIn() {
return
@ -210,6 +213,9 @@ func (c *ApiController) UploadFile() {
c.ServeJSON()
}
// @Title ModeratorUpload
// @Tag File API
// @router /upload-moderator [post]
func (c *ApiController) ModeratorUpload() {
if c.RequireSignedIn() {
return
@ -234,6 +240,9 @@ func (c *ApiController) ModeratorUpload() {
//resp := Response{Status: "ok", Msg: fileName, Data: fileUrl + timeStamp}
}
// @Title UploadAvatar
// @Tag File API
// @router /upload-avatar [post]
func (c *ApiController) UploadAvatar() {
if c.RequireSignedIn() {
return

View File

@ -24,6 +24,7 @@ import (
// @Description Get front confs by field
// @Success 200 {array} object.FrontConf The Response object
// @router /get-front-conf-by-field [get]
// @Tag FrontConf API
func (c *ApiController) GetFrontConfByField() {
field := c.Input().Get("field")
@ -35,6 +36,7 @@ func (c *ApiController) GetFrontConfByField() {
// @Description Get all front confs
// @Success 200 {array} array The Response object
// @router /get-front-confs [get]
// @Tag FrontConf API
func (c *ApiController) GetFrontConfs() {
confs := make(map[string]string)
conf := object.GetFrontConfs()
@ -47,6 +49,9 @@ func (c *ApiController) GetFrontConfs() {
c.ServeJSON()
}
// @router /update-front-conf [post]
// @Tag FrontConf API
// @Title UpdateFrontConf
func (c *ApiController) UpdateFrontConf() {
var confs []*object.FrontConf
@ -63,6 +68,9 @@ func (c *ApiController) UpdateFrontConf() {
}
// @router /update-to-default-conf [post]
// @Tag FrontConf API
// @Title UpdateFrontConfToDefault
func (c *ApiController) UpdateFrontConfToDefault() {
if c.RequireAdmin() {

View File

@ -19,6 +19,9 @@ import (
"github.com/casbin/casnode/util"
)
// @Tag Hot API
// @Title ChangeExpiredDataStatus
// @router /update-expired-data [post]
func (c *ApiController) ChangeExpiredDataStatus() {
expiredNodeDate := util.GetTimeMonth(-object.NodeHitRecordExpiredTime)
expiredTopicDate := util.GetTimeDay(-object.TopicHitRecordExpiredTime)
@ -30,6 +33,9 @@ func (c *ApiController) ChangeExpiredDataStatus() {
c.ServeJSON()
}
// @Tag Hot API
// @Title UpdateHotInfo
// @router /update-hot-info [post]
func (c *ApiController) UpdateHotInfo() {
var updateNodeNum int
var updateTopicNum int

View File

@ -20,6 +20,9 @@ import (
"github.com/casbin/casnode/object"
)
// @Tag Info API
// @Title GetCommunityHealth
// @router /get-community-health [get]
func (c *ApiController) GetCommunityHealth() {
var memberCount int
var topicCount int
@ -52,6 +55,9 @@ func (c *ApiController) GetCommunityHealth() {
c.ResponseOk(res)
}
// @Tag Info API
// @Title GetForumVersion
// @router /get-forum-version [get]
func (c *ApiController) GetForumVersion() {
var resp Response
@ -63,6 +69,9 @@ func (c *ApiController) GetForumVersion() {
c.ServeJSON()
}
// @Tag Info API
// @Title GetOnlineNum
// @router /get-online-num [get]
func (c *ApiController) GetOnlineNum() {
onlineNum := object.GetOnlineMemberNum()
highest := object.GetHighestOnlineNum()
@ -70,6 +79,9 @@ func (c *ApiController) GetOnlineNum() {
c.ResponseOk(onlineNum, highest)
}
// @Tag Info API
// @Title GetNodeNavigation
// @router /node-navigation [get]
func (c *ApiController) GetNodeNavigation() {
var resp Response

View File

@ -25,6 +25,7 @@ import (
// @Param id query string true "id"
// @Success 200 {object} auth.User The Response object
// @router /get-member [get]
// @Tag Member API
func (c *ApiController) GetMember() {
id := c.Input().Get("id")
@ -35,6 +36,7 @@ func (c *ApiController) GetMember() {
// @Description member editortype
// @Success 200 {object} controllers.Response The Response object
// @router /get-member-editor-type [get]
// @Tag Member API
func (c *ApiController) GetMemberEditorType() {
user := c.GetSessionUser()
@ -50,6 +52,7 @@ func (c *ApiController) GetMemberEditorType() {
// @Description RankingRich
// @Success 200 {array} auth.User The Response object
// @router /get-ranking-rich [get]
// @Tag Member API
func (c *ApiController) GetRankingRich() {
users, err := object.GetRankingRich()
if err != nil {
@ -60,6 +63,9 @@ func (c *ApiController) GetRankingRich() {
c.ResponseOk(users)
}
// @Tag Member API
// @Title UpdateMemberEditorType
// @router /update-member-editor-type [post]
func (c *ApiController) UpdateMemberEditorType() {
editorType := c.Input().Get("editorType")
user := c.GetSessionUser()
@ -78,6 +84,9 @@ func (c *ApiController) UpdateMemberEditorType() {
c.ResponseOk(affected)
}
// @Tag Member API
// @Title UpdateMemberLanguage
// @router /update-member-language [post]
func (c *ApiController) UpdateMemberLanguage() {
language := c.Input().Get("language")
@ -108,6 +117,7 @@ func (c *ApiController) UpdateMemberLanguage() {
// @Description MemberLanguage
// @Success 200 {object} controllers.Response The Response object
// @router /get-member-language [get]
// @Tag Member API
func (c *ApiController) GetMemberLanguage() {
user := c.GetSessionUser()

View File

@ -21,11 +21,17 @@ import (
"github.com/casbin/casnode/util"
)
// @Title GetNodes
// @router /get-nodes [get]
// @Tag Node API
func (c *ApiController) GetNodes() {
c.Data["json"] = object.GetNodes()
c.ServeJSON()
}
// @Title GetNodesAdmin
// @router /get-nodes-admin [get]
// @Tag Node API
func (c *ApiController) GetNodesAdmin() {
res := []adminNodeInfo{}
nodes := object.GetNodes()
@ -42,6 +48,9 @@ func (c *ApiController) GetNodesAdmin() {
c.ServeJSON()
}
// @Title GetNode
// @router /get-node [get]
// @Tag Node API
func (c *ApiController) GetNode() {
id := c.Input().Get("id")
@ -49,6 +58,10 @@ func (c *ApiController) GetNode() {
c.ServeJSON()
}
// @Title UpdateNode
// @router /update-node [post]
// @Tag Node API
func (c *ApiController) UpdateNode() {
if c.RequireAdmin() {
return
@ -65,6 +78,9 @@ func (c *ApiController) UpdateNode() {
c.ResponseOk(res)
}
// @Title AddNode
// @router /add-node [post]
// @Tag Node API
func (c *ApiController) AddNode() {
if c.RequireAdmin() {
return
@ -97,6 +113,9 @@ func (c *ApiController) AddNode() {
c.ResponseOk(res)
}
// @Title DeleteNode
// @router /delete-node [post]
// @Tag Node API
func (c *ApiController) DeleteNode() {
if c.RequireAdmin() {
return
@ -108,11 +127,17 @@ func (c *ApiController) DeleteNode() {
c.ServeJSON()
}
// @Title GetNodesNum
// @router /get-nodes-num [get]
// @Tag Node API
func (c *ApiController) GetNodesNum() {
num := object.GetNodesNum()
c.ResponseOk(num)
}
// @Title GetNodeInfo
// @router /get-node-info [get]
// @Tag Node API
func (c *ApiController) GetNodeInfo() {
id := c.Input().Get("id")
@ -128,6 +153,9 @@ func (c *ApiController) GetNodeFromTab() {
c.ResponseOk(nodes)
}
// @Title GetNodeRelation
// @router /get-node-relation [get]
// @Tag Node API
func (c *ApiController) GetNodeRelation() {
id := c.Input().Get("id")
@ -135,6 +163,9 @@ func (c *ApiController) GetNodeRelation() {
c.ResponseOk(res)
}
// @Tag Node API
// @router /get-latest-node [get]
// @Title GetLatestNode
func (c *ApiController) GetLatestNode() {
limitStr := c.Input().Get("limit")
defaultLimit := object.LatestNodeNum
@ -150,6 +181,9 @@ func (c *ApiController) GetLatestNode() {
c.ResponseOk(res)
}
// @Title GetHotNod
// @Tag Node API
// @router /get-hot-node [get]
func (c *ApiController) GetHotNode() {
limitStr := c.Input().Get("limit")
defaultLimit := object.HotNodeNum
@ -165,6 +199,9 @@ func (c *ApiController) GetHotNode() {
c.ResponseOk(res)
}
// @Title AddNodeBrowseCount
// @Tag Node API
// @router /add-node-browse-record [post]
func (c *ApiController) AddNodeBrowseCount() {
nodeId := c.Input().Get("id")
@ -187,6 +224,9 @@ func (c *ApiController) AddNodeBrowseCount() {
c.ServeJSON()
}
// @Title AddNodeModerators
// @Tag Node API
// @router /add-node-moderators [post]
func (c *ApiController) AddNodeModerators() {
if c.RequireAdmin() {
return
@ -212,6 +252,9 @@ func (c *ApiController) AddNodeModerators() {
}
}
// @Title DeleteNodeModerators
// @Tag Node API
// @router /delete-node-moderators [post]
func (c *ApiController) DeleteNodeModerators() {
if c.RequireAdmin() {
return

View File

@ -55,6 +55,9 @@ func (c *ApiController) AddNotification() {
c.ServeJSON()
}
// @router /get-notifications [get]
// @Title GetNotifications
// @Tag Notification API
func (c *ApiController) GetNotifications() {
memberId := c.GetSessionUsername()
limitStr := c.Input().Get("limit")
@ -77,6 +80,9 @@ func (c *ApiController) GetNotifications() {
c.ResponseOk(res, num)
}
// @Title DeleteNotification
// @router /delete-notifications [get]
// @Tag Notification API
func (c *ApiController) DeleteNotification() {
id := c.Input().Get("id")
@ -84,6 +90,9 @@ func (c *ApiController) DeleteNotification() {
c.ResponseOk(res)
}
// @Title GetUnreadNotificationNum
// @router /get-unread-notification-num [post]
// @Tag Notification API
func (c *ApiController) GetUnreadNotificationNum() {
memberId := c.GetSessionUsername()
@ -91,6 +100,9 @@ func (c *ApiController) GetUnreadNotificationNum() {
c.ResponseOk(res)
}
// @Title UpdateReadStatus
// @router /update-read-status [post]
// @Tag Notification API
func (c *ApiController) UpdateReadStatus() {
memberId := c.GetSessionUsername()

View File

@ -26,11 +26,17 @@ func (c *ApiController) GetPlanes() {
c.ServeJSON()
}
// @Title GetPlanesAdmin
// @router /get-planes-admin [get]
// @Tag Plane API
func (c *ApiController) GetPlanesAdmin() {
c.Data["json"] = object.GetAllPlanes()
c.ServeJSON()
}
// @Title GetPlane
// @router /get-plane [get]
// @Tag Plane API
func (c *ApiController) GetPlane() {
id := c.Input().Get("id")
@ -38,6 +44,9 @@ func (c *ApiController) GetPlane() {
c.ServeJSON()
}
// @Title GetPlaneAdmin
// @router /get-planes-admin [get]
// @Tag Plane API
func (c *ApiController) GetPlaneAdmin() {
id := c.Input().Get("id")
@ -45,10 +54,16 @@ func (c *ApiController) GetPlaneAdmin() {
c.ServeJSON()
}
// @Title GetPlaneLis
// @router /get-plane-list [get]
// @Tag Plane API
func (c *ApiController) GetPlaneList() {
c.ResponseOk(object.GetPlaneList())
}
// @Title AddPlane
// @router /add-plane [post]
// @Tag Plane API
func (c *ApiController) AddPlane() {
if c.RequireAdmin() {
return
@ -90,6 +105,9 @@ func (c *ApiController) AddPlane() {
c.ResponseOk(res)
}
// @Title UpdatePlane
// @router /update-plane [post]
// @Tag Plane API
func (c *ApiController) UpdatePlane() {
if c.RequireAdmin() {
return
@ -117,6 +135,9 @@ func (c *ApiController) UpdatePlane() {
c.ResponseOk(res)
}
// @Title DeletePlane
// @router /delete-plane [post]
// @Tag Plane API
func (c *ApiController) DeletePlane() {
if c.RequireAdmin() {
return

View File

@ -24,6 +24,7 @@ import (
// @Description update poster message
// @Success 200 {object} controllers.Response The Response object
// @router /update-poster [post]
// @Tag Poster API
func (c *ApiController) UpdatePoster() {
if c.RequireAdmin() {
return
@ -45,6 +46,7 @@ func (c *ApiController) UpdatePoster() {
// @Param id query string true "id"
// @Success 200 {object} object.Poster The Response object
// @router /read-poster [get]
// @Tag Poster API
func (c *ApiController) ReadPoster() {
n := c.Input().Get("id")
res := object.GetPoster(n)

View File

@ -27,6 +27,9 @@ type NewReplyForm struct {
TopicId int `json:"topicId"`
}
// @Title GetReplies
// @Tag Reply API
// @router /get-replies [get]
func (c *ApiController) GetReplies() {
user := c.GetSessionUser()
@ -64,6 +67,9 @@ func (c *ApiController) GetReplies() {
c.ServeJSON()
}
// @Title GetAllRepliesOfTopic
// @Tag Reply API
// @router /get-replies-of-topic [get]
func (c *ApiController) GetAllRepliesOfTopic() {
topicId := util.ParseInt(c.Input().Get("topicId"))
replies := object.GetRepliesOfTopic(topicId)
@ -71,6 +77,9 @@ func (c *ApiController) GetAllRepliesOfTopic() {
c.ServeJSON()
}
// @Title GetReply
// @Tag Reply API
// @router /get-reply [get]
func (c *ApiController) GetReply() {
idStr := c.Input().Get("id")
@ -80,6 +89,9 @@ func (c *ApiController) GetReply() {
c.ServeJSON()
}
// @Title GetReplyWithDetails
// @Tag Reply API
// @router /get-reply-with-details [get]
func (c *ApiController) GetReplyWithDetails() {
user := c.GetSessionUser()
@ -91,6 +103,9 @@ func (c *ApiController) GetReplyWithDetails() {
c.ServeJSON()
}
// @Title UpdateReply
// @Tag Reply API
// @router /update-reply [post]
func (c *ApiController) UpdateReply() {
idStr := c.Input().Get("id")
@ -105,6 +120,9 @@ func (c *ApiController) UpdateReply() {
c.ServeJSON()
}
// @Title AddReply
// @Tag Reply API
// @router /add-reply [post]
func (c *ApiController) AddReply() {
if c.RequireSignedIn() {
return
@ -155,6 +173,9 @@ func (c *ApiController) AddReply() {
c.ResponseOk(affected)
}
// @Title DeleteReply
// @Tag Reply API
// @router /delete-reply [post]
func (c *ApiController) DeleteReply() {
id := util.ParseInt(c.Input().Get("id"))
@ -183,6 +204,9 @@ func (c *ApiController) DeleteReply() {
c.ResponseOk(affected)
}
// @Title GetLatestReplies
// @Tag Reply API
// @router /get-latest-replies [get]
func (c *ApiController) GetLatestReplies() {
id := c.Input().Get("id")
limitStr := c.Input().Get("limit")
@ -211,8 +235,10 @@ func (c *ApiController) GetLatestReplies() {
c.Data["json"] = object.GetLatestReplies(id, limit, offset)
c.ServeJSON()
}
// GetRepliesNum gets member's all replies num.
// @Title GetMemberRepliesNum
// @Tag Reply API
// @router /get-member-replies-num [get]
// @Description GetRepliesNum gets member's all replies num.
func (c *ApiController) GetMemberRepliesNum() {
id := c.Input().Get("id")

View File

@ -16,6 +16,9 @@ package controllers
import "github.com/casbin/casnode/object"
// @Title Search
// @router /search
// @Tag Search API
func (c *ApiController) Search() {
keyword := c.Input().Get("keyword")

View File

@ -18,6 +18,9 @@ import (
"github.com/casbin/casnode/object"
)
// @Title AddSensitive
// @router /add-sensitive [get]
// @Tag Seneistive API
func (c *ApiController) AddSensitive() {
if c.RequireAdmin() {
return
@ -42,6 +45,9 @@ func (c *ApiController) AddSensitive() {
c.ResponseOk()
}
// @Title DelSensitive
// @router /del-sensitive [get]
// @Tag Seneistive API
func (c *ApiController) DelSensitive() {
if c.RequireAdmin() {
return
@ -62,6 +68,9 @@ func (c *ApiController) DelSensitive() {
c.ResponseOk()
}
// @Title GetSensitive
// @router /get-sensitive [get]
// @Tag Seneistive API
func (c *ApiController) GetSensitive() {
c.Data["json"] = object.GetSensitiveWords()
c.ServeJSON()

View File

@ -21,21 +21,33 @@ import (
"github.com/casbin/casnode/util"
)
// @router /get-tabs [get]
// @Title GetTabs
// @Tag Tab API
func (c *ApiController) GetTabs() {
c.Data["json"] = object.GetHomePageTabs()
c.ServeJSON()
}
// @router /get-all-tabs [get]
// @Title GetAllTabs
// @Tag Tab API
func (c *ApiController) GetAllTabs() {
c.Data["json"] = object.GetAllTabs()
c.ServeJSON()
}
// @router /get-tabs-admin [get]
// @Title GetAllTabsAdmin
// @Tag Tab API
func (c *ApiController) GetAllTabsAdmin() {
c.Data["json"] = object.GetAllTabsAdmin()
c.ServeJSON()
}
// @router /get-tabs-admin [get]
// @Title GetTabAdmin
// @Tag Tab API
func (c *ApiController) GetTabAdmin() {
id := c.Input().Get("id")
@ -43,6 +55,9 @@ func (c *ApiController) GetTabAdmin() {
c.ServeJSON()
}
// @router /get-tabs-admin [get]
// @Title AddTab
// @Tag Tab API
func (c *ApiController) AddTab() {
if c.RequireAdmin() {
return
@ -82,6 +97,9 @@ func (c *ApiController) AddTab() {
c.ResponseOk(res)
}
// @router /update-tab [post]
// @Title UpdateTab
// @Tag Tab API
func (c *ApiController) UpdateTab() {
if c.RequireAdmin() {
return
@ -108,6 +126,9 @@ func (c *ApiController) UpdateTab() {
c.ResponseOk(res)
}
// @router /delete-tab [post]
// @Title DeleteTab
// @Tag Tab API
func (c *ApiController) DeleteTab() {
if c.RequireAdmin() {
return
@ -120,6 +141,9 @@ func (c *ApiController) DeleteTab() {
c.ServeJSON()
}
// @router /get-tab-with-nodes [get]
// @Title GetTabWithNodes
// @Tag Tab API
func (c *ApiController) GetTabWithNodes() {
id := c.Input().Get("id")

View File

@ -41,6 +41,7 @@ type NewTopicForm struct {
// @Param page query string true "offset"
// @Success 200 {array} object.TopicWithAvatar The Response object
// @router /get-topics [get]
// @Tag Topic API
func (c *ApiController) GetTopics() {
limitStr := c.Input().Get("limit")
pageStr := c.Input().Get("page")
@ -77,6 +78,7 @@ func (c *ApiController) GetTopics() {
// @Param fcs query string true "sort: favorite count"
// @Success 200 {object} controllers.Response The Response object
// @router /get-topics-admin [get]
// @Tag Topic API
func (c *ApiController) GetTopicsAdmin() {
limitStr := c.Input().Get("limit")
pageStr := c.Input().Get("page")
@ -118,6 +120,7 @@ func (c *ApiController) GetTopicsAdmin() {
// @Param id query string true "id"
// @Success 200 {object} object.TopicWithAvatar The Response object
// @router /get-topic [get]
// @Tag Topic API
func (c *ApiController) GetTopic() {
user := c.GetSessionUser()
@ -143,6 +146,7 @@ func (c *ApiController) GetTopic() {
//@Param id query string true "id"
// @Success 200 {object} object.AdminTopicInfo The Response object
// @router /get-topic-admin [get]
// @Tag Topic API
func (c *ApiController) GetTopicAdmin() {
idStr := c.Input().Get("id")
@ -171,6 +175,7 @@ func (c *ApiController) UpdateTopic() {
// @Param form body controllers.NewTopicForm true "topic info"
// @Success 200 {object} controllers.Response The Response object
// @router /add-topic [post]
// @Tag Topic API
func (c *ApiController) AddTopic() {
if c.RequireSignedIn() {
return
@ -266,6 +271,7 @@ func (c *ApiController) AddTopic() {
// @Param pic formData string true "the picture base64 code"
// @Success 200 {object} _controllers.Response The Response object
// @router /upload-topic-pic [post]
// @Tag Topic API
func (c *ApiController) UploadTopicPic() {
if c.RequireSignedIn() {
return
@ -294,6 +300,7 @@ func (c *ApiController) UploadTopicPic() {
// @Param id query string true "topic id"
// @Success 200 {bool} bool Delete success or failure
// @router /delete-topic [post]
// @Tag Topic API
func (c *ApiController) DeleteTopic() {
idStr := c.Input().Get("id")
user := c.GetSessionUser()
@ -315,6 +322,7 @@ func (c *ApiController) DeleteTopic() {
// @Description get the total number of topics
// @Success 200 {int} int The topic nums
// @router /get-topics-num [get]
// @Tag Topic API
func (c *ApiController) GetTopicsNum() {
c.Data["json"] = object.GetTopicNum()
c.ServeJSON()
@ -328,6 +336,7 @@ func (c *ApiController) GetTopicsNum() {
// @Param page query string true "page offset"
// @Success 200 {array} object.Topic The Response object
// @router /get-all-created-topics [get]
// @Tag Topic API
func (c *ApiController) GetAllCreatedTopics() {
author := c.Input().Get("id")
tab := c.Input().Get("tab")
@ -362,6 +371,7 @@ func (c *ApiController) GetAllCreatedTopics() {
// @Param id query string true "member id"
// @Success 200 {int} int topics count
// @router /get-created-topics-num [get]
// @Tag Topic API
func (c *ApiController) GetCreatedTopicsNum() {
memberId := c.Input().Get("id")
@ -376,6 +386,7 @@ func (c *ApiController) GetCreatedTopicsNum() {
// @Param page query string true "page offset"
// @Success 200 {array} object.NodeTopic The Response object
// @router /get-topics-by-node [get]
// @Tag Topic API
func (c *ApiController) GetTopicsByNode() {
nodeId := c.Input().Get("node-id")
limitStr := c.Input().Get("limit")
@ -404,6 +415,7 @@ func (c *ApiController) GetTopicsByNode() {
// @Param page query string true "page offset"
// @Success 200 {array} object.NodeTopic The Response object
// @router /get-topics-by-tag [get]
// @Tag Topic API
func (c *ApiController) GetTopicsByTag() {
tagId := c.Input().Get("tag-id")
limitStr := c.Input().Get("limit")
@ -430,6 +442,7 @@ func (c *ApiController) GetTopicsByTag() {
// @Param id query string true "topic id"
// @Success 200 {object} controller.Response The Response object
// @router /add-topic-hit-count [post]
// @Tag Topic API
func (c *ApiController) AddTopicHitCount() {
topicIdStr := c.Input().Get("id")
@ -462,6 +475,7 @@ func (c *ApiController) AddTopicHitCount() {
// @Param page query string true "page offset"
// @Success 200 {array} object.TopicWithAvatar The Response object
// @router /get-topics-by-tab [get]
// @Tag Topic API
func (c *ApiController) GetTopicsByTab() {
tabId := c.Input().Get("tab-id")
limitStr := c.Input().Get("limit")
@ -488,6 +502,7 @@ func (c *ApiController) GetTopicsByTab() {
// @Param id query string true "topicId"
// @Success 200 {object} controller.Response The Response object
// @router /add-topic-browse-record [post]
// @Tag Topic API
func (c *ApiController) AddTopicBrowseCount() {
topicId := c.Input().Get("id")
@ -515,6 +530,7 @@ func (c *ApiController) AddTopicBrowseCount() {
// @Param limit query string true "limit size"
// @Success 200 {object} controller.Response The Response object
// @router /get-hot-topic [get]
// @Tag Topic API
func (c *ApiController) GetHotTopic() {
limitStr := c.Input().Get("limit")
defaultLimit := object.HotTopicNum
@ -541,6 +557,7 @@ func (c *ApiController) GetHotTopic() {
// @Param limit query string true "limit size"
// @Success 200 {object} controller.Response The Response object
// @router /get-hot-topic [get]
// @Tag Topic API
func (c *ApiController) GetSortedTopics() {
limitStr := c.Input().Get("limit")
pageStr := c.Input().Get("page")
@ -572,6 +589,7 @@ func (c *ApiController) GetSortedTopics() {
// @Param updateTopicNode body controllers.updateTopicNode true "topic node info"
// @Success 200 {object} controllers.Response The Response object
// @router /update-topic-node [post]
// @Tag Topic API
func (c *ApiController) UpdateTopicNode() {
if c.RequireSignedIn() {
return
@ -614,6 +632,7 @@ func (c *ApiController) UpdateTopicNode() {
// @Param editType query string true "edit Type"
// @Success 200 {object} controllers.Response The Response object
// @router /edit-content [post]
// @Tag Topic API
func (c *ApiController) EditContent() {
if c.RequireSignedIn() {
return
@ -675,6 +694,9 @@ func (c *ApiController) EditContent() {
c.ServeJSON()
}
// @Title TranslateTopic
// @router /translate-topic [get]
// @Tag Topic API
func (c *ApiController) TranslateTopic() {
topicIdStr := c.Input().Get("id")
targetLang := c.Input().Get("target")
@ -705,6 +727,7 @@ func (c *ApiController) TranslateTopic() {
// @Param id query string true "id"
// @Success 200 {object} controllers.Response The Response object
// @router /top-topic [post]
// @Tag Topic API
func (c *ApiController) TopTopic() {
if c.RequireSignedIn() {
return
@ -750,6 +773,7 @@ func (c *ApiController) TopTopic() {
// @Param id query string true "id"
// @Success 200 {object} controllers.Response The Response object
// @router /cancel-top-topic [post]
// @Tag Topic API
func (c *ApiController) CancelTopTopic() {
if c.RequireSignedIn() {
return
@ -778,6 +802,9 @@ func (c *ApiController) CancelTopTopic() {
c.ServeJSON()
}
// @Title GetTopicByUrlPathAndTitle
// @router /get-topic-by-urlpath-and-title [get]
// @Tag Topic API
func (c *ApiController) GetTopicByUrlPathAndTitle() {
urlPath := c.Input().Get("urlPath")
title := c.Input().Get("title")

View File

@ -6,6 +6,9 @@ import (
"github.com/casbin/casnode/object"
)
// @router /update-translator [post]
// @Title UpdateTranslator
// @Tag Translator API
func (c *ApiController) UpdateTranslator() {
if c.RequireAdmin() {
return
@ -21,6 +24,9 @@ func (c *ApiController) UpdateTranslator() {
c.ResponseOk()
}
// @router /add-translator [post]
// @Title AddTranslator
// @Tag Translator API
func (c *ApiController) AddTranslator() {
if c.RequireAdmin() {
return
@ -52,6 +58,9 @@ func (c *ApiController) AddTranslator() {
}
}
// @router /get-translator [get]
// @Title GetTranslator
// @Tag Translator API
func (c *ApiController) GetTranslator() {
id := c.Input().Get("id")
res := object.GetTranslator(id)
@ -67,6 +76,9 @@ func (c *ApiController) GetEnableTranslator() {
c.ServeJSON()
}
// @router /visible-translator [get]
// @Title VisibleTranslator
// @Tag Translator API
func (c *ApiController) VisibleTranslator() {
c.ResponseOk(false)
@ -78,6 +90,9 @@ func (c *ApiController) VisibleTranslator() {
}
}
// @router /del-translator [post]
// @Title DelTranslator
// @Tag Translator API
func (c *ApiController) DelTranslator() {
id := c.Input().Get("id")
resp := Response{Status: "fail", Msg: "Delete translator failed"}

3
go.mod
View File

@ -4,9 +4,7 @@ go 1.16
require (
github.com/adamzy/cedar-go v0.0.0-20170805034717-80a9c64b256d // indirect
github.com/aliyun/aliyun-oss-go-sdk v2.1.10+incompatible
github.com/astaxie/beego v1.12.3
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
github.com/casbin/google-groups-crawler v0.1.3
github.com/casdoor/casdoor-go-sdk v0.1.5
github.com/chromedp/chromedp v0.6.10
@ -22,7 +20,6 @@ require (
github.com/mozillazg/go-slugify v0.2.0
github.com/mozillazg/go-unidecode v0.1.1 // indirect
github.com/prometheus/client_golang v1.11.0 // indirect
github.com/satori/go.uuid v1.2.0 // indirect
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 // indirect
github.com/stretchr/testify v1.7.0 // indirect
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect

3
go.sum
View File

@ -289,8 +289,6 @@ github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3x
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18 h1:DAYUYH5869yV94zvCES9F51oYtN5oGlwjxJJz7ZCnik=
github.com/shiena/ansicolor v0.0.0-20200904210342-c7312218db18/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
@ -464,7 +462,6 @@ golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

View File

@ -49,7 +49,10 @@ func GetReplyCount() int {
return int(count)
}
// GetReplies returns more information about reply of a topic.
// @Title GetReplies
// @router /get-replies [get]
// @Description GetReplies returns more information about reply of a topic.
// @Tag Reply API
func GetReplies(topicId int, user *auth.User, limit int, page int) ([]*ReplyWithAvatar, int) {
replies := []*ReplyWithAvatar{}
realPage := page

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff