update service publish rule

This commit is contained in:
Liujian
2024-11-27 19:05:11 +08:00
parent 0a9a903d1b
commit 044bd550c9
12 changed files with 204 additions and 51 deletions
+13 -4
View File
@@ -39,8 +39,17 @@ type UpstreamDiff struct {
Status StatusType `json:"status,omitempty"`
}
type Diff struct {
Clusters []string `json:"clusters,omitempty"`
Apis []*ApiDiff `json:"apis"`
Upstreams []*UpstreamDiff `json:"upstreams"`
type StrategyDiff struct {
Strategy string `json:"strategy,omitempty"`
Name string `json:"name"`
Priority int `json:"priority"`
Change ChangeType `json:"change,omitempty"`
Status StatusType `json:"status,omitempty"`
}
type Diff struct {
Clusters []string `json:"clusters,omitempty"`
Apis []*ApiDiff `json:"apis"`
Upstreams []*UpstreamDiff `json:"upstreams"`
Strategies []*StrategyDiff `json:"strategies"`
}
+16 -3
View File
@@ -22,12 +22,25 @@ type imlStrategyService struct {
universally.IServiceEdit[Edit]
}
func (i *imlStrategyService) All(ctx context.Context, scope int, target string) ([]*Strategy, error) {
w := make(map[string]interface{})
w["scope"] = scope
if target != "" {
w["target"] = target
}
list, err := i.store.List(ctx, w)
if err != nil {
return nil, err
}
return utils.SliceToSlice(list, FromEntity), nil
}
func (i *imlStrategyService) Restore(ctx context.Context, id string) error {
_, err := i.store.UpdateWhere(ctx, map[string]interface{}{"uuid": id}, map[string]interface{}{"is_delete": false})
return err
}
func (i *imlStrategyService) SearchAll(ctx context.Context, keyword string, driver string, scope int, target string) ([]*Strategy, error) {
func (i *imlStrategyService) SearchAllByDriver(ctx context.Context, keyword string, driver string, scope int, target string) ([]*Strategy, error) {
w := make(map[string]interface{})
w["scope"] = scope
if target != "" {
@@ -40,7 +53,7 @@ func (i *imlStrategyService) SearchAll(ctx context.Context, keyword string, driv
return utils.SliceToSlice(list, FromEntity), nil
}
func (i *imlStrategyService) AllByScope(ctx context.Context, driver string, scope int, target string) ([]*Strategy, error) {
func (i *imlStrategyService) AllByDriver(ctx context.Context, driver string, scope int, target string) ([]*Strategy, error) {
w := make(map[string]interface{})
w["scope"] = scope
if target != "" {
@@ -100,7 +113,7 @@ func (i *imlStrategyService) ListStrategyCommit(ctx context.Context, commitIds .
return i.commitService.List(ctx, commitIds...)
}
func (i *imlStrategyService) Search(ctx context.Context, keyword string, driver string, scope int, target string, page int, pageSize int, filters []string, order ...string) ([]*Strategy, int64, error) {
func (i *imlStrategyService) SearchByDriver(ctx context.Context, keyword string, driver string, scope int, target string, page int, pageSize int, filters []string, order ...string) ([]*Strategy, int64, error) {
w := map[string]interface{}{
"scope": scope,
"driver": driver,
+4 -3
View File
@@ -14,9 +14,10 @@ import (
type IStrategyService interface {
universally.IServiceCreate[Create]
universally.IServiceEdit[Edit]
AllByScope(ctx context.Context, driver string, scope int, target string) ([]*Strategy, error)
Search(ctx context.Context, keyword string, driver string, scope int, target string, page int, pageSize int, filters []string, order ...string) ([]*Strategy, int64, error)
SearchAll(ctx context.Context, keyword string, driver string, scope int, target string) ([]*Strategy, error)
All(ctx context.Context, scope int, target string) ([]*Strategy, error)
AllByDriver(ctx context.Context, driver string, scope int, target string) ([]*Strategy, error)
SearchByDriver(ctx context.Context, keyword string, driver string, scope int, target string, page int, pageSize int, filters []string, order ...string) ([]*Strategy, int64, error)
SearchAllByDriver(ctx context.Context, keyword string, driver string, scope int, target string) ([]*Strategy, error)
Get(ctx context.Context, id string) (*Strategy, error)
SortDelete(ctx context.Context, id string) error
Delete(ctx context.Context, id ...string) error