swagger docs

This commit is contained in:
wangchuxiao
2022-06-29 11:18:19 +08:00
parent 5213860919
commit 0c7f57d55d
13 changed files with 10383 additions and 79 deletions
+151 -7
View File
@@ -16,6 +16,18 @@ import (
"strings"
)
// @Summary 添加黑名单
// @Description 添加黑名单
// @Tags 好友相关
// @ID AddBlack
// @Accept json
// @Param token header string true "im token"
// @Param req body api.AddBlacklistReq true "fromUserID为设置的用户, toUserID为被设置的用户"
// @Produce json
// @Success 0 {object} api.AddBlacklistResp
// @Failure 500 {object} api.AddBlacklistResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.AddBlacklistResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /friend/add_black [post]
func AddBlack(c *gin.Context) {
params := api.AddBlacklistReq{}
if err := c.BindJSON(&params); err != nil {
@@ -49,6 +61,18 @@ func AddBlack(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 批量加好友
// @Description 批量加好友
// @Tags 好友相关
// @ID ImportFriend
// @Accept json
// @Param token header string true "im token"
// @Param req body api.ImportFriendReq true "fromUserID批量加好友的用户ID, friendUserIDList为"
// @Produce json
// @Success 0 {object} api.ImportFriendResp "data列表中对象的result-1为添加该用户失败, 0为成功"
// @Failure 500 {object} api.ImportFriendResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.ImportFriendResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /friend/import_friend [post]
func ImportFriend(c *gin.Context) {
params := api.ImportFriendReq{}
if err := c.BindJSON(&params); err != nil {
@@ -97,6 +121,18 @@ func ImportFriend(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 添加好友
// @Description 添加好友
// @Tags 好友相关
// @ID AddFriend
// @Accept json
// @Param token header string true "im token"
// @Param req body api.AddFriendReq true "reqMsg为申请信息, fromUserID为申请用户, toUserID为被添加用户"
// @Produce json
// @Success 0 {object} api.AddFriendResp
// @Failure 500 {object} api.AddFriendResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.AddFriendResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /friend/add_friend [post]
func AddFriend(c *gin.Context) {
params := api.AddFriendReq{}
if err := c.BindJSON(&params); err != nil {
@@ -114,7 +150,7 @@ func AddFriend(c *gin.Context) {
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
return
}
@@ -140,6 +176,18 @@ func AddFriend(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 同意/拒绝好友请求
// @Description 同意/拒绝好友请求
// @Tags 好友相关
// @ID AddFriendResponse
// @Accept json
// @Param token header string true "im token"
// @Param req body api.AddFriendResponseReq true "fromUserID同意/拒绝的用户ID, toUserID为申请用户, handleMsg为处理信息, flag为具体操作, 1为同意, 2为拒绝"
// @Produce json
// @Success 0 {object} api.AddFriendResponseResp
// @Failure 500 {object} api.AddFriendResponseResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.AddFriendResponseResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /friend/add_friend_response [post]
func AddFriendResponse(c *gin.Context) {
params := api.AddFriendResponseReq{}
if err := c.BindJSON(&params); err != nil {
@@ -158,7 +206,7 @@ func AddFriendResponse(c *gin.Context) {
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
return
}
@@ -186,6 +234,18 @@ func AddFriendResponse(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 删除好友
// @Description 删除好友
// @Tags 好友相关
// @ID DeleteFriend
// @Accept json
// @Param token header string true "im token"
// @Param req body api.DeleteFriendReq true "fromUserID为操作用户, toUserID为被删除用户"
// @Produce json
// @Success 0 {object} api.DeleteFriendResp
// @Failure 500 {object} api.DeleteFriendResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.DeleteFriendResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /friend/delete_friend [post]
func DeleteFriend(c *gin.Context) {
params := api.DeleteFriendReq{}
if err := c.BindJSON(&params); err != nil {
@@ -228,6 +288,18 @@ func DeleteFriend(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 获取黑名单列表
// @Description 获取黑名单列表
// @Tags 好友相关
// @ID GetBlacklist
// @Accept json
// @Param token header string true "im token"
// @Param req body api.GetBlackListReq true "fromUserID要获取黑名单的用户"
// @Produce json
// @Success 0 {object} api.GetBlackListResp
// @Failure 500 {object} api.GetBlackListResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.GetBlackListResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /friend/get_black_list [post]
func GetBlacklist(c *gin.Context) {
params := api.GetBlackListReq{}
if err := c.BindJSON(&params); err != nil {
@@ -244,7 +316,7 @@ func GetBlacklist(c *gin.Context) {
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@@ -276,6 +348,18 @@ func GetBlacklist(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 设置好友备注
// @Description 设置好友备注
// @Tags 好友相关
// @ID SetFriendRemark
// @Accept json
// @Param token header string true "im token"
// @Param req body api.SetFriendRemarkReq true "fromUserID为设置的用户, toUserID为被设置的用户, remark为好友备注"
// @Produce json
// @Success 0 {object} api.SetFriendRemarkResp
// @Failure 500 {object} api.SetFriendRemarkResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.SetFriendRemarkResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /friend/set_friend_remark [post]
func SetFriendRemark(c *gin.Context) {
params := api.SetFriendRemarkReq{}
if err := c.BindJSON(&params); err != nil {
@@ -319,6 +403,18 @@ func SetFriendRemark(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 把用户移除黑名单
// @Description 把用户移除黑名单
// @Tags 好友相关
// @ID RemoveBlack
// @Accept json
// @Param token header string true "im token"
// @Param req body api.RemoveBlackListReq true "fromUserID要获取黑名单的用户"
// @Produce json
// @Success 0 {object} api.RemoveBlackListResp
// @Failure 500 {object} api.RemoveBlackListResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.RemoveBlackListResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /friend/remove_black [post]
func RemoveBlack(c *gin.Context) {
params := api.RemoveBlackListReq{}
if err := c.BindJSON(&params); err != nil {
@@ -335,7 +431,7 @@ func RemoveBlack(c *gin.Context) {
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@@ -360,6 +456,18 @@ func RemoveBlack(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 检查用户之间是否为好友
// @Description 检查用户之间是否为好友
// @Tags 好友相关
// @ID IsFriend
// @Accept json
// @Param token header string true "im token"
// @Param req body api.IsFriendReq true "fromUserID为请求用户, toUserID为要检查的用户"
// @Produce json
// @Success 0 {object} api.IsFriendResp
// @Failure 500 {object} api.IsFriendResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.IsFriendResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /friend/is_friend [post]
func IsFriend(c *gin.Context) {
params := api.IsFriendReq{}
if err := c.BindJSON(&params); err != nil {
@@ -376,7 +484,7 @@ func IsFriend(c *gin.Context) {
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": errMsg})
return
}
@@ -403,6 +511,18 @@ func IsFriend(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 获取用户的好友列表
// @Description 获取用户的好友列表
// @Tags 好友相关
// @ID GetFriendList
// @Accept json
// @Param token header string true "im token"
// @Param req body api.GetFriendListReq true "fromUserID为要获取好友列表的用户ID"
// @Produce json
// @Success 0 {object} api.GetFriendListResp
// @Failure 500 {object} api.GetFriendListResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.GetFriendListResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /friend/get_friend_list [post]
func GetFriendList(c *gin.Context) {
params := api.GetFriendListReq{}
if err := c.BindJSON(&params); err != nil {
@@ -447,6 +567,18 @@ func GetFriendList(c *gin.Context) {
//c.JSON(http.StatusOK, resp)
}
// @Summary 获取好友申请列表
// @Description 删除好友
// @Tags 好友相关
// @ID GetFriendApplyList
// @Accept json
// @Param token header string true "im token"
// @Param req body api.GetFriendApplyListReq true "fromUserID为要获取申请列表的用户ID"
// @Produce json
// @Success 0 {object} api.GetFriendApplyListResp
// @Failure 500 {object} api.GetFriendApplyListResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.GetFriendApplyListResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /friend/get_friend_apply_list [post]
func GetFriendApplyList(c *gin.Context) {
params := api.GetFriendApplyListReq{}
if err := c.BindJSON(&params); err != nil {
@@ -463,7 +595,7 @@ func GetFriendApplyList(c *gin.Context) {
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@@ -491,6 +623,18 @@ func GetFriendApplyList(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 获取自己的好友申请列表
// @Description 获取自己的好友申请列表
// @Tags 好友相关
// @ID GetSelfFriendApplyList
// @Accept json
// @Param token header string true "im token"
// @Param req body api.GetSelfApplyListReq true "fromUserID为自己的用户ID"
// @Produce json
// @Success 0 {object} api.GetSelfApplyListResp
// @Failure 500 {object} api.GetSelfApplyListResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.GetSelfApplyListResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /friend/get_self_friend_apply_list [post]
func GetSelfFriendApplyList(c *gin.Context) {
params := api.GetSelfApplyListReq{}
if err := c.BindJSON(&params); err != nil {
@@ -507,7 +651,7 @@ func GetSelfFriendApplyList(c *gin.Context) {
if !ok {
errMsg := req.CommID.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.CommID.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}