mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-14 20:41:15 +08:00
@@ -5,6 +5,9 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/eolinker/eosc/log"
|
||||
|
||||
application_authorization "github.com/APIParkLab/APIPark/module/application-authorization"
|
||||
application_authorization_dto "github.com/APIParkLab/APIPark/module/application-authorization/dto"
|
||||
@@ -234,7 +237,12 @@ func (i *imlServiceController) SearchMyServices(ctx *gin.Context, teamId string,
|
||||
//}
|
||||
|
||||
func (i *imlServiceController) Get(ctx *gin.Context, id string) (*service_dto.Service, error) {
|
||||
now := time.Now()
|
||||
defer func() {
|
||||
log.Infof("get service %s cost %d ms", id, time.Since(now).Milliseconds())
|
||||
}()
|
||||
return i.module.Get(ctx, id)
|
||||
|
||||
}
|
||||
|
||||
func (i *imlServiceController) Search(ctx *gin.Context, teamID string, keyword string) ([]*service_dto.ServiceItem, error) {
|
||||
|
||||
@@ -42,6 +42,7 @@ const AiServiceInsidePage:FC = ()=> {
|
||||
|
||||
|
||||
const getApiDefine = ()=>{
|
||||
console.log('@@@@@@@')
|
||||
setApiPrefix('')
|
||||
setPrefixForce(false)
|
||||
fetchData<BasicResponse<{ prefix:string, force:boolean }>>('service/router/define',{method:'GET',eoParams:{service:serviceId,team:teamId}}).then(response=>{
|
||||
@@ -119,7 +120,7 @@ const AiServiceInsidePage:FC = ()=> {
|
||||
}, [currentUrl]);
|
||||
|
||||
useEffect(()=>{
|
||||
if(accessData && accessData.get('team') && accessData.get('team')?.indexOf('team.service.router.view') !== -1){
|
||||
if(accessData && checkPermission('team.service.router.view')){
|
||||
getApiDefine()
|
||||
}
|
||||
},[accessData])
|
||||
|
||||
@@ -117,7 +117,7 @@ const SystemInsidePage:FC = ()=> {
|
||||
}, [currentUrl]);
|
||||
|
||||
useEffect(()=>{
|
||||
if(accessData && accessData.get('team') && accessData.get('team')?.indexOf('team.service.router.view') !== -1){
|
||||
if(accessData && checkPermission('team.service.router.view')){
|
||||
getApiDefine()
|
||||
}
|
||||
},[accessData])
|
||||
|
||||
@@ -5,9 +5,9 @@ go 1.21
|
||||
//toolchain go1.21.1
|
||||
|
||||
require (
|
||||
github.com/eolinker/ap-account v1.0.14
|
||||
github.com/eolinker/ap-account v1.0.15
|
||||
github.com/eolinker/eosc v0.17.3
|
||||
github.com/eolinker/go-common v1.1.0
|
||||
github.com/eolinker/go-common v1.1.1
|
||||
github.com/gabriel-vasile/mimetype v1.4.4
|
||||
github.com/getkin/kin-openapi v0.127.0
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
@@ -75,6 +75,6 @@ require (
|
||||
gorm.io/driver/mysql v1.5.2 // indirect
|
||||
)
|
||||
|
||||
replace github.com/eolinker/ap-account => ../../eolinker/ap-account
|
||||
|
||||
replace github.com/eolinker/go-common => ../../eolinker/go-common
|
||||
//replace github.com/eolinker/ap-account => ../aoaccount
|
||||
//
|
||||
//replace github.com/eolinker/go-common => ../go-common
|
||||
|
||||
@@ -28,8 +28,12 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/eolinker/ap-account v1.0.15 h1:n6DJeL6RHZ8eLlZUcY2U3H4d/GPaA5oelAx3R0E6yL8=
|
||||
github.com/eolinker/ap-account v1.0.15/go.mod h1:zm/Ivs6waJ/M/nEszhpPmM6g50y/MKO+5eABFAdeD0g=
|
||||
github.com/eolinker/eosc v0.17.3 h1:sr2yT+v/AsqEdciRaaZZj0zL9pTufR5RvDW6+65hraQ=
|
||||
github.com/eolinker/eosc v0.17.3/go.mod h1:xgq816hpanlMXFtZw7Ztdctb1eEk9UPHchY4NfFO6Cw=
|
||||
github.com/eolinker/go-common v1.1.1 h1:3WqqecGqcHDgpa8Ljp156c1uWeZKP1CKScdU+6sOfcc=
|
||||
github.com/eolinker/go-common v1.1.1/go.mod h1:Kb/jENMN1mApnodvRgV4YwO9FJby1Jkt2EUjrBjvSX4=
|
||||
github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy+R0LnH8I=
|
||||
github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s=
|
||||
github.com/getkin/kin-openapi v0.127.0 h1:Mghqi3Dhryf3F8vR370nN67pAERW+3a95vomb3MAREY=
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
_ "github.com/APIParkLab/APIPark/plugins/core"
|
||||
_ "github.com/APIParkLab/APIPark/plugins/permit"
|
||||
_ "github.com/APIParkLab/APIPark/plugins/publish_flow"
|
||||
_ "github.com/APIParkLab/APIPark/resources/locale"
|
||||
_ "github.com/eolinker/ap-account/plugin"
|
||||
_ "github.com/eolinker/go-common/cache/cache_redis"
|
||||
_ "github.com/eolinker/go-common/log-init"
|
||||
|
||||
@@ -320,6 +320,7 @@ func (i *imlCatalogueModule) Services(ctx context.Context, keyword string) ([]*c
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
serviceIds := utils.SliceToSlice(items, func(i *service.Service) string {
|
||||
return i.Id
|
||||
}, func(s *service.Service) bool {
|
||||
@@ -330,6 +331,7 @@ func (i *imlCatalogueModule) Services(ctx context.Context, keyword string) ([]*c
|
||||
if len(serviceIds) < 1 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
commits, err := i.releaseService.GetRunningApiDocCommits(ctx, serviceIds...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -75,11 +75,14 @@ type App struct {
|
||||
}
|
||||
|
||||
func ToService(model *service.Service) *Service {
|
||||
|
||||
prefix := "/"
|
||||
if model.Prefix != "" {
|
||||
prefix = model.Prefix
|
||||
}
|
||||
s := &Service{
|
||||
Id: model.Id,
|
||||
Name: model.Name,
|
||||
Prefix: model.Prefix,
|
||||
Prefix: prefix,
|
||||
Description: model.Description,
|
||||
Team: auto.UUID(model.Team),
|
||||
ServiceType: model.ServiceType.String(),
|
||||
|
||||
@@ -6,6 +6,9 @@ import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/eolinker/eosc/log"
|
||||
|
||||
"github.com/APIParkLab/APIPark/resources/access"
|
||||
|
||||
@@ -231,6 +234,7 @@ func (i *imlServiceModule) SearchMyServices(ctx context.Context, teamId string,
|
||||
//}
|
||||
|
||||
func (i *imlServiceModule) Get(ctx context.Context, id string) (*service_dto.Service, error) {
|
||||
now := time.Now()
|
||||
serviceInfo, err := i.serviceService.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -244,6 +248,7 @@ func (i *imlServiceModule) Get(ctx context.Context, id string) (*service_dto.Ser
|
||||
s.Tags = auto.List(utils.SliceToSlice(tags, func(p *service_tag.Tag) string {
|
||||
return p.Tid
|
||||
}))
|
||||
log.Infof("get service cost %d ms", time.Since(now).Milliseconds())
|
||||
return s, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
package core
|
||||
+1
-1
@@ -11,7 +11,7 @@ import (
|
||||
func (p *plugin) aiAPIs() []pm3.Api {
|
||||
return []pm3.Api{
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/ai/providers", []string{"context"}, []string{"providers"}, p.aiProviderController.Providers, access.SystemSettingsAiProviderView),
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/simple/ai/providers", []string{"context"}, []string{"providers"}, p.aiProviderController.SimpleProviders, access.SystemSettingsAiProviderView),
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/simple/ai/providers", []string{"context"}, []string{"providers"}, p.aiProviderController.SimpleProviders),
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/ai/provider/config", []string{"context", "query:provider"}, []string{"provider"}, p.aiProviderController.Provider, access.SystemSettingsAiProviderView),
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/ai/provider/llms", []string{"context", "query:provider"}, []string{"llms", "provider"}, p.aiProviderController.LLMs),
|
||||
//pm3.CreateApiWidthDoc(http.MethodPut, "/api/v1/ai/provider/enable", []string{"context", "query:provider"}, nil, p.aiProviderController.Enable),
|
||||
|
||||
@@ -22,7 +22,7 @@ func (p *plugin) ServiceApis() []pm3.Api {
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/simple/apps/mine", []string{"context", "query:keyword"}, []string{"apps"}, p.appController.MySimpleApps),
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/my_apps", []string{"context", "query:team", "query:keyword"}, []string{"apps"}, p.appController.SearchMyApps),
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/apps", []string{"context", "query:team", "query:keyword"}, []string{"apps"}, p.appController.Search, access.SystemWorkspaceApplicationViewAll),
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/apps/can_subscribe", []string{"context", "query:"}, []string{"app"}, p.appController.SearchCanSubscribe),
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/apps/can_subscribe", []string{"context", "query:service"}, []string{"app"}, p.appController.SearchCanSubscribe),
|
||||
pm3.CreateApiWidthDoc(http.MethodPut, "/api/v1/app/info", []string{"context", "query:app", "body"}, []string{"app"}, p.appController.UpdateApp, access.SystemWorkspaceApplicationManagerAll, access.TeamTeamConsumerManager),
|
||||
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/service/doc", []string{"context", "query:service"}, []string{"doc"}, p.serviceController.ServiceDoc, access.SystemWorkspaceServiceViewAll, access.TeamServiceServiceIntroView),
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
func (p *plugin) catalogueApi() []pm3.Api {
|
||||
return []pm3.Api{
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/catalogues", []string{"context", "query:keyword"}, []string{"catalogues", "tags"}, p.catalogueController.Search, access.SystemSettingsGeneralView),
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/catalogues", []string{"context", "query:keyword"}, []string{"catalogues", "tags"}, p.catalogueController.Search, access.SystemSettingsGeneralView, access.SystemApiPortalApiPortalView),
|
||||
pm3.CreateApiWidthDoc(http.MethodPost, "/api/v1/catalogue", []string{"context", "body"}, nil, p.catalogueController.Create, access.SystemSettingsGeneralManager),
|
||||
pm3.CreateApiWidthDoc(http.MethodPut, "/api/v1/catalogue", []string{"context", "query:catalogue", "body"}, nil, p.catalogueController.Edit, access.SystemSettingsGeneralManager),
|
||||
pm3.CreateApiWidthDoc(http.MethodDelete, "/api/v1/catalogue", []string{"context", "query:catalogue"}, nil, p.catalogueController.Delete, access.SystemSettingsGeneralManager),
|
||||
|
||||
@@ -3,23 +3,25 @@ package core
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/APIParkLab/APIPark/resources/access"
|
||||
|
||||
"github.com/eolinker/go-common/pm3"
|
||||
)
|
||||
|
||||
func (p *plugin) subscribeApis() []pm3.Api {
|
||||
return []pm3.Api{
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/service/subscribers", []string{"context", "query:service", "query:keyword"}, []string{"subscribers"}, p.subscribeController.Search),
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/service/subscribers", []string{"context", "query:service", "query:keyword"}, []string{"subscribers"}, p.subscribeController.Search, access.SystemWorkspaceServiceViewAll, access.TeamServiceSubscriptionView),
|
||||
|
||||
pm3.CreateApiWidthDoc(http.MethodPost, "/api/v1/service/subscriber", []string{"context", "query:service", "body"}, nil, p.subscribeController.AddSubscriber),
|
||||
pm3.CreateApiWidthDoc(http.MethodDelete, "/api/v1/service/subscriber", []string{"context", "query:service", "query:service", "query:application"}, nil, p.subscribeController.DeleteSubscriber),
|
||||
pm3.CreateApiWidthDoc(http.MethodPost, "/api/v1/service/subscriber", []string{"context", "query:service", "body"}, nil, p.subscribeController.AddSubscriber, access.SystemWorkspaceServiceManagerAll, access.TeamServiceSubscriptionManager),
|
||||
pm3.CreateApiWidthDoc(http.MethodDelete, "/api/v1/service/subscriber", []string{"context", "query:service", "query:service", "query:application"}, nil, p.subscribeController.DeleteSubscriber, access.SystemWorkspaceServiceManagerAll, access.TeamServiceSubscriptionManager),
|
||||
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/application/subscriptions", []string{"context", "query:application", "query:keyword"}, []string{"subscriptions"}, p.subscribeController.SearchSubscriptions),
|
||||
pm3.CreateApiWidthDoc(http.MethodPost, "/api/v1/application/subscription/cancel", []string{"context", "query:application", "query:subscription"}, nil, p.subscribeController.RevokeSubscription),
|
||||
pm3.CreateApiWidthDoc(http.MethodPost, "/api/v1/application/subscription/cancel_apply", []string{"context", "query:application", "query:subscription"}, nil, p.subscribeController.RevokeApply),
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/application/subscriptions", []string{"context", "query:application", "query:keyword"}, []string{"subscriptions"}, p.subscribeController.SearchSubscriptions, access.SystemWorkspaceApplicationViewAll, access.TeamConsumerSubscriptionViewSubscribed),
|
||||
pm3.CreateApiWidthDoc(http.MethodPost, "/api/v1/application/subscription/cancel", []string{"context", "query:application", "query:subscription"}, nil, p.subscribeController.RevokeSubscription, access.SystemWorkspaceApplicationManagerAll, access.TeamConsumerSubscriptionSubscribe, access.TeamConsumerSubscriptionManagerSubscribed),
|
||||
pm3.CreateApiWidthDoc(http.MethodPost, "/api/v1/application/subscription/cancel_apply", []string{"context", "query:application", "query:subscription"}, nil, p.subscribeController.RevokeApply, access.SystemWorkspaceApplicationManagerAll, access.TeamConsumerSubscriptionSubscribe, access.TeamConsumerSubscriptionManagerSubscribed),
|
||||
|
||||
// 审核相关
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/service/approval/subscribes", []string{"context", "query:service", "query:status"}, []string{"approvals"}, p.subscribeApprovalController.GetApprovalList),
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/service/approval/subscribe", []string{"context", "query:service", "query:apply"}, []string{"approval"}, p.subscribeApprovalController.GetApprovalDetail),
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/service/approval/subscribes", []string{"context", "query:service", "query:status"}, []string{"approvals"}, p.subscribeApprovalController.GetApprovalList, access.SystemWorkspaceServiceViewAll, access.TeamServiceSubscriptionView),
|
||||
pm3.CreateApiWidthDoc(http.MethodGet, "/api/v1/service/approval/subscribe", []string{"context", "query:service", "query:apply"}, []string{"approval"}, p.subscribeApprovalController.GetApprovalDetail, access.SystemWorkspaceServiceViewAll, access.TeamServiceSubscriptionView),
|
||||
pm3.CreateApiWidthDoc(http.MethodPost, "/api/v1/service/approval/subscribe", []string{"context", "query:service", "query:apply", "body"}, nil, p.subscribeApprovalController.Approval),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,13 +197,6 @@ team:
|
||||
value: 'manager'
|
||||
dependents:
|
||||
- team.service.subscription.view
|
||||
- name: service
|
||||
value: 'service'
|
||||
children:
|
||||
- name: manager
|
||||
value: 'manager'
|
||||
dependents:
|
||||
- team.service.service.manager
|
||||
- name: consumer
|
||||
value: 'consumer'
|
||||
children:
|
||||
@@ -230,11 +223,6 @@ team:
|
||||
value: 'manager'
|
||||
dependents:
|
||||
- team.consumer.authorization.view
|
||||
- name: consumer
|
||||
value: 'application'
|
||||
children:
|
||||
- name: manager
|
||||
value: 'manager'
|
||||
- name: team
|
||||
value: 'team'
|
||||
children:
|
||||
@@ -274,7 +262,6 @@ team:
|
||||
- name: view
|
||||
value: 'view'
|
||||
guest_allow: true
|
||||
apis:
|
||||
- name: manager
|
||||
value: 'manager'
|
||||
apis:
|
||||
|
||||
@@ -62,7 +62,6 @@ team:
|
||||
- name: team admin
|
||||
value: team_admin
|
||||
permits:
|
||||
- team.consumer.application.manager
|
||||
- team.consumer.authorization.manager
|
||||
- team.consumer.authorization.view
|
||||
- team.consumer.subscription.manager_subscribed_services
|
||||
@@ -74,7 +73,6 @@ team:
|
||||
- team.service.api_doc.view
|
||||
- team.service.release.manager
|
||||
- team.service.release.view
|
||||
- team.service.service.manager
|
||||
- team.service.service_intro.manager
|
||||
- team.service.service_intro.view
|
||||
- team.service.subscription.manager
|
||||
@@ -99,7 +97,6 @@ team:
|
||||
- team.service.api_doc.view
|
||||
- team.service.release.manager
|
||||
- team.service.release.view
|
||||
- team.service.service.manager
|
||||
- team.service.service_intro.manager
|
||||
- team.service.service_intro.view
|
||||
- team.service.subscription.manager
|
||||
@@ -134,7 +131,6 @@ team:
|
||||
- name: consumer admin
|
||||
value: consumer_admin
|
||||
permits:
|
||||
- team.consumer.application.manager
|
||||
- team.consumer.authorization.manager
|
||||
- team.consumer.authorization.view
|
||||
- team.consumer.subscription.manager_subscribed_services
|
||||
|
||||
@@ -62,7 +62,7 @@ services:
|
||||
privileged: true
|
||||
restart: always
|
||||
ports:
|
||||
- 6379:6379
|
||||
- "6379:6379"
|
||||
command:
|
||||
- bash
|
||||
- -c
|
||||
|
||||
@@ -31,3 +31,10 @@ if [ ! -d "./aoaccount" ]; then
|
||||
fi
|
||||
cd "./aoaccount" && git pull
|
||||
|
||||
echo "更新go-common"
|
||||
cd "${BASEPATH}/"
|
||||
if [ ! -d "./go-common" ]; then
|
||||
git clone http://gitlab.eolink.com/apinto/go-common.git
|
||||
fi
|
||||
cd "./go-common" && git pull
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ func (i *imlServiceService) ServiceList(ctx context.Context, serviceIds ...strin
|
||||
w["uuid"] = serviceIds
|
||||
}
|
||||
w["as_server"] = true
|
||||
w["is_delete"] = false
|
||||
list, err := i.store.List(ctx, w)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -46,6 +47,7 @@ func (i *imlServiceService) ServiceListByKind(ctx context.Context, kind Kind, se
|
||||
}
|
||||
w["as_server"] = true
|
||||
w["kind"] = kind
|
||||
w["is_delete"] = false
|
||||
list, err := i.store.List(ctx, w)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -57,6 +59,7 @@ func (i *imlServiceService) SearchPublicServices(ctx context.Context, keyword st
|
||||
w := map[string]interface{}{
|
||||
"as_server": true,
|
||||
"service_type": PublicService.Int(),
|
||||
"is_delete": false,
|
||||
}
|
||||
list, err := i.store.Search(ctx, keyword, w)
|
||||
if err != nil {
|
||||
@@ -93,6 +96,7 @@ func (i *imlServiceService) AppList(ctx context.Context, appIds ...string) ([]*S
|
||||
w["uuid"] = appIds
|
||||
}
|
||||
w["as_app"] = true
|
||||
w["is_delete"] = false
|
||||
list, err := i.store.List(ctx, w)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user