commit
fb4c8549dc
@ -1 +1 @@
|
||||
Subproject commit 2257ac8ee528fb1e0038f85e34c8770fbe4758e3
|
||||
Subproject commit a4b710de8df31fe570fd90895887edef30f3a64c
|
@ -0,0 +1,68 @@
|
||||
package organization
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/config"
|
||||
"Open_IM/pkg/common/constant"
|
||||
"Open_IM/pkg/common/log"
|
||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||
rpc "Open_IM/pkg/proto/organization"
|
||||
"Open_IM/pkg/utils"
|
||||
|
||||
"context"
|
||||
"google.golang.org/grpc"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type organizationServer struct {
|
||||
rpcPort int
|
||||
rpcRegisterName string
|
||||
etcdSchema string
|
||||
etcdAddr []string
|
||||
}
|
||||
|
||||
func NewGroupServer(port int) *organizationServer {
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
return &organizationServer{
|
||||
rpcPort: port,
|
||||
rpcRegisterName: config.Config.RpcRegisterName.OpenImGroupName,
|
||||
etcdSchema: config.Config.Etcd.EtcdSchema,
|
||||
etcdAddr: config.Config.Etcd.EtcdAddr,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *organizationServer) Run() {
|
||||
log.NewInfo("", "organization rpc start ")
|
||||
ip := utils.ServerIP
|
||||
registerAddress := ip + ":" + strconv.Itoa(s.rpcPort)
|
||||
//listener network
|
||||
listener, err := net.Listen("tcp", registerAddress)
|
||||
if err != nil {
|
||||
log.NewError("", "Listen failed ", err.Error(), registerAddress)
|
||||
return
|
||||
}
|
||||
log.NewInfo("", "listen network success, ", registerAddress, listener)
|
||||
defer listener.Close()
|
||||
//grpc server
|
||||
srv := grpc.NewServer()
|
||||
defer srv.GracefulStop()
|
||||
//Service registers with etcd
|
||||
rpc.RegisterOrganizationServer(srv, s)
|
||||
err = getcdv3.RegisterEtcd(s.etcdSchema, strings.Join(s.etcdAddr, ","), ip, s.rpcPort, s.rpcRegisterName, 10)
|
||||
if err != nil {
|
||||
log.NewError("", "RegisterEtcd failed ", err.Error())
|
||||
return
|
||||
}
|
||||
log.NewInfo("", "organization rpc RegisterEtcd success", ip, s.rpcPort, s.rpcRegisterName, 10)
|
||||
err = srv.Serve(listener)
|
||||
if err != nil {
|
||||
log.NewError("", "Serve failed ", err.Error())
|
||||
return
|
||||
}
|
||||
log.NewInfo("", "organization rpc success")
|
||||
}
|
||||
|
||||
func (s *organizationServer) CreateDepartment(ctx context.Context, req *rpc.CreateDepartmentReq) (*rpc.CreateDepartmentResp, error) {
|
||||
return nil, nil
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
syntax = "proto3";
|
||||
import "Open_IM/pkg/proto/sdk_ws/ws.proto";
|
||||
option go_package = "./organization;organization";
|
||||
package organization;
|
||||
|
||||
|
||||
message CreateDepartmentReq{
|
||||
server_api_params.Department departmentInfo = 1;
|
||||
string operationID = 2;
|
||||
string opUserID = 3;
|
||||
}
|
||||
|
||||
message CreateDepartmentResp{
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
server_api_params.Department departmentInfo = 3;
|
||||
}
|
||||
|
||||
message UpdateDepartmentReq{
|
||||
server_api_params.Department departmentInfo = 1;
|
||||
string operationID = 2;
|
||||
string opUserID = 3;
|
||||
}
|
||||
|
||||
message UpdateDepartmentResp{
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
}
|
||||
|
||||
|
||||
message GetDepartmentReq{
|
||||
string departmentID = 1;
|
||||
string operationID = 2;
|
||||
string opUserID = 3;
|
||||
}
|
||||
|
||||
message GetDepartmentResp{
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
repeated server_api_params.Department departmentList = 3;
|
||||
}
|
||||
|
||||
message DeleteDepartmentReq{
|
||||
string departmentID = 1;
|
||||
string operationID = 2;
|
||||
string opUserID = 3;
|
||||
}
|
||||
|
||||
message DeleteDepartmentResp{
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
}
|
||||
|
||||
|
||||
message CreateOrganizationUserReq{
|
||||
server_api_params.OrganizationUser organizationUser = 1;
|
||||
string operationID = 2;
|
||||
string opUserID = 3;
|
||||
}
|
||||
|
||||
|
||||
message CreateOrganizationUserResp{
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
}
|
||||
|
||||
|
||||
message UpdateOrganizationUserReq{
|
||||
server_api_params.OrganizationUser organizationUser = 1;
|
||||
string operationID = 2;
|
||||
string opUserID = 3;
|
||||
}
|
||||
|
||||
|
||||
message UpdateOrganizationUserResp{
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
message CreateDepartmentMemberReq{
|
||||
server_api_params.UserInDepartment userInDepartment = 1;
|
||||
string operationID = 2;
|
||||
string opUserID = 3;
|
||||
}
|
||||
message CreateDepartmentMemberResp{
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
}
|
||||
|
||||
|
||||
message GetUserInDepartmentReq{
|
||||
string userID = 1;
|
||||
string operationID = 2;
|
||||
string opUserID = 3;
|
||||
}
|
||||
message GetUserInDepartmentResp{
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
server_api_params.UserInDepartment userInDepartment = 3;
|
||||
}
|
||||
|
||||
|
||||
message UpdateUserInDepartmentReq{
|
||||
server_api_params.UserInDepartment userInDepartment = 1;
|
||||
string operationID = 2;
|
||||
string opUserID = 3;
|
||||
}
|
||||
message UpdateUserInDepartmentResp{
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
}
|
||||
|
||||
|
||||
message DeleteOrganizationReq{
|
||||
string userID = 1;
|
||||
string operationID = 2;
|
||||
string opUserID = 3;
|
||||
}
|
||||
message DeleteOrganizationResp{
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
}
|
||||
|
||||
|
||||
message GetDepartmentMemberReq{
|
||||
string departmentID = 1;
|
||||
string operationID = 2;
|
||||
string opUserID = 3;
|
||||
}
|
||||
|
||||
message GetDepartmentMemberResp{
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
repeated server_api_params.UserInDepartment userInDepartmentList = 3;
|
||||
}
|
||||
|
||||
|
||||
service organization{
|
||||
rpc createDepartment(CreateDepartmentReq) returns(CreateDepartmentResp);
|
||||
rpc UpdateDepartment(UpdateDepartmentReq) returns(UpdateDepartmentResp);
|
||||
rpc GetDepartment(GetDepartmentReq) returns(GetDepartmentResp);
|
||||
rpc DeleteDepartment(DeleteDepartmentReq) returns(DeleteDepartmentResp);
|
||||
rpc CreateOrganizationUser(CreateOrganizationUserReq) returns(CreateOrganizationUserResp);
|
||||
rpc UpdateOrganizationUser(UpdateOrganizationUserReq) returns(UpdateOrganizationUserResp);
|
||||
rpc CreateDepartmentMember(CreateDepartmentMemberReq) returns(CreateDepartmentMemberResp);
|
||||
rpc GetUserInDepartment(GetUserInDepartmentReq) returns(GetUserInDepartmentResp);
|
||||
rpc UpdateUserInDepartment(UpdateUserInDepartmentReq) returns(UpdateUserInDepartmentResp);
|
||||
rpc DeleteOrganization(DeleteOrganizationReq) returns(DeleteOrganizationResp);
|
||||
rpc GetDepartmentMember(GetDepartmentMemberReq) returns(GetDepartmentMemberResp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue