first commit
This commit is contained in:
32
gateway/api/READMD.md
Normal file
32
gateway/api/READMD.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# Gateway
|
||||
|
||||
业务网关层往往又被称作业务聚合层,该层由若干个业务服务构成,负责接收通用网关转发过来的流量。核心作用如下:
|
||||
|
||||
### 1. 路由管理
|
||||
|
||||
业务网关层的服务负责自己服务的路由表维护。
|
||||
|
||||
### 2. 参数校验
|
||||
|
||||
业务网关层的服务负责执行与客户端约定的参数校验,验证通过之后再组装成后端微服务需要的数据结构请求到后端。
|
||||
|
||||
### 3. 权限校验
|
||||
|
||||
各个业务网关层的服务通过底层的用户服务调用来实现权限校验,对于哪些路由需要权限校验,哪些路由不需要,完全由业务网关层的服务自行维护。
|
||||
|
||||
### 4. 接口聚合
|
||||
|
||||
业务网关层的服务可能需要调用多个后端的微服务来组合实现一个接口,根据自身需求来对下层返回的数据进行聚合和处理。
|
||||
|
||||
### 5. 协议转换
|
||||
|
||||
业务网关层的服务接收转发过来的HTTP请求,并转换为内部的一个或者多个GRPC微服务调用来实现接口逻辑。
|
||||
|
||||
### 6. 数据转换
|
||||
|
||||
业务网关层的服务的输入和输出数据结构必须是表示层需要的,因此它所负责的数据结构和后端GRPC微服务的数据结构会不一样。业务网关层的服务需要负责数据结构的转换和封装处理。
|
||||
|
||||
> gateway 里不应该有复杂业务逻辑
|
||||
>
|
||||
|
||||
文档路径 : http://172.16.101.107:8888/swagger/index.html
|
||||
45
gateway/api/v1/CHANGELOG.md
Normal file
45
gateway/api/v1/CHANGELOG.md
Normal file
@@ -0,0 +1,45 @@
|
||||
版本号`major.minor.patch`具体规则如下:
|
||||
|
||||
- major:主版本号,如有重大版本重构则该字段递增,通常各主版本间接口不兼容。
|
||||
- minor:次版本号,各次版本号间接口保持兼容,如有接口新增或优化则该字段递增。
|
||||
- patch:补丁号,如有功能改善或缺陷修复则该字段递增。
|
||||
|
||||
## version 0.1.0 2022_01_20
|
||||
|
||||
**Feature**
|
||||
|
||||
- 增加 `group` 相关 api 接口
|
||||
|
||||
## version 0.0.8
|
||||
|
||||
**Feature**
|
||||
|
||||
- 更新gateway下服务修改signal和noticemsg名称 2021_12_07_17_52_18
|
||||
|
||||
## version 0.0.7
|
||||
|
||||
**配置文件新增**
|
||||
|
||||
所有 `[xxxRPCClient]` 增加 `RegAddrs = "127.0.0.1:2379"` 字段
|
||||
|
||||
**Feature**
|
||||
- 更新 etcdv3.5.0 v0.0.7 2021.11.03
|
||||
|
||||
## version 0.0
|
||||
|
||||
**Feature**
|
||||
- 模块开启接口 @v0.0.2
|
||||
- 撤回消息 @v0.0.4
|
||||
- 改用 imparse 中的 proto @v0.0.5 2021.10.14
|
||||
- 新增撤回消息时限配置文件 v0.0.6 2021.10.22
|
||||
|
||||
|
||||
## example x.x.x @yy.mm.dd
|
||||
|
||||
**Feature**
|
||||
|
||||
**Bug Fixes**
|
||||
|
||||
**Improvement**
|
||||
|
||||
**Breaking Change**
|
||||
48
gateway/api/v1/Makefile
Normal file
48
gateway/api/v1/Makefile
Normal file
@@ -0,0 +1,48 @@
|
||||
# golang1.9 or latest
|
||||
# 1. make help
|
||||
# 2. make dep
|
||||
# 3. make build
|
||||
# ...
|
||||
|
||||
VERSION := $(shell echo $(shell cat gateway.go | grep "projectVersion =" | cut -d '=' -f2))
|
||||
APP_NAME := gateway
|
||||
BUILD_DIR := build
|
||||
APP := ${BUILD_DIR}/${APP_NAME}_v${VERSION}
|
||||
PKG_NAME := ${APP_NAME}_v${VERSION}
|
||||
PKG := ${PKG_NAME}.tar.gz
|
||||
|
||||
main_path = "main"
|
||||
go_version = $(shell go version | awk '{ print $3 }')
|
||||
build_time = $(shell date "+%Y-%m-%d %H:%M:%S %Z")
|
||||
git_commit = $(shell git rev-parse --short=10 HEAD)
|
||||
flags := -ldflags "-X '${main_path}.goVersion=${go_version}' \
|
||||
-X '${main_path}.buildTime=${build_time}' \
|
||||
-X '${main_path}.gitCommit=${git_commit}' \
|
||||
-X 'google.golang.org/protobuf/reflect/protoregistry.conflictPolicy=warn'"
|
||||
|
||||
.PHONY: clean build pkg
|
||||
|
||||
swag:
|
||||
@echo '┌ start gen swag'
|
||||
@swag init -g internal/handler/routes.go
|
||||
@echo '└ end gen swag'
|
||||
|
||||
clean: ## Remove previous build
|
||||
@rm -rf ${BUILD_DIR}
|
||||
@go clean
|
||||
|
||||
build: swag #checkgofmt ## Build the binary file
|
||||
GOOS=linux GOARCH=amd64 GO111MODULE=on GOPROXY=https://goproxy.cn,direct GOSUMDB="sum.golang.google.cn" go build -v $(flags) -o $(APP)
|
||||
|
||||
pkg: build ## Package
|
||||
mkdir -p ${PKG_NAME}/bin
|
||||
mkdir -p ${PKG_NAME}/etc
|
||||
cp ${APP} ${PKG_NAME}/bin/
|
||||
cp etc/* ${PKG_NAME}/etc/
|
||||
tar zvcf ${PKG} ${PKG_NAME}
|
||||
rm -rf ${PKG_NAME}
|
||||
|
||||
REMOTE_BIN_PATH := /opt/dtalk/srv/app/bin
|
||||
upload: build
|
||||
rsync -r $(APP) 107:$(REMOTE_BIN_PATH)
|
||||
ssh 107 "cd $(REMOTE_BIN_PATH) && chmod 777 $(PKG_NAME) && ln -sf $(PKG_NAME) $(APP_NAME) && supervisorctl restart $(APP_NAME)"
|
||||
2330
gateway/api/v1/docs/docs.go
Normal file
2330
gateway/api/v1/docs/docs.go
Normal file
File diff suppressed because it is too large
Load Diff
2270
gateway/api/v1/docs/swagger.json
Normal file
2270
gateway/api/v1/docs/swagger.json
Normal file
File diff suppressed because it is too large
Load Diff
1447
gateway/api/v1/docs/swagger.yaml
Normal file
1447
gateway/api/v1/docs/swagger.yaml
Normal file
File diff suppressed because it is too large
Load Diff
63
gateway/api/v1/etc/gateway.toml
Normal file
63
gateway/api/v1/etc/gateway.toml
Normal file
@@ -0,0 +1,63 @@
|
||||
env = "debug"
|
||||
|
||||
[server]
|
||||
addr = "0.0.0.0:19000"
|
||||
|
||||
[Trace]
|
||||
ServiceName = "gateway"
|
||||
Gen128Bit = true
|
||||
[Trace.Sampler]
|
||||
Type = "const"
|
||||
Param = 1.0
|
||||
[Trace.Reporter]
|
||||
LogSpans = true
|
||||
LocalAgentHostPort = "127.0.0.1:6831"
|
||||
|
||||
[AnswerRPCClient]
|
||||
RegAddrs = "127.0.0.1:2379"
|
||||
Schema = "dtalk"
|
||||
SrvName = "answer"
|
||||
Dial = "1s"
|
||||
Timeout = "1s"
|
||||
|
||||
[StoreRPCClient]
|
||||
RegAddrs = "127.0.0.1:2379"
|
||||
Schema = "dtalk"
|
||||
SrvName = "store"
|
||||
Dial = "1s"
|
||||
Timeout = "1s"
|
||||
|
||||
[GroupRPCClient]
|
||||
RegAddrs = "127.0.0.1:2379"
|
||||
Schema = "dtalk"
|
||||
SrvName = "group"
|
||||
Dial = "1s"
|
||||
Timeout = "1s"
|
||||
|
||||
[[modules]]
|
||||
Name = "wallet"
|
||||
IsEnabled = true
|
||||
EndPoints = ["http://172.16.101.87:8901","http://172.16.101.107:8083"] # changeme (1. 红包服务 http 服务地址, 2. 钱包服务 http 服务地址)
|
||||
|
||||
[[modules]]
|
||||
Name = "redPacket"
|
||||
IsEnabled = true
|
||||
EndPoints = ["http://172.16.101.87:8901","http://172.16.101.107:8083"] # changeme (1. 红包服务 http 服务地址, 2. 钱包服务 http 服务地址)
|
||||
|
||||
[[modules]]
|
||||
Name = "oa"
|
||||
IsEnabled = true
|
||||
EndPoints = ["http://127.0.0.1:20000"] # changeme (oa 服务地址)
|
||||
|
||||
[[modules]]
|
||||
Name = "shop"
|
||||
IsEnabled = true
|
||||
EndPoints = ["http://146.56.218.121:12009"] # changeme (链上购服务地址)
|
||||
|
||||
[[modules]]
|
||||
Name="live"
|
||||
IsEnabled=true
|
||||
EndPoints=[""]
|
||||
|
||||
[Revoke]
|
||||
Expire = "86400h" #ten years (撤回消息有效时间)
|
||||
106
gateway/api/v1/gateway.go
Normal file
106
gateway/api/v1/gateway.go
Normal file
@@ -0,0 +1,106 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/opentracing/opentracing-go"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/config"
|
||||
http "gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/handler"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/im-pkg/trace"
|
||||
)
|
||||
|
||||
const srvName = "gateway"
|
||||
|
||||
var (
|
||||
// projectVersion 项目版本
|
||||
projectVersion = "0.1.2"
|
||||
// goVersion go版本
|
||||
goVersion = ""
|
||||
// gitCommit git提交commit id
|
||||
gitCommit = ""
|
||||
// buildTime 编译时间
|
||||
buildTime = ""
|
||||
|
||||
isShowVersion = flag.Bool("v", false, "show project version")
|
||||
)
|
||||
|
||||
// showVersion 显示项目版本信息
|
||||
func showVersion(isShow bool) {
|
||||
if isShow {
|
||||
fmt.Printf("Project: %s\n", srvName)
|
||||
fmt.Printf(" Version: %s\n", projectVersion)
|
||||
fmt.Printf(" Go Version: %s\n", goVersion)
|
||||
fmt.Printf(" Git Commit: %s\n", gitCommit)
|
||||
fmt.Printf(" Build Time: %s\n", buildTime)
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
// @Title 聊天网关
|
||||
// @Version 0.1
|
||||
// @Description
|
||||
// @SecurityDefinitions.ApiKey ApiKeyAuth
|
||||
// @In header
|
||||
// @Name Authorization
|
||||
// @BasePath /
|
||||
func main() {
|
||||
flag.Parse()
|
||||
showVersion(*isShowVersion)
|
||||
|
||||
if err := config.Init(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
//log init
|
||||
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout}).With().Str("service", srvName).Logger()
|
||||
zerolog.SetGlobalLevel(zerolog.InfoLevel)
|
||||
|
||||
log.Info().
|
||||
Interface("Modules", config.Conf.Modules).
|
||||
Interface("Server", config.Conf.Server).
|
||||
Msg("config info")
|
||||
|
||||
//trace init
|
||||
tracer, tracerCloser := trace.Init(srvName, config.Conf.Trace)
|
||||
//不然后续不会有Jaeger实例
|
||||
opentracing.SetGlobalTracer(tracer)
|
||||
|
||||
// service init
|
||||
ctx := svc.NewServiceContext(*config.Conf)
|
||||
httpSrv := http.Init(ctx)
|
||||
|
||||
// init signal
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
|
||||
for {
|
||||
s := <-c
|
||||
log.Info().Str("signal", s.String()).Msg("service get a signal")
|
||||
switch s {
|
||||
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
if err := httpSrv.Shutdown(ctx); err != nil {
|
||||
log.Error().Err(err).Msg("server shutdown")
|
||||
}
|
||||
if err := tracerCloser.Close(); err != nil {
|
||||
log.Error().Err(err).Msg("tracer close failed")
|
||||
}
|
||||
time.Sleep(time.Second * 2)
|
||||
log.Info().Str("name", srvName).Msg("server exit")
|
||||
return
|
||||
case syscall.SIGHUP:
|
||||
// TODO reload
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
106
gateway/api/v1/internal/config/config.go
Normal file
106
gateway/api/v1/internal/config/config.go
Normal file
@@ -0,0 +1,106 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/uber/jaeger-client-go"
|
||||
traceConfig "github.com/uber/jaeger-client-go/config"
|
||||
xtime "gitlab.33.cn/chat/dtalk/pkg/time"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
confPath string
|
||||
|
||||
Conf *Config
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&confPath, "conf", "gateway.toml", "default config path.")
|
||||
}
|
||||
|
||||
// Init init config.
|
||||
func Init() (err error) {
|
||||
Conf = Default()
|
||||
_, err = toml.DecodeFile(confPath, &Conf)
|
||||
return
|
||||
}
|
||||
|
||||
func Default() *Config {
|
||||
return &Config{
|
||||
Env: "debug",
|
||||
Server: &HttpServer{
|
||||
Addr: "0.0.0.0:18002",
|
||||
},
|
||||
Trace: traceConfig.Configuration{
|
||||
ServiceName: "gateway",
|
||||
Gen128Bit: true,
|
||||
Sampler: &traceConfig.SamplerConfig{
|
||||
Type: jaeger.SamplerTypeConst,
|
||||
Param: 1,
|
||||
},
|
||||
Reporter: &traceConfig.ReporterConfig{
|
||||
LogSpans: true,
|
||||
LocalAgentHostPort: "127.0.0.1:6831",
|
||||
},
|
||||
},
|
||||
Revoke: &Revoke{
|
||||
Expire: xtime.Duration(time.Hour * 24),
|
||||
},
|
||||
AnswerRPCClient: &RPCClient{
|
||||
RegAddrs: "127.0.0.1:2379",
|
||||
Schema: "dtalk",
|
||||
SrvName: "answer",
|
||||
Dial: xtime.Duration(time.Second),
|
||||
Timeout: xtime.Duration(time.Second),
|
||||
},
|
||||
StoreRPCClient: &RPCClient{
|
||||
RegAddrs: "127.0.0.1:2379",
|
||||
Schema: "dtalk",
|
||||
SrvName: "store",
|
||||
Dial: xtime.Duration(time.Second),
|
||||
Timeout: xtime.Duration(time.Second),
|
||||
},
|
||||
GroupRPCClient: &RPCClient{
|
||||
RegAddrs: "127.0.0.1:2379",
|
||||
Schema: "dtalk",
|
||||
SrvName: "group",
|
||||
Dial: xtime.Duration(time.Second),
|
||||
Timeout: xtime.Duration(time.Second),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Env string
|
||||
Server *HttpServer
|
||||
Trace traceConfig.Configuration
|
||||
Modules []Module
|
||||
Revoke *Revoke
|
||||
AnswerRPCClient *RPCClient
|
||||
StoreRPCClient *RPCClient
|
||||
GroupRPCClient *RPCClient
|
||||
}
|
||||
|
||||
type HttpServer struct {
|
||||
Addr string
|
||||
}
|
||||
|
||||
// RPCClient is RPC client config.
|
||||
type RPCClient struct {
|
||||
RegAddrs string // etcd addrs, seperate by ','
|
||||
Schema string
|
||||
SrvName string // call
|
||||
Dial xtime.Duration
|
||||
Timeout xtime.Duration
|
||||
}
|
||||
|
||||
type Module struct {
|
||||
Name string `json:"name"` // enums: wallet、oa、redpacket
|
||||
IsEnabled bool `json:"isEnabled"`
|
||||
EndPoints []string `json:"endPoints"`
|
||||
}
|
||||
|
||||
type Revoke struct {
|
||||
Expire xtime.Duration
|
||||
}
|
||||
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)
|
||||
}
|
||||
}
|
||||
24
gateway/api/v1/internal/logic/group/change_owner.go
Normal file
24
gateway/api/v1/internal/logic/group/change_owner.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) ChangeOwner(req *types.ChangeOwnerReq) (*types.ChangeOwnerResp, error) {
|
||||
groupId := convert.ToInt64(req.Id)
|
||||
personId := l.getOpe()
|
||||
memberId := req.MemberId
|
||||
|
||||
_, err := l.svcCtx.GroupClient.ChangeOwner(l.ctx, &pb.ChangeOwnerReq{
|
||||
GroupId: groupId,
|
||||
PersonId: personId,
|
||||
MemberId: memberId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.ChangeOwnerResp{}, nil
|
||||
}
|
||||
51
gateway/api/v1/internal/logic/group/create_group.go
Normal file
51
gateway/api/v1/internal/logic/group/create_group.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) CreateGroup(req *types.CreateGroupReq) (*types.CreateGroupResp, error) {
|
||||
name := req.Name
|
||||
addr := l.getOpe()
|
||||
owner := &pb.GroupMemberInfo{
|
||||
Id: addr,
|
||||
Name: "",
|
||||
}
|
||||
members := make([]*pb.GroupMemberInfo, 0, len(req.MemberIds))
|
||||
for _, memberId := range req.MemberIds {
|
||||
members = append(members, &pb.GroupMemberInfo{
|
||||
Id: memberId,
|
||||
Name: "",
|
||||
})
|
||||
}
|
||||
|
||||
resp1, err := l.svcCtx.GroupClient.CreateGroup(l.ctx, &pb.CreateGroupReq{
|
||||
Name: name,
|
||||
GroupType: pb.GroupType_GROUP_TYPE_NORMAL,
|
||||
Owner: owner,
|
||||
Members: members,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
groupId := resp1.GroupId
|
||||
|
||||
resp2, err := l.svcCtx.GroupClient.GetPriGroupInfo(l.ctx, &pb.GetPriGroupInfoReq{
|
||||
GroupId: groupId,
|
||||
PersonId: addr,
|
||||
DisplayNum: int32(1 + len(members)),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Group := NewTypesGroupInfo(resp2.Group)
|
||||
Members := NewTypesGroupMemberInfos(resp2.Group.Members)
|
||||
|
||||
return &types.CreateGroupResp{
|
||||
GroupInfo: Group,
|
||||
Members: Members,
|
||||
}, nil
|
||||
}
|
||||
29
gateway/api/v1/internal/logic/group/get_group_info.go
Normal file
29
gateway/api/v1/internal/logic/group/get_group_info.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) GetPriGroupInfo(req *types.GetGroupInfoReq) (*types.GetGroupInfoResp, error) {
|
||||
if req.DisPlayNum == 0 {
|
||||
req.DisPlayNum = 10
|
||||
}
|
||||
|
||||
resp, err := l.svcCtx.GroupClient.GetPriGroupInfo(l.ctx, &pb.GetPriGroupInfoReq{
|
||||
GroupId: req.Id,
|
||||
PersonId: l.getOpe(),
|
||||
DisplayNum: int32(req.DisPlayNum),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Group := NewTypesGroupInfo(resp.Group)
|
||||
Members := NewTypesGroupMemberInfos(resp.Group.Members)
|
||||
|
||||
return &types.GetGroupInfoResp{
|
||||
GroupInfo: Group,
|
||||
Members: Members,
|
||||
}, nil
|
||||
}
|
||||
23
gateway/api/v1/internal/logic/group/get_group_list.go
Normal file
23
gateway/api/v1/internal/logic/group/get_group_list.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) GetGroupList(req *types.GetGroupListReq) (*types.GetGroupListResp, error) {
|
||||
personId := l.getOpe()
|
||||
|
||||
resp, err := l.svcCtx.GroupClient.GetGroupList(l.ctx, &pb.GetGroupListReq{
|
||||
PersonId: personId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Groups := NewTypesGroupInfos(resp.Groups)
|
||||
|
||||
return &types.GetGroupListResp{
|
||||
Groups: Groups,
|
||||
}, nil
|
||||
}
|
||||
26
gateway/api/v1/internal/logic/group/get_group_member_info.go
Normal file
26
gateway/api/v1/internal/logic/group/get_group_member_info.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) GetGroupMemberInfo(req *types.GetGroupMemberInfoReq) (*types.GetGroupMemberInfoResp, error) {
|
||||
groupId := req.Id
|
||||
memberId := req.MemberId
|
||||
|
||||
resp, err := l.svcCtx.GroupClient.GetGroupMemberInfo(l.ctx, &pb.GetGroupMemberInfoReq{
|
||||
GroupId: groupId,
|
||||
PersonId: l.getOpe(),
|
||||
MemberId: memberId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Member := NewTypesGroupMemberInfo(resp.Member)
|
||||
res := &types.GetGroupMemberInfoResp{}
|
||||
res.GroupMember = Member
|
||||
|
||||
return res, nil
|
||||
}
|
||||
27
gateway/api/v1/internal/logic/group/get_group_member_list.go
Normal file
27
gateway/api/v1/internal/logic/group/get_group_member_list.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) GetGroupMemberList(req *types.GetGroupMemberListReq) (*types.GetGroupMemberListResp, error) {
|
||||
groupId := req.Id
|
||||
|
||||
resp, err := l.svcCtx.GroupClient.GetGroupMemberList(l.ctx, &pb.GetGroupMemberListReq{
|
||||
GroupId: groupId,
|
||||
PersonId: l.getOpe(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Members := NewTypesGroupMemberInfos(resp.Members)
|
||||
|
||||
return &types.GetGroupMemberListResp{
|
||||
Id: groupId,
|
||||
IdStr: convert.ToString(groupId),
|
||||
Members: Members,
|
||||
}, nil
|
||||
}
|
||||
19
gateway/api/v1/internal/logic/group/get_mute_list.go
Normal file
19
gateway/api/v1/internal/logic/group/get_mute_list.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) GetMuteList(req *types.GetMuteListReq) (*types.GetMuteListResp, error) {
|
||||
resp, err := l.svcCtx.GroupClient.GetMuteList(l.ctx, &pb.GetMuteListReq{
|
||||
GroupId: req.Id,
|
||||
PersonId: l.getOpe(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Members := NewTypesGroupMemberInfos(resp.Members)
|
||||
return &types.GetMuteListResp{Members: Members}, nil
|
||||
}
|
||||
21
gateway/api/v1/internal/logic/group/get_pub_group_info.go
Normal file
21
gateway/api/v1/internal/logic/group/get_pub_group_info.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) GetPubGroupInfo(req *types.GetGroupPubInfoReq) (*types.GetGroupPubInfoResp, error) {
|
||||
resp, err := l.svcCtx.GroupClient.GetPubGroupInfo(l.ctx, &pb.GetPubGroupInfoReq{
|
||||
GroupId: req.Id,
|
||||
PersonId: l.getOpe(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res := &types.GetGroupPubInfoResp{}
|
||||
Group := NewTypesGroupInfo(resp.Group)
|
||||
res.GroupInfo = Group
|
||||
return res, nil
|
||||
}
|
||||
18
gateway/api/v1/internal/logic/group/group_disband.go
Normal file
18
gateway/api/v1/internal/logic/group/group_disband.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) GroupDisband(req *types.GroupDisbandReq) (*types.GroupDisbandResp, error) {
|
||||
_, err := l.svcCtx.GroupClient.GroupDisband(l.ctx, &pb.GroupDisbandReq{
|
||||
GroupId: req.Id,
|
||||
PersonId: l.getOpe(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.GroupDisbandResp{}, nil
|
||||
}
|
||||
18
gateway/api/v1/internal/logic/group/group_exit.go
Normal file
18
gateway/api/v1/internal/logic/group/group_exit.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) GroupExit(req *types.GroupExitReq) (*types.GroupExitResp, error) {
|
||||
_, err := l.svcCtx.GroupClient.GroupExit(l.ctx, &pb.GroupExitReq{
|
||||
GroupId: req.Id,
|
||||
PersonId: l.getOpe(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.GroupExitResp{}, nil
|
||||
}
|
||||
22
gateway/api/v1/internal/logic/group/group_remove.go
Normal file
22
gateway/api/v1/internal/logic/group/group_remove.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) GroupRemove(req *types.GroupRemoveReq) (*types.GroupRemoveResp, error) {
|
||||
resp, err := l.svcCtx.GroupClient.GroupRemove(l.ctx, &pb.GroupRemoveReq{
|
||||
GroupId: req.Id,
|
||||
PersonId: l.getOpe(),
|
||||
MemberIds: req.MemberIds,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.GroupRemoveResp{
|
||||
MemberNum: resp.MemberNum,
|
||||
MemberIds: resp.MemberIds,
|
||||
}, nil
|
||||
}
|
||||
25
gateway/api/v1/internal/logic/group/invite_group_members.go
Normal file
25
gateway/api/v1/internal/logic/group/invite_group_members.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) InviteGroupMembers(req *types.InviteGroupMembersReq) (*types.InviteGroupMembersResp, error) {
|
||||
groupId := req.Id
|
||||
|
||||
_, err := l.svcCtx.GroupClient.InviteGroupMembers(l.ctx, &pb.InviteGroupMembersReq{
|
||||
GroupId: groupId,
|
||||
InviterId: l.getOpe(),
|
||||
MemberIds: req.NewMemberIds,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.InviteGroupMembersResp{
|
||||
Id: groupId,
|
||||
IdStr: convert.ToString(groupId),
|
||||
}, nil
|
||||
}
|
||||
25
gateway/api/v1/internal/logic/group/join_group.go
Normal file
25
gateway/api/v1/internal/logic/group/join_group.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) JoinGroup(req *types.JoinGroupReq) (*types.JoinGroupResp, error) {
|
||||
groupId := req.Id
|
||||
|
||||
_, err := l.svcCtx.GroupClient.InviteGroupMembers(l.ctx, &pb.InviteGroupMembersReq{
|
||||
GroupId: groupId,
|
||||
InviterId: req.InviterId,
|
||||
MemberIds: []string{l.getOpe()},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.JoinGroupResp{
|
||||
Id: groupId,
|
||||
IdStr: convert.ToString(groupId),
|
||||
}, nil
|
||||
}
|
||||
96
gateway/api/v1/internal/logic/group/newlogic.go
Normal file
96
gateway/api/v1/internal/logic/group/newlogic.go
Normal file
@@ -0,0 +1,96 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
"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"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
"gitlab.33.cn/utils/go-kit/convert"
|
||||
)
|
||||
|
||||
type GroupLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) GroupLogic {
|
||||
return GroupLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GroupLogic) getOpe() string {
|
||||
return api.NewAddrWithContext(l.ctx)
|
||||
}
|
||||
|
||||
func NewTypesGroupInfo(do *pb.GroupBizInfo) *types.GroupInfo {
|
||||
if do == nil {
|
||||
return &types.GroupInfo{}
|
||||
}
|
||||
|
||||
res := &types.GroupInfo{
|
||||
Id: do.Id,
|
||||
IdStr: convert.ToString(do.Id),
|
||||
MarkId: do.MarkId,
|
||||
Name: do.Name,
|
||||
PublicName: do.PubName,
|
||||
Avatar: do.Avatar,
|
||||
Introduce: do.Introduce,
|
||||
Owner: nil,
|
||||
Person: nil,
|
||||
MemberNum: do.MemberNum,
|
||||
Maximum: do.MemberMaximum,
|
||||
Status: int32(do.Status),
|
||||
CreateTime: do.CreateTime,
|
||||
JoinType: int32(do.JoinType),
|
||||
MuteType: int32(do.MuteType),
|
||||
FriendType: int32(do.FriendType),
|
||||
MuteNum: do.MuteNum,
|
||||
AdminNum: do.AdminNum,
|
||||
AESKey: do.AESKey,
|
||||
GroupType: int32(do.GetType()),
|
||||
}
|
||||
|
||||
if do.Owner != nil {
|
||||
res.Owner = NewTypesGroupMemberInfo(do.Owner)
|
||||
}
|
||||
|
||||
if do.Person != nil {
|
||||
res.Person = NewTypesGroupMemberInfo(do.Person)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func NewTypesGroupInfos(dos []*pb.GroupBizInfo) []*types.GroupInfo {
|
||||
dtos := make([]*types.GroupInfo, 0, len(dos))
|
||||
for _, do := range dos {
|
||||
dtos = append(dtos, NewTypesGroupInfo(do))
|
||||
}
|
||||
|
||||
return dtos
|
||||
}
|
||||
|
||||
func NewTypesGroupMemberInfo(do *pb.GroupMemberBizInfo) *types.GroupMember {
|
||||
if do == nil {
|
||||
return &types.GroupMember{}
|
||||
}
|
||||
|
||||
return &types.GroupMember{
|
||||
MemberId: do.Id,
|
||||
MemberName: do.Name,
|
||||
MemberType: int32(do.Type),
|
||||
MemberMuteTime: do.MuteTime,
|
||||
}
|
||||
}
|
||||
|
||||
func NewTypesGroupMemberInfos(dos []*pb.GroupMemberBizInfo) []*types.GroupMember {
|
||||
dtos := make([]*types.GroupMember, 0, len(dos))
|
||||
for _, do := range dos {
|
||||
dtos = append(dtos, NewTypesGroupMemberInfo(do))
|
||||
}
|
||||
|
||||
return dtos
|
||||
}
|
||||
25
gateway/api/v1/internal/logic/group/set_admin.go
Normal file
25
gateway/api/v1/internal/logic/group/set_admin.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) SetAdmin(req *types.SetAdminReq) (*types.SetAdminResp, error) {
|
||||
if _, ok := pb.GroupMemberType_name[req.MemberType]; !ok {
|
||||
return nil, xerror.NewError(xerror.ParamsError)
|
||||
}
|
||||
|
||||
_, err := l.svcCtx.GroupClient.SetAdmin(l.ctx, &pb.SetAdminReq{
|
||||
GroupId: req.Id,
|
||||
PersonId: l.getOpe(),
|
||||
MemberId: req.MemberId,
|
||||
GroupMemberType: pb.GroupMemberType(req.MemberType),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.SetAdminResp{}, nil
|
||||
}
|
||||
19
gateway/api/v1/internal/logic/group/update_group_avatar.go
Normal file
19
gateway/api/v1/internal/logic/group/update_group_avatar.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) UpdateGroupAvatar(req *types.UpdateGroupAvatarReq) (*types.UpdateGroupAvatarResp, error) {
|
||||
_, err := l.svcCtx.GroupClient.UpdateGroupAvatar(l.ctx, &pb.UpdateGroupAvatarReq{
|
||||
GroupId: req.Id,
|
||||
PersonId: l.getOpe(),
|
||||
Avatar: req.Avatar,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.UpdateGroupAvatarResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) UpdateGroupFriendType(req *types.UpdateGroupFriendTypeReq) (*types.UpdateGroupFriendTypeResp, error) {
|
||||
_, err := l.svcCtx.GroupClient.UpdateGroupFriendType(l.ctx, &pb.UpdateGroupFriendTypeReq{
|
||||
GroupId: req.Id,
|
||||
PersonId: l.getOpe(),
|
||||
GroupFriendType: pb.GroupFriendType(req.FriendType),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.UpdateGroupFriendTypeResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) UpdateGroupJoinType(req *types.UpdateGroupJoinTypeReq) (*types.UpdateGroupJoinTypeResp, error) {
|
||||
_, err := l.svcCtx.GroupClient.UpdateGroupJoinType(l.ctx, &pb.UpdateGroupJoinTypeReq{
|
||||
GroupId: req.Id,
|
||||
PersonId: l.getOpe(),
|
||||
GroupJoinType: pb.GroupJoinType(req.JoinType),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.UpdateGroupJoinTypeResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) UpdateGroupMemberMuteTime(req *types.UpdateGroupMemberMuteTimeReq) (*types.UpdateGroupMemberMuteTimeResp, error) {
|
||||
resp, err := l.svcCtx.GroupClient.UpdateGroupMemberMuteTime(l.ctx, &pb.UpdateGroupMemberMuteTimeReq{
|
||||
GroupId: req.Id,
|
||||
PersonId: l.getOpe(),
|
||||
MemberIds: req.MemberIds,
|
||||
MuteTime: req.MuteTime,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Members := NewTypesGroupMemberInfos(resp.Members)
|
||||
|
||||
return &types.UpdateGroupMemberMuteTimeResp{Members: Members}, nil
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) UpdateGroupMemberName(req *types.UpdateGroupMemberNameReq) (*types.UpdateGroupMemberNameResp, error) {
|
||||
_, err := l.svcCtx.GroupClient.UpdateGroupMemberName(l.ctx, &pb.UpdateGroupMemberNameReq{
|
||||
GroupId: req.Id,
|
||||
PersonId: l.getOpe(),
|
||||
MemberName: req.MemberName,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.UpdateGroupMemberNameResp{}, nil
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) UpdateGroupMuteType(req *types.UpdateGroupMuteTypeReq) (*types.UpdateGroupMuteTypeResp, error) {
|
||||
_, err := l.svcCtx.GroupClient.UpdateGroupMuteType(l.ctx, &pb.UpdateGroupMuteTypeReq{
|
||||
GroupId: req.Id,
|
||||
PersonId: l.getOpe(),
|
||||
GroupMuteType: pb.GroupMuteType(req.MuteType),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.UpdateGroupMuteTypeResp{}, nil
|
||||
}
|
||||
20
gateway/api/v1/internal/logic/group/update_group_name.go
Normal file
20
gateway/api/v1/internal/logic/group/update_group_name.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
pb "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
)
|
||||
|
||||
func (l *GroupLogic) UpdateGroupName(req *types.UpdateGroupNameReq) (*types.UpdateGroupNameResp, error) {
|
||||
_, err := l.svcCtx.GroupClient.UpdateGroupName(l.ctx, &pb.UpdateGroupNameReq{
|
||||
GroupId: req.Id,
|
||||
PersonId: l.getOpe(),
|
||||
Name: req.Name,
|
||||
PublicName: req.PublicName,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.UpdateGroupNameResp{}, nil
|
||||
}
|
||||
87
gateway/api/v1/internal/logic/record/focus.go
Normal file
87
gateway/api/v1/internal/logic/record/focus.go
Normal file
@@ -0,0 +1,87 @@
|
||||
package record
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
xproto "github.com/golang/protobuf/proto"
|
||||
"github.com/pkg/errors"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/model"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/util"
|
||||
"gitlab.33.cn/chat/dtalk/service/group/model/biz"
|
||||
"gitlab.33.cn/chat/imparse/proto"
|
||||
)
|
||||
|
||||
func (l *Logic) FocusPersonal(Operator string, logId int64) error {
|
||||
//查找消息
|
||||
rd, err := l.svcCtx.StoreClient.GetRecord(l.ctx, proto.Channel_ToUser, logId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
target := rd.ReceiverId
|
||||
sender := rd.SenderId
|
||||
if Operator == sender || Operator != target {
|
||||
return model.ErrPermission
|
||||
}
|
||||
now := uint64(util.TimeNowUnixNano() / int64(time.Millisecond))
|
||||
num, err := l.svcCtx.StoreClient.AddRecordFocus(l.ctx, Operator, logId, now)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
action := &proto.SignalFocusMessage{
|
||||
Mid: logId,
|
||||
Uid: Operator,
|
||||
CurrentNum: num,
|
||||
Time: now,
|
||||
}
|
||||
body, err := xproto.Marshal(action)
|
||||
if err != nil {
|
||||
return errors.WithMessagef(err, "proto.Marshal, action=%+v", action)
|
||||
}
|
||||
err = l.svcCtx.AnswerClient.UniCastSignal(l.ctx, proto.SignalType_FocusMessage, sender, body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return l.svcCtx.AnswerClient.UniCastSignal(l.ctx, proto.SignalType_FocusMessage, target, body)
|
||||
}
|
||||
|
||||
func (l *Logic) FocusGroup(Operator string, logId int64) error {
|
||||
//查找消息
|
||||
rd, err := l.svcCtx.StoreClient.GetRecord(l.ctx, proto.Channel_ToGroup, logId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
target := rd.ReceiverId
|
||||
sender := rd.SenderId
|
||||
if Operator == sender {
|
||||
return model.ErrPermission
|
||||
}
|
||||
//群成员判断
|
||||
memOpt, err := l.svcCtx.GroupClient.GetMember(l.ctx, util.ToInt64(target), Operator)
|
||||
if err != nil || memOpt == nil {
|
||||
return err
|
||||
}
|
||||
switch memOpt.GroupMemberType {
|
||||
case biz.GroupMemberTypeOwner:
|
||||
case biz.GroupMemberTypeAdmin:
|
||||
case biz.GroupMemberTypeNormal:
|
||||
default:
|
||||
return model.ErrPermission
|
||||
}
|
||||
|
||||
now := uint64(util.TimeNowUnixNano() / int64(time.Millisecond))
|
||||
num, err := l.svcCtx.StoreClient.AddRecordFocus(l.ctx, Operator, logId, now)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
action := &proto.SignalFocusMessage{
|
||||
Mid: logId,
|
||||
Uid: Operator,
|
||||
CurrentNum: num,
|
||||
Time: now,
|
||||
}
|
||||
body, err := xproto.Marshal(action)
|
||||
if err != nil {
|
||||
return errors.WithMessagef(err, "proto.Marshal, action=%+v", action)
|
||||
}
|
||||
return l.svcCtx.AnswerClient.GroupCastSignal(l.ctx, proto.SignalType_FocusMessage, target, body)
|
||||
}
|
||||
5
gateway/api/v1/internal/logic/record/push.go
Normal file
5
gateway/api/v1/internal/logic/record/push.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package record
|
||||
|
||||
func (l *Logic) Push(key, from string, body []byte) (int64, uint64, error) {
|
||||
return l.svcCtx.AnswerClient.PushCommonMsg(l.ctx, key, from, body)
|
||||
}
|
||||
47
gateway/api/v1/internal/logic/record/record.go
Normal file
47
gateway/api/v1/internal/logic/record/record.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package record
|
||||
|
||||
import (
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/model"
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/util"
|
||||
store "gitlab.33.cn/chat/dtalk/service/record/store/api"
|
||||
storeModel "gitlab.33.cn/chat/dtalk/service/record/store/model"
|
||||
"gitlab.33.cn/chat/imparse/proto"
|
||||
)
|
||||
|
||||
func (l *Logic) GetPriRecord(req *model.GetPriRecordsReq) (*model.GetPriRecordsResp, error) {
|
||||
resp, err := l.svcCtx.StoreClient.GetRecordsAfterMid(l.ctx, &store.GetRecordsAfterMidReq{
|
||||
Tp: proto.Channel_ToUser,
|
||||
Mid: util.ToInt64(req.Mid),
|
||||
From: req.FromId,
|
||||
Target: req.TargetId,
|
||||
Count: req.RecordCount,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, xerror.NewError(xerror.QueryFailed).SetExtMessage(err.Error())
|
||||
}
|
||||
|
||||
res := &model.GetPriRecordsResp{
|
||||
RecordCount: len(resp.Records),
|
||||
Records: toChatRecord(resp.Records),
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// toChatRecord []MsgContent -> []Record , content json -> proto
|
||||
func toChatRecord(msgs []*store.GetRecordReply) []*model.Record {
|
||||
Result := make([]*model.Record, len(msgs))
|
||||
for i, msg := range msgs {
|
||||
Result[i] = &model.Record{
|
||||
Mid: msg.Mid,
|
||||
Seq: msg.Seq,
|
||||
FromId: msg.SenderId,
|
||||
TargetId: msg.ReceiverId,
|
||||
MsgType: int32(msg.MsgType),
|
||||
Content: storeModel.JsonUnmarshal(msg.MsgType, []byte(msg.Content)),
|
||||
CreateTime: msg.CreateTime,
|
||||
}
|
||||
}
|
||||
return Result
|
||||
}
|
||||
101
gateway/api/v1/internal/logic/record/revoke.go
Normal file
101
gateway/api/v1/internal/logic/record/revoke.go
Normal file
@@ -0,0 +1,101 @@
|
||||
package record
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gitlab.33.cn/chat/dtalk/service/group/model/biz"
|
||||
"time"
|
||||
|
||||
xproto "github.com/golang/protobuf/proto"
|
||||
"github.com/pkg/errors"
|
||||
"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/util"
|
||||
"gitlab.33.cn/chat/imparse/proto"
|
||||
)
|
||||
|
||||
type Logic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewLogic(ctx context.Context, svcCtx *svc.ServiceContext) Logic {
|
||||
return Logic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *Logic) RevokePersonal(Operator string, mid int64) error {
|
||||
//查找消息
|
||||
rd, err := l.svcCtx.StoreClient.GetRecord(l.ctx, proto.Channel_ToUser, mid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
target := rd.ReceiverId
|
||||
if rd.SenderId != Operator || time.Since(util.UnixToTime(int64(rd.CreateTime))) > time.Duration(l.svcCtx.Config().Revoke.Expire) {
|
||||
return model.ErrPermission
|
||||
}
|
||||
action := &proto.SignalRevoke{
|
||||
Mid: mid,
|
||||
Operator: Operator,
|
||||
Self: rd.SenderId == Operator,
|
||||
}
|
||||
body, err := xproto.Marshal(action)
|
||||
if err != nil {
|
||||
return errors.WithMessagef(err, "proto.Marshal, action=%+v", action)
|
||||
}
|
||||
err = l.svcCtx.AnswerClient.UniCastSignal(l.ctx, proto.SignalType_Revoke, target, body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := l.svcCtx.StoreClient.DelRecord(l.ctx, proto.Channel_ToUser, mid); err != nil {
|
||||
return err
|
||||
}
|
||||
return l.svcCtx.AnswerClient.UniCastSignal(l.ctx, proto.SignalType_Revoke, Operator, body)
|
||||
}
|
||||
|
||||
func (l *Logic) RevokeGroup(Operator string, mid int64) error {
|
||||
//查找消息
|
||||
rd, err := l.svcCtx.StoreClient.GetRecord(l.ctx, proto.Channel_ToGroup, mid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
target := rd.ReceiverId
|
||||
if rd.SenderId == Operator && time.Since(util.UnixToTime(int64(rd.CreateTime))) > time.Duration(l.svcCtx.Config().Revoke.Expire) {
|
||||
return model.ErrPermission
|
||||
}
|
||||
if rd.SenderId != Operator {
|
||||
//执行者
|
||||
memOpt, err := l.svcCtx.GroupClient.GetMember(l.ctx, util.ToInt64(target), Operator)
|
||||
if err != nil || memOpt == nil {
|
||||
return err
|
||||
}
|
||||
//消息所有者
|
||||
memOwn, err := l.svcCtx.GroupClient.GetMember(l.ctx, util.ToInt64(target), rd.SenderId)
|
||||
if err != nil || memOwn == nil {
|
||||
return err
|
||||
}
|
||||
switch memOpt.GroupMemberType {
|
||||
case biz.GroupMemberTypeOwner:
|
||||
case biz.GroupMemberTypeAdmin:
|
||||
if memOwn.GroupMemberType == biz.GroupMemberTypeOwner {
|
||||
return model.ErrPermission
|
||||
}
|
||||
default:
|
||||
return model.ErrPermission
|
||||
}
|
||||
}
|
||||
action := &proto.SignalRevoke{
|
||||
Mid: mid,
|
||||
Operator: Operator,
|
||||
Self: rd.SenderId == Operator,
|
||||
}
|
||||
body, err := xproto.Marshal(action)
|
||||
if err != nil {
|
||||
return errors.WithMessagef(err, "proto.Marshal, action=%+v", action)
|
||||
}
|
||||
if err := l.svcCtx.StoreClient.DelRecord(l.ctx, proto.Channel_ToGroup, mid); err != nil {
|
||||
return err
|
||||
}
|
||||
return l.svcCtx.AnswerClient.GroupCastSignal(l.ctx, proto.SignalType_Revoke, target, body)
|
||||
}
|
||||
24
gateway/api/v1/internal/logic/test/testlogic.go
Normal file
24
gateway/api/v1/internal/logic/test/testlogic.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/svc"
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/types"
|
||||
)
|
||||
|
||||
type TestLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewTestLogic(ctx context.Context, svcCtx *svc.ServiceContext) TestLogic {
|
||||
return TestLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *TestLogic) GetHelloWorld() (*types.Hello, error) {
|
||||
return &types.Hello{Content: "hello world"}, nil
|
||||
}
|
||||
7
gateway/api/v1/internal/model/account.go
Normal file
7
gateway/api/v1/internal/model/account.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package model
|
||||
|
||||
// 用户地址登录请求结果
|
||||
type AddressLoginResp struct {
|
||||
// 用户地址
|
||||
Address string `json:"address" example:"123"`
|
||||
}
|
||||
6
gateway/api/v1/internal/model/const.go
Normal file
6
gateway/api/v1/internal/model/const.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package model
|
||||
|
||||
const (
|
||||
Private = 0
|
||||
Group = 1
|
||||
)
|
||||
7
gateway/api/v1/internal/model/error.go
Normal file
7
gateway/api/v1/internal/model/error.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package model
|
||||
|
||||
import "errors"
|
||||
|
||||
var (
|
||||
ErrPermission = errors.New("权限不足")
|
||||
)
|
||||
7
gateway/api/v1/internal/model/general.go
Normal file
7
gateway/api/v1/internal/model/general.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package model
|
||||
|
||||
type GeneralResponse struct {
|
||||
Result int `json:"result"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
7
gateway/api/v1/internal/model/modules.go
Normal file
7
gateway/api/v1/internal/model/modules.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package model
|
||||
|
||||
type GetModuleResp struct {
|
||||
Name string `json:"name" enums:"wallet,oa,redpacket"`
|
||||
IsEnabled bool `json:"isEnabled"`
|
||||
EndPoints []string `json:"endPoints"`
|
||||
}
|
||||
50
gateway/api/v1/internal/model/record.go
Normal file
50
gateway/api/v1/internal/model/record.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package model
|
||||
|
||||
type RevokeMsgReq struct {
|
||||
Type int `json:"type" enums:"0,1"`
|
||||
Mid int64 `json:"logId" binding:"required"`
|
||||
}
|
||||
|
||||
type FocusMsgReq struct {
|
||||
Type int `json:"type" enums:"0,1"`
|
||||
LogId int64 `json:"logId" binding:"required"`
|
||||
}
|
||||
|
||||
type Record struct {
|
||||
// log id
|
||||
Mid string `json:"logId"`
|
||||
// msg id (uuid)
|
||||
Seq string `json:"msgId"`
|
||||
// 发送者 id
|
||||
FromId string `json:"fromId"`
|
||||
// 接收者 id
|
||||
TargetId string `json:"targetId"`
|
||||
// 消息类型
|
||||
MsgType int32 `json:"msgType"`
|
||||
// 消息内容
|
||||
Content interface{} `json:"content"`
|
||||
// 消息发送时间
|
||||
CreateTime uint64 `json:"createTime"`
|
||||
}
|
||||
|
||||
type GetPriRecordsReq struct {
|
||||
// 发送者 ID
|
||||
FromId string `json:"-"`
|
||||
|
||||
// 发送者 ID
|
||||
//FromId string `json:"fromId" binding:"required"`
|
||||
|
||||
// 接受者 ID
|
||||
TargetId string `json:"targetId" binding:"required"`
|
||||
// 消息数量
|
||||
RecordCount int64 `json:"count" binding:"required,min=1,max=100"`
|
||||
// 消息 ID
|
||||
Mid string `json:"logId"`
|
||||
}
|
||||
|
||||
type GetPriRecordsResp struct {
|
||||
// 聊天记录数量
|
||||
RecordCount int `json:"record_count"`
|
||||
// 聊天记录
|
||||
Records []*Record `json:"records"`
|
||||
}
|
||||
48
gateway/api/v1/internal/svc/servicecontext.go
Normal file
48
gateway/api/v1/internal/svc/servicecontext.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
xerror "gitlab.33.cn/chat/dtalk/pkg/error"
|
||||
"gitlab.33.cn/chat/dtalk/pkg/interceptor/trace"
|
||||
group "gitlab.33.cn/chat/dtalk/service/group/api"
|
||||
store "gitlab.33.cn/chat/dtalk/service/record/store/api"
|
||||
"google.golang.org/grpc"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gitlab.33.cn/chat/dtalk/gateway/api/v1/internal/config"
|
||||
answer "gitlab.33.cn/chat/dtalk/service/record/answer/api"
|
||||
)
|
||||
|
||||
// ServiceContext 服务上下文
|
||||
type ServiceContext struct {
|
||||
m sync.RWMutex
|
||||
c config.Config
|
||||
|
||||
AnswerClient *answer.Client
|
||||
StoreClient *store.Client
|
||||
GroupClient *group.Client
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
sc := &ServiceContext{
|
||||
c: c,
|
||||
AnswerClient: answer.New(c.AnswerRPCClient.RegAddrs, c.AnswerRPCClient.Schema, c.AnswerRPCClient.SrvName, time.Duration(c.AnswerRPCClient.Dial)),
|
||||
StoreClient: store.New(c.StoreRPCClient.RegAddrs, c.StoreRPCClient.Schema, c.StoreRPCClient.SrvName, time.Duration(c.StoreRPCClient.Dial)),
|
||||
GroupClient: group.New(c.GroupRPCClient.RegAddrs,
|
||||
c.GroupRPCClient.Schema,
|
||||
c.GroupRPCClient.SrvName,
|
||||
time.Duration(c.GroupRPCClient.Dial),
|
||||
grpc.WithChainUnaryInterceptor(xerror.ErrClientInterceptor, trace.UnaryClientInterceptor),
|
||||
),
|
||||
}
|
||||
|
||||
return sc
|
||||
}
|
||||
|
||||
// Config 获取全局配置
|
||||
func (sc *ServiceContext) Config() config.Config {
|
||||
sc.m.RLock()
|
||||
defer sc.m.RUnlock()
|
||||
|
||||
return sc.c
|
||||
}
|
||||
431
gateway/api/v1/internal/types/group.go
Normal file
431
gateway/api/v1/internal/types/group.go
Normal file
@@ -0,0 +1,431 @@
|
||||
package types
|
||||
|
||||
type GeneralResp struct {
|
||||
Result int `json:"result"`
|
||||
Message int `json:"message"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
|
||||
type GroupMember struct {
|
||||
// 用户 ID
|
||||
MemberId string `json:"memberId" form:"memberId"`
|
||||
// 用户群昵称
|
||||
MemberName string `json:"memberName" form:"memberName"`
|
||||
// 用户角色,2=群主,1=管理员,0=群员,10=退群
|
||||
MemberType int32 `json:"memberType" form:"memberType"`
|
||||
// 该用户被禁言结束的时间 9223372036854775807=永久禁言
|
||||
MemberMuteTime int64 `json:"memberMuteTime"`
|
||||
}
|
||||
|
||||
type GroupInfo struct {
|
||||
// 群 ID
|
||||
Id int64 `json:"id" form:"id"`
|
||||
IdStr string `json:"idStr"`
|
||||
// 群显示的 ID
|
||||
MarkId string `json:"markId" form:"markId"`
|
||||
// 群名称 加密的
|
||||
Name string `json:"name" form:"name"`
|
||||
// 公开的群名称 不加密的
|
||||
PublicName string `json:"publicName"`
|
||||
// 头像 url
|
||||
Avatar string `json:"avatar" form:"avatar"`
|
||||
Introduce string `json:"introduce" form:"introduce"`
|
||||
// 群主 信息
|
||||
Owner *GroupMember `json:"owner" form:"owner"`
|
||||
// 本人在群内的信息
|
||||
Person *GroupMember `json:"person" form:"person"`
|
||||
// 群人数
|
||||
MemberNum int32 `json:"memberNum" form:"memberNum"`
|
||||
// 群人数上限
|
||||
Maximum int32 `json:"maximum" form:"maximum"`
|
||||
// 群状态,0=正常 1=封禁 2=解散
|
||||
Status int32 `json:"status" form:"status"`
|
||||
// 群创建时间
|
||||
CreateTime int64 `json:"createTime" form:"createTime"`
|
||||
// 加群方式,0=无需审批(默认),1=禁止加群,群主和管理员邀请加群, 2=普通人邀请需要审批,群主和管理员直接加群
|
||||
JoinType int32 `json:"joinType" form:"joinType"`
|
||||
// 禁言, 0=全员可发言, 1=全员禁言(除群主和管理员)
|
||||
MuteType int32 `json:"muteType" form:"muteType"`
|
||||
// 加好友限制, 0=群内可加好友,1=群内禁止加好友
|
||||
FriendType int32 `json:"friendType"`
|
||||
// 群内当前被禁言的人数
|
||||
MuteNum int32 `json:"muteNum"`
|
||||
// 群内管理员数量
|
||||
AdminNum int32 `json:"adminNum"`
|
||||
//
|
||||
AESKey string `json:"key"`
|
||||
// 群类型 (0: 普通群, 1: 全员群, 2: 部门群)
|
||||
GroupType int32 `json:"groupType"`
|
||||
}
|
||||
|
||||
type CreateGroupReq struct {
|
||||
Name string `json:"name" form:"name"`
|
||||
Avatar string `json:"avatar" form:"avatar"`
|
||||
Introduce string `json:"introduce" form:"introduce"`
|
||||
MemberIds []string `json:"memberIds" form:"memberIds"`
|
||||
}
|
||||
|
||||
type CreateGroupResp struct {
|
||||
*GroupInfo
|
||||
// 群成员
|
||||
Members []*GroupMember `json:"members" form:"members"`
|
||||
}
|
||||
|
||||
type InviteGroupMembersReq struct {
|
||||
Id int64 `json:"id" form:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
Inviter GroupMember `json:"-"`
|
||||
NewMembers []GroupMember `json:"-"`
|
||||
NewMemberIds []string `json:"newMemberIds" form:"newMemberIds" binding:"required"`
|
||||
}
|
||||
|
||||
type InviteGroupMembersResp struct {
|
||||
Id int64 `json:"id" form:"id" example:"123821199217135616"`
|
||||
IdStr string `json:"idStr"`
|
||||
MemberNum int32 `json:"memberNum" form:"memberNum" example:"5"`
|
||||
//Inviter GroupMember `json:"inviter" form:"inviter"`
|
||||
//NewMembers []GroupMember `json:"newMembers" form:"newMembers"`
|
||||
}
|
||||
|
||||
type GetGroupInfoReq struct {
|
||||
Id int64 `json:"id" uri:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
PersonId string `json:"-"`
|
||||
DisPlayNum int64 `json:"-"`
|
||||
}
|
||||
|
||||
type GetGroupInfoResp struct {
|
||||
*GroupInfo
|
||||
Members []*GroupMember `json:"members" form:"members"`
|
||||
}
|
||||
|
||||
type GetGroupListReq struct {
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type GetGroupListResp struct {
|
||||
Groups []*GroupInfo `json:"groups"`
|
||||
}
|
||||
|
||||
type GetGroupMemberListReq struct {
|
||||
Id int64 `json:"id" uri:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type GetGroupMemberListResp struct {
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
Members []*GroupMember `json:"members"`
|
||||
}
|
||||
|
||||
type GetGroupMemberInfoReq struct {
|
||||
Id int64 `json:"id" uri:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
MemberId string `json:"memberId" uri:"memberId" binding:"required"`
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type GetGroupMemberInfoResp struct {
|
||||
*GroupMember
|
||||
}
|
||||
|
||||
type GroupExitReq struct {
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type GroupExitResp struct {
|
||||
}
|
||||
|
||||
type GroupRemoveReq struct {
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
MemberIds []string `json:"memberIds" binding:"required"`
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type GroupRemoveResp struct {
|
||||
// 群人数
|
||||
MemberNum int32 `json:"memberNum" form:"memberNum"`
|
||||
// 成功被踢的成员列表
|
||||
MemberIds []string `json:"memberIds"`
|
||||
}
|
||||
|
||||
type GroupDisbandReq struct {
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type GroupDisbandResp struct {
|
||||
}
|
||||
|
||||
type UpdateGroupNameReq struct {
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
PersonId string `json:"-"`
|
||||
Name string `json:"name"`
|
||||
PublicName string `json:"publicName"`
|
||||
}
|
||||
|
||||
type UpdateGroupNameResp struct {
|
||||
}
|
||||
|
||||
type UpdateGroupAvatarReq struct {
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
PersonId string `json:"-"`
|
||||
Avatar string `json:"avatar"`
|
||||
}
|
||||
|
||||
type UpdateGroupAvatarResp struct {
|
||||
}
|
||||
|
||||
type UpdateGroupMemberNameReq struct {
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
PersonId string `json:"-"`
|
||||
MemberName string `json:"memberName"`
|
||||
}
|
||||
|
||||
type UpdateGroupMemberNameResp struct {
|
||||
}
|
||||
|
||||
type UpdateGroupJoinTypeReq struct {
|
||||
// 群 ID
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
PersonId string `json:"-"`
|
||||
// 加群方式,0=无需审批(默认),1=禁止加群,群主和管理员邀请加群, 2=普通人邀请需要审批,群主和管理员直接加群
|
||||
JoinType int32 `json:"joinType" binding:"oneof=0 1 2"`
|
||||
}
|
||||
|
||||
type UpdateGroupJoinTypeResp struct {
|
||||
}
|
||||
|
||||
type UpdateGroupFriendTypeReq struct {
|
||||
// 群 ID
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
PersonId string `json:"-"`
|
||||
// 加好友限制, 0=群内可加好友,1=群内禁止加好友
|
||||
FriendType int32 `json:"friendType" binding:"oneof=0 1"`
|
||||
}
|
||||
|
||||
type UpdateGroupFriendTypeResp struct {
|
||||
}
|
||||
|
||||
type ChangeOwnerReq struct {
|
||||
// 群 ID
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
// 被转让为群主的群成员 ID
|
||||
MemberId string `json:"memberId" binding:"required"`
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type ChangeOwnerResp struct {
|
||||
}
|
||||
|
||||
// JoinGroupReq 扫二维码加群
|
||||
type JoinGroupReq struct {
|
||||
Id int64 `json:"id"`
|
||||
IdStr string `json:"idStr"`
|
||||
InviterId string `json:"inviterId"`
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type JoinGroupResp struct {
|
||||
Id int64 `json:"id"`
|
||||
IdStr string `json:"idStr"`
|
||||
}
|
||||
|
||||
type SetAdminReq struct {
|
||||
// 群 ID
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
// 被设置的群成员 ID
|
||||
MemberId string `json:"memberId" binding:"required"`
|
||||
PersonId string `json:"-"`
|
||||
// 用户角色 0=群员, 1=管理员
|
||||
MemberType int32 `json:"memberType" binding:"oneof=0 1"`
|
||||
}
|
||||
|
||||
type SetAdminResp struct {
|
||||
}
|
||||
|
||||
type UpdateGroupMuteTypeReq struct {
|
||||
// 群 ID
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
// 禁言, 0=全员可发言, 1=全员禁言(除群主和管理员)
|
||||
MuteType int32 `json:"muteType" binding:"oneof=0 1"`
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type UpdateGroupMuteTypeResp struct {
|
||||
}
|
||||
|
||||
type UpdateGroupMemberMuteTimeReq struct {
|
||||
// 群 ID
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
// 被禁言的群员 ID
|
||||
MemberIds []string `json:"memberIds" binding:"required"`
|
||||
// 禁言持续时间, 传9223372036854775807=永久禁言, 0=解除禁言
|
||||
MuteTime int64 `json:"muteTime"`
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type UpdateGroupMemberMuteTimeResp struct {
|
||||
Members []*GroupMember `json:"members"`
|
||||
}
|
||||
|
||||
type GetMuteListReq struct {
|
||||
// 群 ID
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type GetMuteListResp struct {
|
||||
Members []*GroupMember `json:"members"`
|
||||
}
|
||||
|
||||
type GetGroupPubInfoReq struct {
|
||||
// 群 ID
|
||||
Id int64 `json:"id"`
|
||||
// 如果同时填了 idStr, 则优先选择 idStr
|
||||
IdStr string `json:"idStr"`
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type GetGroupPubInfoResp struct {
|
||||
*GroupInfo
|
||||
}
|
||||
|
||||
type GetGroupInfoByConditionReq struct {
|
||||
// 查询方法 0:groupMarkId, 1:groupId
|
||||
Tp int32 `json:"tp" binding:"oneof=0 1"`
|
||||
Query string `json:"query" binding:"required"`
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type GetGroupInfoByConditionResp struct {
|
||||
Groups []*GroupInfo `json:"groups"`
|
||||
}
|
||||
|
||||
// ---群审批------------------
|
||||
|
||||
// GroupApplyInfo 群审批信息
|
||||
type GroupApplyInfo struct {
|
||||
// 审批 ID
|
||||
ApplyId string `json:"applyId,omitempty"`
|
||||
// 群 ID
|
||||
GroupId string `json:"id,omitempty"`
|
||||
// 邀请人 ID, 空表示是自己主动申请的
|
||||
InviterId string `json:"inviterId,omitempty"`
|
||||
// 申请加入人 ID
|
||||
MemberId string `json:"memberId,omitempty"`
|
||||
// 申请备注
|
||||
ApplyNote string `json:"applyNote,omitempty"`
|
||||
// 审批人 ID
|
||||
OperatorId string `json:"operatorId,omitempty"`
|
||||
// 审批情况 0=待审批, 1=审批通过, 2=审批不通过, 10=审批忽略
|
||||
ApplyStatus int32 `json:"applyStatus,omitempty"`
|
||||
// 拒绝原因
|
||||
RejectReason string `json:"rejectReason,omitempty"`
|
||||
// 创建时间 ms
|
||||
CreateTime int64 `json:"createTime,omitempty"`
|
||||
// 修改时间 ms
|
||||
UpdateTime int64 `json:"updateTime,omitempty"`
|
||||
}
|
||||
|
||||
// CreateGroupApplyReq 创建群审批请求
|
||||
type CreateGroupApplyReq struct {
|
||||
// 群 ID
|
||||
Id string `json:"id,omitempty" binding:"required"`
|
||||
// 申请备注
|
||||
ApplyNote string `json:"applyNote,omitempty"`
|
||||
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
// CreateGroupApplyResp 创建群审批响应
|
||||
type CreateGroupApplyResp struct {
|
||||
}
|
||||
|
||||
// GetGroupApplyByIdReq 查询群审批请求
|
||||
type GetGroupApplyByIdReq struct {
|
||||
// 审批 ID
|
||||
ApplyId string `json:"applyId" binding:"required"`
|
||||
// 群 ID
|
||||
Id string `json:"id" binding:"required"`
|
||||
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
// GetGroupApplysReq 查询群审批列表请求
|
||||
type GetGroupApplysReq struct {
|
||||
// 群 ID
|
||||
Id string `json:"id" binding:"required"`
|
||||
// 每页记录数
|
||||
Count int32 `json:"count" binding:"required"`
|
||||
// 当前审批记录数量
|
||||
Offset int32 `json:"offset"`
|
||||
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
// GetGroupApplysResp 查询群审批响应
|
||||
type GetGroupApplysResp struct {
|
||||
GroupApplys []*GroupApplyInfo `json:"applys"`
|
||||
}
|
||||
|
||||
// AcceptGroupApplyReq 接受加群审批请求
|
||||
type AcceptGroupApplyReq struct {
|
||||
// 审批 ID
|
||||
ApplyId string `json:"applyId" binding:"required"`
|
||||
// 群 ID
|
||||
Id string `json:"id" binding:"required"`
|
||||
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type AcceptGroupApplyResp struct {
|
||||
}
|
||||
|
||||
// RejectGroupApplyReq 拒绝加群审批请求
|
||||
type RejectGroupApplyReq struct {
|
||||
// 审批 ID
|
||||
ApplyId string `json:"applyId" binding:"required"`
|
||||
// 群 ID
|
||||
Id string `json:"id" binding:"required"`
|
||||
// 拒绝原因
|
||||
RejectReason string `json:"rejectReason"`
|
||||
|
||||
PersonId string `json:"-"`
|
||||
}
|
||||
|
||||
type RejectGroupApplyResp struct {
|
||||
}
|
||||
6
gateway/api/v1/internal/types/types.go
Normal file
6
gateway/api/v1/internal/types/types.go
Normal file
@@ -0,0 +1,6 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
package types
|
||||
|
||||
type Hello struct {
|
||||
Content string `json:"content"`
|
||||
}
|
||||
16
gateway/api/v1/version.go
Normal file
16
gateway/api/v1/version.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
//var (
|
||||
// // The full version string
|
||||
// Version = "0.0.7"
|
||||
//
|
||||
// // GitCommit is set with --ldflags "-X main.gitCommit=$(git rev-parse --short=8 HEAD)"
|
||||
// GitCommit string
|
||||
//)
|
||||
//
|
||||
//func GetVersion() string {
|
||||
// if GitCommit != "" {
|
||||
// return Version + "-" + GitCommit
|
||||
// }
|
||||
// return Version
|
||||
//}
|
||||
Reference in New Issue
Block a user