diff --git a/api/desc/core/pcm-core.api b/api/desc/core/pcm-core.api index 463f2137..5f6be796 100644 --- a/api/desc/core/pcm-core.api +++ b/api/desc/core/pcm-core.api @@ -726,8 +726,8 @@ type ( ) type ClusterReq { - Id string `json:"id,optional"` - AdapterId string `json:"adapterId,optional"` + Id string `form:"id,optional"` + AdapterId string `form:"adapterId,optional"` Name string `json:"name,optional"` Nickname string `json:"nickname,optional"` Description string `json:"description,optional"` diff --git a/api/internal/logic/adapters/clusterlistlogic.go b/api/internal/logic/adapters/clusterlistlogic.go index 5bf7a5bc..a2806a1e 100644 --- a/api/internal/logic/adapters/clusterlistlogic.go +++ b/api/internal/logic/adapters/clusterlistlogic.go @@ -26,7 +26,11 @@ func NewClusterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Clust func (l *ClusterListLogic) ClusterList(req *types.ClusterReq) (resp *types.ClusterListResp, err error) { resp = &types.ClusterListResp{} + sql := fmt.Sprintf(`select c.* from t_cluster c left join t_adapter a on c.adapter_id = a.id where c.deleted_at is null`) + if req.AdapterId != "" { + sql = fmt.Sprintf(`select * from t_cluster where adapter_id = %s and deleted_at is null `, req.AdapterId) + } if req.Type != "" { sql = fmt.Sprintf(`select c.* from t_cluster c left join t_adapter a on c.adapter_id = a.id where c.deleted_at is null and a.type = %s`, req.Type) } diff --git a/api/internal/types/types.go b/api/internal/types/types.go index 002edab4..a38dfb33 100644 --- a/api/internal/types/types.go +++ b/api/internal/types/types.go @@ -694,8 +694,8 @@ type AdapterRelation struct { } type ClusterReq struct { - Id string `json:"id,optional"` - AdapterId string `json:"adapterId,optional"` + Id string `form:"id,optional"` + AdapterId string `form:"adapterId,optional"` Name string `json:"name,optional"` Nickname string `json:"nickname,optional"` Description string `json:"description,optional"`