Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
服务广场服务详情调整
  • Loading branch information
Dot-Liu committed Aug 5, 2024
commit 2b1e511437cb25cd60c7ce212b95802e16b26945
4 changes: 2 additions & 2 deletions controller/certificate/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
)

type ICertificateController interface {
Create(ctx *gin.Context, partitionId string, create *certificate_dto.FileInput) error
Create(ctx *gin.Context, create *certificate_dto.FileInput) error
Update(ctx *gin.Context, id string, edit *certificate_dto.FileInput) error
ListForPartition(ctx *gin.Context, partitionId string) ([]*certificate_dto.Certificate, 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)
}
Expand Down
8 changes: 4 additions & 4 deletions controller/certificate/iml.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ type imlCertificate struct {
module certificate.ICertificateModule `autowired:""`
}

func (c *imlCertificate) Create(ctx *gin.Context, partitionId string, create *certificate_dto.FileInput) error {
return c.module.Create(ctx, partitionId, create)
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, partitionId string) ([]*certificate_dto.Certificate, error) {
return c.module.List(ctx, partitionId)
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) {
Expand Down
20 changes: 10 additions & 10 deletions controller/dynamic-module/iml.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (i *imlDynamicModuleController) Get(ctx *gin.Context, module string, id str
return i.module.Get(ctx, module, id)
}

func (i *imlDynamicModuleController) List(ctx *gin.Context, module string, keyword string, partitionId string, page string, pageSize string) ([]map[string]interface{}, *dynamic_module_dto.PluginInfo, int64, error) {
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
Expand All @@ -93,15 +93,15 @@ func (i *imlDynamicModuleController) List(ctx *gin.Context, module string, keywo
if err != nil {
return nil, nil, 0, err
}
if partitionId == "" {
partitionId = "[]"
}
ids := make([]string, 0)
err = json.Unmarshal([]byte(partitionId), &ids)
if err != nil {
return nil, nil, 0, err
}
plugin, err := i.module.PluginInfo(ctx, module, ids...)
//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
}
Expand Down
4 changes: 4 additions & 0 deletions controller/service/iml.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ 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)
}
Expand Down
1 change: 1 addition & 0 deletions controller/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type IAppController interface {
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)
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/driver/mysql v1.5.2 // indirect
)


replace (
github.com/eolinker/ap-account v1.0.3 => ../ap-account
)
12 changes: 7 additions & 5 deletions module/catalogue/dto/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ type ServiceDetail struct {
Document string `json:"document"`
Basic *ServiceBasic `json:"basic"`
Apis []*ServiceApi `json:"apis"`
//DisableApis []*ServiceApiBasic `json:"disable_apis"`
}

type ServiceBasic struct {
//Service auto.Label `json:"service" aolabel:"service"`
Team auto.Label `json:"team" aolabel:"team"`
ApiNum int `json:"api_num"`
SubscriberNum int `json:"subscriber_num"`
Team auto.Label `json:"team" aolabel:"team"`
ApiNum int `json:"api_num"`
AppNum int `json:"app_num"`
Tags []auto.Label `json:"tags" aolabel:"tag"`
Catalogue auto.Label `json:"catalogue" aolabel:"catalogue"`
Version string `json:"version"`
UpdateTime auto.TimeLabel `json:"update_time"`
}

type ServiceApiBasic struct {
Expand Down
20 changes: 16 additions & 4 deletions module/catalogue/iml.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,27 @@ func (i *imlCatalogueModule) ServiceDetail(ctx context.Context, sid string) (*ca
if err != nil {
return nil, err
}

tags, err := i.serviceTagService.List(ctx, []string{sid}, nil)
if err != nil {
return nil, err
}
tagIds := utils.SliceToSlice(tags, func(t *service_tag.Tag) string {
return t.Tid
}, func(t *service_tag.Tag) bool {
return t.Sid == sid
})
return &catalogue_dto.ServiceDetail{
Name: s.Name,
Description: s.Description,
Document: docStr,
Basic: &catalogue_dto.ServiceBasic{
Team: auto.UUID(s.Team),
ApiNum: len(apis),
SubscriberNum: int(countMap[s.Id]),
Team: auto.UUID(s.Team),
ApiNum: len(apis),
AppNum: int(countMap[s.Id]),
Tags: auto.List(tagIds),
Catalogue: auto.UUID(s.Catalogue),
Version: r.Version,
UpdateTime: auto.TimeLabel(r.CreateAt),
},
Apis: apis,
}, nil
Expand Down
4 changes: 2 additions & 2 deletions module/certificate/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
)

type ICertificateModule interface {
Create(ctx context.Context, clusterId string, create *certificate_dto.FileInput) error
Create(ctx context.Context, create *certificate_dto.FileInput) error
Update(ctx context.Context, id string, edit *certificate_dto.FileInput) error
List(ctx context.Context, clusterId string) ([]*certificate_dto.Certificate, error)
List(ctx context.Context) ([]*certificate_dto.Certificate, error)
Detail(ctx context.Context, id string) (*certificate_dto.Certificate, *certificate_dto.File, error)
Delete(ctx context.Context, id string) error
}
Expand Down
14 changes: 7 additions & 7 deletions module/certificate/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (m *imlCertificate) initGateway(ctx context.Context, clusterId string, clie
return certificateClient.Online(ctx, certs...)
}

func (m *imlCertificate) save(ctx context.Context, id string, partitionId string, create *certificatedto.FileInput) (*certificatedto.Certificate, error) {
func (m *imlCertificate) save(ctx context.Context, id string, clusterId string, create *certificatedto.FileInput) (*certificatedto.Certificate, error) {

keyData, err := base64.StdEncoding.DecodeString(create.Key)
if err != nil {
Expand All @@ -86,7 +86,7 @@ func (m *imlCertificate) save(ctx context.Context, id string, partitionId string
if err != nil {
return nil, fmt.Errorf("decode cert error: %w", err)
}
o, err := m.service.Save(ctx, id, partitionId, keyData, certData)
o, err := m.service.Save(ctx, id, clusterId, keyData, certData)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -115,12 +115,12 @@ func (m *imlCertificate) syncGateway(ctx context.Context, clusterId string, rele
return dynamicClient.Offline(ctx, releaseInfo)
}

func (m *imlCertificate) Create(ctx context.Context, clusterId string, create *certificatedto.FileInput) error {
func (m *imlCertificate) Create(ctx context.Context, create *certificatedto.FileInput) error {

return m.transaction.Transaction(ctx, func(ctx context.Context) error {
id := uuid.New().String()
version := time.Now().Format("20060102150405")
err := m.syncGateway(ctx, clusterId, &gateway.DynamicRelease{
err := m.syncGateway(ctx, cluster.DefaultClusterID, &gateway.DynamicRelease{
BasicItem: &gateway.BasicItem{
ID: id,
Description: "",
Expand All @@ -137,7 +137,7 @@ func (m *imlCertificate) Create(ctx context.Context, clusterId string, create *c
if err != nil {
return err
}
_, err = m.save(ctx, id, clusterId, create)
_, err = m.save(ctx, id, cluster.DefaultClusterID, create)
if err != nil {
return err
}
Expand Down Expand Up @@ -183,8 +183,8 @@ func (m *imlCertificate) Update(ctx context.Context, id string, edit *certificat
return nil
})
}
func (m *imlCertificate) List(ctx context.Context, clusterId string) ([]*certificatedto.Certificate, error) {
certs, err := m.service.List(ctx, clusterId)
func (m *imlCertificate) List(ctx context.Context) ([]*certificatedto.Certificate, error) {
certs, err := m.service.List(ctx, cluster.DefaultClusterID)
if err != nil {
return nil, err
}
Expand Down
18 changes: 9 additions & 9 deletions module/dynamic-module/dto/input.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package dynamic_module_dto

type CreateDynamicModule struct {
Id string `json:"id"`
Name string `json:"title"`
Driver string `json:"driver"`
Description string `json:"description"`
Config map[string]PartitionConfig `json:"config"`
Id string `json:"id"`
Name string `json:"title"`
Driver string `json:"driver"`
Description string `json:"description"`
Config map[string]interface{} `json:"config"`
}

type PartitionConfig map[string]interface{}
//type PartitionConfig map[string]interface{}

type EditDynamicModule struct {
Name *string `json:"title"`
Description *string `json:"description"`
Config *map[string]PartitionConfig `json:"config"`
Name *string `json:"title"`
Description *string `json:"description"`
Config *map[string]interface{} `json:"config"`
}

type ClusterInput struct {
Expand Down
10 changes: 5 additions & 5 deletions module/dynamic-module/dto/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
)

type DynamicModule struct {
Id string `json:"id"`
Name string `json:"title"`
Driver string `json:"driver"`
Description string `json:"description"`
Config map[string]PartitionConfig `json:"config"`
Id string `json:"id"`
Name string `json:"title"`
Driver string `json:"driver"`
Description string `json:"description"`
Config map[string]interface{} `json:"config"`
}

type PluginBasic struct {
Expand Down
Loading