🐛 fix bugs
Signed-off-by: jagger <cossjie@foxmail.com> Former-commit-id: 53a7c41f3f2d4bb67da7c6593893d63d1d4ea189
This commit is contained in:
parent
8abba1912b
commit
1bd68400ce
|
@ -510,6 +510,7 @@ type (
|
|||
Nickname string `form:"nickname,optional"`
|
||||
Version string `form:"version,optional"`
|
||||
Server string `form:"server,optional"`
|
||||
PageInfo
|
||||
}
|
||||
AdapterReq {
|
||||
Id string `json:"id,optional" db:"id"`
|
||||
|
@ -560,54 +561,83 @@ type (
|
|||
}
|
||||
)
|
||||
|
||||
type ClusterReq {
|
||||
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"`
|
||||
Server string `json:"server,optional"`
|
||||
MonitorServer string `json:"monitorServer,optional"`
|
||||
Username string `json:"username,optional"`
|
||||
Password string `json:"password,optional"`
|
||||
Token string `json:"token,optional"`
|
||||
Ak string `json:"ak,optional"`
|
||||
Sk string `json:"sk,optional"`
|
||||
Region string `json:"region,optional"`
|
||||
ProjectId string `json:"projectId,optional"`
|
||||
Version string `json:"version,optional"`
|
||||
Label string `json:"label,optional"`
|
||||
OwnerId string `json:"ownerId,omitempty,optional"`
|
||||
AuthType string `json:"authType,optional"`
|
||||
Type string `json:"type,optional"`
|
||||
}
|
||||
type (
|
||||
ClusterReq {
|
||||
Id string `form:"id,optional"`
|
||||
AdapterId string `form:"adapterId,optional"`
|
||||
Name string `form:"name,optional"`
|
||||
Nickname string `form:"nickname,optional"`
|
||||
Description string `form:"description,optional"`
|
||||
Server string `form:"server,optional"`
|
||||
MonitorServer string `form:"monitorServer,optional"`
|
||||
Username string `form:"username,optional"`
|
||||
Password string `form:"password,optional"`
|
||||
Token string `form:"token,optional"`
|
||||
Ak string `form:"ak,optional"`
|
||||
Sk string `form:"sk,optional"`
|
||||
Region string `form:"region,optional"`
|
||||
ProjectId string `form:"projectId,optional"`
|
||||
Version string `form:"version,optional"`
|
||||
Label string `form:"label,optional"`
|
||||
OwnerId string `form:"ownerId,omitempty,optional"`
|
||||
AuthType string `form:"authType,optional"`
|
||||
Type string `form:"type,optional"`
|
||||
producerDict string `form:"producerDict,optional"`
|
||||
regionDict string `form:"regionDict,optional"`
|
||||
PageInfo
|
||||
}
|
||||
|
||||
ClusterCreateReq {
|
||||
Id string `json:"id,optional"`
|
||||
AdapterId string `json:"adapterId,optional"`
|
||||
Name string `json:"name,optional"`
|
||||
Nickname string `json:"nickname,optional"`
|
||||
Description string `json:"description,optional"`
|
||||
Server string `json:"server,optional"`
|
||||
MonitorServer string `json:"monitorServer,optional"`
|
||||
Username string `json:"username,optional"`
|
||||
Password string `json:"password,optional"`
|
||||
Token string `json:"token,optional"`
|
||||
Ak string `json:"ak,optional"`
|
||||
Sk string `json:"sk,optional"`
|
||||
Region string `json:"region,optional"`
|
||||
ProjectId string `json:"projectId,optional"`
|
||||
Version string `json:"version,optional"`
|
||||
Label string `json:"label,optional"`
|
||||
OwnerId string `json:"ownerId,omitempty,optional"`
|
||||
AuthType string `json:"authType,optional"`
|
||||
producerDict string `json:"producerDict,optional"`
|
||||
regionDict string `json:"regionDict,optional"`
|
||||
}
|
||||
ClusterInfo {
|
||||
Id string `json:"id,omitempty" db:"id"`
|
||||
AdapterId string `json:"adapterId,omitempty" db:"adapter_id"`
|
||||
Name string `json:"name,omitempty" db:"name"`
|
||||
Nickname string `json:"nickname,omitempty" db:"nickname"`
|
||||
Description string `json:"description,omitempty" db:"description"`
|
||||
Server string `json:"server,omitempty" db:"server"`
|
||||
MonitorServer string `json:"monitorServer,omitempty" db:"monitor_server"`
|
||||
Username string `json:"username,omitempty" db:"username"`
|
||||
Password string `json:"password,omitempty" db:"password"`
|
||||
Token string `json:"token,omitempty" db:"token"`
|
||||
Ak string `json:"ak,omitempty" db:"ak"`
|
||||
Sk string `json:"sk,omitempty" db:"sk"`
|
||||
Region string `json:"region,omitempty" db:"region"`
|
||||
ProjectId string `json:"projectId,omitempty" db:"project_id"`
|
||||
Version string `json:"version,omitempty" db:"version"`
|
||||
Label string `json:"label,omitempty" db:"label"`
|
||||
OwnerId string `json:"ownerId,omitempty" db:"owner_id"`
|
||||
AuthType string `json:"authType,omitempty" db:"auth_type"`
|
||||
producerDict string `json:"producerDict,omitempty" db:"producer_dict"`
|
||||
regionDict string `json:"regionDict,omitempty" db:"region_dict"`
|
||||
CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"`
|
||||
}
|
||||
)
|
||||
|
||||
type ClusterDelReq {
|
||||
Id string `form:"id,optional"`
|
||||
}
|
||||
|
||||
type ClusterInfo {
|
||||
Id string `json:"id,omitempty" db:"id"`
|
||||
AdapterId string `json:"adapterId,omitempty" db:"adapter_id"`
|
||||
Name string `json:"name,omitempty" db:"name"`
|
||||
Nickname string `json:"nickname,omitempty" db:"nickname"`
|
||||
Description string `json:"description,omitempty" db:"description"`
|
||||
Server string `json:"server,omitempty" db:"server"`
|
||||
MonitorServer string `json:"monitorServer,omitempty" db:"monitor_server"`
|
||||
Username string `json:"username,omitempty" db:"username"`
|
||||
Password string `json:"password,omitempty" db:"password"`
|
||||
Token string `json:"token,omitempty" db:"token"`
|
||||
Ak string `json:"ak,omitempty" db:"ak"`
|
||||
Sk string `json:"sk,omitempty" db:"sk"`
|
||||
Region string `json:"region,omitempty" db:"region"`
|
||||
ProjectId string `json:"projectId,omitempty" db:"project_id"`
|
||||
Version string `json:"version,omitempty" db:"version"`
|
||||
Label string `json:"label,omitempty" db:"label"`
|
||||
OwnerId string `json:"ownerId,omitempty" db:"owner_id"`
|
||||
AuthType string `json:"authType,omitempty" db:"auth_type"`
|
||||
CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"`
|
||||
}
|
||||
|
||||
type ClusterResp {
|
||||
List ClusterInfo `json:"list,omitempty"`
|
||||
}
|
||||
|
@ -770,6 +800,10 @@ type (
|
|||
CIds {
|
||||
Ids []string `json:"ids,omitempty" validate:"required"`
|
||||
}
|
||||
|
||||
FId {
|
||||
Id string `form:"id":"id,omitempty" validate:"required"`
|
||||
}
|
||||
)
|
||||
|
||||
type (
|
||||
|
|
|
@ -806,7 +806,7 @@ service pcm {
|
|||
|
||||
service pcm {
|
||||
@handler AdaptersListHandler
|
||||
get /adapter/list (AdapterQueryReq) returns (AdapterListResp)
|
||||
get /adapter/list (AdapterQueryReq) returns (PageResult)
|
||||
|
||||
@handler CreateAdapterHandler
|
||||
post /adapter/create (AdapterCreateReq) returns (AdapterResp)
|
||||
|
@ -821,22 +821,22 @@ service pcm {
|
|||
get /adapter/get (AdapterDelReq) returns (AdapterInfo)
|
||||
|
||||
@handler ClusterListHandler
|
||||
get /adapter/cluster/list (ClusterReq) returns (ClusterListResp)
|
||||
get /adapter/cluster/list (ClusterReq) returns (PageResult)
|
||||
|
||||
@handler CreateClusterHandler
|
||||
post /adapter/cluster/create (ClusterReq) returns (ClusterResp)
|
||||
post /adapter/cluster/create (ClusterCreateReq) returns (ClusterResp)
|
||||
|
||||
@handler UpdateClusterHandler
|
||||
put /adapter/cluster/update (ClusterReq) returns (ClusterResp)
|
||||
put /adapter/cluster/update (ClusterCreateReq) returns (ClusterResp)
|
||||
|
||||
@handler DeleteClusterHandler
|
||||
delete /adapter/cluster/delete (ClusterDelReq) returns (ClusterResp)
|
||||
delete /adapter/cluster/delete (FId) returns (ClusterResp)
|
||||
|
||||
@handler GetClusterHandler
|
||||
get /adapter/cluster/get (ClusterDelReq) returns (ClusterResp)
|
||||
get /adapter/cluster/get (FId) returns (ClusterResp)
|
||||
|
||||
@handler GetAdapterRelationHandler
|
||||
get /adapter/relation (AdapterQueryReq) returns (AdapterRelationResp)
|
||||
get /adapter/relation (AdapterQueryReq) returns (PageResult)
|
||||
|
||||
@handler GetClusterSumHandler
|
||||
get /adapter/clusterSum (clusterSumReq) returns (clusterSumReqResp)
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
package adapters
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func AdaptersListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdapterQueryReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := adapters.NewAdaptersListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.AdaptersList(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
package adapters
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func ClusterListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ClusterReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := adapters.NewClusterListLogic(r.Context(), svcCtx)
|
||||
resp, err := l.ClusterList(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
package adapters
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func CreateAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdapterCreateReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := adapters.NewCreateAdapterLogic(r.Context(), svcCtx)
|
||||
resp, err := l.CreateAdapter(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
package adapters
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func CreateClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ClusterReq
|
||||
var req types.ClusterCreateReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := adapters.NewCreateClusterLogic(r.Context(), svcCtx)
|
||||
resp, err := l.CreateCluster(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
package adapters
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func DeleteAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdapterDelReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := adapters.NewDeleteAdapterLogic(r.Context(), svcCtx)
|
||||
resp, err := l.DeleteAdapter(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
package adapters
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func DeleteClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ClusterDelReq
|
||||
var req types.FId
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := adapters.NewDeleteClusterLogic(r.Context(), svcCtx)
|
||||
resp, err := l.DeleteCluster(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
package adapters
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdapterDelReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := adapters.NewGetAdapterLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetAdapter(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
package adapters
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetAdapterRelationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdapterQueryReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := adapters.NewGetAdapterRelationLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetAdapterRelation(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
package adapters
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ClusterDelReq
|
||||
var req types.FId
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := adapters.NewGetClusterLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetCluster(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
package adapters
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func GetClusterSumHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ClusterSumReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := adapters.NewGetClusterSumLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetClusterSum(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
package adapters
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func UpdateAdapterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.AdapterReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := adapters.NewUpdateAdapterLogic(r.Context(), svcCtx)
|
||||
resp, err := l.UpdateAdapter(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,24 @@
|
|||
package adapters
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/logic/adapters"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func UpdateClusterHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ClusterReq
|
||||
var req types.ClusterCreateReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := adapters.NewUpdateClusterLogic(r.Context(), svcCtx)
|
||||
resp, err := l.UpdateCluster(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@ package adapters
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
|
||||
|
@ -24,16 +22,38 @@ func NewAdaptersListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Adap
|
|||
}
|
||||
}
|
||||
|
||||
func (l *AdaptersListLogic) AdaptersList(req *types.AdapterQueryReq) (resp *types.AdapterListResp, err error) {
|
||||
resp = &types.AdapterListResp{}
|
||||
sqlStr := "select * from t_adapter where `deleted_at` IS NULL ORDER BY create_time Desc"
|
||||
func (l *AdaptersListLogic) AdaptersList(req *types.AdapterQueryReq) (resp *types.PageResult, err error) {
|
||||
limit := req.PageSize
|
||||
offset := req.PageSize * (req.PageNum - 1)
|
||||
resp = &types.PageResult{}
|
||||
var list []types.AdapterInfo
|
||||
db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter")
|
||||
|
||||
if req.Name != "" {
|
||||
sqlStr = fmt.Sprintf("select * from t_adapter where `deleted_at` IS NULL and name like '%%%s%%' ORDER BY create_time Desc", req.Name)
|
||||
db = db.Where("name LIKE ?", "%"+req.Name+"%")
|
||||
}
|
||||
tx := l.svcCtx.DbEngin.Raw(sqlStr).Scan(&resp.List)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return nil, tx.Error
|
||||
if req.Nickname != "" {
|
||||
db = db.Where("nickname LIKE ?", "%"+req.Nickname+"%")
|
||||
}
|
||||
if req.Type != "" {
|
||||
db = db.Where("type = ?", req.Type)
|
||||
}
|
||||
if req.Version != "" {
|
||||
db = db.Where("version = ?", req.Version)
|
||||
}
|
||||
var total int64
|
||||
err = db.Count(&total).Error
|
||||
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
db = db.Where("deleted_at is null").Limit(limit).Offset(offset)
|
||||
err = db.Order("create_time desc").Find(&list).Error
|
||||
|
||||
resp.List = list
|
||||
resp.PageSize = req.PageSize
|
||||
resp.PageNum = req.PageNum
|
||||
resp.Total = total
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@ package adapters
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types"
|
||||
|
||||
|
@ -24,20 +22,56 @@ func NewClusterListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Clust
|
|||
}
|
||||
}
|
||||
|
||||
func (l *ClusterListLogic) ClusterList(req *types.ClusterReq) (resp *types.ClusterListResp, err error) {
|
||||
resp = &types.ClusterListResp{}
|
||||
func (l *ClusterListLogic) ClusterList(req *types.ClusterReq) (resp *types.PageResult, err error) {
|
||||
limit := req.PageSize
|
||||
offset := req.PageSize * (req.PageNum - 1)
|
||||
resp = &types.PageResult{}
|
||||
var list []types.ClusterInfo
|
||||
db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter")
|
||||
|
||||
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`)
|
||||
db = db.Joins("left join t_cluster on t_adapter.id = t_cluster.adapter_id").
|
||||
Where("t_cluster.deleted_at is null")
|
||||
if req.Name != "" {
|
||||
db = db.Where("t_cluster.name LIKE ?", "%"+req.Name+"%")
|
||||
}
|
||||
if req.AdapterId != "" {
|
||||
sql = fmt.Sprintf(`select * from t_cluster where adapter_id = %s and deleted_at is null `, req.AdapterId)
|
||||
db = db.Where("t_cluster.adapter_id = ?", "%"+req.AdapterId+"%")
|
||||
}
|
||||
if req.Nickname != "" {
|
||||
db = db.Where("t_cluster.nickname LIKE ?", "%"+req.Nickname+"%")
|
||||
}
|
||||
if req.Label != "" {
|
||||
db = db.Where("t_cluster.label = ?", req.Label)
|
||||
}
|
||||
if req.Version != "" {
|
||||
db = db.Where("t_cluster.version = ?", req.Version)
|
||||
}
|
||||
if req.ProducerDict != "" {
|
||||
db = db.Where("t_cluster.producer_dict = ?", req.ProducerDict)
|
||||
}
|
||||
if req.RegionDict != "" {
|
||||
db = db.Where("t_cluster.region_dict = ?", req.RegionDict)
|
||||
}
|
||||
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)
|
||||
db = db.Where("t_adapter.type = ?", req.Type)
|
||||
}
|
||||
tx := l.svcCtx.DbEngin.Raw(sql).Scan(&resp.List)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return nil, tx.Error
|
||||
|
||||
//count total
|
||||
var total int64
|
||||
err = db.Select("*").Count(&total).Error
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
db = db.Limit(limit).Offset(offset)
|
||||
err = db.Select("t_cluster.*").Order("t_cluster.create_time desc").Scan(&list).Error
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
resp.List = list
|
||||
resp.PageSize = req.PageSize
|
||||
resp.PageNum = req.PageNum
|
||||
resp.Total = total
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ func NewCreateClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Cre
|
|||
}
|
||||
}
|
||||
|
||||
func (l *CreateClusterLogic) CreateCluster(req *types.ClusterReq) (resp *types.ClusterResp, err error) {
|
||||
func (l *CreateClusterLogic) CreateCluster(req *types.ClusterCreateReq) (resp *types.ClusterResp, err error) {
|
||||
adapter := &types.AdapterInfo{}
|
||||
result := l.svcCtx.DbEngin.Table("t_adapter").First(&adapter, req.AdapterId)
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
|
|
|
@ -24,7 +24,7 @@ func NewDeleteClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Del
|
|||
}
|
||||
}
|
||||
|
||||
func (l *DeleteClusterLogic) DeleteCluster(req *types.ClusterDelReq) (resp *types.ClusterResp, err error) {
|
||||
func (l *DeleteClusterLogic) DeleteCluster(req *types.FId) (resp *types.ClusterResp, err error) {
|
||||
db := l.svcCtx.DbEngin.Table("t_cluster").Where("id = ?", req.Id).First(&types.ClusterInfo{})
|
||||
if db.Error != nil {
|
||||
logx.Errorf("err %v", db.Error.Error())
|
||||
|
|
|
@ -2,7 +2,6 @@ package adapters
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils"
|
||||
|
||||
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
||||
|
@ -25,19 +24,32 @@ func NewGetAdapterRelationLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
}
|
||||
}
|
||||
|
||||
func (l *GetAdapterRelationLogic) GetAdapterRelation(req *types.AdapterQueryReq) (resp *types.AdapterRelationResp, err error) {
|
||||
resp = &types.AdapterRelationResp{}
|
||||
adapter := make([]types.AdapterInfo, 0)
|
||||
sqlStr := "select * from t_adapter where `deleted_at` IS NULL ORDER BY create_time Desc"
|
||||
func (l *GetAdapterRelationLogic) GetAdapterRelation(req *types.AdapterQueryReq) (resp *types.PageResult, err error) {
|
||||
resp = &types.PageResult{}
|
||||
var list []types.AdapterInfo
|
||||
db := l.svcCtx.DbEngin.Model(&types.AdapterInfo{}).Table("t_adapter")
|
||||
|
||||
if req.Name != "" {
|
||||
sqlStr = fmt.Sprintf("select * from t_adapter where `deleted_at` IS NULL and name like '%%%s%%' ORDER BY create_time Desc", req.Name)
|
||||
db = db.Where("name LIKE ?", "%"+req.Name+"%")
|
||||
}
|
||||
tx := l.svcCtx.DbEngin.Raw(sqlStr).Scan(&adapter)
|
||||
if tx.Error != nil {
|
||||
logx.Errorf(tx.Error.Error())
|
||||
return nil, tx.Error
|
||||
if req.Nickname != "" {
|
||||
db = db.Where("nickname LIKE ?", "%"+req.Nickname+"%")
|
||||
}
|
||||
for _, v := range adapter {
|
||||
if req.Type != "" {
|
||||
db = db.Where("type = ?", req.Type)
|
||||
}
|
||||
if req.Version != "" {
|
||||
db = db.Where("version = ?", req.Version)
|
||||
}
|
||||
|
||||
err = db.Where("deleted_at is null").Order("create_time desc").Find(&list).Error
|
||||
|
||||
if err != nil {
|
||||
return resp, err
|
||||
}
|
||||
|
||||
rlist := make([]*types.ClusterRelationInfo, 0)
|
||||
for _, v := range list {
|
||||
cr := &types.ClusterRelationInfo{}
|
||||
utils.Convert(&v, &cr)
|
||||
clusters := make([]*types.ClusterInfo, 0)
|
||||
|
@ -64,11 +76,12 @@ func (l *GetAdapterRelationLogic) GetAdapterRelation(req *types.AdapterQueryReq)
|
|||
cr.COwnerId = c.OwnerId
|
||||
cr.CAuthType = c.AuthType
|
||||
cr.CCreateTime = c.CreateTime
|
||||
resp.List = append(resp.List, cr)
|
||||
rlist = append(rlist, cr)
|
||||
}
|
||||
if len(clusters) == 0 {
|
||||
resp.List = append(resp.List, cr)
|
||||
rlist = append(rlist, cr)
|
||||
}
|
||||
}
|
||||
resp.List = rlist
|
||||
return resp, nil
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ func NewGetClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClu
|
|||
}
|
||||
}
|
||||
|
||||
func (l *GetClusterLogic) GetCluster(req *types.ClusterDelReq) (resp *types.ClusterInfo, err error) {
|
||||
func (l *GetClusterLogic) GetCluster(req *types.FId) (resp *types.ClusterInfo, err error) {
|
||||
resp = &types.ClusterInfo{}
|
||||
db := l.svcCtx.DbEngin.Table("t_cluster").Where("id = ?", req.Id).First(&resp)
|
||||
if db.Error != nil {
|
||||
|
|
|
@ -26,7 +26,7 @@ func NewUpdateClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Upd
|
|||
}
|
||||
}
|
||||
|
||||
func (l *UpdateClusterLogic) UpdateCluster(req *types.ClusterReq) (resp *types.ClusterResp, err error) {
|
||||
func (l *UpdateClusterLogic) UpdateCluster(req *types.ClusterCreateReq) (resp *types.ClusterResp, err error) {
|
||||
cluster := &types.ClusterInfo{}
|
||||
result := l.svcCtx.DbEngin.Table("t_cluster").First(&cluster, req.Id)
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
|
|
|
@ -38,6 +38,7 @@ import (
|
|||
"gitlink.org.cn/jcce-pcm/pcm-participant-octopus/octopusclient"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
"gorm.io/gorm/schema"
|
||||
"time"
|
||||
)
|
||||
|
@ -84,6 +85,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
|||
NamingStrategy: schema.NamingStrategy{
|
||||
SingularTable: true, // 使用单数表名,启用该选项,此时,`User` 的表名应该是 `t_user`
|
||||
},
|
||||
Logger: logger.Default.LogMode(logger.Info),
|
||||
})
|
||||
if err != nil {
|
||||
logx.Errorf("数据库连接失败, err%v", err)
|
||||
|
|
|
@ -485,6 +485,7 @@ type AdapterQueryReq struct {
|
|||
Nickname string `form:"nickname,optional"`
|
||||
Version string `form:"version,optional"`
|
||||
Server string `form:"server,optional"`
|
||||
PageInfo
|
||||
}
|
||||
|
||||
type AdapterReq struct {
|
||||
|
@ -545,6 +546,31 @@ type AdapterRelation struct {
|
|||
type ClusterReq struct {
|
||||
Id string `form:"id,optional"`
|
||||
AdapterId string `form:"adapterId,optional"`
|
||||
Name string `form:"name,optional"`
|
||||
Nickname string `form:"nickname,optional"`
|
||||
Description string `form:"description,optional"`
|
||||
Server string `form:"server,optional"`
|
||||
MonitorServer string `form:"monitorServer,optional"`
|
||||
Username string `form:"username,optional"`
|
||||
Password string `form:"password,optional"`
|
||||
Token string `form:"token,optional"`
|
||||
Ak string `form:"ak,optional"`
|
||||
Sk string `form:"sk,optional"`
|
||||
Region string `form:"region,optional"`
|
||||
ProjectId string `form:"projectId,optional"`
|
||||
Version string `form:"version,optional"`
|
||||
Label string `form:"label,optional"`
|
||||
OwnerId string `form:"ownerId,omitempty,optional"`
|
||||
AuthType string `form:"authType,optional"`
|
||||
Type string `form:"type,optional"`
|
||||
ProducerDict string `form:"producerDict,optional"`
|
||||
RegionDict string `form:"regionDict,optional"`
|
||||
PageInfo
|
||||
}
|
||||
|
||||
type ClusterCreateReq struct {
|
||||
Id string `json:"id,optional"`
|
||||
AdapterId string `json:"adapterId,optional"`
|
||||
Name string `json:"name,optional"`
|
||||
Nickname string `json:"nickname,optional"`
|
||||
Description string `json:"description,optional"`
|
||||
|
@ -561,11 +587,8 @@ type ClusterReq struct {
|
|||
Label string `json:"label,optional"`
|
||||
OwnerId string `json:"ownerId,omitempty,optional"`
|
||||
AuthType string `json:"authType,optional"`
|
||||
Type string `json:"type,optional"`
|
||||
}
|
||||
|
||||
type ClusterDelReq struct {
|
||||
Id string `form:"id,optional"`
|
||||
ProducerDict string `json:"producerDict,optional"`
|
||||
RegionDict string `json:"regionDict,optional"`
|
||||
}
|
||||
|
||||
type ClusterInfo struct {
|
||||
|
@ -587,9 +610,15 @@ type ClusterInfo struct {
|
|||
Label string `json:"label,omitempty" db:"label"`
|
||||
OwnerId string `json:"ownerId,omitempty" db:"owner_id"`
|
||||
AuthType string `json:"authType,omitempty" db:"auth_type"`
|
||||
ProducerDict string `json:"producerDict,omitempty" db:"producer_dict"`
|
||||
RegionDict string `json:"regionDict,omitempty" db:"region_dict"`
|
||||
CreateTime string `json:"createTime,omitempty" db:"created_time" gorm:"autoCreateTime"`
|
||||
}
|
||||
|
||||
type ClusterDelReq struct {
|
||||
Id string `form:"id,optional"`
|
||||
}
|
||||
|
||||
type ClusterResp struct {
|
||||
List ClusterInfo `json:"list,omitempty"`
|
||||
}
|
||||
|
@ -748,6 +777,10 @@ type CIds struct {
|
|||
Ids []string `json:"ids,omitempty" validate:"required"`
|
||||
}
|
||||
|
||||
type FId struct {
|
||||
Id string `form:"id":"id,omitempty" validate:"required"`
|
||||
}
|
||||
|
||||
type PageInfo struct {
|
||||
PageNum int `form:"pageNum"`
|
||||
PageSize int `form:"pageSize"`
|
||||
|
|
Loading…
Reference in New Issue