mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-14 20:41:15 +08:00
修复动态模块上下线失败的问题
This commit is contained in:
@@ -6,6 +6,7 @@ type Item struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Children []*Item `json:"children"`
|
||||
Sort int `json:"-"`
|
||||
}
|
||||
|
||||
type ServiceItem struct {
|
||||
|
||||
@@ -347,9 +347,10 @@ func (i *imlCatalogueModule) Services(ctx context.Context, keyword string) ([]*c
|
||||
|
||||
func (i *imlCatalogueModule) recurseUpdateSort(ctx context.Context, parent string, sorts []*catalogue_dto.SortItem) error {
|
||||
for index, item := range sorts {
|
||||
s := index
|
||||
err := i.catalogueService.Save(ctx, item.Id, &catalogue.EditCatalogue{
|
||||
Parent: &parent,
|
||||
Sort: &index,
|
||||
Sort: &s,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -488,8 +489,12 @@ func treeItems(parentId string, parentMap map[string][]*catalogue.Catalogue) []*
|
||||
Id: v.Id,
|
||||
Name: v.Name,
|
||||
Children: childItems,
|
||||
Sort: v.Sort,
|
||||
})
|
||||
}
|
||||
}
|
||||
sort.Slice(items, func(i, j int) bool {
|
||||
return items[i].Sort < items[j].Sort
|
||||
})
|
||||
return items
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ func NewRoot(list []*catalogue.Catalogue) *Root {
|
||||
Name: i.Name,
|
||||
Depth: 0,
|
||||
children: nil,
|
||||
sort: i.Sort,
|
||||
}
|
||||
l = append(l, g)
|
||||
m[g.Uuid] = g
|
||||
@@ -137,7 +138,7 @@ func (g Groups) Less(i, j int) bool {
|
||||
}
|
||||
return g[i].sort < g[j].sort
|
||||
}
|
||||
return g[i].Parent < g[i].Parent
|
||||
return g[i].Parent < g[j].Parent
|
||||
}
|
||||
return g[i].Depth < g[j].Depth
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ type IDynamicModuleModule interface {
|
||||
Render(ctx context.Context, module string) (map[string]interface{}, error)
|
||||
ModuleDrivers(ctx context.Context, group string) ([]*dynamic_module_dto.ModuleDriver, error)
|
||||
|
||||
Online(ctx context.Context, module string, id string, clusterInput *dynamic_module_dto.ClusterInput) error
|
||||
Offline(ctx context.Context, module string, id string, clusterInput *dynamic_module_dto.ClusterInput) error
|
||||
Online(ctx context.Context, module string, id string) error
|
||||
Offline(ctx context.Context, module string, id string) error
|
||||
//PartitionStatuses(ctx context.Context, module string, keyword string, page int, pageSize int) (map[string]map[string]string, error)
|
||||
//PartitionStatus(ctx context.Context, module string, id string) (*dynamic_module_dto.OnlineInfo, error)
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func (i *imlDynamicModule) initGateway(ctx context.Context, clusterId string, cl
|
||||
return nil
|
||||
}
|
||||
|
||||
func (i *imlDynamicModule) Online(ctx context.Context, module string, id string, clusterInput *dynamic_module_dto.ClusterInput) error {
|
||||
func (i *imlDynamicModule) Online(ctx context.Context, module string, id string) error {
|
||||
_, has := driver.Get(module)
|
||||
if !has {
|
||||
return fmt.Errorf("模块【%s】不存在", module)
|
||||
@@ -56,7 +56,7 @@ func (i *imlDynamicModule) Online(ctx context.Context, module string, id string,
|
||||
if err != nil {
|
||||
return fmt.Errorf("上线失败,配置不存在")
|
||||
}
|
||||
clusters, err := i.clusterService.List(ctx, clusterInput.Clusters...)
|
||||
clusters, err := i.clusterService.List(ctx)
|
||||
if err != nil || len(clusters) == 0 {
|
||||
return fmt.Errorf("上线失败,集群不存在")
|
||||
}
|
||||
@@ -102,28 +102,21 @@ func (i *imlDynamicModule) Online(ctx context.Context, module string, id string,
|
||||
})
|
||||
}
|
||||
|
||||
func (i *imlDynamicModule) Offline(ctx context.Context, module string, id string, clusterInput *dynamic_module_dto.ClusterInput) error {
|
||||
func (i *imlDynamicModule) Offline(ctx context.Context, module string, id string) error {
|
||||
_, has := driver.Get(module)
|
||||
if !has {
|
||||
return fmt.Errorf("模块【%s】不存在", module)
|
||||
}
|
||||
//if len(clusterInput.Clusters) == 0 {
|
||||
// return fmt.Errorf("下线分区失败,分区为空")
|
||||
//}
|
||||
|
||||
return i.transaction.Transaction(ctx, func(ctx context.Context) error {
|
||||
id = strings.ToLower(fmt.Sprintf("%s_%s", id, module))
|
||||
if len(clusterInput.Clusters) == 0 {
|
||||
clusters, err := i.clusterService.List(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
clusterInput.Clusters = make([]string, 0)
|
||||
for _, c := range clusters {
|
||||
clusterInput.Clusters = append(clusterInput.Clusters, c.Uuid)
|
||||
}
|
||||
clusters, err := i.clusterService.List(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, clusterId := range clusterInput.Clusters {
|
||||
clusterIds := utils.SliceToSlice(clusters, func(s *cluster.Cluster) string {
|
||||
return s.Uuid
|
||||
})
|
||||
for _, clusterId := range clusterIds {
|
||||
err := i.dynamicClient(ctx, clusterId, module, func(dynamicClient gateway.IDynamicClient) error {
|
||||
return dynamicClient.Offline(ctx, &gateway.DynamicRelease{
|
||||
BasicItem: &gateway.BasicItem{
|
||||
|
||||
@@ -64,6 +64,7 @@ type Member struct {
|
||||
User auto.Label `json:"user" aolabel:"user"`
|
||||
Roles []auto.Label `json:"roles" aolabel:"role"`
|
||||
AttachTime auto.TimeLabel `json:"attach_time"`
|
||||
IsDelete bool `json:"is_delete"`
|
||||
}
|
||||
|
||||
func ToMember(model *team_member.Member, roles ...string) *Member {
|
||||
|
||||
@@ -48,6 +48,7 @@ func (m *imlTeamModule) UpdateMemberRole(ctx context.Context, id string, input *
|
||||
if len(input.Roles) < 1 {
|
||||
return errors.New("at least one role")
|
||||
}
|
||||
|
||||
err = m.roleMemberService.RemoveUserRole(ctx, role.TeamTarget(id), input.Users...)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user