organization

pull/218/head
skiffer-git 3 years ago
parent bd6e8d093a
commit f53f34559a

@ -159,6 +159,7 @@ func main() {
organizationGroup.POST("/update_department", organization.UpdateDepartment)
organizationGroup.POST("/get_sub_department", organization.GetSubDepartment)
organizationGroup.POST("/delete_department", organization.DeleteDepartment)
organizationGroup.POST("/get_all_department", organization.GetAllDepartment)
organizationGroup.POST("/create_organization_user", organization.CreateOrganizationUser)
organizationGroup.POST("/update_organization_user", organization.UpdateOrganizationUser)
@ -170,6 +171,7 @@ func main() {
organizationGroup.POST("/get_department_member", organization.GetDepartmentMember)
organizationGroup.POST("/delete_user_in_department", organization.DeleteUserInDepartment)
}
go apiThird.MinioInit()

@ -122,6 +122,10 @@ func GetSubDepartment(c *gin.Context) {
c.JSON(http.StatusOK, apiResp)
}
func GetAllDepartment(c *gin.Context) {
}
func DeleteDepartment(c *gin.Context) {
params := api.DeleteDepartmentReq{}
if err := c.BindJSON(&params); err != nil {

@ -0,0 +1,75 @@
package msg
import (
"Open_IM/pkg/common/constant"
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
"Open_IM/pkg/common/log"
utils2 "Open_IM/pkg/common/utils"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)
func OrganizationNotificationToAll(opUserID string, operationID string) {
err, userIDList := imdb.GetAllOrganizationUserID()
if err != nil {
log.Error(operationID, "GetAllOrganizationUserID failed ", err.Error())
return
}
tips := open_im_sdk.OrganizationChangedTips{OpUser: &open_im_sdk.UserInfo{}}
user, err := imdb.GetUserByUserID(opUserID)
if err != nil {
log.NewError(operationID, "GetUserByUserID failed ", err.Error(), opUserID)
return
}
utils2.UserDBCopyOpenIM(tips.OpUser, user)
for _, v := range userIDList {
OrganizationNotification(opUserID, v, constant.OrganizationChangedNotification, &tips, operationID)
}
}
func OrganizationNotification(opUserID string, recvUserID string, contentType int32, m proto.Message, operationID string) {
log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType, opUserID)
var err error
var tips open_im_sdk.TipsComm
tips.Detail, err = proto.Marshal(m)
if err != nil {
log.Error(operationID, "Marshal failed ", err.Error(), m.String())
return
}
marshaler := jsonpb.Marshaler{
OrigName: true,
EnumsAsInts: false,
EmitDefaults: false,
}
tips.JsonDetail, _ = marshaler.MarshalToString(m)
switch contentType {
case constant.OrganizationChangedNotification:
tips.DefaultTips = "OrganizationChangedNotification"
default:
log.Error(operationID, "contentType failed ", contentType)
return
}
var n NotificationMsg
n.SendID = opUserID
n.RecvID = recvUserID
n.ContentType = contentType
n.SessionType = constant.SingleChatType
n.MsgFrom = constant.SysMsgType
n.OperationID = operationID
n.Content, err = proto.Marshal(&tips)
if err != nil {
log.Error(operationID, "Marshal failed ", err.Error(), tips.String())
return
}
Notification(&n)
}

@ -562,6 +562,7 @@ func Notification(n *NotificationMsg) {
ex = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Ext
reliabilityLevel = config.Config.Notification.GroupMemberCancelMuted.Conversation.ReliabilityLevel
unReadCount = config.Config.Notification.GroupMemberCancelMuted.Conversation.UnreadCount
}
switch reliabilityLevel {
case constant.UnreliableNotification:

@ -1,6 +1,7 @@
package organization
import (
chat "Open_IM/internal/rpc/msg"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
@ -97,6 +98,7 @@ func (s *organizationServer) CreateDepartment(ctx context.Context, req *rpc.Crea
resp := &rpc.CreateDepartmentResp{DepartmentInfo: &open_im_sdk.Department{}}
utils.CopyStructFields(resp.DepartmentInfo, createdDepartment)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@ -120,6 +122,7 @@ func (s *organizationServer) UpdateDepartment(ctx context.Context, req *rpc.Upda
resp := &rpc.UpdateDepartmentResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@ -159,6 +162,7 @@ func (s *organizationServer) DeleteDepartment(ctx context.Context, req *rpc.Dele
log.Debug(req.OperationID, "DeleteDepartment ", req.DepartmentID)
resp := &rpc.DeleteDepartmentResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@ -182,6 +186,7 @@ func (s *organizationServer) CreateOrganizationUser(ctx context.Context, req *rp
log.Debug(req.OperationID, "CreateOrganizationUser ", organizationUser)
resp := &rpc.CreateOrganizationUserResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@ -209,6 +214,7 @@ func (s *organizationServer) UpdateOrganizationUser(ctx context.Context, req *rp
log.Debug(req.OperationID, "UpdateOrganizationUser ", organizationUser)
resp := &rpc.UpdateOrganizationUserResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@ -240,6 +246,7 @@ func (s *organizationServer) CreateDepartmentMember(ctx context.Context, req *rp
resp := &rpc.CreateDepartmentMemberResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@ -298,6 +305,7 @@ func (s *organizationServer) UpdateUserInDepartment(ctx context.Context, req *rp
}
resp := &rpc.UpdateUserInDepartmentResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@ -318,6 +326,7 @@ func (s *organizationServer) DeleteUserInDepartment(ctx context.Context, req *rp
log.Debug(req.OperationID, "DeleteUserInDepartment success ", req.DepartmentID, req.UserID)
resp := &rpc.DeleteUserInDepartmentResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@ -337,6 +346,7 @@ func (s *organizationServer) DeleteOrganizationUser(ctx context.Context, req *rp
log.Debug(req.OperationID, "DeleteOrganizationUser success ", req.UserID)
resp := &rpc.DeleteOrganizationUserResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}

@ -309,6 +309,11 @@ type config struct {
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"groupMemberInfoSet"`
OrganizationChanged struct {
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"organizationChanged"`
////////////////////////user///////////////////////
UserInfoUpdated struct {

@ -44,7 +44,12 @@ func GetSubDepartmentList(departmentID string) (error, []db.Department) {
return err, nil
}
var departmentList []db.Department
err = dbConn.Table("departments").Where("parent_id=?", departmentID).Find(&departmentList).Error
if departmentID == "-1" {
err = dbConn.Table("departments").Find(&departmentList).Error
} else {
err = dbConn.Table("departments").Where("parent_id=?", departmentID).Find(&departmentList).Error
}
return err, departmentList
}
@ -187,3 +192,13 @@ func GetDepartmentMemberList(departmentID string) (error, []db.DepartmentMember)
}
return err, departmentMemberList
}
func GetAllOrganizationUserID() (error, []string) {
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
if err != nil {
return err, nil
}
var OrganizationUser db.OrganizationUser
var result []string
return dbConn.Model(&OrganizationUser).Pluck("user_id", &result).Error, result
}

File diff suppressed because it is too large Load Diff

@ -358,6 +358,13 @@ message GroupMemberInfoSetTips{
GroupMemberFullInfo changedUser = 4;
}
message OrganizationChangedTips{
UserInfo opUser = 2;
int64 operationTime = 3;
}
//////////////////////friend/////////////////////
//message FriendInfo{
// UserInfo OwnerUser = 1;

Loading…
Cancel
Save