mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-26 16:01:56 +08:00
首次提交APIPark代码,面向开源
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
|
||||
api_dto "github.com/APIParkLab/APIPark/module/api/dto"
|
||||
)
|
||||
|
||||
type IAPIController interface {
|
||||
// Detail 获取API详情
|
||||
Detail(ctx *gin.Context, serviceId string, apiId string) (*api_dto.ApiDetail, error)
|
||||
// SimpleDetail 获取API简要详情
|
||||
SimpleDetail(ctx *gin.Context, serviceId string, apiId string) (*api_dto.ApiSimpleDetail, error)
|
||||
// Search 获取API列表
|
||||
Search(ctx *gin.Context, keyword string, serviceId string) ([]*api_dto.ApiItem, error)
|
||||
// SimpleSearch 获取API简要列表
|
||||
SimpleSearch(ctx *gin.Context, keyword string, serviceId string) ([]*api_dto.ApiSimpleItem, error)
|
||||
//SimpleList(ctx *gin.Context, serviceId string) ([]*api_dto.ApiSimpleItem, error)
|
||||
// Create 创建API
|
||||
Create(ctx *gin.Context, serviceId string, dto *api_dto.CreateApi) (*api_dto.ApiSimpleDetail, error)
|
||||
// Edit 编辑API
|
||||
Edit(ctx *gin.Context, serviceId string, apiId string, dto *api_dto.EditApi) (*api_dto.ApiSimpleDetail, error)
|
||||
// Delete 删除API
|
||||
Delete(ctx *gin.Context, serviceId string, apiId string) error
|
||||
// Copy 复制API
|
||||
Copy(ctx *gin.Context, serviceId string, apiId string, dto *api_dto.CreateApi) (*api_dto.ApiSimpleDetail, error)
|
||||
// ApiDocDetail 获取API文档详情
|
||||
ApiDocDetail(ctx *gin.Context, serviceId string, apiId string) (*api_dto.ApiDocDetail, error)
|
||||
// ApiProxyDetail 获取API代理详情
|
||||
ApiProxyDetail(ctx *gin.Context, serviceId string, apiId string) (*api_dto.ApiProxyDetail, error)
|
||||
// Prefix 获取API前缀
|
||||
Prefix(ctx *gin.Context, serviceId string) (string, bool, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[IAPIController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlAPIController))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/APIParkLab/APIPark/module/api"
|
||||
api_dto "github.com/APIParkLab/APIPark/module/api/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var _ IAPIController = (*imlAPIController)(nil)
|
||||
|
||||
type imlAPIController struct {
|
||||
module api.IApiModule `autowired:""`
|
||||
}
|
||||
|
||||
//func (i *imlAPIController) SimpleList(ctx *gin.Context, serviceId string) ([]*api_dto.ApiSimpleItem, error) {
|
||||
// return i.module.SimpleList(ctx, serviceId)
|
||||
//}
|
||||
|
||||
func (i *imlAPIController) Detail(ctx *gin.Context, serviceId string, apiId string) (*api_dto.ApiDetail, error) {
|
||||
return i.module.Detail(ctx, serviceId, apiId)
|
||||
}
|
||||
|
||||
func (i *imlAPIController) SimpleDetail(ctx *gin.Context, serviceId string, apiId string) (*api_dto.ApiSimpleDetail, error) {
|
||||
return i.module.SimpleDetail(ctx, serviceId, apiId)
|
||||
}
|
||||
|
||||
func (i *imlAPIController) Search(ctx *gin.Context, keyword string, serviceId string) ([]*api_dto.ApiItem, error) {
|
||||
return i.module.Search(ctx, keyword, serviceId)
|
||||
}
|
||||
|
||||
func (i *imlAPIController) SimpleSearch(ctx *gin.Context, keyword string, serviceId string) ([]*api_dto.ApiSimpleItem, error) {
|
||||
return i.module.SimpleSearch(ctx, keyword, serviceId)
|
||||
}
|
||||
|
||||
func (i *imlAPIController) Create(ctx *gin.Context, serviceId string, dto *api_dto.CreateApi) (*api_dto.ApiSimpleDetail, error) {
|
||||
return i.module.Create(ctx, serviceId, dto)
|
||||
}
|
||||
|
||||
func (i *imlAPIController) Edit(ctx *gin.Context, serviceId string, apiId string, dto *api_dto.EditApi) (*api_dto.ApiSimpleDetail, error) {
|
||||
return i.module.Edit(ctx, serviceId, apiId, dto)
|
||||
}
|
||||
|
||||
func (i *imlAPIController) Delete(ctx *gin.Context, serviceId string, apiId string) error {
|
||||
return i.module.Delete(ctx, serviceId, apiId)
|
||||
}
|
||||
|
||||
func (i *imlAPIController) Copy(ctx *gin.Context, serviceId string, apiId string, dto *api_dto.CreateApi) (*api_dto.ApiSimpleDetail, error) {
|
||||
return i.module.Copy(ctx, serviceId, apiId, dto)
|
||||
}
|
||||
|
||||
func (i *imlAPIController) ApiDocDetail(ctx *gin.Context, serviceId string, apiId string) (*api_dto.ApiDocDetail, error) {
|
||||
return i.module.ApiDocDetail(ctx, serviceId, apiId)
|
||||
}
|
||||
|
||||
func (i *imlAPIController) ApiProxyDetail(ctx *gin.Context, serviceId string, apiId string) (*api_dto.ApiProxyDetail, error) {
|
||||
return i.module.ApiProxyDetail(ctx, serviceId, apiId)
|
||||
}
|
||||
|
||||
func (i *imlAPIController) Prefix(ctx *gin.Context, serviceId string) (string, bool, error) {
|
||||
prefix, err := i.module.Prefix(ctx, serviceId)
|
||||
if err != nil {
|
||||
return "", false, err
|
||||
}
|
||||
return prefix, true, nil
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package application_authorization
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
|
||||
application_authorization_dto "github.com/APIParkLab/APIPark/module/application-authorization/dto"
|
||||
)
|
||||
|
||||
type IAuthorizationController interface {
|
||||
// AddAuthorization 添加项目鉴权信息
|
||||
AddAuthorization(ctx *gin.Context, pid string, info *application_authorization_dto.CreateAuthorization) (*application_authorization_dto.Authorization, error)
|
||||
// EditAuthorization 修改项目鉴权信息
|
||||
EditAuthorization(ctx *gin.Context, pid string, aid string, info *application_authorization_dto.EditAuthorization) (*application_authorization_dto.Authorization, error)
|
||||
// DeleteAuthorization 删除项目鉴权
|
||||
DeleteAuthorization(ctx *gin.Context, pid string, aid string) error
|
||||
// Authorizations 获取项目鉴权列表
|
||||
Authorizations(ctx *gin.Context, pid string) ([]*application_authorization_dto.AuthorizationItem, error)
|
||||
// Detail 获取项目鉴权详情(弹窗用)
|
||||
Detail(ctx *gin.Context, pid string, aid string) ([]application_authorization_dto.DetailItem, error)
|
||||
// Info 获取项目鉴权详情
|
||||
Info(ctx *gin.Context, pid string, aid string) (*application_authorization_dto.Authorization, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[IAuthorizationController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlAuthorizationController))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package application_authorization
|
||||
|
||||
import (
|
||||
application_authorization "github.com/APIParkLab/APIPark/module/application-authorization"
|
||||
application_authorization_dto "github.com/APIParkLab/APIPark/module/application-authorization/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var _ IAuthorizationController = (*imlAuthorizationController)(nil)
|
||||
|
||||
type imlAuthorizationController struct {
|
||||
module application_authorization.IAuthorizationModule `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlAuthorizationController) AddAuthorization(ctx *gin.Context, pid string, info *application_authorization_dto.CreateAuthorization) (*application_authorization_dto.Authorization, error) {
|
||||
return i.module.AddAuthorization(ctx, pid, info)
|
||||
}
|
||||
|
||||
func (i *imlAuthorizationController) EditAuthorization(ctx *gin.Context, pid string, aid string, info *application_authorization_dto.EditAuthorization) (*application_authorization_dto.Authorization, error) {
|
||||
return i.module.EditAuthorization(ctx, pid, aid, info)
|
||||
}
|
||||
|
||||
func (i *imlAuthorizationController) DeleteAuthorization(ctx *gin.Context, pid string, aid string) error {
|
||||
return i.module.DeleteAuthorization(ctx, pid, aid)
|
||||
}
|
||||
|
||||
func (i *imlAuthorizationController) Authorizations(ctx *gin.Context, pid string) ([]*application_authorization_dto.AuthorizationItem, error) {
|
||||
return i.module.Authorizations(ctx, pid)
|
||||
}
|
||||
|
||||
func (i *imlAuthorizationController) Detail(ctx *gin.Context, pid string, aid string) ([]application_authorization_dto.DetailItem, error) {
|
||||
return i.module.Detail(ctx, pid, aid)
|
||||
}
|
||||
|
||||
func (i *imlAuthorizationController) Info(ctx *gin.Context, pid string, aid string) (*application_authorization_dto.Authorization, error) {
|
||||
return i.module.Info(ctx, pid, aid)
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package catalogue
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"reflect"
|
||||
|
||||
tag_dto "github.com/APIParkLab/APIPark/module/tag/dto"
|
||||
|
||||
catalogue_dto "github.com/APIParkLab/APIPark/module/catalogue/dto"
|
||||
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
)
|
||||
|
||||
type ICatalogueController interface {
|
||||
// Search 搜索目录、标签列表
|
||||
Search(ctx *gin.Context, keyword string) ([]*catalogue_dto.Item, []*tag_dto.Item, error)
|
||||
// Create 创建目录
|
||||
Create(ctx *gin.Context, input *catalogue_dto.CreateCatalogue) error
|
||||
// Edit 修改目录
|
||||
Edit(ctx *gin.Context, id string, input *catalogue_dto.EditCatalogue) error
|
||||
// Delete 删除目录
|
||||
Delete(ctx *gin.Context, id string) error
|
||||
// Services 服务列表
|
||||
Services(ctx *gin.Context, keyword string) ([]*catalogue_dto.ServiceItem, error)
|
||||
// ServiceDetail 服务详情
|
||||
ServiceDetail(ctx *gin.Context, sid string) (*catalogue_dto.ServiceDetail, error)
|
||||
// Subscribe 订阅服务
|
||||
Subscribe(ctx *gin.Context, subscribeInfo *catalogue_dto.SubscribeService) error
|
||||
Sort(ctx *gin.Context, sorts *[]*catalogue_dto.SortItem) error
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[ICatalogueController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlCatalogueController))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package catalogue
|
||||
|
||||
import (
|
||||
"github.com/APIParkLab/APIPark/module/catalogue"
|
||||
catalogue_dto "github.com/APIParkLab/APIPark/module/catalogue/dto"
|
||||
"github.com/APIParkLab/APIPark/module/tag"
|
||||
tag_dto "github.com/APIParkLab/APIPark/module/tag/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
_ ICatalogueController = (*imlCatalogueController)(nil)
|
||||
)
|
||||
|
||||
type imlCatalogueController struct {
|
||||
catalogueModule catalogue.ICatalogueModule `autowired:""`
|
||||
tagModule tag.ITagModule `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlCatalogueController) Sort(ctx *gin.Context, sorts *[]*catalogue_dto.SortItem) error {
|
||||
return i.catalogueModule.Sort(ctx, *sorts)
|
||||
}
|
||||
|
||||
func (i *imlCatalogueController) Subscribe(ctx *gin.Context, subscribeInfo *catalogue_dto.SubscribeService) error {
|
||||
return i.catalogueModule.Subscribe(ctx, subscribeInfo)
|
||||
}
|
||||
|
||||
func (i *imlCatalogueController) ServiceDetail(ctx *gin.Context, sid string) (*catalogue_dto.ServiceDetail, error) {
|
||||
return i.catalogueModule.ServiceDetail(ctx, sid)
|
||||
}
|
||||
|
||||
func (i *imlCatalogueController) Search(ctx *gin.Context, keyword string) ([]*catalogue_dto.Item, []*tag_dto.Item, error) {
|
||||
catalogues, err := i.catalogueModule.Search(ctx, keyword)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
tags, err := i.tagModule.Search(ctx, keyword)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return catalogues, tags, nil
|
||||
}
|
||||
|
||||
func (i *imlCatalogueController) Create(ctx *gin.Context, input *catalogue_dto.CreateCatalogue) error {
|
||||
return i.catalogueModule.Create(ctx, input)
|
||||
}
|
||||
|
||||
func (i *imlCatalogueController) Edit(ctx *gin.Context, id string, input *catalogue_dto.EditCatalogue) error {
|
||||
return i.catalogueModule.Edit(ctx, id, input)
|
||||
}
|
||||
|
||||
func (i *imlCatalogueController) Delete(ctx *gin.Context, id string) error {
|
||||
return i.catalogueModule.Delete(ctx, id)
|
||||
}
|
||||
|
||||
func (i *imlCatalogueController) Services(ctx *gin.Context, keyword string) ([]*catalogue_dto.ServiceItem, error) {
|
||||
items, err := i.catalogueModule.Services(ctx, keyword)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package certificate
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
certificate_dto "github.com/APIParkLab/APIPark/module/certificate/dto"
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ICertificateController interface {
|
||||
Create(ctx *gin.Context, create *certificate_dto.FileInput) error
|
||||
Update(ctx *gin.Context, id string, edit *certificate_dto.FileInput) error
|
||||
ListForPartition(ctx *gin.Context) ([]*certificate_dto.Certificate, error)
|
||||
Detail(ctx *gin.Context, id string) (*certificate_dto.Certificate, *certificate_dto.File, error)
|
||||
Delete(ctx *gin.Context, id string) (string, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[ICertificateController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlCertificate))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package certificate
|
||||
|
||||
import (
|
||||
"github.com/APIParkLab/APIPark/module/certificate"
|
||||
certificate_dto "github.com/APIParkLab/APIPark/module/certificate/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
_ ICertificateController = (*imlCertificate)(nil)
|
||||
)
|
||||
|
||||
type imlCertificate struct {
|
||||
module certificate.ICertificateModule `autowired:""`
|
||||
}
|
||||
|
||||
func (c *imlCertificate) Create(ctx *gin.Context, create *certificate_dto.FileInput) error {
|
||||
return c.module.Create(ctx, create)
|
||||
}
|
||||
|
||||
func (c *imlCertificate) Update(ctx *gin.Context, id string, edit *certificate_dto.FileInput) error {
|
||||
return c.module.Update(ctx, id, edit)
|
||||
}
|
||||
|
||||
func (c *imlCertificate) ListForPartition(ctx *gin.Context) ([]*certificate_dto.Certificate, error) {
|
||||
return c.module.List(ctx)
|
||||
}
|
||||
|
||||
func (c *imlCertificate) Detail(ctx *gin.Context, id string) (*certificate_dto.Certificate, *certificate_dto.File, error) {
|
||||
return c.module.Detail(ctx, id)
|
||||
}
|
||||
|
||||
func (c *imlCertificate) Delete(ctx *gin.Context, id string) (string, error) {
|
||||
err := c.module.Delete(ctx, id)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cluster
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
cluster_dto "github.com/APIParkLab/APIPark/module/cluster/dto"
|
||||
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type IClusterController interface {
|
||||
Nodes(ctx *gin.Context, clusterId string) ([]*cluster_dto.Node, error)
|
||||
ResetCluster(ctx *gin.Context, clusterId string, input *cluster_dto.ResetCluster) ([]*cluster_dto.Node, error)
|
||||
Check(ctx *gin.Context, input *cluster_dto.CheckCluster) ([]*cluster_dto.Node, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[IClusterController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlCluster))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package cluster
|
||||
|
||||
import (
|
||||
"github.com/APIParkLab/APIPark/module/cluster"
|
||||
cluster_dto "github.com/APIParkLab/APIPark/module/cluster/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
_ IClusterController = (*imlCluster)(nil)
|
||||
)
|
||||
|
||||
type imlCluster struct {
|
||||
module cluster.IClusterModule `autowired:""`
|
||||
}
|
||||
|
||||
func (p *imlCluster) Nodes(ctx *gin.Context, clusterId string) ([]*cluster_dto.Node, error) {
|
||||
if clusterId == "" {
|
||||
clusterId = "default"
|
||||
}
|
||||
return p.module.ClusterNodes(ctx, clusterId)
|
||||
}
|
||||
|
||||
func (p *imlCluster) ResetCluster(ctx *gin.Context, clusterId string, input *cluster_dto.ResetCluster) ([]*cluster_dto.Node, error) {
|
||||
if clusterId == "" {
|
||||
clusterId = "default"
|
||||
}
|
||||
return p.module.ResetCluster(ctx, clusterId, input.ManagerAddress)
|
||||
}
|
||||
|
||||
func (p *imlCluster) Check(ctx *gin.Context, input *cluster_dto.CheckCluster) ([]*cluster_dto.Node, error) {
|
||||
return p.module.CheckCluster(ctx, input.Address)
|
||||
}
|
||||
|
||||
//
|
||||
//func (p *imlCluster) SimpleWithCluster(ctx *gin.Context) ([]*parition_dto.SimpleWithCluster, error) {
|
||||
// return p.module.SimpleWithCluster(ctx)
|
||||
//}
|
||||
//
|
||||
//func (p *imlCluster) Delete(ctx *gin.Context, id string) (string, error) {
|
||||
// err := p.module.Delete(ctx, id)
|
||||
// if err != nil {
|
||||
// return "", err
|
||||
// }
|
||||
// return id, nil
|
||||
//}
|
||||
//
|
||||
//func (p *imlCluster) Search(ctx *gin.Context, keyword string) ([]*parition_dto.Item, error) {
|
||||
// return p.module.Search(ctx, keyword)
|
||||
//}
|
||||
//
|
||||
//func (p *imlCluster) Simple(ctx *gin.Context) ([]*parition_dto.Simple, error) {
|
||||
// return p.module.Simple(ctx)
|
||||
//}
|
||||
//
|
||||
//func (p *imlCluster) Info(ctx *gin.Context, id string) (*parition_dto.Detail, error) {
|
||||
// if id == "" {
|
||||
// return nil, errors.New("id is empty")
|
||||
// }
|
||||
// return p.module.Get(ctx, id)
|
||||
//}
|
||||
//
|
||||
//func (p *imlCluster) Update(ctx *gin.Context, id string, input *parition_dto.Edit) (*parition_dto.Detail, error) {
|
||||
// return p.module.Update(ctx, id, input)
|
||||
//}
|
||||
//
|
||||
//func (p *imlCluster) Create(ctx *gin.Context, input *parition_dto.Create) (*parition_dto.Detail, string, auto.TimeLabel, error) {
|
||||
// detail, err := p.module.CreatePartition(ctx, input)
|
||||
// if err != nil {
|
||||
// return nil, "", auto.TimeLabel{}, err
|
||||
// }
|
||||
// return detail, detail.Id, detail.UpdateTime, nil
|
||||
//}
|
||||
@@ -0,0 +1,17 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type ICommonController interface {
|
||||
Version(ctx *gin.Context) (string, string, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[ICommonController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlCommonController))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/APIParkLab/APIPark/common/version"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var _ ICommonController = (*imlCommonController)(nil)
|
||||
|
||||
type imlCommonController struct{}
|
||||
|
||||
func (i imlCommonController) Version(ctx *gin.Context) (string, string, error) {
|
||||
return version.Version, version.BuildTime, nil
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// Description: This package is used to handle all the request from the client
|
||||
// and return the response to the client.
|
||||
// 只能使用 module 下面的封装好的接口,不能直接使用 service 下面的接口
|
||||
|
||||
package controller
|
||||
@@ -0,0 +1,29 @@
|
||||
package dynamic_module
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
dynamic_module_dto "github.com/APIParkLab/APIPark/module/dynamic-module/dto"
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type IDynamicModuleController interface {
|
||||
Create(ctx *gin.Context, module string, input *dynamic_module_dto.CreateDynamicModule) (*dynamic_module_dto.DynamicModule, error)
|
||||
Edit(ctx *gin.Context, module string, id string, input *dynamic_module_dto.EditDynamicModule) (*dynamic_module_dto.DynamicModule, error)
|
||||
Delete(ctx *gin.Context, module string, ids string) error
|
||||
Get(ctx *gin.Context, module string, id string) (*dynamic_module_dto.DynamicModule, error)
|
||||
List(ctx *gin.Context, module string, keyword string, cluster string, page string, pageSize string) ([]map[string]interface{}, *dynamic_module_dto.PluginInfo, int64, error)
|
||||
Render(ctx *gin.Context, module string) (*dynamic_module_dto.PluginBasic, map[string]interface{}, error)
|
||||
ModuleDrivers(ctx *gin.Context, group string) ([]*dynamic_module_dto.ModuleDriver, error)
|
||||
Online(ctx *gin.Context, module string, id string, partitionInput *dynamic_module_dto.ClusterInput) error
|
||||
Offline(ctx *gin.Context, module string, id string, partitionInput *dynamic_module_dto.ClusterInput) error
|
||||
//PartitionStatuses(ctx *gin.Context, module string, keyword string, page string, pageSize string) (map[string]map[string]string, error)
|
||||
//PartitionStatus(ctx *gin.Context, module string, id string) (*dynamic_module_dto.OnlineInfo, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[IDynamicModuleController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlDynamicModuleController))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package dynamic_module
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
|
||||
dynamic_module "github.com/APIParkLab/APIPark/module/dynamic-module"
|
||||
dynamic_module_dto "github.com/APIParkLab/APIPark/module/dynamic-module/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var _ IDynamicModuleController = (*imlDynamicModuleController)(nil)
|
||||
|
||||
type imlDynamicModuleController struct {
|
||||
module dynamic_module.IDynamicModuleModule `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlDynamicModuleController) Online(ctx *gin.Context, module string, id string, partitionInput *dynamic_module_dto.ClusterInput) error {
|
||||
return i.module.Online(ctx, module, id, partitionInput)
|
||||
}
|
||||
|
||||
func (i *imlDynamicModuleController) Offline(ctx *gin.Context, module string, id string, partitionInput *dynamic_module_dto.ClusterInput) error {
|
||||
return i.module.Offline(ctx, module, id, partitionInput)
|
||||
}
|
||||
|
||||
//func (i *imlDynamicModuleController) PartitionStatuses(ctx *gin.Context, module string, keyword string, page string, pageSize string) (map[string]map[string]string, error) {
|
||||
// p, err := strconv.Atoi(page)
|
||||
// if err != nil {
|
||||
// p = 1
|
||||
// }
|
||||
// ps, err := strconv.Atoi(pageSize)
|
||||
// if err != nil {
|
||||
// ps = 20
|
||||
// }
|
||||
// return i.module.PartitionStatuses(ctx, module, keyword, p, ps)
|
||||
//}
|
||||
//
|
||||
//func (i *imlDynamicModuleController) PartitionStatus(ctx *gin.Context, module string, id string) (*dynamic_module_dto.OnlineInfo, error) {
|
||||
// return i.module.PartitionStatus(ctx, module, id)
|
||||
//}
|
||||
|
||||
func (i *imlDynamicModuleController) ModuleDrivers(ctx *gin.Context, group string) ([]*dynamic_module_dto.ModuleDriver, error) {
|
||||
return i.module.ModuleDrivers(ctx, group)
|
||||
}
|
||||
|
||||
func (i *imlDynamicModuleController) Render(ctx *gin.Context, module string) (*dynamic_module_dto.PluginBasic, map[string]interface{}, error) {
|
||||
render, err := i.module.Render(ctx, module)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
pluginInfo, err := i.module.PluginInfo(ctx, module)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return pluginInfo.PluginBasic, render, nil
|
||||
}
|
||||
|
||||
func (i *imlDynamicModuleController) Create(ctx *gin.Context, module string, input *dynamic_module_dto.CreateDynamicModule) (*dynamic_module_dto.DynamicModule, error) {
|
||||
return i.module.Create(ctx, module, input)
|
||||
}
|
||||
|
||||
func (i *imlDynamicModuleController) Edit(ctx *gin.Context, module string, id string, input *dynamic_module_dto.EditDynamicModule) (*dynamic_module_dto.DynamicModule, error) {
|
||||
return i.module.Edit(ctx, module, id, input)
|
||||
}
|
||||
|
||||
func (i *imlDynamicModuleController) Delete(ctx *gin.Context, module string, idStr string) error {
|
||||
ids := make([]string, 0)
|
||||
err := json.Unmarshal([]byte(idStr), &ids)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
return nil
|
||||
}
|
||||
return i.module.Delete(ctx, module, ids)
|
||||
}
|
||||
|
||||
func (i *imlDynamicModuleController) Get(ctx *gin.Context, module string, id string) (*dynamic_module_dto.DynamicModule, error) {
|
||||
return i.module.Get(ctx, module, id)
|
||||
}
|
||||
|
||||
func (i *imlDynamicModuleController) List(ctx *gin.Context, module string, keyword string, clusterId string, page string, pageSize string) ([]map[string]interface{}, *dynamic_module_dto.PluginInfo, int64, error) {
|
||||
p, err := strconv.Atoi(page)
|
||||
if err != nil {
|
||||
p = 1
|
||||
}
|
||||
ps, err := strconv.Atoi(pageSize)
|
||||
if err != nil {
|
||||
ps = 20
|
||||
|
||||
}
|
||||
list, total, err := i.module.List(ctx, module, keyword, p, ps)
|
||||
if err != nil {
|
||||
return nil, nil, 0, err
|
||||
}
|
||||
//if clusterId == "" {
|
||||
// clusterId = "[]"
|
||||
//}
|
||||
//ids := make([]string, 0)
|
||||
//err = json.Unmarshal([]byte(clusterId), &ids)
|
||||
//if err != nil {
|
||||
// return nil, nil, 0, err
|
||||
//}
|
||||
plugin, err := i.module.PluginInfo(ctx, module)
|
||||
if err != nil {
|
||||
return nil, nil, 0, err
|
||||
}
|
||||
return list, plugin, total, nil
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package my_team
|
||||
|
||||
import (
|
||||
my_team "github.com/APIParkLab/APIPark/module/my-team"
|
||||
team_dto "github.com/APIParkLab/APIPark/module/my-team/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
_ ITeamController = (*imlTeamController)(nil)
|
||||
)
|
||||
|
||||
type imlTeamController struct {
|
||||
module my_team.ITeamModule `autowired:""`
|
||||
}
|
||||
|
||||
func (c *imlTeamController) UpdateMemberRole(ctx *gin.Context, id string, input *team_dto.UpdateMemberRole) error {
|
||||
return c.module.UpdateMemberRole(ctx, id, input)
|
||||
}
|
||||
|
||||
func (c *imlTeamController) GetTeam(ctx *gin.Context, id string) (*team_dto.Team, error) {
|
||||
return c.module.GetTeam(ctx, id)
|
||||
}
|
||||
|
||||
func (c *imlTeamController) Search(ctx *gin.Context, keyword string) ([]*team_dto.Item, error) {
|
||||
|
||||
return c.module.Search(ctx, keyword)
|
||||
}
|
||||
|
||||
func (c *imlTeamController) EditTeam(ctx *gin.Context, id string, team *team_dto.EditTeam) (*team_dto.Team, error) {
|
||||
return c.module.Edit(ctx, id, team)
|
||||
}
|
||||
|
||||
func (c *imlTeamController) SimpleTeams(ctx *gin.Context, keyword string) ([]*team_dto.SimpleTeam, error) {
|
||||
return c.module.SimpleTeams(ctx, keyword)
|
||||
}
|
||||
|
||||
func (c *imlTeamController) AddMember(ctx *gin.Context, id string, users *team_dto.UserIDs) error {
|
||||
return c.module.AddMember(ctx, id, users.Users...)
|
||||
}
|
||||
|
||||
func (c *imlTeamController) RemoveMember(ctx *gin.Context, id string, uuid string) error {
|
||||
return c.module.RemoveMember(ctx, id, uuid)
|
||||
}
|
||||
|
||||
func (c *imlTeamController) Members(ctx *gin.Context, id string, keyword string) ([]*team_dto.Member, error) {
|
||||
return c.module.Members(ctx, id, keyword)
|
||||
}
|
||||
|
||||
func (c *imlTeamController) SimpleMembers(ctx *gin.Context, id string, keyword string) ([]*team_dto.SimpleMember, error) {
|
||||
return c.module.SimpleMembers(ctx, id, keyword)
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package my_team
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
team_dto "github.com/APIParkLab/APIPark/module/my-team/dto"
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ITeamController interface {
|
||||
// GetTeam 获取团队信息
|
||||
GetTeam(ctx *gin.Context, id string) (*team_dto.Team, error)
|
||||
Search(ctx *gin.Context, keyword string) ([]*team_dto.Item, error)
|
||||
EditTeam(ctx *gin.Context, id string, team *team_dto.EditTeam) (*team_dto.Team, error)
|
||||
SimpleTeams(ctx *gin.Context, keyword string) ([]*team_dto.SimpleTeam, error)
|
||||
AddMember(ctx *gin.Context, id string, users *team_dto.UserIDs) error
|
||||
RemoveMember(ctx *gin.Context, id string, uuid string) error
|
||||
Members(ctx *gin.Context, id string, keyword string) ([]*team_dto.Member, error)
|
||||
SimpleMembers(ctx *gin.Context, id string, keyword string) ([]*team_dto.SimpleMember, error)
|
||||
UpdateMemberRole(ctx *gin.Context, id string, input *team_dto.UpdateMemberRole) error
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[ITeamController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlTeamController))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package permit_system
|
||||
|
||||
import (
|
||||
"github.com/APIParkLab/APIPark/module/permit/system"
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
_ ISystemPermitController = (*imlSystemPermitController)(nil)
|
||||
_ autowire.Complete = (*imlSystemPermitController)(nil)
|
||||
)
|
||||
|
||||
type imlSystemPermitController struct {
|
||||
systemPermitModule system.ISystemPermitModule `autowired:""`
|
||||
}
|
||||
|
||||
func (c *imlSystemPermitController) Permissions(ctx *gin.Context) ([]string, error) {
|
||||
return c.systemPermitModule.Permissions(ctx)
|
||||
}
|
||||
|
||||
func (c *imlSystemPermitController) OnComplete() {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package permit_system
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ISystemPermitController interface {
|
||||
Permissions(ctx *gin.Context) ([]string, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[ISystemPermitController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlSystemPermitController))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package permit_team
|
||||
|
||||
import (
|
||||
"github.com/APIParkLab/APIPark/module/permit/team"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
_ ITeamPermitController = (*imlTeamPermitController)(nil)
|
||||
)
|
||||
|
||||
type imlTeamPermitController struct {
|
||||
teamPermitModule team.ITeamPermitModule `autowired:""`
|
||||
}
|
||||
|
||||
func (c *imlTeamPermitController) Permissions(ctx *gin.Context, team string) ([]string, error) {
|
||||
return c.teamPermitModule.Permissions(ctx, team)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package permit_team
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ITeamPermitController interface {
|
||||
Permissions(ctx *gin.Context, team string) ([]string, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[ITeamPermitController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlTeamPermitController))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package plugin_cluster
|
||||
|
||||
import (
|
||||
"github.com/APIParkLab/APIPark/model/plugin_model"
|
||||
"github.com/APIParkLab/APIPark/module/plugin-cluster"
|
||||
"github.com/APIParkLab/APIPark/module/plugin-cluster/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
_ IPluginClusterController = (*imlPluginClusterController)(nil)
|
||||
)
|
||||
|
||||
type imlPluginClusterController struct {
|
||||
module plugin_cluster.IPluginClusterModule `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlPluginClusterController) Info(ctx *gin.Context, name string) (*dto.Define, error) {
|
||||
return i.module.GetDefine(ctx, name)
|
||||
}
|
||||
|
||||
func (i *imlPluginClusterController) Option(ctx *gin.Context, project string) ([]*dto.PluginOption, error) {
|
||||
return i.module.Options(ctx)
|
||||
}
|
||||
|
||||
func (i *imlPluginClusterController) List(ctx *gin.Context, clusterId string) ([]*dto.Item, error) {
|
||||
return i.module.List(ctx, clusterId)
|
||||
}
|
||||
|
||||
func (i *imlPluginClusterController) Get(ctx *gin.Context, clusterId string, name string) (config *dto.PluginOutput, render plugin_model.Render, er error) {
|
||||
return i.module.Get(ctx, clusterId, name)
|
||||
}
|
||||
|
||||
func (i *imlPluginClusterController) Set(ctx *gin.Context, clusterId string, name string, config *dto.PluginSetting) error {
|
||||
return i.module.Set(ctx, clusterId, name, config)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package plugin_cluster
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/APIParkLab/APIPark/model/plugin_model"
|
||||
"github.com/APIParkLab/APIPark/module/plugin-cluster/dto"
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type IPluginClusterController interface {
|
||||
List(ctx *gin.Context, clusterId string) ([]*dto.Item, error)
|
||||
Get(ctx *gin.Context, clusterId string, name string) (config *dto.PluginOutput, render plugin_model.Render, er error)
|
||||
Set(ctx *gin.Context, clusterId string, name string, config *dto.PluginSetting) error
|
||||
Option(ctx *gin.Context, project string) ([]*dto.PluginOption, error)
|
||||
Info(ctx *gin.Context, name string) (*dto.Define, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[IPluginClusterController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlPluginClusterController))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package publish
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/APIParkLab/APIPark/module/publish"
|
||||
"github.com/APIParkLab/APIPark/module/publish/dto"
|
||||
"github.com/APIParkLab/APIPark/module/release"
|
||||
dto2 "github.com/APIParkLab/APIPark/module/release/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
_ IPublishController = (*imlPublishController)(nil)
|
||||
)
|
||||
|
||||
type imlPublishController struct {
|
||||
publishModule publish.IPublishModule `autowired:""`
|
||||
releaseModule release.IReleaseModule `autowired:""`
|
||||
}
|
||||
|
||||
func (c *imlPublishController) ReleaseDo(ctx *gin.Context, serviceId string, input *dto.ApplyOnReleaseInput) (*dto.Publish, error) {
|
||||
newReleaseId, err := c.releaseModule.Create(ctx, serviceId, &dto2.CreateInput{
|
||||
Version: input.Version,
|
||||
Remark: input.VersionRemark,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
apply, err := c.publishModule.Apply(ctx, serviceId, &dto.ApplyInput{
|
||||
Release: newReleaseId,
|
||||
Remark: input.PublishRemark,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = c.publishModule.Accept(ctx, serviceId, apply.Id, "")
|
||||
if err != nil {
|
||||
c.releaseModule.Delete(ctx, serviceId, newReleaseId)
|
||||
return nil, err
|
||||
}
|
||||
err = c.publishModule.Publish(ctx, serviceId, apply.Id)
|
||||
if err != nil {
|
||||
c.releaseModule.Delete(ctx, serviceId, newReleaseId)
|
||||
return nil, err
|
||||
}
|
||||
err = c.publishModule.Publish(ctx, serviceId, apply.Id)
|
||||
if err != nil {
|
||||
c.releaseModule.Delete(ctx, serviceId, newReleaseId)
|
||||
return nil, err
|
||||
}
|
||||
return apply, err
|
||||
}
|
||||
|
||||
func (c *imlPublishController) PublishStatuses(ctx *gin.Context, serviceId string, id string) ([]*dto.PublishStatus, error) {
|
||||
return c.publishModule.PublishStatuses(ctx, serviceId, id)
|
||||
}
|
||||
|
||||
func (c *imlPublishController) ApplyOnRelease(ctx *gin.Context, serviceId string, input *dto.ApplyOnReleaseInput) (*dto.Publish, error) {
|
||||
newReleaseId, err := c.releaseModule.Create(ctx, serviceId, &dto2.CreateInput{
|
||||
Version: input.Version,
|
||||
Remark: input.VersionRemark,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
apply, err := c.publishModule.Apply(ctx, serviceId, &dto.ApplyInput{
|
||||
Release: newReleaseId,
|
||||
Remark: input.PublishRemark,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apply, nil
|
||||
}
|
||||
|
||||
func (c *imlPublishController) Apply(ctx *gin.Context, serviceId string, input *dto.ApplyInput) (*dto.Publish, error) {
|
||||
apply, err := c.publishModule.Apply(ctx, serviceId, input)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return apply, nil
|
||||
}
|
||||
|
||||
func (c *imlPublishController) CheckPublish(ctx *gin.Context, serviceId string, releaseId string) (*dto.DiffOut, error) {
|
||||
return c.publishModule.CheckPublish(ctx, serviceId, releaseId)
|
||||
}
|
||||
|
||||
func (c *imlPublishController) Close(ctx *gin.Context, serviceId string, id string) error {
|
||||
err := c.publishModule.Stop(ctx, serviceId, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *imlPublishController) Stop(ctx *gin.Context, serviceId string, id string) error {
|
||||
return c.publishModule.Stop(ctx, serviceId, id)
|
||||
}
|
||||
|
||||
func (c *imlPublishController) Refuse(ctx *gin.Context, serviceId string, id string, input *dto.Comments) error {
|
||||
return c.publishModule.Refuse(ctx, serviceId, id, input.Comments)
|
||||
}
|
||||
|
||||
func (c *imlPublishController) Accept(ctx *gin.Context, serviceId string, id string, input *dto.Comments) error {
|
||||
return c.publishModule.Accept(ctx, serviceId, id, input.Comments)
|
||||
}
|
||||
|
||||
func (c *imlPublishController) Publish(ctx *gin.Context, serviceId string, id string) error {
|
||||
return c.publishModule.Publish(ctx, serviceId, id)
|
||||
}
|
||||
|
||||
func (c *imlPublishController) ListPage(ctx *gin.Context, serviceId string, page, pageSize string) ([]*dto.Publish, int, int, int64, error) {
|
||||
pageNum, _ := strconv.Atoi(page)
|
||||
pageSizeNum, _ := strconv.Atoi(pageSize)
|
||||
if pageNum < 1 {
|
||||
pageNum = 1
|
||||
}
|
||||
if pageSizeNum <= 0 {
|
||||
pageSizeNum = 50
|
||||
}
|
||||
list, total, err := c.publishModule.List(ctx, serviceId, pageNum, pageSizeNum)
|
||||
if err != nil {
|
||||
return nil, 0, 0, 0, err
|
||||
}
|
||||
|
||||
return list, pageNum, pageSizeNum, total, nil
|
||||
}
|
||||
|
||||
func (c *imlPublishController) Detail(ctx *gin.Context, serviceId string, id string) (*dto.PublishDetail, error) {
|
||||
return c.publishModule.Detail(ctx, serviceId, id)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package publish
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/APIParkLab/APIPark/module/publish/dto"
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
_ IPublishController = (*imlPublishController)(nil)
|
||||
)
|
||||
|
||||
type IPublishController interface {
|
||||
CheckPublish(ctx *gin.Context, serviceId string, releaseId string) (*dto.DiffOut, error)
|
||||
ReleaseDo(ctx *gin.Context, serviceId string, input *dto.ApplyOnReleaseInput) (*dto.Publish, error)
|
||||
ApplyOnRelease(ctx *gin.Context, serviceId string, input *dto.ApplyOnReleaseInput) (*dto.Publish, error)
|
||||
Apply(ctx *gin.Context, serviceId string, input *dto.ApplyInput) (*dto.Publish, error)
|
||||
Close(ctx *gin.Context, serviceId string, id string) error
|
||||
Stop(ctx *gin.Context, serviceId string, id string) error
|
||||
Refuse(ctx *gin.Context, serviceId string, id string, input *dto.Comments) error
|
||||
Accept(ctx *gin.Context, serviceId string, id string, input *dto.Comments) error
|
||||
Publish(ctx *gin.Context, serviceId string, id string) error
|
||||
ListPage(ctx *gin.Context, serviceId string, page, pageSize string) ([]*dto.Publish, int, int, int64, error)
|
||||
Detail(ctx *gin.Context, serviceId string, id string) (*dto.PublishDetail, error)
|
||||
PublishStatuses(ctx *gin.Context, serviceId string, id string) ([]*dto.PublishStatus, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[IPublishController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlPublishController))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package release
|
||||
|
||||
import (
|
||||
"github.com/APIParkLab/APIPark/module/release"
|
||||
"github.com/APIParkLab/APIPark/module/release/dto"
|
||||
service_diff "github.com/APIParkLab/APIPark/module/service-diff"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
_ IReleaseController = (*imlReleaseController)(nil)
|
||||
)
|
||||
|
||||
type imlReleaseController struct {
|
||||
module release.IReleaseModule `autowired:""`
|
||||
diffModule service_diff.IServiceDiffModule `autowired:""`
|
||||
}
|
||||
|
||||
func (c *imlReleaseController) Create(ctx *gin.Context, project string, input *dto.CreateInput) error {
|
||||
|
||||
_, err := c.module.Create(ctx, project, input)
|
||||
return err
|
||||
}
|
||||
func (c *imlReleaseController) Delete(ctx *gin.Context, project string, id string) error {
|
||||
return c.module.Delete(ctx, project, id)
|
||||
}
|
||||
func (c *imlReleaseController) Detail(ctx *gin.Context, project string, id string) (*dto.Detail, error) {
|
||||
return c.module.Detail(ctx, project, id)
|
||||
}
|
||||
func (c *imlReleaseController) List(ctx *gin.Context, project string) ([]*dto.Release, error) {
|
||||
return c.module.List(ctx, project)
|
||||
}
|
||||
func (c *imlReleaseController) Preview(ctx *gin.Context, project string) (*dto.Release, *service_diff.DiffOut, bool, error) {
|
||||
releaseInfo, diff, complete, err := c.module.Preview(ctx, project)
|
||||
if err != nil {
|
||||
return nil, nil, false, err
|
||||
}
|
||||
|
||||
out, err := c.diffModule.Out(ctx, diff)
|
||||
if err != nil {
|
||||
return nil, nil, false, err
|
||||
}
|
||||
return releaseInfo, out, complete, nil
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package release
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
service_diff "github.com/APIParkLab/APIPark/module/service-diff"
|
||||
|
||||
"github.com/APIParkLab/APIPark/module/release/dto"
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type IReleaseController interface {
|
||||
Create(ctx *gin.Context, project string, input *dto.CreateInput) error
|
||||
Delete(ctx *gin.Context, project string, id string) error
|
||||
Detail(ctx *gin.Context, project string, id string) (*dto.Detail, error)
|
||||
List(ctx *gin.Context, project string) ([]*dto.Release, error)
|
||||
Preview(ctx *gin.Context, project string) (*dto.Release, *service_diff.DiffOut, bool, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[IReleaseController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlReleaseController))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/APIParkLab/APIPark/module/service"
|
||||
service_dto "github.com/APIParkLab/APIPark/module/service/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
_ IServiceController = (*imlServiceController)(nil)
|
||||
_ IAppController = (*imlAppController)(nil)
|
||||
)
|
||||
|
||||
type imlServiceController struct {
|
||||
module service.IServiceModule `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlServiceController) SearchMyServices(ctx *gin.Context, teamId string, keyword string) ([]*service_dto.ServiceItem, error) {
|
||||
return i.module.SearchMyServices(ctx, teamId, keyword)
|
||||
}
|
||||
|
||||
func (i *imlServiceController) Simple(ctx *gin.Context, keyword string) ([]*service_dto.SimpleServiceItem, error) {
|
||||
return i.module.Simple(ctx, keyword)
|
||||
}
|
||||
|
||||
func (i *imlServiceController) MySimple(ctx *gin.Context, keyword string) ([]*service_dto.SimpleServiceItem, error) {
|
||||
return i.module.MySimple(ctx, keyword)
|
||||
}
|
||||
|
||||
func (i *imlServiceController) Get(ctx *gin.Context, id string) (*service_dto.Service, error) {
|
||||
return i.module.Get(ctx, id)
|
||||
}
|
||||
|
||||
func (i *imlServiceController) Search(ctx *gin.Context, teamID string, keyword string) ([]*service_dto.ServiceItem, error) {
|
||||
return i.module.Search(ctx, teamID, keyword)
|
||||
}
|
||||
|
||||
func (i *imlServiceController) Create(ctx *gin.Context, teamID string, input *service_dto.CreateService) (*service_dto.Service, error) {
|
||||
return i.module.Create(ctx, teamID, input)
|
||||
}
|
||||
|
||||
func (i *imlServiceController) Edit(ctx *gin.Context, id string, input *service_dto.EditService) (*service_dto.Service, error) {
|
||||
return i.module.Edit(ctx, id, input)
|
||||
}
|
||||
|
||||
func (i *imlServiceController) Delete(ctx *gin.Context, id string) error {
|
||||
return i.module.Delete(ctx, id)
|
||||
}
|
||||
|
||||
func (i *imlServiceController) ServiceDoc(ctx *gin.Context, id string) (*service_dto.ServiceDoc, error) {
|
||||
return i.module.ServiceDoc(ctx, id)
|
||||
}
|
||||
|
||||
func (i *imlServiceController) SaveServiceDoc(ctx *gin.Context, id string, input *service_dto.SaveServiceDoc) error {
|
||||
return i.module.SaveServiceDoc(ctx, id, input)
|
||||
}
|
||||
|
||||
type imlAppController struct {
|
||||
module service.IAppModule `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlAppController) Search(ctx *gin.Context, teamId string, keyword string) ([]*service_dto.AppItem, error) {
|
||||
return i.module.Search(ctx, teamId, keyword)
|
||||
}
|
||||
|
||||
func (i *imlAppController) CreateApp(ctx *gin.Context, teamID string, input *service_dto.CreateApp) (*service_dto.App, error) {
|
||||
return i.module.CreateApp(ctx, teamID, input)
|
||||
}
|
||||
func (i *imlAppController) UpdateApp(ctx *gin.Context, appId string, input *service_dto.UpdateApp) (*service_dto.App, error) {
|
||||
return i.module.UpdateApp(ctx, appId, input)
|
||||
}
|
||||
|
||||
func (i *imlAppController) SearchMyApps(ctx *gin.Context, teamId string, keyword string) ([]*service_dto.AppItem, error) {
|
||||
return i.module.SearchMyApps(ctx, teamId, keyword)
|
||||
}
|
||||
|
||||
func (i *imlAppController) SimpleApps(ctx *gin.Context, keyword string) ([]*service_dto.SimpleAppItem, error) {
|
||||
return i.module.SimpleApps(ctx, keyword)
|
||||
}
|
||||
|
||||
func (i *imlAppController) MySimpleApps(ctx *gin.Context, keyword string) ([]*service_dto.SimpleAppItem, error) {
|
||||
return i.module.MySimpleApps(ctx, keyword)
|
||||
}
|
||||
|
||||
func (i *imlAppController) GetApp(ctx *gin.Context, appId string) (*service_dto.App, error) {
|
||||
return i.module.GetApp(ctx, appId)
|
||||
}
|
||||
|
||||
func (i *imlAppController) DeleteApp(ctx *gin.Context, appId string) error {
|
||||
return i.module.DeleteApp(ctx, appId)
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
service_dto "github.com/APIParkLab/APIPark/module/service/dto"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
)
|
||||
|
||||
type IServiceController interface {
|
||||
// Get 获取
|
||||
Get(ctx *gin.Context, id string) (*service_dto.Service, error)
|
||||
// SearchMyServices 搜索服务
|
||||
SearchMyServices(ctx *gin.Context, teamID string, keyword string) ([]*service_dto.ServiceItem, error)
|
||||
Search(ctx *gin.Context, teamID string, keyword string) ([]*service_dto.ServiceItem, error)
|
||||
// Create 创建
|
||||
Create(ctx *gin.Context, teamID string, input *service_dto.CreateService) (*service_dto.Service, error)
|
||||
// Edit 编辑
|
||||
Edit(ctx *gin.Context, id string, input *service_dto.EditService) (*service_dto.Service, error)
|
||||
// Delete 删除
|
||||
Delete(ctx *gin.Context, id string) error
|
||||
// Simple 获取简易列表
|
||||
Simple(ctx *gin.Context, keyword string) ([]*service_dto.SimpleServiceItem, error)
|
||||
// MySimple 获取我的简易列表
|
||||
MySimple(ctx *gin.Context, keyword string) ([]*service_dto.SimpleServiceItem, error)
|
||||
ServiceDoc(ctx *gin.Context, id string) (*service_dto.ServiceDoc, error)
|
||||
SaveServiceDoc(ctx *gin.Context, id string, input *service_dto.SaveServiceDoc) error
|
||||
}
|
||||
|
||||
type IAppController interface {
|
||||
// CreateApp 创建应用
|
||||
CreateApp(ctx *gin.Context, teamID string, project *service_dto.CreateApp) (*service_dto.App, error)
|
||||
|
||||
UpdateApp(ctx *gin.Context, appId string, project *service_dto.UpdateApp) (*service_dto.App, error)
|
||||
Search(ctx *gin.Context, teamId string, keyword string) ([]*service_dto.AppItem, error)
|
||||
SearchMyApps(ctx *gin.Context, teamId string, keyword string) ([]*service_dto.AppItem, error)
|
||||
// SimpleApps 获取简易项目列表
|
||||
SimpleApps(ctx *gin.Context, keyword string) ([]*service_dto.SimpleAppItem, error)
|
||||
MySimpleApps(ctx *gin.Context, keyword string) ([]*service_dto.SimpleAppItem, error)
|
||||
GetApp(ctx *gin.Context, appId string) (*service_dto.App, error)
|
||||
DeleteApp(ctx *gin.Context, appId string) error
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[IServiceController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlServiceController))
|
||||
})
|
||||
|
||||
autowire.Auto[IAppController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlAppController))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package subscribe
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/APIParkLab/APIPark/module/subscribe"
|
||||
subscribe_dto "github.com/APIParkLab/APIPark/module/subscribe/dto"
|
||||
)
|
||||
|
||||
var (
|
||||
_ ISubscribeController = (*imlSubscribeController)(nil)
|
||||
)
|
||||
|
||||
type imlSubscribeController struct {
|
||||
module subscribe.ISubscribeModule `autowired:""`
|
||||
}
|
||||
|
||||
//func (i *imlSubscribeController) PartitionServices(ctx *gin.Context, app string) ([]*subscribe_dto.PartitionServiceItem, error) {
|
||||
// return i.module.PartitionServices(ctx, app)
|
||||
//}
|
||||
|
||||
func (i *imlSubscribeController) SearchSubscriptions(ctx *gin.Context, appId string, keyword string) ([]*subscribe_dto.SubscriptionItem, error) {
|
||||
return i.module.SearchSubscriptions(ctx, appId, keyword)
|
||||
}
|
||||
|
||||
func (i *imlSubscribeController) RevokeSubscription(ctx *gin.Context, service string, uuid string) error {
|
||||
return i.module.RevokeSubscription(ctx, service, uuid)
|
||||
}
|
||||
|
||||
func (i *imlSubscribeController) DeleteSubscription(ctx *gin.Context, service string, uuid string) error {
|
||||
return i.module.DeleteSubscription(ctx, service, uuid)
|
||||
}
|
||||
|
||||
func (i *imlSubscribeController) AddSubscriber(ctx *gin.Context, service string, input *subscribe_dto.AddSubscriber) error {
|
||||
return i.module.AddSubscriber(ctx, service, input)
|
||||
}
|
||||
|
||||
func (i *imlSubscribeController) DeleteSubscriber(ctx *gin.Context, service string, serviceId string, applicationId string) error {
|
||||
return i.module.DeleteSubscriber(ctx, service, serviceId, applicationId)
|
||||
}
|
||||
|
||||
func (i *imlSubscribeController) RevokeApply(ctx *gin.Context, service string, uuid string) error {
|
||||
return i.module.RevokeApply(ctx, service, uuid)
|
||||
}
|
||||
|
||||
func (i *imlSubscribeController) Search(ctx *gin.Context, service string, keyword string) ([]*subscribe_dto.Subscriber, error) {
|
||||
return i.module.SearchSubscribers(ctx, service, keyword)
|
||||
}
|
||||
|
||||
var _ ISubscribeApprovalController = (*imlSubscribeApprovalController)(nil)
|
||||
|
||||
type imlSubscribeApprovalController struct {
|
||||
module subscribe.ISubscribeApprovalModule `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlSubscribeApprovalController) GetApprovalList(ctx *gin.Context, service string, status int) ([]*subscribe_dto.ApprovalItem, error) {
|
||||
return i.module.GetApprovalList(ctx, service, status)
|
||||
}
|
||||
|
||||
func (i *imlSubscribeApprovalController) GetApprovalDetail(ctx *gin.Context, service string, id string) (*subscribe_dto.Approval, error) {
|
||||
return i.module.GetApprovalDetail(ctx, service, id)
|
||||
}
|
||||
|
||||
func (i *imlSubscribeApprovalController) Approval(ctx *gin.Context, service string, id string, approveInfo *subscribe_dto.Approve) error {
|
||||
switch approveInfo.Operate {
|
||||
case "pass":
|
||||
return i.module.Pass(ctx, service, id, approveInfo)
|
||||
case "refuse":
|
||||
return i.module.Reject(ctx, service, id, approveInfo)
|
||||
}
|
||||
return fmt.Errorf("unknown operate: %s", approveInfo.Operate)
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package subscribe
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
subscribe_dto "github.com/APIParkLab/APIPark/module/subscribe/dto"
|
||||
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
)
|
||||
|
||||
type ISubscribeController interface {
|
||||
// AddSubscriber 添加订阅者
|
||||
AddSubscriber(ctx *gin.Context, project string, input *subscribe_dto.AddSubscriber) error
|
||||
// DeleteSubscriber 删除订阅者
|
||||
DeleteSubscriber(ctx *gin.Context, project string, serviceId string, applicationId string) error
|
||||
// Search 关键字获取订阅者列表
|
||||
Search(ctx *gin.Context, project string, keyword string) ([]*subscribe_dto.Subscriber, error)
|
||||
// SearchSubscriptions 关键字获取订阅服务列表
|
||||
SearchSubscriptions(ctx *gin.Context, appId string, keyword string) ([]*subscribe_dto.SubscriptionItem, error)
|
||||
// RevokeSubscription 取消订阅
|
||||
RevokeSubscription(ctx *gin.Context, project string, uuid string) error
|
||||
// DeleteSubscription 删除订阅
|
||||
DeleteSubscription(ctx *gin.Context, project string, uuid string) error
|
||||
// RevokeApply 取消申请
|
||||
RevokeApply(ctx *gin.Context, project string, uuid string) error
|
||||
//PartitionServices(ctx *gin.Context, app string) ([]*subscribe_dto.PartitionServiceItem, error)
|
||||
}
|
||||
|
||||
type ISubscribeApprovalController interface {
|
||||
// GetApprovalList 获取审批列表
|
||||
GetApprovalList(ctx *gin.Context, project string, status int) ([]*subscribe_dto.ApprovalItem, error)
|
||||
// GetApprovalDetail 获取审批详情
|
||||
GetApprovalDetail(ctx *gin.Context, project string, id string) (*subscribe_dto.Approval, error)
|
||||
// Approval 审批
|
||||
Approval(ctx *gin.Context, project string, id string, approveInfo *subscribe_dto.Approve) error
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[ISubscribeController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlSubscribeController))
|
||||
})
|
||||
autowire.Auto[ISubscribeApprovalController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlSubscribeApprovalController))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package team_manager
|
||||
|
||||
import (
|
||||
"github.com/APIParkLab/APIPark/module/team"
|
||||
team_dto "github.com/APIParkLab/APIPark/module/team/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
_ ITeamManagerController = (*imlTeamManagerController)(nil)
|
||||
)
|
||||
|
||||
type imlTeamManagerController struct {
|
||||
module team.ITeamModule `autowired:""`
|
||||
}
|
||||
|
||||
func (c *imlTeamManagerController) GetTeam(ctx *gin.Context, id string) (*team_dto.Team, error) {
|
||||
return c.module.GetTeam(ctx, id)
|
||||
}
|
||||
|
||||
func (c *imlTeamManagerController) Search(ctx *gin.Context, keyword string) ([]*team_dto.Item, error) {
|
||||
return c.module.Search(ctx, keyword)
|
||||
}
|
||||
|
||||
func (c *imlTeamManagerController) CreateTeam(ctx *gin.Context, team *team_dto.CreateTeam) (*team_dto.Team, error) {
|
||||
return c.module.Create(ctx, team)
|
||||
}
|
||||
|
||||
func (c *imlTeamManagerController) EditTeam(ctx *gin.Context, id string, team *team_dto.EditTeam) (*team_dto.Team, error) {
|
||||
return c.module.Edit(ctx, id, team)
|
||||
}
|
||||
|
||||
func (c *imlTeamManagerController) DeleteTeam(ctx *gin.Context, id string) (string, error) {
|
||||
err := c.module.Delete(ctx, id)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package team_manager
|
||||
|
||||
import (
|
||||
team_dto "github.com/APIParkLab/APIPark/module/team/dto"
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
"github.com/gin-gonic/gin"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type ITeamManagerController interface {
|
||||
// GetTeam 获取团队信息
|
||||
GetTeam(ctx *gin.Context, id string) (*team_dto.Team, error)
|
||||
Search(ctx *gin.Context, keyword string) ([]*team_dto.Item, error)
|
||||
CreateTeam(ctx *gin.Context, team *team_dto.CreateTeam) (*team_dto.Team, error)
|
||||
EditTeam(ctx *gin.Context, id string, team *team_dto.EditTeam) (*team_dto.Team, error)
|
||||
DeleteTeam(ctx *gin.Context, id string) (string, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[ITeamManagerController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlTeamManagerController))
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package upstream
|
||||
|
||||
import (
|
||||
"github.com/APIParkLab/APIPark/module/cluster"
|
||||
"github.com/APIParkLab/APIPark/module/service"
|
||||
"github.com/APIParkLab/APIPark/module/upstream"
|
||||
upstream_dto "github.com/APIParkLab/APIPark/module/upstream/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var (
|
||||
_ IUpstreamController = (*imlUpstreamController)(nil)
|
||||
)
|
||||
|
||||
type imlUpstreamController struct {
|
||||
upstreamModule upstream.IUpstreamModule `autowired:""`
|
||||
projectModule service.IServiceModule `autowired:""`
|
||||
partitionModule cluster.IClusterModule `autowired:""`
|
||||
}
|
||||
|
||||
func (i *imlUpstreamController) Get(ctx *gin.Context, serviceId string) (upstream_dto.UpstreamConfig, error) {
|
||||
return i.upstreamModule.Get(ctx, serviceId)
|
||||
}
|
||||
|
||||
func (i *imlUpstreamController) Save(ctx *gin.Context, serviceId string, upstream *upstream_dto.UpstreamConfig) (upstream_dto.UpstreamConfig, error) {
|
||||
return i.upstreamModule.Save(ctx, serviceId, *upstream)
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package upstream
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
|
||||
"github.com/eolinker/go-common/autowire"
|
||||
|
||||
upstream_dto "github.com/APIParkLab/APIPark/module/upstream/dto"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type IUpstreamController interface {
|
||||
Get(ctx *gin.Context, serviceId string) (upstream_dto.UpstreamConfig, error)
|
||||
Save(ctx *gin.Context, serviceId string, upstream *upstream_dto.UpstreamConfig) (upstream_dto.UpstreamConfig, error)
|
||||
}
|
||||
|
||||
func init() {
|
||||
autowire.Auto[IUpstreamController](func() reflect.Value {
|
||||
return reflect.ValueOf(new(imlUpstreamController))
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user