Merge remote-tracking branch 'origin/tuoyun' into tuoyun

pull/141/head
wenxu12345 3 years ago
commit 5e65e394a6

@ -0,0 +1,25 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_cms_api
BIN_DIR=../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi

@ -0,0 +1,23 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_admin_cms
BIN_DIR=../../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi

@ -0,0 +1,23 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_message_cms
BIN_DIR=../../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi

@ -6,7 +6,7 @@ import (
) )
func main() { func main() {
rpcPort := flag.Int("port", 10301, "rpc listening port") rpcPort := flag.Int("port", 10300, "rpc listening port")
flag.Parse() flag.Parse()
rpcServer := rpcChat.NewRpcChatServer(*rpcPort) rpcServer := rpcChat.NewRpcChatServer(*rpcPort)
rpcServer.Run() rpcServer.Run()

@ -0,0 +1,23 @@
.PHONY: all build run gotool install clean help
BINARY_NAME=open_im_statistics
BIN_DIR=../../../bin/
all: gotool build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s"
run:
@go run ./
gotool:
go fmt ./
go vet ./
install:
make build
mv ${BINARY_NAME} ${BIN_DIR}
clean:
@if [ -f ${BINARY_NAME} ] ; then rm ${BINARY_NAME} ; fi

@ -6,7 +6,7 @@ import (
) )
func main() { func main() {
rpcPort := flag.Int("port", 10101, "rpc listening port") rpcPort := flag.Int("port", 10100, "rpc listening port")
flag.Parse() flag.Parse()
rpcServer := user.NewUserServer(*rpcPort) rpcServer := user.NewUserServer(*rpcPort)
rpcServer.Run() rpcServer.Run()

@ -60,6 +60,7 @@ serverip: 0.0.0.0
# endpoints 内部组件间访问的端点host名称访问时可以内部直接访问 host:port 来访问 # endpoints 内部组件间访问的端点host名称访问时可以内部直接访问 host:port 来访问
endpoints: endpoints:
api: openim_api api: openim_api
cmsapi: openim_cms_api
push: openim_push push: openim_push
msg_gateway: openim_msg_gateway msg_gateway: openim_msg_gateway
rpc_auth: openim_rpc_auth rpc_auth: openim_rpc_auth
@ -67,11 +68,14 @@ endpoints:
rpc_group: openim_rpc_group rpc_group: openim_rpc_group
rpc_msg: openim_rpc_msg rpc_msg: openim_rpc_msg
rpc_user: openim_rpc_user rpc_user: openim_rpc_user
rpc_statistic: openim_rpc_statistic
rpc_admin_cms: openim_rpc_admin_cms
rpc_message_cms: openim_rpc_admin_cms
api: api:
openImApiPort: [ 10000 ] openImApiPort: [ 10000 ]
cmsapi: cmsapi:
openImCMSPort: [ 8000 ] openImCmsApiPort: [ 8000 ]
sdk: sdk:
openImSdkWsPort: [ 30000 ] openImSdkWsPort: [ 30000 ]
@ -92,9 +96,9 @@ rpcport:
openImGroupPort: [ 10500 ] openImGroupPort: [ 10500 ]
openImAuthPort: [ 10600 ] openImAuthPort: [ 10600 ]
openImPushPort: [ 10700 ] openImPushPort: [ 10700 ]
openImOpenImStatisticPort: [ 10800 ] openImStatisticsPort: [ 10800 ]
OpenImMessageCMSPort: [ 10900 ] openImMessageCmsPort: [ 10900 ]
openImAdminCMSPort: [11000] openImAdminCmsPort: [ 11000 ]
c2c: c2c:
callbackBeforeSendMsg: callbackBeforeSendMsg:
switch: false switch: false
@ -153,7 +157,7 @@ push:
pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end" pushIntent: "intent:#Intent;component=io.openim.app.enterprisechat/io.openim.app.enterprisechat.MainActivity;end"
manager: manager:
appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"] appManagerUid: [ "openIM123456","openIM654321", "openIM333", "openIMAdmin"]
secrets: [ "openIM1","openIM2", "openIM333" ] secrets: [ "openIM1","openIM2", "openIM333", "openIMAdmin"]
secret: tuoyun secret: tuoyun

@ -696,7 +696,6 @@ func (s *groupServer) GetGroup(_ context.Context, req *pbGroup.GetGroupReq) (*pb
groupMember, err := imdb.GetGroupMaster(v.GroupID) groupMember, err := imdb.GetGroupMaster(v.GroupID)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster error", err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetGroupMaster error", err.Error())
continue
} }
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{ resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{
GroupInfo: &open_im_sdk.GroupInfo{ GroupInfo: &open_im_sdk.GroupInfo{
@ -738,7 +737,6 @@ func (s *groupServer) GetGroups(_ context.Context, req *pbGroup.GetGroupsReq) (*
groupMember, err := imdb.GetGroupMaster(v.GroupID) groupMember, err := imdb.GetGroupMaster(v.GroupID)
if err != nil { if err != nil {
log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error()) log.NewError(req.OperationID, utils.GetSelfFuncName(), err.Error())
continue
} }
resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{ resp.CMSGroups = append(resp.CMSGroups, &pbGroup.CMSGroup{
GroupInfo: &open_im_sdk.GroupInfo{ GroupInfo: &open_im_sdk.GroupInfo{

@ -6,6 +6,7 @@ import (
"Open_IM/pkg/utils" "Open_IM/pkg/utils"
"errors" "errors"
"fmt" "fmt"
"github.com/jinzhu/gorm"
"time" "time"
) )
@ -124,17 +125,56 @@ func OperateGroupRole(userId, groupId string, roleLevel int32) error {
groupMember := db.GroupMember{ groupMember := db.GroupMember{
UserID: userId, UserID: userId,
GroupID: groupId, GroupID: groupId,
RoleLevel: roleLevel,
} }
updateInfo := db.GroupMember{ updateInfo := db.GroupMember{
RoleLevel: roleLevel, RoleLevel: roleLevel,
} }
result := dbConn.Table("group_members").Find(&groupMember).Update(updateInfo) groupMaster := db.GroupMember{
if result.Error != nil { }
return result.Error switch roleLevel {
} case constant.GroupOwner:
if result.RowsAffected == 0 { return dbConn.Transaction(func(tx *gorm.DB) error {
return errors.New(fmt.Sprintf("user %s not exist in group %s or already operate", userId, groupId)) result := dbConn.Table("group_members").Where("group_id = ? and role_level = ?", groupId, constant.GroupOwner).First(&groupMaster).Update(&db.GroupMember{
RoleLevel: constant.GroupOrdinaryUsers,
})
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return errors.New(fmt.Sprintf("user %s not exist in group %s or already operate", userId, groupId))
}
result = dbConn.Table("group_members").First(&groupMember).Update(updateInfo)
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return errors.New(fmt.Sprintf("user %s not exist in group %s or already operate", userId, groupId))
}
return nil
})
case constant.GroupOrdinaryUsers:
return dbConn.Transaction(func(tx *gorm.DB) error {
result := dbConn.Table("group_members").Where("group_id = ? and role_level = ?", groupId, constant.GroupOwner).First(&groupMaster)
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return errors.New(fmt.Sprintf("user %s not exist in group %s or already operate", userId, groupId))
}
if groupMaster.UserID == userId {
return errors.New(fmt.Sprintf("user %s is master of %s, cant set to ordinary user", userId, groupId))
} else {
result = dbConn.Table("group_members").Find(&groupMember).Update(updateInfo)
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return errors.New(fmt.Sprintf("user %s not exist in group %s or already operate", userId, groupId))
}
}
return nil
})
} }
return nil return nil
} }

@ -4,6 +4,7 @@ source ./style_info.cfg
source ./path_info.cfg source ./path_info.cfg
source ./function.sh source ./function.sh
service_port_name=( service_port_name=(
openImCmsApiPort
openImApiPort openImApiPort
openImUserPort openImUserPort
openImFriendPort openImFriendPort
@ -15,6 +16,9 @@ service_port_name=(
openImWsPort openImWsPort
openImSdkWsPort openImSdkWsPort
openImDemoPort openImDemoPort
openImAdminCmsPort
openImMessageCmsPort
openImStatisticsPort
) )
switch=$(cat $config_path | grep demoswitch |awk -F '[:]' '{print $NF}') switch=$(cat $config_path | grep demoswitch |awk -F '[:]' '{print $NF}')
for i in ${service_port_name[*]}; do for i in ${service_port_name[*]}; do

@ -39,11 +39,15 @@ config_path="../config/config.yaml"
service_source_root=( service_source_root=(
#api service file #api service file
../cmd/open_im_api/ ../cmd/open_im_api/
../cmd/open_im_cms_api/
#rpc service file #rpc service file
../cmd/rpc/open_im_user/ ../cmd/rpc/open_im_user/
../cmd/rpc/open_im_friend/ ../cmd/rpc/open_im_friend/
../cmd/rpc/open_im_group/ ../cmd/rpc/open_im_group/
../cmd/rpc/open_im_auth/ ../cmd/rpc/open_im_auth/
../cmd/rpc/open_im_admin_cms/
../cmd/rpc/open_im_message_cms/
../cmd/rpc/open_im_statistics/
${msg_gateway_source_root} ${msg_gateway_source_root}
${msg_transfer_source_root} ${msg_transfer_source_root}
${msg_source_root} ${msg_source_root}
@ -56,11 +60,15 @@ service_source_root=(
service_names=( service_names=(
#api service filename #api service filename
open_im_api open_im_api
open_im_cms_api
#rpc service filename #rpc service filename
open_im_user open_im_user
open_im_friend open_im_friend
open_im_group open_im_group
open_im_auth open_im_auth
open_im_admin_cms
open_im_message_cms
open_im_statistics
${msg_gateway_name} ${msg_gateway_name}
${msg_transfer_name} ${msg_transfer_name}
${msg_name} ${msg_name}

@ -8,11 +8,15 @@ source ./function.sh
service_filename=( service_filename=(
#api #api
open_im_api open_im_api
open_im_cms_api
#rpc #rpc
open_im_user open_im_user
open_im_friend open_im_friend
open_im_group open_im_group
open_im_auth open_im_auth
open_im_admin_cms
open_im_message_cms
open_im_statistics
${msg_name} ${msg_name}
) )
@ -20,11 +24,15 @@ service_filename=(
service_port_name=( service_port_name=(
#api port name #api port name
openImApiPort openImApiPort
openImCmsApiPort
#rpc port name #rpc port name
openImUserPort openImUserPort
openImFriendPort openImFriendPort
openImGroupPort openImGroupPort
openImAuthPort openImAuthPort
openImAdminCmsPort
openImMessageCmsPort
openImStatisticsPort
openImOfflineMessagePort openImOfflineMessagePort
) )

Loading…
Cancel
Save