mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
add
This commit is contained in:
parent
6de61cb214
commit
52579c5fab
14
cmd/rpc/open_im_admin_cms/main.go
Normal file
14
cmd/rpc/open_im_admin_cms/main.go
Normal file
@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
rpcMessageCMS "Open_IM/internal/rpc/admin_cms"
|
||||
"flag"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rpcPort := flag.Int("port", 11000, "rpc listening port")
|
||||
flag.Parse()
|
||||
rpcServer := rpcMessageCMS.NewAdminCMSServer(*rpcPort)
|
||||
rpcServer.Run()
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ mysql:
|
||||
dbMysqlAddress: [ 43.128.5.63:13306 ]
|
||||
dbMysqlUserName: root
|
||||
dbMysqlPassword: openIM
|
||||
dbMysqlDatabaseName: openIM
|
||||
dbMysqlDatabaseName: openIMtest1
|
||||
dbTableName: eMsg
|
||||
dbMsgTableNum: 1
|
||||
dbMaxOpenConns: 20
|
||||
@ -30,7 +30,7 @@ mongo:
|
||||
dbRetainChatRecords: 7
|
||||
|
||||
redis:
|
||||
dbAddress: 127.0.0.1:16379
|
||||
dbAddress: 43.128.5.63:16379
|
||||
dbMaxIdle: 128
|
||||
dbMaxActive: 0
|
||||
dbIdleTimeout: 120
|
||||
@ -94,6 +94,7 @@ rpcport:
|
||||
openImPushPort: [ 10700 ]
|
||||
openImOpenImStatisticPort: [ 10800 ]
|
||||
OpenImMessageCMSPort: [ 10900 ]
|
||||
openImAdminCMSPort: [10100]
|
||||
c2c:
|
||||
callbackBeforeSendMsg:
|
||||
switch: false
|
||||
@ -114,6 +115,7 @@ rpcregistername:
|
||||
openImAuthName: Auth
|
||||
OpenImStatisticsName: Statistics
|
||||
OpenImMessageCMSName: MessageCMS
|
||||
openImAdminCMSName: AdminCMS
|
||||
|
||||
log:
|
||||
storageLocation: ../logs/
|
||||
@ -150,7 +152,7 @@ push:
|
||||
pushUrl: "https://api.jpush.cn/v3/push"
|
||||
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
|
||||
manager:
|
||||
appManagerUid: [ "openIM123456","openIM654321", "openIM333" ]
|
||||
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"]
|
||||
secrets: [ "openIM1","openIM2", "openIM333" ]
|
||||
|
||||
secret: tuoyun
|
||||
|
@ -1,24 +1,42 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"Open_IM/pkg/cms_api_struct"
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
openIMHttp "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAdmin "Open_IM/pkg/proto/admin_cms"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// register
|
||||
func AdminLogin(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"message": "someJSON", "status": 200})
|
||||
}
|
||||
|
||||
func AdminRegister(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"message": "someJSON", "status": 200})
|
||||
}
|
||||
|
||||
func GetAdminSettings(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"message": "someJSON", "status": 200})
|
||||
}
|
||||
|
||||
func AlterAdminSettings(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"message": "someJSON", "status": 200})
|
||||
var (
|
||||
req cms_api_struct.AdminLoginRequest
|
||||
resp cms_api_struct.AdminLoginResponse
|
||||
reqPb pbAdmin.AdminLoginReq
|
||||
)
|
||||
if err := c.BindJSON(&req); err != nil {
|
||||
log.NewInfo("0", utils.GetSelfFuncName(), err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
|
||||
return
|
||||
}
|
||||
reqPb.Secret = req.Secret
|
||||
reqPb.AdminID = req.AdminName
|
||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAdminCMSName)
|
||||
client := pbAdmin.NewAdminCMSClient(etcdConn)
|
||||
respPb, err := client.AdminLogin(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "rpc failed", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
resp.Token = respPb.Token
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ func GetGroupMembers(c *gin.Context) {
|
||||
respPb, err := client.GetGroupMembersCMS(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetGroupMembersCMS failed:", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
resp.ResponsePagination = cms_api_struct.ResponsePagination{
|
||||
@ -392,6 +392,6 @@ func SetGroupMaster(c *gin.Context) {
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
|
||||
func GetMemberInGroup(c *gin.Context) {
|
||||
func SetMemberInGroup(c *gin.Context) {
|
||||
|
||||
}
|
@ -26,7 +26,7 @@ func BroadcastMessage(c *gin.Context) {
|
||||
_, err := client.BoradcastMessage(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
||||
openIMHttp.RespHttp200S(c, err, nil)
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
@ -61,7 +61,7 @@ func GetChatLogs(c *gin.Context) {
|
||||
respPb, err := client.GetChatLogs(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetChatLogs rpc failed", err.Error())
|
||||
openIMHttp.RespHttp200S(c, constant.ErrServer, resp)
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&resp, &respPb)
|
||||
|
@ -1,11 +1,23 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func JWTAuth() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
|
||||
ok, token := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||
fmt.Println(token)
|
||||
if !ok {
|
||||
log.NewError("","GetUserIDFromToken false ", c.Request.Header.Get("token"))
|
||||
c.Abort()
|
||||
http.RespHttp200(c, constant.ErrParseToken, nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,15 +16,14 @@ func NewGinRouter() *gin.Engine {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
baseRouter := gin.Default()
|
||||
router := baseRouter.Group("/api")
|
||||
router.Use(middleware.JWTAuth())
|
||||
router.Use(middleware.CorsHandler())
|
||||
adminRouterGroup := router.Group("/admin")
|
||||
{
|
||||
adminRouterGroup.POST("/register", admin.AdminRegister)
|
||||
adminRouterGroup.GET("/get_user_settings", admin.GetAdminSettings)
|
||||
adminRouterGroup.POST("/alter_user_settings", admin.AlterAdminSettings)
|
||||
adminRouterGroup.POST("/login", admin.AdminLogin)
|
||||
}
|
||||
statisticsRouterGroup := router.Group("/statistics")
|
||||
r2 := router.Group("")
|
||||
r2.Use(middleware.JWTAuth())
|
||||
statisticsRouterGroup := r2.Group("/statistics")
|
||||
{
|
||||
statisticsRouterGroup.GET("/get_messages_statistics", statistics.GetMessagesStatistics)
|
||||
statisticsRouterGroup.GET("/get_user_statistics", statistics.GetUserStatistics)
|
||||
@ -32,7 +31,7 @@ func NewGinRouter() *gin.Engine {
|
||||
statisticsRouterGroup.GET("/get_active_user", statistics.GetActiveUser)
|
||||
statisticsRouterGroup.GET("/get_active_group", statistics.GetActiveGroup)
|
||||
}
|
||||
organizationRouterGroup := router.Group("/organization")
|
||||
organizationRouterGroup := r2.Group("/organization")
|
||||
{
|
||||
organizationRouterGroup.GET("/get_staffs", organization.GetStaffs)
|
||||
organizationRouterGroup.GET("/get_organizations", organization.GetOrganizations)
|
||||
@ -46,7 +45,7 @@ func NewGinRouter() *gin.Engine {
|
||||
organizationRouterGroup.PATCH("/alter_corps_info", organization.AlterStaffsInfo)
|
||||
organizationRouterGroup.POST("/add_child_org", organization.AddChildOrganization)
|
||||
}
|
||||
groupRouterGroup := router.Group("/group")
|
||||
groupRouterGroup := r2.Group("/group")
|
||||
{
|
||||
groupRouterGroup.GET("/get_group_by_id", group.GetGroupById)
|
||||
groupRouterGroup.GET("/get_groups", group.GetGroups)
|
||||
@ -60,10 +59,10 @@ func NewGinRouter() *gin.Engine {
|
||||
groupRouterGroup.POST("/ban_group_chat", group.BanGroupChat)
|
||||
groupRouterGroup.POST("/open_group_chat", group.OpenGroupChat)
|
||||
groupRouterGroup.POST("/delete_group", group.DeleteGroup)
|
||||
groupRouterGroup.POST("/get_members_in_group", group.GetMemberInGroup)
|
||||
groupRouterGroup.POST("/get_members_in_group", group.GetGroupMembers)
|
||||
groupRouterGroup.POST("/set_group_master", group.SetGroupMaster)
|
||||
}
|
||||
userRouterGroup := router.Group("/user")
|
||||
userRouterGroup := r2.Group("/user")
|
||||
{
|
||||
userRouterGroup.POST("/resign", user.ResignUser)
|
||||
userRouterGroup.GET("/get_user", user.GetUserById)
|
||||
@ -77,13 +76,13 @@ func NewGinRouter() *gin.Engine {
|
||||
userRouterGroup.POST("/delete_user", user.DeleteUser)
|
||||
userRouterGroup.GET("/get_users_by_name", user.GetUsersByName)
|
||||
}
|
||||
friendRouterGroup := router.Group("/friend")
|
||||
friendRouterGroup := r2.Group("/friend")
|
||||
{
|
||||
friendRouterGroup.POST("/get_friends_by_id")
|
||||
friendRouterGroup.POST("/set_friend")
|
||||
friendRouterGroup.POST("/remove_friend")
|
||||
}
|
||||
messageCMSRouterGroup := router.Group("/message")
|
||||
messageCMSRouterGroup := r2.Group("/message")
|
||||
{
|
||||
messageCMSRouterGroup.GET("/get_chat_logs", messageCMS.GetChatLogs)
|
||||
messageCMSRouterGroup.POST("/broadcast_message", messageCMS.BroadcastMessage)
|
||||
|
@ -35,7 +35,7 @@ func GetUserById(c *gin.Context) {
|
||||
respPb, err := client.GetUserById(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
if respPb.User.UserId == "" {
|
||||
@ -67,7 +67,7 @@ func GetUsersByName(c *gin.Context) {
|
||||
respPb, err := client.GetUsersByName(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "rpc", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&resp.Users, respPb.Users)
|
||||
@ -94,7 +94,7 @@ func GetUsers(c *gin.Context) {
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetUsers(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, resp)
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
return
|
||||
}
|
||||
utils.CopyStructFields(&resp.Users, respPb.User)
|
||||
@ -122,7 +122,7 @@ func ResignUser(c *gin.Context) {
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
_, err := client.ResignUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, resp)
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
}
|
||||
@ -144,7 +144,7 @@ func AlterUser(c *gin.Context) {
|
||||
_, err := client.AlterUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError("0", "microserver failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
}
|
||||
@ -164,7 +164,7 @@ func AddUser(c *gin.Context) {
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
_, err := client.AddUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
@ -189,7 +189,7 @@ func BlockUser(c *gin.Context) {
|
||||
fmt.Println(reqPb)
|
||||
_, err := client.BlockUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, resp)
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
@ -211,7 +211,7 @@ func UnblockUser(c *gin.Context) {
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
_, err := client.UnBlockUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, resp)
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, resp)
|
||||
@ -236,7 +236,8 @@ func GetBlockUsers(c *gin.Context) {
|
||||
client := pb.NewUserClient(etcdConn)
|
||||
respPb, err := client.GetBlockUsers(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, resp)
|
||||
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "GetBlockUsers rpc", err.Error())
|
||||
openIMHttp.RespHttp200(c, err, resp)
|
||||
return
|
||||
}
|
||||
for _, v := range respPb.BlockUsers {
|
||||
@ -275,7 +276,7 @@ func GetBlockUserById(c *gin.Context) {
|
||||
respPb, err := client.GetBlockUserById(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError("0", "GetBlockUserById rpc failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
resp.EndDisableTime = respPb.BlockUser.EndDisableTime
|
||||
@ -300,7 +301,7 @@ func DeleteUser(c *gin.Context) {
|
||||
_, err := client.DeleteUser(context.Background(), &reqPb)
|
||||
if err != nil {
|
||||
log.NewError("0", "DeleteUser rpc failed ", err.Error())
|
||||
openIMHttp.RespHttp200(c, constant.ErrServer, nil)
|
||||
openIMHttp.RespHttp200(c, err, nil)
|
||||
return
|
||||
}
|
||||
openIMHttp.RespHttp200(c, constant.OK, nil)
|
||||
|
92
internal/rpc/admin_cms/admin_cms.go
Normal file
92
internal/rpc/admin_cms/admin_cms.go
Normal file
@ -0,0 +1,92 @@
|
||||
package admin_cms
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
openIMHttp "Open_IM/pkg/common/http"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
pbAdminCMS "Open_IM/pkg/proto/admin_cms"
|
||||
"Open_IM/pkg/utils"
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type adminCMSServer struct {
|
||||
rpcPort int
|
||||
rpcRegisterName string
|
||||
etcdSchema string
|
||||
etcdAddr []string
|
||||
}
|
||||
|
||||
func NewAdminCMSServer(port int) *adminCMSServer {
|
||||
log.NewPrivateLog("AdminCMS")
|
||||
return &adminCMSServer{
|
||||
rpcPort: port,
|
||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImAdminCMSName,
|
||||
etcdSchema: config.Config.Etcd.EtcdSchema,
|
||||
etcdAddr: config.Config.Etcd.EtcdAddr,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) Run() {
|
||||
log.NewInfo("0", "AdminCMS rpc start ")
|
||||
ip := utils.ServerIP
|
||||
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
|
||||
//listener network
|
||||
listener, err := net.Listen("tcp", registerAddress)
|
||||
if err != nil {
|
||||
log.NewError("0", "Listen failed ", err.Error(), registerAddress)
|
||||
return
|
||||
}
|
||||
log.NewInfo("0", "listen network success, ", registerAddress, listener)
|
||||
defer listener.Close()
|
||||
//grpc server
|
||||
srv := grpc.NewServer()
|
||||
defer srv.GracefulStop()
|
||||
//Service registers with etcd
|
||||
pbAdminCMS.RegisterAdminCMSServer(srv, s)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError("0", "RegisterEtcd failed ", err.Error())
|
||||
return
|
||||
}
|
||||
err = srv.Serve(listener)
|
||||
if err != nil {
|
||||
log.NewError("0", "Serve failed ", err.Error())
|
||||
return
|
||||
}
|
||||
log.NewInfo("0", "message cms rpc success")
|
||||
}
|
||||
|
||||
func (s *adminCMSServer) AdminLogin(_ context.Context, req *pbAdminCMS.AdminLoginReq) (*pbAdminCMS.AdminLoginResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbAdminCMS.AdminLoginResp{}
|
||||
for _, adminID := range config.Config.Manager.AppManagerUid{
|
||||
if adminID == req.AdminID {
|
||||
for _, secret := range config.Config.Manager.Secrets {
|
||||
if secret == req.Secret {
|
||||
str := secret+adminID
|
||||
token, expTime, err := token_verify.CreateToken(str,9843)
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "generate token success", "token: ", token, "expTime:", expTime)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "generate token failed", "str: ", str, err.Error())
|
||||
return resp, openIMHttp.WrapError(constant.ErrTokenUnknown)
|
||||
}
|
||||
resp.Token = token
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if resp.Token == "" {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "failed")
|
||||
return resp, openIMHttp.WrapError(constant.ErrTokenMalformed)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
@ -834,11 +834,22 @@ func (s *groupServer) RemoveGroupMembersCMS(_ context.Context, req *pbGroup.Remo
|
||||
func (s *groupServer) AddGroupMembersCMS(_ context.Context, req *pbGroup.AddGroupMembersCMSReq) (*pbGroup.AddGroupMembersCMSResp, error) {
|
||||
log.NewInfo(req.OperationId, utils.GetSelfFuncName(), "args:", req.String())
|
||||
resp := &pbGroup.AddGroupMembersCMSResp{}
|
||||
for _, userIds := range req.UserIds {
|
||||
for _, userId := range req.UserIds {
|
||||
if isExist := imdb.IsExistGroupMember(req.GroupId, userId); isExist {
|
||||
log.NewError(req.OperationId, utils.GetSelfFuncName(), "user is exist in group", userId, req.GroupId)
|
||||
resp.Failed = append(resp.Failed, userId)
|
||||
continue
|
||||
}
|
||||
user, err := imdb.GetUserByUserID(userId)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationId, utils.GetSelfFuncName(), "GetUserByUserID", err.Error())
|
||||
resp.Failed = append(resp.Failed, userId)
|
||||
continue
|
||||
}
|
||||
groupMember := db.GroupMember{
|
||||
GroupID: req.GroupId,
|
||||
UserID: userIds,
|
||||
Nickname: "",
|
||||
UserID: userId,
|
||||
Nickname: user.Nickname,
|
||||
FaceUrl: "",
|
||||
RoleLevel: 1,
|
||||
JoinTime: time.Time{},
|
||||
@ -848,9 +859,9 @@ func (s *groupServer) AddGroupMembersCMS(_ context.Context, req *pbGroup.AddGrou
|
||||
}
|
||||
if err := imdb.InsertIntoGroupMember(groupMember); err != nil {
|
||||
log.NewError(req.OperationId, utils.GetSelfFuncName(), "InsertIntoGroupMember failed", req.String())
|
||||
resp.Failed = append(resp.Failed, userIds)
|
||||
resp.Failed = append(resp.Failed, userId)
|
||||
} else {
|
||||
resp.Success = append(resp.Success, userIds)
|
||||
resp.Success = append(resp.Success, userId)
|
||||
}
|
||||
}
|
||||
return resp, nil
|
||||
@ -862,7 +873,7 @@ func (s *groupServer) SetGroupMaster(_ context.Context, req *pbGroup.SetGroupMas
|
||||
err := imdb.OperateGroupRole(req.UserId, req.GroupId, constant.GroupOwner)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationId, utils.GetSelfFuncName(),"OperateGroupRole failed", err.Error())
|
||||
return resp, nil
|
||||
return resp, constant.ErrDB
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/common/http"
|
||||
errors "Open_IM/pkg/common/http"
|
||||
"context"
|
||||
|
||||
"Open_IM/pkg/common/log"
|
||||
@ -73,19 +73,24 @@ func (s *messageCMSServer) Run() {
|
||||
func (s *messageCMSServer) BoradcastMessage(_ context.Context, req *pbMessageCMS.BoradcastMessageReq) (*pbMessageCMS.BoradcastMessageResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "BoradcastMessage", req.String())
|
||||
resp := &pbMessageCMS.BoradcastMessageResp{}
|
||||
return resp, http.WarpError(constant.ErrDB)
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
|
||||
func (s *messageCMSServer) GetChatLogs(_ context.Context, req *pbMessageCMS.GetChatLogsReq) (*pbMessageCMS.GetChatLogsResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "GetChatLogs", req.String())
|
||||
resp := &pbMessageCMS.GetChatLogsResp{}
|
||||
time, err := utils.TimeStringToTime(req.Date)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "time string parse error", err.Error())
|
||||
}
|
||||
chatLog := db.ChatLog{
|
||||
Content: req.Content,
|
||||
SendTime: time,
|
||||
}
|
||||
chatLogs, err := imdb.GetChatLog(chatLog, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||
chatLogs, err := imdb.GetChatLog(chatLog, req.Pagination.PageNumber, req.Pagination.ShowNumber)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetChatLog", err.Error())
|
||||
return resp, http.WarpError(constant.ErrDB)
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
for _, chatLog := range chatLogs {
|
||||
pbChatLog := &pbMessageCMS.ChatLogs{
|
||||
@ -134,6 +139,5 @@ func (s *messageCMSServer) MassSendMessage(_ context.Context, req *pbMessageCMS.
|
||||
func (s *messageCMSServer) WithdrawMessage(_ context.Context, req *pbMessageCMS.WithdrawMessageReq) (*pbMessageCMS.WithdrawMessageResp, error) {
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "WithdrawMessage", req.String())
|
||||
resp := &pbMessageCMS.WithdrawMessageResp{}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/db"
|
||||
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||
errors "Open_IM/pkg/common/http"
|
||||
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/common/token_verify"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
@ -249,7 +251,7 @@ func (s *userServer) GetUsersByName(ctx context.Context, req *pbUser.GetUsersByN
|
||||
users, err := imdb.GetUserByName(req.UserName, req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserByName failed", err.Error())
|
||||
return resp, err
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
for _, user := range users {
|
||||
isBlock, err := imdb.UserIsBlock(user.UserID)
|
||||
@ -269,14 +271,14 @@ func (s *userServer) GetUsersByName(ctx context.Context, req *pbUser.GetUsersByN
|
||||
userNums, err := imdb.GetUsersCount(user)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "", err.Error())
|
||||
return resp, err
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
resp.UserNums = userNums
|
||||
resp.Pagination = &sdkws.ResponsePagination{
|
||||
CurrentPage: req.Pagination.PageNumber,
|
||||
ShowNumber: req.Pagination.ShowNumber,
|
||||
}
|
||||
return resp, err
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (s *userServer) GetUserById(ctx context.Context, req *pbUser.GetUserByIdReq) (*pbUser.GetUserByIdResp, error) {
|
||||
@ -284,11 +286,13 @@ func (s *userServer) GetUserById(ctx context.Context, req *pbUser.GetUserByIdReq
|
||||
resp := &pbUser.GetUserByIdResp{User: &pbUser.User{}}
|
||||
user, err := imdb.GetUserByUserID(req.UserId)
|
||||
if err != nil {
|
||||
return resp, nil
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
isBlock, err := imdb.UserIsBlock(req.UserId)
|
||||
if err != nil {
|
||||
return resp, err
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "req:", req.String())
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
resp.User = &pbUser.User{
|
||||
ProfilePhoto: user.FaceURL,
|
||||
@ -301,11 +305,11 @@ func (s *userServer) GetUserById(ctx context.Context, req *pbUser.GetUserByIdReq
|
||||
}
|
||||
|
||||
func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pbUser.GetUsersResp, error) {
|
||||
log.NewInfo(req.OperationID, "GetUsers args ", req.String())
|
||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "req: ", req.String())
|
||||
resp := &pbUser.GetUsersResp{User: []*pbUser.User{}}
|
||||
users, err := imdb.GetUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||
if err != nil {
|
||||
return resp, nil
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
for _, v := range users {
|
||||
isBlock, err := imdb.UserIsBlock(v.UserID)
|
||||
@ -324,10 +328,10 @@ func (s *userServer) GetUsers(ctx context.Context, req *pbUser.GetUsersReq) (*pb
|
||||
nums, err := imdb.GetUsersCount(user)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUsersCount failed", err.Error())
|
||||
return resp, err
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
resp.UserNums = nums
|
||||
resp.Pagination = &sdkws.ResponsePagination{ShowNumber:req.Pagination.ShowNumber, CurrentPage:req.Pagination.ShowNumber}
|
||||
resp.Pagination = &sdkws.ResponsePagination{ShowNumber:req.Pagination.ShowNumber, CurrentPage:req.Pagination.PageNumber}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
@ -346,8 +350,8 @@ func (s *userServer) AlterUser(ctx context.Context, req *pbUser.AlterUserReq) (*
|
||||
UserID: req.UserId,
|
||||
}
|
||||
if err := imdb.UpdateUserInfo(user); err != nil {
|
||||
log.NewError(req.OperationID, err)
|
||||
return resp, err
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "UpdateUserInfo", err.Error())
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
@ -357,7 +361,8 @@ func (s *userServer) AddUser(ctx context.Context, req *pbUser.AddUserReq) (*pbUs
|
||||
resp := &pbUser.AddUserResp{}
|
||||
err := imdb.AddUser(req.UserId, req.PhoneNumber, req.Name)
|
||||
if err != nil {
|
||||
return resp, constant.ErrDB
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "AddUser", err.Error())
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
@ -368,8 +373,8 @@ func (s *userServer) BlockUser(ctx context.Context, req *pbUser.BlockUserReq) (*
|
||||
resp := &pbUser.BlockUserResp{}
|
||||
err := imdb.BlockUser(req.UserId, req.EndDisableTime)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return resp, constant.ErrDB
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "BlockUser", err.Error())
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
@ -379,7 +384,8 @@ func (s *userServer) UnBlockUser(ctx context.Context, req *pbUser.UnBlockUserReq
|
||||
resp := &pbUser.UnBlockUserResp{}
|
||||
err := imdb.UnBlockUser(req.UserId)
|
||||
if err != nil {
|
||||
return resp, constant.ErrDB
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "unBlockUser", err.Error())
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
@ -389,10 +395,8 @@ func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUser
|
||||
resp := &pbUser.GetBlockUsersResp{}
|
||||
blockUsers, err := imdb.GetBlockUsers(req.Pagination.ShowNumber, req.Pagination.PageNumber)
|
||||
if err != nil {
|
||||
return resp, constant.ErrDB
|
||||
}
|
||||
if err != nil {
|
||||
return resp, constant.ErrDB
|
||||
log.Error(req.OperationID, utils.GetSelfFuncName(), "GetBlockUsers", err.Error())
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
for _, v := range blockUsers {
|
||||
resp.BlockUsers = append(resp.BlockUsers, &pbUser.BlockUser{
|
||||
@ -412,7 +416,7 @@ func (s *userServer) GetBlockUsers(ctx context.Context, req *pbUser.GetBlockUser
|
||||
nums, err := imdb.GetBlockUsersNumCount()
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetBlockUsersNumCount failed", err.Error())
|
||||
return resp, err
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
resp.UserNums = nums
|
||||
return resp, nil
|
||||
@ -423,8 +427,8 @@ func (s *userServer) GetBlockUserById(_ context.Context, req *pbUser.GetBlockUse
|
||||
resp := &pbUser.GetBlockUserByIdResp{}
|
||||
user, err := imdb.GetBlockUserById(req.UserId)
|
||||
if err != nil {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), err)
|
||||
return resp, err
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetBlockUserById", err)
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
resp.BlockUser = &pbUser.BlockUser{
|
||||
User: &pbUser.User{
|
||||
@ -444,7 +448,7 @@ func (s *userServer) DeleteUser(_ context.Context, req *pbUser.DeleteUserReq) (*
|
||||
resp := &pbUser.DeleteUserResp{}
|
||||
if row := imdb.DeleteUser(req.UserId); row == 0 {
|
||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "delete failed", "delete rows:", row)
|
||||
return resp, constant.ErrDB
|
||||
return resp, errors.WrapError(constant.ErrDB)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
@ -1 +1,10 @@
|
||||
package cms_api_struct
|
||||
|
||||
type AdminLoginRequest struct {
|
||||
AdminName string `json:"admin_name" binding:"required"`
|
||||
Secret string `json:"secret" binding:"required"`
|
||||
}
|
||||
|
||||
type AdminLoginResponse struct {
|
||||
Token string `json:"token"`
|
||||
}
|
@ -57,6 +57,15 @@ type SetGroupMasterRequest struct {
|
||||
type SetGroupMasterResponse struct {
|
||||
}
|
||||
|
||||
type SetGroupMemberRequest struct {
|
||||
GroupId string `json:"group_id" binding:"required"`
|
||||
UserId string `json:"user_id" binding:"required"`
|
||||
}
|
||||
|
||||
type SetGroupMemberRespones struct {
|
||||
|
||||
}
|
||||
|
||||
type BanGroupChatRequest struct {
|
||||
GroupId string `json:"group_id" binding:"required"`
|
||||
}
|
||||
|
@ -43,6 +43,6 @@ type ChatLog struct {
|
||||
|
||||
type GetChatLogsResponse struct {
|
||||
ChatLogs []ChatLog `json:"chat_logs"`
|
||||
|
||||
logNums int `json:"log_nums"`
|
||||
ResponsePagination
|
||||
}
|
||||
|
@ -86,6 +86,7 @@ type config struct {
|
||||
OpenImGroupName string `yaml:"openImGroupName"`
|
||||
OpenImAuthName string `yaml:"openImAuthName"`
|
||||
OpenImMessageCMSName string `yaml:"openImMessageCMSName"`
|
||||
OpenImAdminCMSName string `yaml:"openImAdminCMSName"`
|
||||
}
|
||||
Etcd struct {
|
||||
EtcdSchema string `yaml:"etcdSchema"`
|
||||
|
@ -15,7 +15,7 @@ var (
|
||||
// ErrMysql = ErrInfo{100, ""}
|
||||
// ErrMongo = ErrInfo{110, ""}
|
||||
// ErrRedis = ErrInfo{120, ""}
|
||||
ErrParseToken = ErrInfo{200, ParseTokenMsg.Error()}
|
||||
ErrParseToken = ErrInfo{700, ParseTokenMsg.Error()}
|
||||
// ErrCreateToken = ErrInfo{201, "Create token failed"}
|
||||
// ErrAppServerKey = ErrInfo{300, "key error"}
|
||||
ErrTencentCredential = ErrInfo{400, ThirdPartyMsg.Error()}
|
||||
|
@ -12,6 +12,18 @@ func GetChatLog(chatLog db.ChatLog, pageNumber, showNumber int32) ([]db.ChatLog,
|
||||
return chatLogs, err
|
||||
}
|
||||
dbConn.LogMode(true)
|
||||
err = dbConn.Table("chat_logs").Where(fmt.Sprintf(" content like '%%%s%%' ", chatLog.Content)).Limit(showNumber).Offset(showNumber * (pageNumber - 1)).Find(&chatLogs).Error
|
||||
err = dbConn.Table("chat_logs").Where(fmt.Sprintf(" content like '%%%s%%'", chatLog.Content)).
|
||||
Limit(showNumber).Offset(showNumber * (pageNumber - 1)).Find(&chatLogs).Error
|
||||
return chatLogs, err
|
||||
}
|
||||
|
||||
func GetChatLogCount(chatLog db.ChatLog) (int64, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
var count int64
|
||||
if err != nil {
|
||||
return count, err
|
||||
}
|
||||
dbConn.LogMode(true)
|
||||
err = dbConn.Table("chat_logs").Where(fmt.Sprintf(" content like '%%%s%%' and ", chatLog.Content)).Count(&count).Error
|
||||
return count, err
|
||||
}
|
@ -159,7 +159,7 @@ func UserIsBlock(userId string) (bool, error) {
|
||||
return false, err
|
||||
}
|
||||
var user db.BlackList
|
||||
rows := dbConn.Table("black_list").Where("uid=?", userId).First(&user).RowsAffected
|
||||
rows := dbConn.Table("black_lists").Where("uid=?", userId).First(&user).RowsAffected
|
||||
if rows >= 1 {
|
||||
return true, nil
|
||||
}
|
||||
@ -183,7 +183,7 @@ func BlockUser(userId, endDisableTime string) error {
|
||||
return constant.ErrDB
|
||||
}
|
||||
var blockUser db.BlackList
|
||||
dbConn.Table("black_list").Where("uid=?", userId).First(&blockUser)
|
||||
dbConn.Table("black_lists").Where("uid=?", userId).First(&blockUser)
|
||||
if blockUser.UserId != "" {
|
||||
dbConn.Model(&blockUser).Where("uid=?", blockUser.UserId).Update("end_disable_time", end)
|
||||
return nil
|
||||
@ -222,7 +222,7 @@ func GetBlockUserById(userId string) (BlockUserInfo, error) {
|
||||
if err != nil {
|
||||
return blockUserInfo, err
|
||||
}
|
||||
if err = dbConn.Table("black_list").Where("uid=?", userId).Find(&blockUser).Error; err != nil {
|
||||
if err = dbConn.Table("black_lists").Where("uid=?", userId).Find(&blockUser).Error; err != nil {
|
||||
return blockUserInfo, err
|
||||
}
|
||||
user := db.Users{
|
||||
|
@ -2,15 +2,14 @@ package http
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/constant"
|
||||
"fmt"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
|
||||
//"Open_IM/pkg/cms_api_struct"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
)
|
||||
|
||||
type BaseResp struct {
|
||||
@ -20,32 +19,15 @@ type BaseResp struct {
|
||||
}
|
||||
|
||||
func RespHttp200(ctx *gin.Context, err error, data interface{}) {
|
||||
var resp BaseResp
|
||||
if v, ok := err.(constant.ErrInfo); ok {
|
||||
resp.Code = v.Code()
|
||||
resp.ErrMsg = v.Error()
|
||||
} else {
|
||||
resp.Code = constant.ErrServer.Code()
|
||||
resp.ErrMsg = constant.ErrServer.Error()
|
||||
}
|
||||
resp.Data=data
|
||||
ctx.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// warp error
|
||||
func WarpError(err constant.ErrInfo) error {
|
||||
return status.Error(codes.Code(err.ErrCode), err.ErrMsg)
|
||||
}
|
||||
|
||||
// parse error from server
|
||||
func RespHttp200S(ctx *gin.Context, err error, data interface{}) {
|
||||
var resp BaseResp
|
||||
switch e := err.(type) {
|
||||
case constant.ErrInfo:
|
||||
resp.Code = e.ErrCode
|
||||
resp.ErrMsg = e.ErrMsg
|
||||
default:
|
||||
s, ok := status.FromError(err)
|
||||
if !ok {
|
||||
fmt.Println("need grpc format error")
|
||||
return
|
||||
}
|
||||
resp.Code = int32(s.Code())
|
||||
@ -55,6 +37,7 @@ func RespHttp200S(ctx *gin.Context, err error, data interface{}) {
|
||||
ctx.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
//func CheckErr(pb interface{}) constant.ErrInfo{
|
||||
//
|
||||
//}
|
||||
// warp error
|
||||
func WrapError(err constant.ErrInfo) error {
|
||||
return status.Error(codes.Code(err.ErrCode), err.ErrMsg)
|
||||
}
|
||||
|
317
pkg/proto/admin_cms/admin_cms.pb.go
Normal file
317
pkg/proto/admin_cms/admin_cms.pb.go
Normal file
@ -0,0 +1,317 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.27.1
|
||||
// protoc v3.15.5
|
||||
// source: admin_cms/admin_cms.proto
|
||||
|
||||
package admin_cms
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type AdminLoginReq struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
OperationID string `protobuf:"bytes,1,opt,name=OperationID,proto3" json:"OperationID,omitempty"`
|
||||
AdminID string `protobuf:"bytes,2,opt,name=AdminID,proto3" json:"AdminID,omitempty"`
|
||||
Secret string `protobuf:"bytes,3,opt,name=Secret,proto3" json:"Secret,omitempty"`
|
||||
}
|
||||
|
||||
func (x *AdminLoginReq) Reset() {
|
||||
*x = AdminLoginReq{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_admin_cms_admin_cms_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *AdminLoginReq) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*AdminLoginReq) ProtoMessage() {}
|
||||
|
||||
func (x *AdminLoginReq) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_admin_cms_admin_cms_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use AdminLoginReq.ProtoReflect.Descriptor instead.
|
||||
func (*AdminLoginReq) Descriptor() ([]byte, []int) {
|
||||
return file_admin_cms_admin_cms_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *AdminLoginReq) GetOperationID() string {
|
||||
if x != nil {
|
||||
return x.OperationID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AdminLoginReq) GetAdminID() string {
|
||||
if x != nil {
|
||||
return x.AdminID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *AdminLoginReq) GetSecret() string {
|
||||
if x != nil {
|
||||
return x.Secret
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type AdminLoginResp struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
|
||||
}
|
||||
|
||||
func (x *AdminLoginResp) Reset() {
|
||||
*x = AdminLoginResp{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_admin_cms_admin_cms_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *AdminLoginResp) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*AdminLoginResp) ProtoMessage() {}
|
||||
|
||||
func (x *AdminLoginResp) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_admin_cms_admin_cms_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use AdminLoginResp.ProtoReflect.Descriptor instead.
|
||||
func (*AdminLoginResp) Descriptor() ([]byte, []int) {
|
||||
return file_admin_cms_admin_cms_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *AdminLoginResp) GetToken() string {
|
||||
if x != nil {
|
||||
return x.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_admin_cms_admin_cms_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_admin_cms_admin_cms_proto_rawDesc = []byte{
|
||||
0x0a, 0x19, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x5f, 0x63, 0x6d, 0x73, 0x2f, 0x61, 0x64, 0x6d, 0x69,
|
||||
0x6e, 0x5f, 0x63, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x61, 0x64, 0x6d,
|
||||
0x69, 0x6e, 0x5f, 0x63, 0x6d, 0x73, 0x22, 0x63, 0x0a, 0x0d, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4c,
|
||||
0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x20, 0x0a, 0x0b, 0x4f, 0x70, 0x65, 0x72, 0x61,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x4f, 0x70,
|
||||
0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x41, 0x64, 0x6d,
|
||||
0x69, 0x6e, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x41, 0x64, 0x6d, 0x69,
|
||||
0x6e, 0x49, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x06, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x22, 0x26, 0x0a, 0x0e, 0x41,
|
||||
0x64, 0x6d, 0x69, 0x6e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x14, 0x0a,
|
||||
0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f,
|
||||
0x6b, 0x65, 0x6e, 0x32, 0x4d, 0x0a, 0x08, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x43, 0x4d, 0x53, 0x12,
|
||||
0x41, 0x0a, 0x0a, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x18, 0x2e,
|
||||
0x61, 0x64, 0x6d, 0x69, 0x6e, 0x5f, 0x63, 0x6d, 0x73, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4c,
|
||||
0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x5f,
|
||||
0x63, 0x6d, 0x73, 0x2e, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65,
|
||||
0x73, 0x70, 0x42, 0x17, 0x5a, 0x15, 0x2e, 0x2f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x5f, 0x63, 0x6d,
|
||||
0x73, 0x3b, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x5f, 0x63, 0x6d, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_admin_cms_admin_cms_proto_rawDescOnce sync.Once
|
||||
file_admin_cms_admin_cms_proto_rawDescData = file_admin_cms_admin_cms_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_admin_cms_admin_cms_proto_rawDescGZIP() []byte {
|
||||
file_admin_cms_admin_cms_proto_rawDescOnce.Do(func() {
|
||||
file_admin_cms_admin_cms_proto_rawDescData = protoimpl.X.CompressGZIP(file_admin_cms_admin_cms_proto_rawDescData)
|
||||
})
|
||||
return file_admin_cms_admin_cms_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_admin_cms_admin_cms_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_admin_cms_admin_cms_proto_goTypes = []interface{}{
|
||||
(*AdminLoginReq)(nil), // 0: admin_cms.AdminLoginReq
|
||||
(*AdminLoginResp)(nil), // 1: admin_cms.AdminLoginResp
|
||||
}
|
||||
var file_admin_cms_admin_cms_proto_depIdxs = []int32{
|
||||
0, // 0: admin_cms.adminCMS.AdminLogin:input_type -> admin_cms.AdminLoginReq
|
||||
1, // 1: admin_cms.adminCMS.AdminLogin:output_type -> admin_cms.AdminLoginResp
|
||||
1, // [1:2] is the sub-list for method output_type
|
||||
0, // [0:1] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_admin_cms_admin_cms_proto_init() }
|
||||
func file_admin_cms_admin_cms_proto_init() {
|
||||
if File_admin_cms_admin_cms_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_admin_cms_admin_cms_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*AdminLoginReq); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_admin_cms_admin_cms_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*AdminLoginResp); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_admin_cms_admin_cms_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_admin_cms_admin_cms_proto_goTypes,
|
||||
DependencyIndexes: file_admin_cms_admin_cms_proto_depIdxs,
|
||||
MessageInfos: file_admin_cms_admin_cms_proto_msgTypes,
|
||||
}.Build()
|
||||
File_admin_cms_admin_cms_proto = out.File
|
||||
file_admin_cms_admin_cms_proto_rawDesc = nil
|
||||
file_admin_cms_admin_cms_proto_goTypes = nil
|
||||
file_admin_cms_admin_cms_proto_depIdxs = nil
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConnInterface
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion6
|
||||
|
||||
// AdminCMSClient is the client API for AdminCMS service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type AdminCMSClient interface {
|
||||
AdminLogin(ctx context.Context, in *AdminLoginReq, opts ...grpc.CallOption) (*AdminLoginResp, error)
|
||||
}
|
||||
|
||||
type adminCMSClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewAdminCMSClient(cc grpc.ClientConnInterface) AdminCMSClient {
|
||||
return &adminCMSClient{cc}
|
||||
}
|
||||
|
||||
func (c *adminCMSClient) AdminLogin(ctx context.Context, in *AdminLoginReq, opts ...grpc.CallOption) (*AdminLoginResp, error) {
|
||||
out := new(AdminLoginResp)
|
||||
err := c.cc.Invoke(ctx, "/admin_cms.adminCMS/AdminLogin", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// AdminCMSServer is the server API for AdminCMS service.
|
||||
type AdminCMSServer interface {
|
||||
AdminLogin(context.Context, *AdminLoginReq) (*AdminLoginResp, error)
|
||||
}
|
||||
|
||||
// UnimplementedAdminCMSServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedAdminCMSServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedAdminCMSServer) AdminLogin(context.Context, *AdminLoginReq) (*AdminLoginResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AdminLogin not implemented")
|
||||
}
|
||||
|
||||
func RegisterAdminCMSServer(s *grpc.Server, srv AdminCMSServer) {
|
||||
s.RegisterService(&_AdminCMS_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _AdminCMS_AdminLogin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AdminLoginReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AdminCMSServer).AdminLogin(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/admin_cms.adminCMS/AdminLogin",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AdminCMSServer).AdminLogin(ctx, req.(*AdminLoginReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _AdminCMS_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "admin_cms.adminCMS",
|
||||
HandlerType: (*AdminCMSServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "AdminLogin",
|
||||
Handler: _AdminCMS_AdminLogin_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "admin_cms/admin_cms.proto",
|
||||
}
|
18
pkg/proto/admin_cms/admin_cms.proto
Normal file
18
pkg/proto/admin_cms/admin_cms.proto
Normal file
@ -0,0 +1,18 @@
|
||||
syntax = "proto3";
|
||||
option go_package = "./admin_cms;admin_cms";
|
||||
package admin_cms;
|
||||
|
||||
message AdminLoginReq {
|
||||
string OperationID = 1;
|
||||
string AdminID = 2;
|
||||
string Secret = 3;
|
||||
}
|
||||
|
||||
|
||||
message AdminLoginResp {
|
||||
string token = 1;
|
||||
}
|
||||
|
||||
service adminCMS {
|
||||
rpc AdminLogin(AdminLoginReq) returns(AdminLoginResp);
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
|
||||
all_proto=(
|
||||
message_cms/message_cms.proto
|
||||
#statistics/statistics.proto
|
||||
# message_cms/message_cms.proto
|
||||
admin_cms/admin_cms.proto
|
||||
# statistics/statistics.proto
|
||||
# auth/auth.proto
|
||||
# friend/friend.proto
|
||||
# group/group.proto
|
||||
|
Loading…
x
Reference in New Issue
Block a user