mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-12 18:11:34 +08:00
api文档完成
This commit is contained in:
@@ -3,16 +3,13 @@ package subscribe_dto
|
||||
import "github.com/eolinker/go-common/auto"
|
||||
|
||||
type Subscriber struct {
|
||||
Id string `json:"id"`
|
||||
Service auto.Label `json:"service" aolabel:"service"`
|
||||
//Cluster []auto.Label `json:"partition" aolabel:"partition"`
|
||||
|
||||
Id string `json:"id"`
|
||||
Service auto.Label `json:"service" aolabel:"service"`
|
||||
Subscriber auto.Label `json:"subscriber" aolabel:"service"`
|
||||
Team auto.Label `json:"team" aolabel:"team"`
|
||||
ApplyTime auto.TimeLabel `json:"apply_time"`
|
||||
Applier auto.Label `json:"applier" aolabel:"user"`
|
||||
//Approver auto.Label `json:"approver" aolabel:"user"`
|
||||
From int `json:"from"`
|
||||
From int `json:"from"`
|
||||
}
|
||||
|
||||
type SubscriptionItem struct {
|
||||
@@ -54,9 +51,17 @@ type ApprovalItem struct {
|
||||
Status int `json:"status"`
|
||||
}
|
||||
|
||||
//
|
||||
//type PartitionServiceItem struct {
|
||||
// Id string `json:"id"`
|
||||
// Name string `json:"name"`
|
||||
// ServiceNum int64 `json:"service_num"`
|
||||
//}
|
||||
type ExportApproval struct {
|
||||
Service string `json:"service"`
|
||||
Application string `json:"application"`
|
||||
Reason string `json:"reason"`
|
||||
}
|
||||
|
||||
type ExportSubscriber struct {
|
||||
Id string `json:"id"`
|
||||
Service string `json:"service"`
|
||||
Subscriber string `json:"subscriber"`
|
||||
Team string `json:"team"`
|
||||
Applier string `json:"applier"`
|
||||
From int `json:"from"`
|
||||
}
|
||||
|
||||
+46
-2
@@ -26,7 +26,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
_ ISubscribeModule = (*imlSubscribeModule)(nil)
|
||||
_ ISubscribeModule = (*imlSubscribeModule)(nil)
|
||||
_ IExportSubscribeModule = (*imlSubscribeModule)(nil)
|
||||
)
|
||||
|
||||
type imlSubscribeModule struct {
|
||||
@@ -37,6 +38,31 @@ type imlSubscribeModule struct {
|
||||
transaction store.ITransaction `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlSubscribeModule) ExistSubscriber(ctx context.Context, serviceId string, app string) error {
|
||||
_, err := i.subscribeService.GetByServiceAndApplication(ctx, serviceId, app)
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (i *imlSubscribeModule) ExportAll(ctx context.Context) ([]*subscribe_dto.ExportSubscriber, error) {
|
||||
list, err := i.subscribeService.List(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return utils.SliceToSlice(list, func(s *subscribe.Subscribe) *subscribe_dto.ExportSubscriber {
|
||||
return &subscribe_dto.ExportSubscriber{
|
||||
Id: s.Id,
|
||||
Service: s.Service,
|
||||
Subscriber: s.Application,
|
||||
Applier: s.Applier,
|
||||
From: s.From,
|
||||
}
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (i *imlSubscribeModule) getSubscribers(ctx context.Context, serviceIds []string) ([]*gateway.SubscribeRelease, error) {
|
||||
subscribers, err := i.subscribeService.SubscribersByProject(ctx, serviceIds...)
|
||||
if err != nil {
|
||||
@@ -343,7 +369,10 @@ func (i *imlSubscribeModule) SearchSubscribers(ctx context.Context, serviceId st
|
||||
return items, nil
|
||||
}
|
||||
|
||||
var _ ISubscribeApprovalModule = (*imlSubscribeApprovalModule)(nil)
|
||||
var (
|
||||
_ ISubscribeApprovalModule = (*imlSubscribeApprovalModule)(nil)
|
||||
_ ISubscribeApprovalModule = (*imlSubscribeApprovalModule)(nil)
|
||||
)
|
||||
|
||||
type imlSubscribeApprovalModule struct {
|
||||
subscribeService subscribe.ISubscribeService `autowired:""`
|
||||
@@ -353,6 +382,21 @@ type imlSubscribeApprovalModule struct {
|
||||
transaction store.ITransaction `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlSubscribeApprovalModule) ExportAll(ctx context.Context) ([]*subscribe_dto.ExportApproval, error) {
|
||||
|
||||
list, err := i.subscribeApplyService.List(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return utils.SliceToSlice(list, func(s *subscribe.Apply) *subscribe_dto.ExportApproval {
|
||||
return &subscribe_dto.ExportApproval{
|
||||
Service: s.Service,
|
||||
Application: s.Application,
|
||||
Reason: s.Reason,
|
||||
}
|
||||
}), nil
|
||||
}
|
||||
|
||||
func (i *imlSubscribeApprovalModule) Pass(ctx context.Context, pid string, id string, approveInfo *subscribe_dto.Approve) error {
|
||||
applyInfo, err := i.subscribeApplyService.Get(ctx, id)
|
||||
if err != nil {
|
||||
|
||||
@@ -2,16 +2,18 @@ package subscribe
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/APIParkLab/APIPark/module/system"
|
||||
"reflect"
|
||||
|
||||
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
|
||||
|
||||
subscribe_dto "github.com/APIParkLab/APIPark/module/subscribe/dto"
|
||||
)
|
||||
|
||||
type ISubscribeModule interface {
|
||||
// AddSubscriber 新增订阅方
|
||||
AddSubscriber(ctx context.Context, pid string, input *subscribe_dto.AddSubscriber) error
|
||||
ExistSubscriber(ctx context.Context, serviceId string, app string) error
|
||||
// DeleteSubscriber 删除订阅方
|
||||
DeleteSubscriber(ctx context.Context, project string, serviceId string, applicationId string) error
|
||||
// SearchSubscribers 关键字获取订阅方列表
|
||||
@@ -24,7 +26,12 @@ type ISubscribeModule interface {
|
||||
DeleteSubscription(ctx context.Context, pid string, uuid string) error
|
||||
// RevokeApply 取消申请
|
||||
RevokeApply(ctx context.Context, app string, uuid string) error
|
||||
//PartitionServices(ctx context.Context, app string) ([]*subscribe_dto.PartitionServiceItem, error)
|
||||
|
||||
//ExportAll(ctx context.Context) ([]*subscribe_dto.ExportSubscriber, error)
|
||||
}
|
||||
|
||||
type IExportSubscribeModule interface {
|
||||
system.IExportModule[subscribe_dto.ExportSubscriber]
|
||||
}
|
||||
|
||||
type ISubscribeApprovalModule interface {
|
||||
@@ -36,14 +43,30 @@ type ISubscribeApprovalModule interface {
|
||||
Pass(ctx context.Context, pid string, id string, approveInfo *subscribe_dto.Approve) error
|
||||
// Reject 驳回审批
|
||||
Reject(ctx context.Context, pid string, id string, approveInfo *subscribe_dto.Approve) error
|
||||
|
||||
ExportAll(ctx context.Context) ([]*subscribe_dto.ExportApproval, error)
|
||||
}
|
||||
|
||||
type IExportSubscribeApprovalModule interface {
|
||||
system.IExportModule[subscribe_dto.ExportApproval]
|
||||
}
|
||||
|
||||
func init() {
|
||||
subscribeModule := new(imlSubscribeModule)
|
||||
autowire.Auto[ISubscribeModule](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlSubscribeModule))
|
||||
return reflect.ValueOf(subscribeModule)
|
||||
})
|
||||
|
||||
|
||||
autowire.Auto[IExportSubscribeModule](func() reflect.Value {
|
||||
return reflect.ValueOf(subscribeModule)
|
||||
})
|
||||
|
||||
applyModule := new(imlSubscribeApprovalModule)
|
||||
autowire.Auto[ISubscribeApprovalModule](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlSubscribeApprovalModule))
|
||||
return reflect.ValueOf(applyModule)
|
||||
})
|
||||
|
||||
autowire.Auto[IExportSubscribeApprovalModule](func() reflect.Value {
|
||||
return reflect.ValueOf(applyModule)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user