Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun

pull/213/head
wangchuxiao 3 years ago
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
}

@ -238,26 +238,26 @@ func (Department) TableName() string {
return "departments" return "departments"
} }
type DepartmentUser struct { type OrganizationUser struct {
UserID string `gorm:"column:user_id;primary_key;size:64"` UserID string `gorm:"column:user_id;primary_key;size:64"`
Nickname string `gorm:"column:nickname;size:256"` Nickname string `gorm:"column:nickname;size:256"`
EnglishName string `gorm:"column:english_name;size:256"` EnglishName string `gorm:"column:english_name;size:256"`
FaceURL string `gorm:"column:face_url;size:256"` FaceURL string `gorm:"column:face_url;size:256"`
Gender int32 `gorm:"column:gender"` Gender int32 `gorm:"column:gender"`
mobile string `gorm:"column:mobile;size:32"` Mobile string `gorm:"column:mobile;size:32"`
telephone string `gorm:"column:telephone;size:32"` Telephone string `gorm:"column:telephone;size:32"`
Birth time.Time `gorm:"column:birth"` Birth time.Time `gorm:"column:birth"`
Email string `gorm:"column:email;size:64"` Email string `gorm:"column:email;size:64"`
CreateTime time.Time `gorm:"column:create_time"` CreateTime time.Time `gorm:"column:create_time"`
Ex string `gorm:"column:ex;size:1024"` Ex string `gorm:"column:ex;size:1024"`
} }
func (DepartmentUser) TableName() string { func (OrganizationUser) TableName() string {
return "Department_users" return "organization_users"
} }
type DepartmentMember struct { type DepartmentMember struct {
userID string `gorm:"column:user_id;primary_key;size:64"` UserID string `gorm:"column:user_id;primary_key;size:64"`
DepartmentID string `gorm:"column:department_id;primary_key;size:64"` DepartmentID string `gorm:"column:department_id;primary_key;size:64"`
Order int32 `gorm:"column:order" json:"order"` Order int32 `gorm:"column:order" json:"order"`
Position string `gorm:"column:position;size:256" json:"position"` Position string `gorm:"column:position;size:256" json:"position"`

@ -106,18 +106,20 @@ func initMysqlDB() {
fmt.Println("CreateTable Conversation") fmt.Println("CreateTable Conversation")
db.CreateTable(&Conversation{}) db.CreateTable(&Conversation{})
} }
if db.HasTable(&Department{}) { /*
fmt.Println("CreateTable Department") if db.HasTable(&Department{}) {
db.CreateTable(&Department{}) fmt.Println("CreateTable Department")
} db.CreateTable(&Department{})
if db.HasTable(&DepartmentUser{}) { }
fmt.Println("CreateTable DepartmentUser") if db.HasTable(&OrganizationUser{}) {
db.CreateTable(&DepartmentUser{}) fmt.Println("CreateTable OrganizationUser")
} db.CreateTable(&OrganizationUser{})
if db.HasTable(&DepartmentMember{}) { }
fmt.Println("CreateTable DepartmentMember") if db.HasTable(&DepartmentMember{}) {
db.CreateTable(&DepartmentMember{}) fmt.Println("CreateTable DepartmentMember")
} db.CreateTable(&DepartmentMember{})
}
*/
return return
} }

@ -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

@ -105,9 +105,67 @@ message FriendRequest{
string ex = 15; string ex = 15;
} }
///////////////////////////////////base end///////////////////////////////////// ///////////////////////////////////organization/////////////////////////////////////
message Department {
string departmentID = 1;
string faceURL = 2;
string name = 3;
string parentID = 4;
int32 order = 5;
int32 departmentType = 6;
uint32 createTime = 7;
uint32 subDepartmentNum = 8;
uint32 memberNum = 9;
string ex = 10;
}
message OrganizationUser {
string userID = 1;
string nickname = 2;
string englishName = 3;
string faceURL = 4;
int32 gender = 5;
string mobile = 6;
string telephone = 7;
uint32 birth = 8;
string email = 9;
uint32 createTime = 10;
string ex = 11;
}
message DepartmentMember {
string userID = 1;
string DepartmentID = 2;
int32 Order = 3;
string Position = 4;
int32 Leader = 5;
int32 Status = 6;
string Ex = 7;
}
message UserInDepartment {
OrganizationUser departmentUser = 1;
repeated DepartmentMember departmentMemberList = 2;
}
///////////////////////////////////organization end//////////////////////////////////
///////////////////////////////////base end/////////////////////////////////////
message PullMessageBySeqListResp { message PullMessageBySeqListResp {
int32 errCode = 1; int32 errCode = 1;
string errMsg = 2; string errMsg = 2;

Loading…
Cancel
Save