mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Organization
This commit is contained in:
parent
31d2527cfe
commit
066fae0b74
@ -140,6 +140,16 @@ func (s *organizationServer) GetSubDepartment(ctx context.Context, req *rpc.GetS
|
|||||||
v1 := open_im_sdk.Department{}
|
v1 := open_im_sdk.Department{}
|
||||||
utils.CopyStructFields(&v1, v)
|
utils.CopyStructFields(&v1, v)
|
||||||
log.Debug(req.OperationID, "src ", v, "dst ", v1)
|
log.Debug(req.OperationID, "src ", v, "dst ", v1)
|
||||||
|
err, v1.MemberNum = imdb.GetDepartmentMemberNum(v1.DepartmentID)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(req.OperationID, "GetDepartmentMemberNum failed ", err.Error(), v1.DepartmentID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
err, v1.SubDepartmentNum = imdb.GetSubDepartmentNum(v1.DepartmentID)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(req.OperationID, "GetSubDepartmentNum failed ", err.Error(), v1.DepartmentID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
resp.DepartmentList = append(resp.DepartmentList, &v1)
|
resp.DepartmentList = append(resp.DepartmentList, &v1)
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
||||||
|
@ -2,6 +2,7 @@ package im_mysql_model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -207,3 +208,31 @@ func GetAllOrganizationUserID() (error, []string) {
|
|||||||
var result []string
|
var result []string
|
||||||
return dbConn.Model(&OrganizationUser).Pluck("user_id", &result).Error, result
|
return dbConn.Model(&OrganizationUser).Pluck("user_id", &result).Error, result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetDepartmentMemberNum(departmentID string) (error, uint32) {
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return utils.Wrap(err, "DefaultGormDB failed"), 0
|
||||||
|
}
|
||||||
|
var number uint32
|
||||||
|
err = dbConn.Table("department_members").Where("department_id=?", departmentID).Count(&number).Error
|
||||||
|
if err != nil {
|
||||||
|
return utils.Wrap(err, ""), 0
|
||||||
|
}
|
||||||
|
return nil, number
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSubDepartmentNum(departmentID string) (error, uint32) {
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return utils.Wrap(err, "DefaultGormDB failed"), 0
|
||||||
|
}
|
||||||
|
var number uint32
|
||||||
|
err = dbConn.Table("departments").Where("parent_id=?", departmentID).Count(&number).Error
|
||||||
|
if err != nil {
|
||||||
|
return utils.Wrap(err, ""), 0
|
||||||
|
}
|
||||||
|
return nil, number
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user