mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-05 01:25:58 +08:00
organization
This commit is contained in:
@@ -397,6 +397,11 @@ type config struct {
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
} `yaml:"workMomentsNotification"`
|
||||
JoinDepartmentNotification struct {
|
||||
Conversation PConversation `yaml:"conversation"`
|
||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||
} `yaml:"joinDepartmentNotification"`
|
||||
}
|
||||
Demo struct {
|
||||
Port []int `yaml:"openImDemoPort"`
|
||||
@@ -416,6 +421,7 @@ type config struct {
|
||||
SmtpAddr string `yaml:"smtpAddr"`
|
||||
SmtpPort int `yaml:"smtpPort"`
|
||||
}
|
||||
TestDepartMentID string `yaml:"testDepartMentID"`
|
||||
}
|
||||
Rtc struct {
|
||||
Port int `yaml:"port"`
|
||||
|
||||
@@ -151,6 +151,10 @@ const (
|
||||
GroupStatusDismissed = 2
|
||||
GroupStatusMuted = 3
|
||||
|
||||
//GroupType
|
||||
NormalGroup = 0
|
||||
DepartmentGroup = 1
|
||||
|
||||
GroupBaned = 3
|
||||
GroupBanPrivateChat = 4
|
||||
|
||||
|
||||
@@ -232,6 +232,7 @@ type Department struct {
|
||||
ParentID string `gorm:"column:parent_id;size:64" json:"parentID" binding:"required"` // "0" or Real parent id
|
||||
Order int32 `gorm:"column:order" json:"order" ` // 1, 2, ...
|
||||
DepartmentType int32 `gorm:"column:department_type" json:"departmentType"` //1, 2...
|
||||
RelatedGroupID string `gorm:"column:related_group_id;size:64" json:"relatedGroupID"`
|
||||
CreateTime time.Time `gorm:"column:create_time" json:"createTime"`
|
||||
Ex string `gorm:"column:ex;type:varchar(1024)" json:"ex"`
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ func initMysqlDB() {
|
||||
&GroupMember{},
|
||||
&GroupRequest{},
|
||||
&User{},
|
||||
&Black{}, &ChatLog{}, &Register{}, &Conversation{}, &AppVersion{})
|
||||
&Black{}, &ChatLog{}, &Register{}, &Conversation{}, &AppVersion{}, &Department{})
|
||||
db.Set("gorm:table_options", "CHARSET=utf8")
|
||||
db.Set("gorm:table_options", "collation=utf8_unicode_ci")
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package im_mysql_model
|
||||
import (
|
||||
"Open_IM/pkg/common/db"
|
||||
"Open_IM/pkg/utils"
|
||||
"github.com/jinzhu/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -234,5 +235,48 @@ func GetSubDepartmentNum(departmentID string) (error, uint32) {
|
||||
return utils.Wrap(err, ""), 0
|
||||
}
|
||||
return nil, number
|
||||
|
||||
}
|
||||
|
||||
func GetDepartmentRelatedGroupIDList(departmentIDList []string) ([]string, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, utils.Wrap(err, "DefaultGormDB failed")
|
||||
}
|
||||
var groupIDList []string
|
||||
err = dbConn.Table("departments").Where("department_id IN (?) ", departmentIDList).Pluck("related_group_id", &groupIDList).Error
|
||||
return groupIDList, err
|
||||
}
|
||||
|
||||
func getDepartmentParent(departmentID string, dbConn *gorm.DB) (*db.Department, error) {
|
||||
var department db.Department
|
||||
var parentID string
|
||||
dbConn.LogMode(true)
|
||||
// select * from departments where department_id = (select parent_id from departments where department_id= zx234fd);
|
||||
err := dbConn.Table("departments").Where("department_id=?", dbConn.Table("departments").Where("department_id=?", departmentID).Pluck("parent_id", parentID)).Error
|
||||
return &department, err
|
||||
}
|
||||
|
||||
func GetDepartmentParent(departmentID string, dbConn *gorm.DB, parentIDList []string) (*db.Department, error) {
|
||||
department, err := getDepartmentParent(departmentID, dbConn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if department.ParentID != "" {
|
||||
parentIDList = append(parentIDList, department.ParentID)
|
||||
_, err = GetDepartmentParent(departmentID, dbConn, parentIDList)
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func GetDepartmentParentIDList(departmentID string) ([]string, error) {
|
||||
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var parentIDList []string
|
||||
_, err = GetDepartmentParent(departmentID, dbConn, parentIDList)
|
||||
return parentIDList, err
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,6 +51,17 @@ message DeleteDepartmentResp{
|
||||
string errMsg = 2;
|
||||
}
|
||||
|
||||
message GetDepartmentParentIDListReq {
|
||||
string departmentID = 1;
|
||||
string operationID = 2;
|
||||
}
|
||||
|
||||
message GetDepartmentParentIDListResp {
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
repeated string parentIDList = 3;
|
||||
}
|
||||
|
||||
|
||||
message CreateOrganizationUserReq{
|
||||
server_api_params.OrganizationUser organizationUser = 1;
|
||||
@@ -148,12 +159,23 @@ message GetDepartmentMemberResp{
|
||||
repeated server_api_params.UserDepartmentMember userDepartmentMemberList = 3;
|
||||
}
|
||||
|
||||
message GetDepartmentRelatedGroupIDListReq {
|
||||
string operationID = 1;
|
||||
repeated string departmentIDList = 2;
|
||||
}
|
||||
|
||||
message GetDepartmentRelatedGroupIDListResp {
|
||||
int32 errCode = 1;
|
||||
string errMsg = 2;
|
||||
repeated string groupIDList = 3;
|
||||
}
|
||||
|
||||
service organization{
|
||||
rpc CreateDepartment(CreateDepartmentReq) returns(CreateDepartmentResp);
|
||||
rpc UpdateDepartment(UpdateDepartmentReq) returns(UpdateDepartmentResp);
|
||||
rpc GetSubDepartment(GetSubDepartmentReq) returns(GetSubDepartmentResp);
|
||||
rpc DeleteDepartment(DeleteDepartmentReq) returns(DeleteDepartmentResp);
|
||||
rpc GetDepartmentParentIDList(GetDepartmentParentIDListReq) returns(GetDepartmentParentIDListResp);
|
||||
|
||||
rpc CreateOrganizationUser(CreateOrganizationUserReq) returns(CreateOrganizationUserResp);
|
||||
rpc UpdateOrganizationUser(UpdateOrganizationUserReq) returns(UpdateOrganizationUserResp);
|
||||
@@ -165,6 +187,7 @@ service organization{
|
||||
rpc DeleteUserInDepartment(DeleteUserInDepartmentReq) returns(DeleteUserInDepartmentResp);
|
||||
rpc UpdateUserInDepartment(UpdateUserInDepartmentReq) returns(UpdateUserInDepartmentResp);
|
||||
rpc GetDepartmentMember(GetDepartmentMemberReq) returns(GetDepartmentMemberResp);
|
||||
rpc GetDepartmentRelatedGroupIDList(GetDepartmentRelatedGroupIDListReq) returns(GetDepartmentRelatedGroupIDListResp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user