mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-28 16:36:37 +08:00
增加修改服务所在分组API
This commit is contained in:
@@ -338,12 +338,31 @@ func (this *ServerDAO) UpdateServerBasic(tx *dbs.Tx, serverId int64, name string
|
||||
return nil
|
||||
}
|
||||
|
||||
// UpdateServerGroupIds 修改服务所在分组
|
||||
func (this *ServerDAO) UpdateServerGroupIds(tx *dbs.Tx, serverId int64, groupIds []int64) error {
|
||||
if groupIds == nil {
|
||||
groupIds = []int64{}
|
||||
}
|
||||
groupIdsJSON, err := json.Marshal(groupIds)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = this.Query(tx).
|
||||
Pk(serverId).
|
||||
Set("groupIds", groupIdsJSON).
|
||||
UpdateQuickly()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return this.NotifyUpdate(tx, serverId)
|
||||
}
|
||||
|
||||
// UpdateUserServerBasic 设置用户相关的基本信息
|
||||
func (this *ServerDAO) UpdateUserServerBasic(tx *dbs.Tx, serverId int64, name string) error {
|
||||
if serverId <= 0 {
|
||||
return errors.New("serverId should not be smaller than 0")
|
||||
}
|
||||
op := NewServerOperator()
|
||||
var op = NewServerOperator()
|
||||
op.Id = serverId
|
||||
op.Name = name
|
||||
|
||||
|
||||
@@ -410,6 +410,17 @@ func (this *ServerGroupDAO) CheckUserGroup(tx *dbs.Tx, userId int64, groupId int
|
||||
return nil
|
||||
}
|
||||
|
||||
// ExistsGroup 检查分组ID是否存在
|
||||
func (this *ServerGroupDAO) ExistsGroup(tx *dbs.Tx, groupId int64) (bool, error) {
|
||||
if groupId <= 0 {
|
||||
return false, nil
|
||||
}
|
||||
return this.Query(tx).
|
||||
Pk(groupId).
|
||||
State(ServerGroupStateEnabled).
|
||||
Exist()
|
||||
}
|
||||
|
||||
// NotifyUpdate 通知更新
|
||||
func (this *ServerGroupDAO) NotifyUpdate(tx *dbs.Tx, groupId int64) error {
|
||||
serverIds, err := SharedServerDAO.FindAllEnabledServerIdsWithGroupId(tx, groupId)
|
||||
|
||||
Reference in New Issue
Block a user