swagger doc

pull/241/head
wangchuxiao 2 years ago
parent 226108f558
commit 5207e268de

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -64,6 +64,19 @@ func DeleteUser(c *gin.Context) {
log.NewInfo(req.OperationID, "DeleteUser api return", resp)
c.JSON(http.StatusOK, resp)
}
// @Summary 获取所有用户uid列表
// @Description 获取所有用户uid列表
// @Tags 用户相关
// @ID GetAllUsersUid
// @Accept json
// @Param token header string true "im token"
// @Param req body api.GetAllUsersUidReq true "请求体"
// @Produce json
// @Success 0 {object} api.GetAllUsersUidResp
// @Failure 500 {object} api.GetAllUsersUidResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.GetAllUsersUidResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /user/get_all_users_uid [post]
func GetAllUsersUid(c *gin.Context) {
params := api.GetAllUsersUidReq{}
if err := c.BindJSON(&params); err != nil {
@ -79,7 +92,7 @@ func GetAllUsersUid(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@ -106,6 +119,19 @@ func GetAllUsersUid(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 检查列表账户注册状态,并且返回结果
// @Description 传入UserIDList检查列表账户注册状态并且返回结果
// @Tags 用户相关
// @ID AccountCheck
// @Accept json
// @Param token header string true "im token"
// @Param req body api.AccountCheckReq true "请求体"
// @Produce json
// @Success 0 {object} api.AccountCheckResp
// @Failure 500 {object} api.AccountCheckResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.AccountCheckResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /user/account_check [post]
func AccountCheck(c *gin.Context) {
params := api.AccountCheckReq{}
if err := c.BindJSON(&params); err != nil {
@ -121,7 +147,7 @@ func AccountCheck(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}

@ -1,7 +1,7 @@
package office
import (
apistruct "Open_IM/pkg/base_info"
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
@ -16,10 +16,22 @@ import (
"strings"
)
// @Summary 获取用户标签信息
// @Description 用户获取自己的所有的标签
// @Tags 标签
// @ID GetUserTags
// @Accept json
// @Param token header string true "im token"
// @Param req body api.GetUserTagsReq true "请求"
// @Produce json
// @Success 0 {object} api.GetUserTagsResp
// @Failure 500 {object} api.GetUserTagsResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.GetUserTagsResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/get_user_tags [post]
func GetUserTags(c *gin.Context) {
var (
req apistruct.GetUserTagsReq
resp apistruct.GetUserTagsResp
req api.GetUserTagsReq
resp api.GetUserTagsResp
reqPb pbOffice.GetUserTagsReq
respPb *pbOffice.GetUserTagsResp
)
@ -36,7 +48,7 @@ func GetUserTags(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@ -67,10 +79,22 @@ func GetUserTags(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 创建标签
// @Description 创建标签
// @Tags 标签
// @ID CreateTag
// @Accept json
// @Param token header string true "im token"
// @Param req body api.CreateTagReq true "请求"
// @Produce json
// @Success 0 {object} api.CreateTagResp
// @Failure 500 {object} api.CreateTagResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.CreateTagResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/create_tag [post]
func CreateTag(c *gin.Context) {
var (
req apistruct.CreateTagReq
resp apistruct.CreateTagResp
req api.CreateTagReq
resp api.CreateTagResp
reqPb pbOffice.CreateTagReq
respPb *pbOffice.CreateTagResp
)
@ -90,7 +114,7 @@ func CreateTag(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@ -115,10 +139,22 @@ func CreateTag(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 删除标签
// @Description 根据标签ID创建标签
// @Tags 标签
// @ID DeleteTag
// @Accept json
// @Param token header string true "im token"
// @Param req body api.DeleteTagReq true "请求"
// @Produce json
// @Success 0 {object} api.DeleteTagResp
// @Failure 500 {object} api.DeleteTagResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.DeleteTagResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/delete_tag [post]
func DeleteTag(c *gin.Context) {
var (
req apistruct.DeleteTagReq
resp apistruct.DeleteTagResp
req api.DeleteTagReq
resp api.DeleteTagResp
reqPb pbOffice.DeleteTagReq
respPb *pbOffice.DeleteTagResp
)
@ -138,7 +174,7 @@ func DeleteTag(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@ -163,10 +199,22 @@ func DeleteTag(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 修改标签
// @Description 根据标签ID修改标签用户列表, 名称
// @Tags 标签
// @ID SetTag
// @Accept json
// @Param token header string true "im token"
// @Param req body api.SetTagReq true "请求"
// @Produce json
// @Success 0 {object} api.SetTagResp
// @Failure 500 {object} api.SetTagResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.SetTagResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/set_tag [post]
func SetTag(c *gin.Context) {
var (
req apistruct.SetTagReq
resp apistruct.SetTagResp
req api.SetTagReq
resp api.SetTagResp
reqPb pbOffice.SetTagReq
respPb *pbOffice.SetTagResp
)
@ -211,10 +259,22 @@ func SetTag(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 发送标签消息
// @Description 对标签用户发送消息
// @Tags 标签
// @ID SendMsg2Tag
// @Accept json
// @Param token header string true "im token"
// @Param req body api.SendMsg2TagReq true "请求"
// @Produce json
// @Success 0 {object} api.SendMsg2TagResp
// @Failure 500 {object} api.SendMsg2TagResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.SendMsg2TagResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/send_msg_to_tag [post]
func SendMsg2Tag(c *gin.Context) {
var (
req apistruct.SendMsg2TagReq
resp apistruct.SendMsg2TagResp
req api.SendMsg2TagReq
resp api.SendMsg2TagResp
reqPb pbOffice.SendMsg2TagReq
respPb *pbOffice.SendMsg2TagResp
)
@ -234,7 +294,7 @@ func SendMsg2Tag(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@ -259,10 +319,22 @@ func SendMsg2Tag(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 获取发送历史记录
// @Description 分页获取发送历史记录
// @Tags 标签
// @ID GetTagSendLogs
// @Accept json
// @Param token header string true "im token"
// @Param req body api.GetTagSendLogsReq true "请求"
// @Produce json
// @Success 0 {object} api.GetTagSendLogsResp
// @Failure 500 {object} api.GetTagSendLogsResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.GetTagSendLogsResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/get_send_tag_log [post]
func GetTagSendLogs(c *gin.Context) {
var (
req apistruct.GetTagSendLogsReq
resp apistruct.GetTagSendLogsResp
req api.GetTagSendLogsReq
resp api.GetTagSendLogsResp
reqPb pbOffice.GetTagSendLogsReq
respPb *pbOffice.GetTagSendLogsResp
)
@ -279,7 +351,7 @@ func GetTagSendLogs(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@ -293,7 +365,7 @@ func GetTagSendLogs(c *gin.Context) {
if etcdConn == nil {
errMsg := req.OperationID + "getcdv3.GetConn == nil"
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
client := pbOffice.NewOfficeServiceClient(etcdConn)
@ -317,10 +389,22 @@ func GetTagSendLogs(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 获取该用户的标签信息
// @Description 通过标签id获取该用户的标签信息
// @Tags 标签
// @ID GetUserTagByID
// @Accept json
// @Param token header string true "im token"
// @Param req body api.GetUserTagByIDReq true "请求"
// @Produce json
// @Success 0 {object} api.GetUserTagByIDResp
// @Failure 500 {object} api.GetUserTagByIDResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.GetUserTagByIDResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/get_user_tag_by_id [post]
func GetUserTagByID(c *gin.Context) {
var (
req apistruct.GetUserTagByIDReq
resp apistruct.GetUserTagByIDResp
req api.GetUserTagByIDReq
resp api.GetUserTagByIDResp
reqPb pbOffice.GetUserTagByIDReq
respPb *pbOffice.GetUserTagByIDResp
)
@ -337,7 +421,7 @@ func GetUserTagByID(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}

@ -1,7 +1,7 @@
package office
import (
apiStruct "Open_IM/pkg/base_info"
api "Open_IM/pkg/base_info"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/log"
"Open_IM/pkg/common/token_verify"
@ -15,10 +15,22 @@ import (
"strings"
)
// @Summary 创建一条工作圈
// @Description 用户创建一条工作圈
// @Tags 工作圈
// @ID CreateOneWorkMoment
// @Accept json
// @Param token header string true "im token"
// @Param req body api.CreateOneWorkMomentReq true "请求 atUserList likeUserList permissionGroupList permissionUserList 字段中userName可以不填"
// @Produce json
// @Success 0 {object} api.CreateOneWorkMomentResp
// @Failure 500 {object} api.CreateOneWorkMomentResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.CreateOneWorkMomentResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/create_one_work_moment [post]
func CreateOneWorkMoment(c *gin.Context) {
var (
req apiStruct.CreateOneWorkMomentReq
resp apiStruct.CreateOneWorkMomentResp
req api.CreateOneWorkMomentReq
resp api.CreateOneWorkMomentResp
reqPb pbOffice.CreateOneWorkMomentReq
respPb *pbOffice.CreateOneWorkMomentResp
)
@ -36,7 +48,7 @@ func CreateOneWorkMoment(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@ -59,7 +71,7 @@ func CreateOneWorkMoment(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "CreateOneWorkMoment rpc server failed" + err.Error()})
return
}
resp.CommResp = apiStruct.CommResp{
resp.CommResp = api.CommResp{
ErrCode: respPb.CommonResp.ErrCode,
ErrMsg: respPb.CommonResp.ErrMsg,
}
@ -67,10 +79,22 @@ func CreateOneWorkMoment(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 删除一条工作圈
// @Description 根据用户工作圈ID删除一条工作圈
// @Tags 工作圈
// @ID DeleteOneWorkMoment
// @Accept json
// @Param token header string true "im token"
// @Param req body api.DeleteOneWorkMomentReq true "请求"
// @Produce json
// @Success 0 {object} api.DeleteOneWorkMomentResp
// @Failure 500 {object} api.DeleteOneWorkMomentResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.DeleteOneWorkMomentResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/delete_one_work_moment [post]
func DeleteOneWorkMoment(c *gin.Context) {
var (
req apiStruct.DeleteOneWorkMomentReq
resp apiStruct.DeleteOneWorkMomentResp
req api.DeleteOneWorkMomentReq
resp api.DeleteOneWorkMomentResp
reqPb pbOffice.DeleteOneWorkMomentReq
respPb *pbOffice.DeleteOneWorkMomentResp
)
@ -88,7 +112,7 @@ func DeleteOneWorkMoment(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@ -118,10 +142,22 @@ func DeleteOneWorkMoment(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 点赞一条工作圈
// @Description 工作圈ID点赞一条工作圈
// @Tags 工作圈
// @ID LikeOneWorkMoment
// @Accept json
// @Param token header string true "im token"
// @Param req body api.LikeOneWorkMomentReq true "请求"
// @Produce json
// @Success 0 {object} api.LikeOneWorkMomentResp
// @Failure 500 {object} api.LikeOneWorkMomentResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.LikeOneWorkMomentResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/like_one_work_moment [post]
func LikeOneWorkMoment(c *gin.Context) {
var (
req apiStruct.LikeOneWorkMomentReq
resp apiStruct.LikeOneWorkMomentResp
req api.LikeOneWorkMomentReq
resp api.LikeOneWorkMomentResp
reqPb pbOffice.LikeOneWorkMomentReq
respPb *pbOffice.LikeOneWorkMomentResp
)
@ -168,10 +204,22 @@ func LikeOneWorkMoment(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 评论一条工作圈
// @Description 评论一条工作圈
// @Tags 工作圈
// @ID CommentOneWorkMoment
// @Accept json
// @Param token header string true "im token"
// @Param req body api.CommentOneWorkMomentReq true "请求"
// @Produce json
// @Success 0 {object} api.CommentOneWorkMomentResp
// @Failure 500 {object} api.CommentOneWorkMomentResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.CommentOneWorkMomentResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/comment_one_work_moment [post]
func CommentOneWorkMoment(c *gin.Context) {
var (
req apiStruct.CommentOneWorkMomentReq
resp apiStruct.CommentOneWorkMomentResp
req api.CommentOneWorkMomentReq
resp api.CommentOneWorkMomentResp
reqPb pbOffice.CommentOneWorkMomentReq
respPb *pbOffice.CommentOneWorkMomentResp
)
@ -218,10 +266,22 @@ func CommentOneWorkMoment(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 删除一条评论
// @Description 删除一条评论
// @Tags 工作圈
// @ID DeleteComment
// @Accept json
// @Param token header string true "im token"
// @Param req body api.DeleteCommentReq true "请求"
// @Produce json
// @Success 0 {object} api.DeleteCommentResp
// @Failure 500 {object} api.DeleteCommentResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.DeleteCommentResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/delete_comment [post]
func DeleteComment(c *gin.Context) {
var (
req apiStruct.DeleteCommentReq
resp apiStruct.DeleteCommentResp
req api.DeleteCommentReq
resp api.DeleteCommentResp
reqPb pbOffice.DeleteCommentReq
respPb *pbOffice.DeleteCommentResp
)
@ -266,10 +326,22 @@ func DeleteComment(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 通过ID获取工作圈
// @Description 通过ID获取工作圈
// @Tags 工作圈
// @ID GetWorkMomentByID
// @Accept json
// @Param token header string true "im token"
// @Param req body api.GetWorkMomentByIDReq true "请求"
// @Produce json
// @Success 0 {object} api.GetWorkMomentByIDResp
// @Failure 500 {object} api.GetWorkMomentByIDResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.GetWorkMomentByIDResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/get_work_moment_by_id [post]
func GetWorkMomentByID(c *gin.Context) {
var (
req apiStruct.GetWorkMomentByIDReq
resp apiStruct.GetWorkMomentByIDResp
req api.GetWorkMomentByIDReq
resp api.GetWorkMomentByIDResp
reqPb pbOffice.GetWorkMomentByIDReq
respPb *pbOffice.GetWorkMomentByIDResp
)
@ -311,8 +383,8 @@ func GetWorkMomentByID(c *gin.Context) {
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
resp.Data.WorkMoment = &apiStruct.WorkMoment{LikeUserList: []*apiStruct.WorkMomentUser{}, Comments: []*apiStruct.Comment{},
AtUserList: []*apiStruct.WorkMomentUser{}, PermissionUserList: []*apiStruct.WorkMomentUser{}}
resp.Data.WorkMoment = &api.WorkMoment{LikeUserList: []*api.WorkMomentUser{}, Comments: []*api.Comment{},
AtUserList: []*api.WorkMomentUser{}, PermissionUserList: []*api.WorkMomentUser{}}
if err := utils.CopyStructFields(&resp.Data.WorkMoment, respPb.WorkMoment); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
@ -320,10 +392,22 @@ func GetWorkMomentByID(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 查询用户工作圈
// @Description 查询用户工作圈
// @Tags 工作圈
// @ID GetUserWorkMoments
// @Accept json
// @Param token header string true "im token"
// @Param req body api.GetUserWorkMomentsReq true "请求"
// @Produce json
// @Success 0 {object} api.GetUserWorkMomentsResp
// @Failure 500 {object} api.GetUserWorkMomentsResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.GetUserWorkMomentsResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/get_user_work_moments [post]
func GetUserWorkMoments(c *gin.Context) {
var (
req apiStruct.GetUserWorkMomentsReq
resp apiStruct.GetUserWorkMomentsResp
req api.GetUserWorkMomentsReq
resp api.GetUserWorkMomentsResp
reqPb pbOffice.GetUserWorkMomentsReq
respPb *pbOffice.GetUserWorkMomentsResp
)
@ -366,29 +450,26 @@ func GetUserWorkMoments(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserWorkMoments rpc server failed" + err.Error()})
return
}
resp.Data.WorkMoments = []*apiStruct.WorkMoment{}
resp.Data.WorkMoments = []*api.WorkMoment{}
if err := utils.CopyStructFields(&resp, respPb.CommonResp); err != nil {
log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
}
//if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
// log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
//}
for _, v := range respPb.WorkMoments {
workMoment := apiStruct.WorkMoment{
workMoment := api.WorkMoment{
WorkMomentID: v.WorkMomentID,
UserID: v.UserID,
Content: v.Content,
FaceURL: v.FaceURL,
UserName: v.UserName,
CreateTime: v.CreateTime,
Comments: make([]*apiStruct.Comment, len(v.Comments)),
LikeUserList: make([]*apiStruct.WorkMomentUser, len(v.LikeUserList)),
AtUserList: make([]*apiStruct.WorkMomentUser, len(v.AtUserList)),
PermissionUserList: make([]*apiStruct.WorkMomentUser, len(v.PermissionUserList)),
Comments: make([]*api.Comment, len(v.Comments)),
LikeUserList: make([]*api.WorkMomentUser, len(v.LikeUserList)),
AtUserList: make([]*api.WorkMomentUser, len(v.AtUserList)),
PermissionUserList: make([]*api.WorkMomentUser, len(v.PermissionUserList)),
Permission: v.Permission,
}
for i, comment := range v.Comments {
workMoment.Comments[i] = &apiStruct.Comment{
workMoment.Comments[i] = &api.Comment{
UserID: comment.UserID,
UserName: comment.UserName,
ReplyUserID: comment.ReplyUserID,
@ -399,19 +480,19 @@ func GetUserWorkMoments(c *gin.Context) {
}
}
for i, likeUser := range v.LikeUserList {
workMoment.LikeUserList[i] = &apiStruct.WorkMomentUser{
workMoment.LikeUserList[i] = &api.WorkMomentUser{
UserID: likeUser.UserID,
UserName: likeUser.UserName,
}
}
for i, atUser := range v.AtUserList {
workMoment.AtUserList[i] = &apiStruct.WorkMomentUser{
workMoment.AtUserList[i] = &api.WorkMomentUser{
UserID: atUser.UserID,
UserName: atUser.UserName,
}
}
for i, permissionUser := range v.PermissionUserList {
workMoment.PermissionUserList[i] = &apiStruct.WorkMomentUser{
workMoment.PermissionUserList[i] = &api.WorkMomentUser{
UserID: permissionUser.UserID,
UserName: permissionUser.UserName,
}
@ -424,10 +505,22 @@ func GetUserWorkMoments(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 查询自己大工作圈页面
// @Description 查询用户工作圈页面
// @Tags 工作圈
// @ID GetUserFriendWorkMoments
// @Accept json
// @Param token header string true "im token"
// @Param req body api.GetUserFriendWorkMomentsReq true "请求"
// @Produce json
// @Success 0 {object} api.GetUserFriendWorkMomentsResp
// @Failure 500 {object} api.GetUserFriendWorkMomentsResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.GetUserFriendWorkMomentsResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /office/get_user_friend_work_moments [post]
func GetUserFriendWorkMoments(c *gin.Context) {
var (
req apiStruct.GetUserFriendWorkMomentsReq
resp apiStruct.GetUserFriendWorkMomentsResp
req api.GetUserFriendWorkMomentsReq
resp api.GetUserFriendWorkMomentsResp
reqPb pbOffice.GetUserFriendWorkMomentsReq
respPb *pbOffice.GetUserFriendWorkMomentsResp
)
@ -475,23 +568,23 @@ func GetUserFriendWorkMoments(c *gin.Context) {
//if err := utils.CopyStructFields(&resp.Data.WorkMoments, respPb.WorkMoments); err != nil {
// log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error())
//}
resp.Data.WorkMoments = []*apiStruct.WorkMoment{}
resp.Data.WorkMoments = []*api.WorkMoment{}
for _, v := range respPb.WorkMoments {
workMoment := apiStruct.WorkMoment{
workMoment := api.WorkMoment{
WorkMomentID: v.WorkMomentID,
UserID: v.UserID,
Content: v.Content,
FaceURL: v.FaceURL,
UserName: v.UserName,
CreateTime: v.CreateTime,
Comments: make([]*apiStruct.Comment, len(v.Comments)),
LikeUserList: make([]*apiStruct.WorkMomentUser, len(v.LikeUserList)),
AtUserList: make([]*apiStruct.WorkMomentUser, len(v.AtUserList)),
PermissionUserList: make([]*apiStruct.WorkMomentUser, len(v.PermissionUserList)),
Comments: make([]*api.Comment, len(v.Comments)),
LikeUserList: make([]*api.WorkMomentUser, len(v.LikeUserList)),
AtUserList: make([]*api.WorkMomentUser, len(v.AtUserList)),
PermissionUserList: make([]*api.WorkMomentUser, len(v.PermissionUserList)),
Permission: v.Permission,
}
for i, comment := range v.Comments {
workMoment.Comments[i] = &apiStruct.Comment{
workMoment.Comments[i] = &api.Comment{
UserID: comment.UserID,
UserName: comment.UserName,
ReplyUserID: comment.ReplyUserID,
@ -502,19 +595,19 @@ func GetUserFriendWorkMoments(c *gin.Context) {
}
}
for i, likeUser := range v.LikeUserList {
workMoment.LikeUserList[i] = &apiStruct.WorkMomentUser{
workMoment.LikeUserList[i] = &api.WorkMomentUser{
UserID: likeUser.UserID,
UserName: likeUser.UserName,
}
}
for i, atUser := range v.AtUserList {
workMoment.AtUserList[i] = &apiStruct.WorkMomentUser{
workMoment.AtUserList[i] = &api.WorkMomentUser{
UserID: atUser.UserID,
UserName: atUser.UserName,
}
}
for i, permissionUser := range v.PermissionUserList {
workMoment.PermissionUserList[i] = &apiStruct.WorkMomentUser{
workMoment.PermissionUserList[i] = &api.WorkMomentUser{
UserID: permissionUser.UserID,
UserName: permissionUser.UserName,
}
@ -529,8 +622,8 @@ func GetUserFriendWorkMoments(c *gin.Context) {
func SetUserWorkMomentsLevel(c *gin.Context) {
var (
req apiStruct.SetUserWorkMomentsLevelReq
resp apiStruct.SetUserWorkMomentsLevelResp
req api.SetUserWorkMomentsLevelReq
resp api.SetUserWorkMomentsLevelResp
reqPb pbOffice.SetUserWorkMomentsLevelReq
respPb *pbOffice.SetUserWorkMomentsLevelResp
)

@ -35,7 +35,7 @@ func GetUsersInfoFromCache(c *gin.Context) {
if !ok {
errMsg := "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName, req.OperationID)
@ -147,6 +147,18 @@ func GetBlackIDListFromCache(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 获取用户信息
// @Description 根据用户列表批量获取用户信息
// @Tags 用户相关
// @ID GetUsersInfo
// @Accept json
// @Param token header string true "im token"
// @Param req body api.GetUsersInfoReq true "请求体"
// @Produce json
// @Success 0 {object} api.GetUsersInfoResp
// @Failure 500 {object} api.GetUsersInfoResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.GetUsersInfoResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /user/get_users_info [post]
func GetUsersInfo(c *gin.Context) {
params := api.GetUsersInfoReq{}
if err := c.BindJSON(&params); err != nil {
@ -163,7 +175,7 @@ func GetUsersInfo(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@ -197,11 +209,11 @@ func GetUsersInfo(c *gin.Context) {
// @Summary 修改用户信息
// @Description 修改用户信息 userID faceURL等
// @Tags 用户信息
// @Tags 用户相关
// @ID UpdateUserInfo
// @Accept json
// @Param token header string true "im token"
// @Param req body api.UpdateSelfUserInfoReq true "请求"
// @Param req body api.UpdateSelfUserInfoReq true "请求"
// @Produce json
// @Success 0 {object} api.UpdateUserInfoResp
// @Failure 500 {object} api.UpdateUserInfoResp "errCode为500 一般为服务器内部错误"
@ -223,7 +235,7 @@ func UpdateUserInfo(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(params.OperationID, "UpdateUserInfo args ", req.String())
@ -246,6 +258,18 @@ func UpdateUserInfo(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 设置全局免打扰
// @Description 设置全局免打扰
// @Tags 用户相关
// @ID SetGlobalRecvMessageOpt
// @Accept json
// @Param token header string true "im token"
// @Param req body api.SetGlobalRecvMessageOptReq true "请求体"
// @Produce json
// @Success 0 {object} api.SetGlobalRecvMessageOptResp
// @Failure 500 {object} api.SetGlobalRecvMessageOptResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.SetGlobalRecvMessageOptResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /user/set_global_msg_recv_opt [post]
func SetGlobalRecvMessageOpt(c *gin.Context) {
params := api.SetGlobalRecvMessageOptReq{}
if err := c.BindJSON(&params); err != nil {
@ -262,7 +286,7 @@ func SetGlobalRecvMessageOpt(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
log.NewInfo(params.OperationID, "SetGlobalRecvMessageOpt args ", req.String())
@ -285,6 +309,18 @@ func SetGlobalRecvMessageOpt(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
// @Summary 获取自己的信息
// @Description 传入ID获取自己的信息
// @Tags 用户相关
// @ID GetSelfUserInfo
// @Accept json
// @Param token header string true "im token"
// @Param req body api.GetSelfUserInfoReq true "请求体"
// @Produce json
// @Success 0 {object} api.GetSelfUserInfoResp
// @Failure 500 {object} api.GetSelfUserInfoResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.GetSelfUserInfoResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /user/get_self_user_info [post]
func GetSelfUserInfo(c *gin.Context) {
params := api.GetSelfUserInfoReq{}
if err := c.BindJSON(&params); err != nil {
@ -302,7 +338,7 @@ func GetSelfUserInfo(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}
@ -336,6 +372,18 @@ func GetSelfUserInfo(c *gin.Context) {
}
// @Summary 获取用户在线状态
// @Description 获取用户在线状态
// @Tags 用户相关
// @ID GetUsersOnlineStatus
// @Accept json
// @Param token header string true "im token"
// @Param req body api.GetUsersOnlineStatusReq true "请求体"
// @Produce json
// @Success 0 {object} api.GetUsersOnlineStatusResp
// @Failure 500 {object} api.GetUsersOnlineStatusResp "errCode为500 一般为服务器内部错误"
// @Failure 400 {object} api.GetUsersOnlineStatusResp "errCode为400 一般为参数输入错误, token未带上等"
// @Router /user/get_users_online_status [post]
func GetUsersOnlineStatus(c *gin.Context) {
params := api.GetUsersOnlineStatusReq{}
if err := c.BindJSON(&params); err != nil {
@ -351,7 +399,7 @@ func GetUsersOnlineStatus(c *gin.Context) {
if !ok {
errMsg := req.OperationID + " " + "GetUserIDFromToken failed " + errInfo + " token:" + c.Request.Header.Get("token")
log.NewError(req.OperationID, errMsg)
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": errMsg})
c.JSON(http.StatusBadRequest, gin.H{"errCode": 500, "errMsg": errMsg})
return
}

@ -16,8 +16,8 @@ type GetUserTagsResp struct {
}
type CreateTagReq struct {
TagName string `json:"tagName" binding:"required"`
UserIDList []string `json:"userIDList" binding:"required"`
TagName string `json:"tagName" binding:"required"` // tag名称
UserIDList []string `json:"userIDList" binding:"required"` // 用户ID列表
OperationID string `json:"operationID" binding:"required"`
}

@ -6,8 +6,8 @@ import (
)
type ApiUserInfo struct {
UserID string `json:"userID" binding:"required,min=1,max=64"`
Nickname string `json:"nickname" binding:"omitempty,min=1,max=64"`
UserID string `json:"userID" binding:"required,min=1,max=64" swaggo:"true,用户ID,"`
Nickname string `json:"nickname" binding:"omitempty,min=1,max=64" swaggo:"true,my id,19"`
FaceURL string `json:"faceURL" binding:"omitempty,max=1024"`
Gender int32 `json:"gender" binding:"omitempty,oneof=0 1 2"`
PhoneNumber string `json:"phoneNumber" binding:"omitempty,max=32"`

@ -12,7 +12,8 @@ type CreateOneWorkMomentResp struct {
}
type DeleteOneWorkMomentReq struct {
office.DeleteOneWorkMomentReq
WorkMomentID string `json:"workMomentID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
type DeleteOneWorkMomentResp struct {
@ -21,7 +22,8 @@ type DeleteOneWorkMomentResp struct {
}
type LikeOneWorkMomentReq struct {
office.LikeOneWorkMomentReq
WorkMomentID string `json:"workMomentID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
type LikeOneWorkMomentResp struct {
@ -30,7 +32,10 @@ type LikeOneWorkMomentResp struct {
}
type CommentOneWorkMomentReq struct {
office.CommentOneWorkMomentReq
WorkMomentID string `json:"workMomentID" binding:"required"`
ReplyUserID string `json:"replyUserID" binding:"required"`
Content string `json:"content" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
type CommentOneWorkMomentResp struct {
@ -39,7 +44,9 @@ type CommentOneWorkMomentResp struct {
}
type DeleteCommentReq struct {
office.DeleteCommentReq
WorkMomentID string `json:"workMomentID" binding:"required"`
ContentID string `json:"contentID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
type DeleteCommentResp struct {
@ -54,7 +61,8 @@ type WorkMomentsUserCommonReq struct {
}
type GetWorkMomentByIDReq struct {
office.GetWorkMomentByIDReq
WorkMomentID string `json:"workMomentID" binding:"required"`
OperationID string `json:"operationID" binding:"required"`
}
type WorkMoment struct {

Loading…
Cancel
Save