first commit
This commit is contained in:
27
gateway/api/v1/internal/handler/account/userloginhandler.go
Normal file
27
gateway/api/v1/internal/handler/account/userloginhandler.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/model"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
)
|
||||
|
||||
// AddressLogin
|
||||
// @Summary 用户登录
|
||||
// @Description 内部接口,comet层使用
|
||||
// @Author dld@33.cn
|
||||
// @Tags account 账户模块
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Success 200 {object} model.GeneralResponse{data=model.AddressLoginResp}
|
||||
// @Router /user/login [post]
|
||||
func AddressLogin(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
c.Set(api.ReqResult, &model.AddressLoginResp{
|
||||
Address: c.MustGet(api.Address).(string),
|
||||
})
|
||||
c.Set(api.ReqError, nil)
|
||||
}
|
||||
}
|
||||
45
gateway/api/v1/internal/handler/group/change_owner.go
Normal file
45
gateway/api/v1/internal/handler/group/change_owner.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// ChangeOwnerHandler
|
||||
// @Summary 转让群
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群动作
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.ChangeOwnerReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.ChangeOwnerResp}
|
||||
// @Router /group/app/change-owner [post]
|
||||
func ChangeOwnerHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.ChangeOwnerReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.ChangeOwner(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
35
gateway/api/v1/internal/handler/group/create_group.go
Normal file
35
gateway/api/v1/internal/handler/group/create_group.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
)
|
||||
|
||||
// CreateGroupHandler
|
||||
// @Summary 创建群
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群动作
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.CreateGroupReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.CreateGroupResp}
|
||||
// @Router /group/app/create-group [post]
|
||||
func CreateGroupHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.CreateGroupReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.CreateGroup(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
45
gateway/api/v1/internal/handler/group/get_group_info.go
Normal file
45
gateway/api/v1/internal/handler/group/get_group_info.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// GetGroupInfoHandler
|
||||
// @Summary 查询群信息
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群信息
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.GetGroupInfoReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.GetGroupInfoResp}
|
||||
// @Router /group/app/group-info [post]
|
||||
func GetGroupInfoHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.GetGroupInfoReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.GetPriGroupInfo(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
29
gateway/api/v1/internal/handler/group/get_group_list.go
Normal file
29
gateway/api/v1/internal/handler/group/get_group_list.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
)
|
||||
|
||||
// GetGroupListHandler
|
||||
// @Summary 查询群列表
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群信息
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.GetGroupListReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.GetGroupListResp}
|
||||
// @Router /app/group-list [post]
|
||||
func GetGroupListHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.GetGroupListReq{}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.GetGroupList(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// GetGroupMemberInfoHandler
|
||||
// @Summary 查询群成员信息
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群成员信息
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.GetGroupMemberInfoReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.GetGroupMemberInfoResp}
|
||||
// @Router /group/app/group-member-info [post]
|
||||
func GetGroupMemberInfoHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.GetGroupMemberInfoReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.GetGroupMemberInfo(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// GetGroupMemberListHandler
|
||||
// @Summary 查询群成员列表
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群成员信息
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.GetGroupMemberListReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.GetGroupMemberListResp}
|
||||
// @Router /group/app/group-member-list [post]
|
||||
func GetGroupMemberListHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.GetGroupMemberListReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.GetGroupMemberList(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
45
gateway/api/v1/internal/handler/group/get_mute_list.go
Normal file
45
gateway/api/v1/internal/handler/group/get_mute_list.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// GetMuteListHandler
|
||||
// @Summary 查询群内被禁言成员名单
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 禁言
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.GetMuteListReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.GetMuteListResp}
|
||||
// @Router /app/mute-list [post]
|
||||
func GetMuteListHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.GetMuteListReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.GetMuteList(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
45
gateway/api/v1/internal/handler/group/get_pub_group_info.go
Normal file
45
gateway/api/v1/internal/handler/group/get_pub_group_info.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// GetGroupPubInfoHandler
|
||||
// @Summary 查询群公开信息
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群信息
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.GetGroupPubInfoReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.GetGroupPubInfoResp}
|
||||
// @Router /group/app/group-pub-info [post]
|
||||
func GetGroupPubInfoHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.GetGroupPubInfoReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.GetPubGroupInfo(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
45
gateway/api/v1/internal/handler/group/group_disband.go
Normal file
45
gateway/api/v1/internal/handler/group/group_disband.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// GroupDisbandHandler
|
||||
// @Summary 解散群
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群动作
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.GroupDisbandReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.GroupDisbandResp}
|
||||
// @Router /group/app/group-disband [post]
|
||||
func GroupDisbandHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.GroupDisbandReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.GroupDisband(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
45
gateway/api/v1/internal/handler/group/group_exit.go
Normal file
45
gateway/api/v1/internal/handler/group/group_exit.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// GroupExitHandler
|
||||
// @Summary 退群
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群动作
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.GroupExitReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.GroupExitResp}
|
||||
// @Router /group/app/group-exit [post]
|
||||
func GroupExitHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.GroupExitReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.GroupExit(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
45
gateway/api/v1/internal/handler/group/group_remove.go
Normal file
45
gateway/api/v1/internal/handler/group/group_remove.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// GroupRemoveHandler
|
||||
// @Summary 踢人
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群动作
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.GroupRemoveReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.GroupRemoveResp}
|
||||
// @Router /group/app/group-remove [post]
|
||||
func GroupRemoveHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.GroupRemoveReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.GroupRemove(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// InviteGroupMembersHandler
|
||||
// @Summary 邀请新群员
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群动作
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.InviteGroupMembersReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.InviteGroupMembersResp}
|
||||
// @Router /group/app/invite-group-members [post]
|
||||
func InviteGroupMembersHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.InviteGroupMembersReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.InviteGroupMembers(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
45
gateway/api/v1/internal/handler/group/join_group.go
Normal file
45
gateway/api/v1/internal/handler/group/join_group.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// JoinGroupHandler
|
||||
// @Summary 直接进群
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群动作
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.JoinGroupReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.JoinGroupResp}
|
||||
// @Router /group/app/join-group [post]
|
||||
func JoinGroupHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.JoinGroupReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.JoinGroup(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
45
gateway/api/v1/internal/handler/group/set_admin.go
Normal file
45
gateway/api/v1/internal/handler/group/set_admin.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// SetAdminHandler
|
||||
// @Summary 设置管理员
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群成员信息
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.SetAdminReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.SetAdminResp}
|
||||
// @Router /group/app/member/type [post]
|
||||
func SetAdminHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.SetAdminReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.SetAdmin(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
45
gateway/api/v1/internal/handler/group/update_group_avatar.go
Normal file
45
gateway/api/v1/internal/handler/group/update_group_avatar.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// UpdateGroupAvatarHandler
|
||||
// @Summary 更新群头像
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群信息
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.UpdateGroupAvatarReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.UpdateGroupAvatarResp}
|
||||
// @Router /group/app/avatar [post]
|
||||
func UpdateGroupAvatarHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.UpdateGroupAvatarReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.UpdateGroupAvatar(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// UpdateGroupFriendTypeHandler
|
||||
// @Summary 更新群内加好友设置
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群信息
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.UpdateGroupFriendTypeReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.UpdateGroupFriendTypeResp}
|
||||
// @Router /group/app/friendType [post]
|
||||
func UpdateGroupFriendTypeHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.UpdateGroupFriendTypeReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.UpdateGroupFriendType(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// UpdateGroupJoinTypeHandler
|
||||
// @Summary 更新群内加好友设置
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群信息
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.UpdateGroupJoinTypeReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.UpdateGroupJoinTypeResp}
|
||||
// @Router /group/app/joinType [post]
|
||||
func UpdateGroupJoinTypeHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.UpdateGroupJoinTypeReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.UpdateGroupJoinType(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// UpdateGroupMemberMuteTimeHandler
|
||||
// @Summary 更新群成员禁言时间
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 禁言
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.UpdateGroupMemberMuteTimeReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.UpdateGroupMemberMuteTimeResp}
|
||||
// @Router /group/app/member/muteTime [post]
|
||||
func UpdateGroupMemberMuteTimeHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.UpdateGroupMemberMuteTimeReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.UpdateGroupMemberMuteTime(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// UpdateGroupMemberNameHandler
|
||||
// @Summary 更新群成员昵称
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群成员信息
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.UpdateGroupMemberNameReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.UpdateGroupMemberNameResp}
|
||||
// @Router /group/app/member/name [post]
|
||||
func UpdateGroupMemberNameHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.UpdateGroupMemberNameReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.UpdateGroupMemberName(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// UpdateGroupMuteTypeHandler
|
||||
// @Summary 更新群内加好友设置
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群信息
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.UpdateGroupMuteTypeReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.UpdateGroupMuteTypeResp}
|
||||
// @Router /group/app/muteType [post]
|
||||
func UpdateGroupMuteTypeHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.UpdateGroupMuteTypeReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.UpdateGroupMuteType(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
45
gateway/api/v1/internal/handler/group/update_group_name.go
Normal file
45
gateway/api/v1/internal/handler/group/update_group_name.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package group
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/group"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
// UpdateGroupNameHandler
|
||||
// @Summary 更新群名称
|
||||
// @Author chy@33.cn
|
||||
// @Tags group 群信息
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body types.UpdateGroupNameReq false "body"
|
||||
// @Success 200 {object} types.GeneralResp{data=types.UpdateGroupNameResp}
|
||||
// @Router /group/app/name [post]
|
||||
func UpdateGroupNameHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &types.UpdateGroupNameReq{}
|
||||
err := c.ShouldBind(req)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
if req.Id == 0 && req.IdStr == "" {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError))
|
||||
return
|
||||
}
|
||||
|
||||
if req.IdStr != "" {
|
||||
req.Id = convert.ToInt64(req.IdStr)
|
||||
}
|
||||
|
||||
l := logic.NewGroupLogic(c, ctx)
|
||||
res, err := l.UpdateGroupName(req)
|
||||
|
||||
c.Set(api.ReqResult, res)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
34
gateway/api/v1/internal/handler/modules/getmoduleshandler.go
Normal file
34
gateway/api/v1/internal/handler/modules/getmoduleshandler.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package modules
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/model"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
)
|
||||
|
||||
// GetModulesHandler
|
||||
// @Summary 获取模块启用状态
|
||||
// @Description
|
||||
// @Author dld@33.cn
|
||||
// @Tags startup 初始化模块
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} model.GeneralResponse{data=[]model.GetModuleResp}
|
||||
// @Router /app/modules/all [post]
|
||||
func GetModulesHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
modules := ctx.Config().Modules
|
||||
var ret = make([]model.GetModuleResp, len(modules))
|
||||
for i, v := range modules {
|
||||
ret[i] = model.GetModuleResp{
|
||||
Name: v.Name,
|
||||
IsEnabled: v.IsEnabled,
|
||||
EndPoints: v.EndPoints,
|
||||
}
|
||||
}
|
||||
c.Set(api.ReqResult, ret)
|
||||
c.Set(api.ReqError, nil)
|
||||
}
|
||||
}
|
||||
48
gateway/api/v1/internal/handler/record/focushandler.go
Normal file
48
gateway/api/v1/internal/handler/record/focushandler.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package record
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/record"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/model"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
)
|
||||
|
||||
//@Summary 关注消息
|
||||
//@Description
|
||||
//@Author dld@33.cn
|
||||
//@Tags record 消息模块
|
||||
//@Accept json
|
||||
//@Produce json
|
||||
//@Param FZM-SIGNATURE header string true "MOCK"
|
||||
//@Param data body model.FocusMsgReq true "body"
|
||||
//@Success 200 {object} model.GeneralResponse{}
|
||||
//@Router /app/record/focus [post]
|
||||
func FocusHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &model.FocusMsgReq{}
|
||||
if err := c.ShouldBind(req); err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
var err error
|
||||
operator := c.MustGet(api.Address).(string)
|
||||
l := record.NewLogic(c.Request.Context(), ctx)
|
||||
switch req.Type {
|
||||
case model.Private:
|
||||
err = l.FocusPersonal(operator, req.LogId)
|
||||
case model.Group:
|
||||
err = l.FocusGroup(operator, req.LogId)
|
||||
default:
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage("undefined type"))
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.CodeInnerError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
c.Set(api.ReqResult, nil)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
142
gateway/api/v1/internal/handler/record/pushhandler.go
Normal file
142
gateway/api/v1/internal/handler/record/pushhandler.go
Normal file
@@ -0,0 +1,142 @@
|
||||
package record
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/record"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
comet "gitlab.33.cn/chat/im/api/comet/grpc"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
// PushToUid
|
||||
// @Summary 推送消息
|
||||
// @Description comet.Proto由接口组装,客户端只需传入comet.Proto的body部分
|
||||
// @Author dld@33.cn
|
||||
// @Tags record 消息模块
|
||||
// @Accept mpfd
|
||||
// @Produce json
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param message body string true "消息协议序列化"
|
||||
// @Success 200 {object} model.GeneralResponse{}
|
||||
// @Router /record/push [post]
|
||||
func PushToUid(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
form, err := c.MultipartForm()
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage("MultipartForm"+err.Error()))
|
||||
return
|
||||
}
|
||||
files := form.File["message"]
|
||||
|
||||
if len(files) < 1 {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage("file len less than 1"))
|
||||
return
|
||||
}
|
||||
|
||||
//file, err := c.FormFile("")
|
||||
file := files[0]
|
||||
f, err := file.Open()
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage("Open File"+err.Error()))
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage("ReadAll"+err.Error()))
|
||||
return
|
||||
}
|
||||
if len(body) == 0 {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage("error message length 0"))
|
||||
return
|
||||
}
|
||||
p := comet.Proto{
|
||||
Ver: 1,
|
||||
Op: int32(comet.Op_SendMsg),
|
||||
Seq: 0,
|
||||
Ack: 0,
|
||||
Body: body,
|
||||
}
|
||||
data, err := proto.Marshal(&p)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.SendMsgFailed).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
uid := c.MustGet(api.Address).(string)
|
||||
l := record.NewLogic(c.Request.Context(), ctx)
|
||||
mid, createTime, err := l.Push("", uid, data)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.SendMsgFailed).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
ret := map[string]interface{}{
|
||||
"logId": mid,
|
||||
"datetime": createTime,
|
||||
}
|
||||
c.Set(api.ReqResult, ret)
|
||||
c.Set(api.ReqError, nil)
|
||||
}
|
||||
}
|
||||
|
||||
// PushToUid2
|
||||
// @Summary 推送消息2
|
||||
// @Description comet.Proto由客户端传入
|
||||
// @Author dld@33.cn
|
||||
// @Tags record 消息模块
|
||||
// @Accept mpfd
|
||||
// @Produce json
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param message body string true "消息协议序列化"
|
||||
// @Success 200 {object} model.GeneralResponse{}
|
||||
// @Router /record/push2 [post]
|
||||
func PushToUid2(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
form, err := c.MultipartForm()
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage("MultipartForm"+err.Error()))
|
||||
return
|
||||
}
|
||||
files := form.File["message"]
|
||||
|
||||
if len(files) < 1 {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage("file len less than 1"))
|
||||
return
|
||||
}
|
||||
|
||||
//file, err := c.FormFile("")
|
||||
file := files[0]
|
||||
f, err := file.Open()
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage("Open File"+err.Error()))
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
body, err := ioutil.ReadAll(f)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage("ReadAll"+err.Error()))
|
||||
return
|
||||
}
|
||||
if len(body) == 0 {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage("error message length 0"))
|
||||
return
|
||||
}
|
||||
uid := c.MustGet(api.Address).(string)
|
||||
l := record.NewLogic(c.Request.Context(), ctx)
|
||||
mid, createTime, err := l.Push("", uid, body)
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.SendMsgFailed).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
ret := map[string]interface{}{
|
||||
"logId": mid,
|
||||
"datetime": createTime,
|
||||
}
|
||||
c.Set(api.ReqResult, ret)
|
||||
c.Set(api.ReqError, nil)
|
||||
}
|
||||
}
|
||||
46
gateway/api/v1/internal/handler/record/recordhandler.go
Normal file
46
gateway/api/v1/internal/handler/record/recordhandler.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package record
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/record"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/model"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
)
|
||||
|
||||
// GetPriRecords
|
||||
// @Summary 获得聊天记录
|
||||
// @Author chy@33.cn
|
||||
// @Tags record 消息模块
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body model.GetPriRecordsReq false "body"
|
||||
// @Success 200 {object} model.GeneralResponse{data=model.GetPriRecordsResp}
|
||||
// @Router /app/pri-chat-record [post]
|
||||
func GetPriRecords(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &model.GetPriRecordsReq{}
|
||||
if err := c.ShouldBind(req); err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
userId, ok := c.Get(api.Address)
|
||||
if !ok {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.SignatureInvalid))
|
||||
return
|
||||
}
|
||||
req.FromId = userId.(string)
|
||||
|
||||
if req.Mid == "" {
|
||||
req.Mid = "999999999999999999"
|
||||
}
|
||||
|
||||
l := record.NewLogic(c.Request.Context(), ctx)
|
||||
data, err := l.GetPriRecord(req)
|
||||
c.Set(api.ReqResult, data)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
49
gateway/api/v1/internal/handler/record/revokehandler.go
Normal file
49
gateway/api/v1/internal/handler/record/revokehandler.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package record
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/record"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/model"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
)
|
||||
|
||||
// RevokeHandler
|
||||
// @Summary 撤回消息
|
||||
// @Description
|
||||
// @Author dld@33.cn
|
||||
// @Tags record 消息模块
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param FZM-SIGNATURE header string true "MOCK"
|
||||
// @Param data body model.RevokeMsgReq true "body"
|
||||
// @Success 200 {object} model.GeneralResponse{}
|
||||
// @Router /app/record/revoke [post]
|
||||
func RevokeHandler(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
req := &model.RevokeMsgReq{}
|
||||
if err := c.ShouldBind(req); err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
var err error
|
||||
operator := c.MustGet(api.Address).(string)
|
||||
l := record.NewLogic(c.Request.Context(), ctx)
|
||||
switch req.Type {
|
||||
case model.Private:
|
||||
err = l.RevokePersonal(operator, req.Mid)
|
||||
case model.Group:
|
||||
err = l.RevokeGroup(operator, req.Mid)
|
||||
default:
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.ParamsError).SetExtMessage("undefined type"))
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
c.Set(api.ReqError, xerror.NewError(xerror.CodeInnerError).SetExtMessage(err.Error()))
|
||||
return
|
||||
}
|
||||
c.Set(api.ReqResult, nil)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
152
gateway/api/v1/internal/handler/routes.go
Normal file
152
gateway/api/v1/internal/handler/routes.go
Normal file
@@ -0,0 +1,152 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
zlog "github.com/rs/zerolog/log"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
"github.com/swaggo/gin-swagger/swaggerFiles"
|
||||
_ "gitlab.33.cn/chat/dtalk/gateway/api/v1/docs"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/handler/account"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/handler/group"
|
||||
modules "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/handler/modules"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/handler/record"
|
||||
test "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/handler/test"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api/logger"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api/trace"
|
||||
xlog "gitlab.33.cn/chat/dtalk/pkg/logger"
|
||||
otrace "gitlab.33.cn/chat/im-pkg/trace"
|
||||
)
|
||||
|
||||
var (
|
||||
serverCtx *svc.ServiceContext
|
||||
log = zlog.Logger
|
||||
)
|
||||
|
||||
func Init(ctx *svc.ServiceContext) *http.Server {
|
||||
serverCtx = ctx
|
||||
addr := serverCtx.Config().Server.Addr
|
||||
engine := Default()
|
||||
SetupEngine(engine)
|
||||
SetupGroupRoutes(engine)
|
||||
SetupResourceRoutes(engine)
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: addr,
|
||||
Handler: engine,
|
||||
}
|
||||
go func() {
|
||||
// service connections
|
||||
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
log.Error().Err(err).Msg("engineInner.Start() err")
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
return srv
|
||||
}
|
||||
|
||||
// Default returns an Engine instance with the Logger and Recovery middleware already attached.
|
||||
func Default() *gin.Engine {
|
||||
router := gin.New()
|
||||
// LoggerWithFormatter middleware will write the logs to gin.DefaultWriter
|
||||
// By default gin.DefaultWriter = os.Stdout
|
||||
router.Use(gin.LoggerWithFormatter(api.Chat33GinLogFormatter))
|
||||
router.Use(gin.Recovery())
|
||||
return router
|
||||
}
|
||||
|
||||
// @title 即时通讯系统后端接口
|
||||
// @version 1.0
|
||||
// @description
|
||||
// @termsOfService
|
||||
// @contact.name
|
||||
// @contact.url
|
||||
// @contact.email
|
||||
// @schemes https
|
||||
// @host localhost:8080
|
||||
// @BasePath /api/v1
|
||||
func SetupEngine(e *gin.Engine) *gin.Engine {
|
||||
root := e.Group("/", otrace.OpenTracingServerMiddleWare(), api.RespMiddleWare())
|
||||
root.POST("/test", test.GetHelloWord(serverCtx))
|
||||
|
||||
userRoute := root.Group("/user")
|
||||
//获取服务器列表
|
||||
userRoute.Use(api.AuthMiddleWare())
|
||||
{
|
||||
userRoute.POST("/login", account.AddressLogin(serverCtx))
|
||||
}
|
||||
|
||||
app := root.Group("/app")
|
||||
{
|
||||
modulesRoute := app.Group("/modules")
|
||||
//获取模块启用状态
|
||||
modulesRoute.POST("/all", modules.GetModulesHandler(serverCtx))
|
||||
|
||||
recordRoute := app.Group("/record")
|
||||
{
|
||||
recordRoute.POST("/revoke", api.AuthMiddleWare(), record.RevokeHandler(serverCtx))
|
||||
recordRoute.POST("/focus", api.AuthMiddleWare(), record.FocusHandler(serverCtx))
|
||||
}
|
||||
}
|
||||
|
||||
recordRoute := root.Group("/record")
|
||||
recordRoute.Use(api.AuthMiddleWare())
|
||||
{
|
||||
recordRoute.POST("/push", record.PushToUid(serverCtx))
|
||||
recordRoute.POST("/push2", record.PushToUid2(serverCtx))
|
||||
}
|
||||
|
||||
store := root.Group("/store/app", api.RespMiddleWare())
|
||||
store.Use(api.AuthMiddleWare())
|
||||
{
|
||||
store.POST("/pri-chat-record", record.GetPriRecords(serverCtx))
|
||||
}
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
func SetupGroupRoutes(e *gin.Engine) *gin.Engine {
|
||||
logMiddleware := logger.NewMiddleware(xlog.New(serverCtx.Config().Env, "group"))
|
||||
|
||||
root := e.Group("/group/app", api.RespMiddleWare())
|
||||
root.Use(api.AuthMiddleWare(), trace.TraceMiddleware(), logMiddleware.Handle())
|
||||
{
|
||||
root.POST("/create-group", group.CreateGroupHandler(serverCtx))
|
||||
root.POST("/invite-group-members", group.InviteGroupMembersHandler(serverCtx))
|
||||
root.POST("/group-exit", group.GroupExitHandler(serverCtx))
|
||||
root.POST("/group-disband", group.GroupDisbandHandler(serverCtx))
|
||||
root.POST("/group-remove", group.GroupRemoveHandler(serverCtx))
|
||||
root.POST("/change-owner", group.ChangeOwnerHandler(serverCtx))
|
||||
root.POST("/join-group", group.JoinGroupHandler(serverCtx))
|
||||
|
||||
root.POST("/name", group.UpdateGroupNameHandler(serverCtx))
|
||||
root.POST("/avatar", group.UpdateGroupAvatarHandler(serverCtx))
|
||||
root.POST("/joinType", group.UpdateGroupJoinTypeHandler(serverCtx))
|
||||
root.POST("/friendType", group.UpdateGroupFriendTypeHandler(serverCtx))
|
||||
root.POST("/muteType", group.UpdateGroupMuteTypeHandler(serverCtx))
|
||||
root.POST("/member/name", group.UpdateGroupMemberNameHandler(serverCtx))
|
||||
root.POST("/member/type", group.SetAdminHandler(serverCtx))
|
||||
root.POST("/member/muteTime", group.UpdateGroupMemberMuteTimeHandler(serverCtx))
|
||||
|
||||
root.POST("/group-info", group.GetGroupInfoHandler(serverCtx))
|
||||
root.POST("/group-pub-info", group.GetGroupPubInfoHandler(serverCtx))
|
||||
root.POST("/group-list", group.GetGroupListHandler(serverCtx))
|
||||
root.POST("/group-member-list", group.GetGroupMemberListHandler(serverCtx))
|
||||
root.POST("/group-member-info", group.GetGroupMemberInfoHandler(serverCtx))
|
||||
root.POST("/mute-list", group.GetMuteListHandler(serverCtx))
|
||||
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
func SetupResourceRoutes(e *gin.Engine) *gin.Engine {
|
||||
// swagger 文档接口
|
||||
if serverCtx.Config().Env == "debug" {
|
||||
// todo : 单独开一个 swagger 服务
|
||||
e.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
}
|
||||
return e
|
||||
}
|
||||
17
gateway/api/v1/internal/handler/test/test.go
Normal file
17
gateway/api/v1/internal/handler/test/test.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
logic "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/logic/test"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/api"
|
||||
)
|
||||
|
||||
func GetHelloWord(ctx *svc.ServiceContext) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
l := logic.NewTestLogic(c.Request.Context(), ctx)
|
||||
resp, err := l.GetHelloWorld()
|
||||
c.Set(api.ReqResult, resp)
|
||||
c.Set(api.ReqError, err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user