|
|
@ -116,10 +116,10 @@ func DeleteGroup(groupId string) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func OperateGroupRole(userId, groupId string, roleLevel int32) error {
|
|
|
|
func OperateGroupRole(userId, groupId string, roleLevel int32) (string, string, error) {
|
|
|
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
|
|
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return "", "", err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dbConn.LogMode(true)
|
|
|
|
dbConn.LogMode(true)
|
|
|
|
groupMember := db.GroupMember{
|
|
|
|
groupMember := db.GroupMember{
|
|
|
@ -133,7 +133,7 @@ func OperateGroupRole(userId, groupId string, roleLevel int32) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
switch roleLevel {
|
|
|
|
switch roleLevel {
|
|
|
|
case constant.GroupOwner:
|
|
|
|
case constant.GroupOwner:
|
|
|
|
return dbConn.Transaction(func(tx *gorm.DB) error {
|
|
|
|
err = dbConn.Transaction(func(tx *gorm.DB) error {
|
|
|
|
result := dbConn.Table("group_members").Where("group_id = ? and role_level = ?", groupId, constant.GroupOwner).First(&groupMaster).Update(&db.GroupMember{
|
|
|
|
result := dbConn.Table("group_members").Where("group_id = ? and role_level = ?", groupId, constant.GroupOwner).First(&groupMaster).Update(&db.GroupMember{
|
|
|
|
RoleLevel: constant.GroupOrdinaryUsers,
|
|
|
|
RoleLevel: constant.GroupOrdinaryUsers,
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -153,8 +153,9 @@ func OperateGroupRole(userId, groupId string, roleLevel int32) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
case constant.GroupOrdinaryUsers:
|
|
|
|
case constant.GroupOrdinaryUsers:
|
|
|
|
return dbConn.Transaction(func(tx *gorm.DB) error {
|
|
|
|
err = dbConn.Transaction(func(tx *gorm.DB) error {
|
|
|
|
result := dbConn.Table("group_members").Where("group_id = ? and role_level = ?", groupId, constant.GroupOwner).First(&groupMaster)
|
|
|
|
result := dbConn.Table("group_members").Where("group_id = ? and role_level = ?", groupId, constant.GroupOwner).First(&groupMaster)
|
|
|
|
if result.Error != nil {
|
|
|
|
if result.Error != nil {
|
|
|
|
return result.Error
|
|
|
|
return result.Error
|
|
|
@ -176,7 +177,7 @@ func OperateGroupRole(userId, groupId string, roleLevel int32) error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
return "", "", nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func GetGroupsCountNum(group db.Group) (int32, error) {
|
|
|
|
func GetGroupsCountNum(group db.Group) (int32, error) {
|
|
|
|