cloud app删除接口实现
Signed-off-by: devad <cossjie@foxmail.com>
This commit is contained in:
parent
f40f21e142
commit
a899d04925
|
@ -549,21 +549,21 @@ service pcm {
|
|||
|
||||
@doc "删除应用"
|
||||
@handler DeleteAppByAppName
|
||||
get /apps/deleteApp (DeleteAppReq) returns (DeleteAppResp)
|
||||
delete /apps/deleteApp (DeleteAppReq) returns (DeleteAppResp)
|
||||
|
||||
@doc "更新应用"
|
||||
@handler UpdateAppByAppName
|
||||
get /apps/updateApp (DeleteAppReq) returns (AppTaskResp)
|
||||
put /apps/updateApp (DeleteAppReq) returns (AppTaskResp)
|
||||
|
||||
@doc "重启应用"
|
||||
@handler RestartAppByAppName
|
||||
get /apps/restartApp (DeleteAppReq) returns (AppTaskResp)
|
||||
put /apps/restartApp (DeleteAppReq) returns (AppTaskResp)
|
||||
|
||||
@doc "暂停应用"
|
||||
@handler PauseAppByAppName
|
||||
get /apps/pauseApp (DeleteAppReq) returns (AppTaskResp)
|
||||
put /apps/pauseApp (DeleteAppReq) returns (AppTaskResp)
|
||||
|
||||
@doc "启动应用"
|
||||
@handler StartAppByAppName
|
||||
get /apps/startApp (DeleteAppReq) returns (AppTaskResp)
|
||||
put /apps/startApp (DeleteAppReq) returns (AppTaskResp)
|
||||
}
|
|
@ -1,28 +1,24 @@
|
|||
package apps
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/apps"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func DeleteAppByAppNameHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.DeleteAppReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := apps.NewDeleteAppByAppNameLogic(r.Context(), svcCtx)
|
||||
resp, err := l.DeleteAppByAppName(&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 apps
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/apps"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func PauseAppByAppNameHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.DeleteAppReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := apps.NewPauseAppByAppNameLogic(r.Context(), svcCtx)
|
||||
resp, err := l.PauseAppByAppName(&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 apps
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/apps"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func RestartAppByAppNameHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.DeleteAppReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := apps.NewRestartAppByAppNameLogic(r.Context(), svcCtx)
|
||||
resp, err := l.RestartAppByAppName(&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 apps
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/apps"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func StartAppByAppNameHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.DeleteAppReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := apps.NewStartAppByAppNameLogic(r.Context(), svcCtx)
|
||||
resp, err := l.StartAppByAppName(&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 apps
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/apps"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/repository/result"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func UpdateAppByAppNameHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.DeleteAppReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
result.ParamErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := apps.NewUpdateAppByAppNameLogic(r.Context(), svcCtx)
|
||||
resp, err := l.UpdateAppByAppName(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -660,27 +660,27 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||
Handler: apps.GetAppByAppNameHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Method: http.MethodDelete,
|
||||
Path: "/apps/deleteApp",
|
||||
Handler: apps.DeleteAppByAppNameHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Method: http.MethodPut,
|
||||
Path: "/apps/updateApp",
|
||||
Handler: apps.UpdateAppByAppNameHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Method: http.MethodPut,
|
||||
Path: "/apps/restartApp",
|
||||
Handler: apps.RestartAppByAppNameHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Method: http.MethodPut,
|
||||
Path: "/apps/pauseApp",
|
||||
Handler: apps.PauseAppByAppNameHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Method: http.MethodPut,
|
||||
Path: "/apps/startApp",
|
||||
Handler: apps.StartAppByAppNameHandler(serverCtx),
|
||||
},
|
||||
|
|
|
@ -2,13 +2,11 @@ package apps
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes/kubernetes"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/constants"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
|
||||
)
|
||||
|
||||
type DeleteAppByAppNameLogic struct {
|
||||
|
@ -25,24 +23,6 @@ func NewDeleteAppByAppNameLogic(ctx context.Context, svcCtx *svc.ServiceContext)
|
|||
}
|
||||
}
|
||||
|
||||
type Cloud struct {
|
||||
Id int64 `db:"id"` // id
|
||||
TaskId int64 `db:"task_id"` // 任务id
|
||||
ParticipantId int64 `db:"participant_id"` // 集群静态信息id
|
||||
ApiVersion string `db:"api_version"` //api版本
|
||||
Name string `db:"name"` // 名称
|
||||
Namespace string `db:"namespace"` // 命名空间
|
||||
Kind string `db:"kind"` // 种类
|
||||
Status string `db:"status"` // 状态
|
||||
StartTime string `db:"start_time"` // 开始时间
|
||||
RunningTime int64 `db:"running_time"` // 运行时长
|
||||
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||
YamlString string `db:"yaml_string"`
|
||||
Result string `db:"result"` // 运行结果
|
||||
NsID string `db:"ns_id"`
|
||||
Replica int32 `db:"replica"`
|
||||
}
|
||||
|
||||
func (l *DeleteAppByAppNameLogic) DeleteAppByAppName(req *types.DeleteAppReq) (resp *types.DeleteAppResp, err error) {
|
||||
resp = &types.DeleteAppResp{}
|
||||
var task = &Task{}
|
||||
|
@ -53,26 +33,17 @@ func (l *DeleteAppByAppNameLogic) DeleteAppByAppName(req *types.DeleteAppReq) (r
|
|||
resp.Msg = "App not fount"
|
||||
return resp, err
|
||||
}
|
||||
var clouds []Cloud
|
||||
l.svcCtx.DbEngin.Raw(`select * from cloud where task_id= ? `, task.Id).Scan(&clouds)
|
||||
for _, cloud := range clouds {
|
||||
toYaml := utils.StringToYaml(cloud.YamlString)
|
||||
//调用p端接口查询应用详情
|
||||
_, err = l.svcCtx.K8sRpc.DeleteYaml(context.Background(), &kubernetes.ApplyReq{
|
||||
YamlString: *toYaml,
|
||||
})
|
||||
//删除主任务信息
|
||||
l.svcCtx.DbEngin.Model(&models.Task{}).Where("id", task.Id).Update("status", "Deleted")
|
||||
tx := l.svcCtx.DbEngin.Delete(&models.Task{}, task.Id)
|
||||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
logx.Errorf("调用p端接口删除应用失败,err:%v", err)
|
||||
resp.Code = 500
|
||||
resp.Msg = err.Error()
|
||||
return resp, nil
|
||||
// 将子任务状态修改为待删除
|
||||
tx = l.svcCtx.DbEngin.Model(&models.Cloud{}).Where("task_id", task.Id).Update("status", constants.WaitDelete)
|
||||
l.svcCtx.DbEngin.Where("task_id = ?", task.Id).Delete(&models.Cloud{})
|
||||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
}
|
||||
//删除task跟cloud表数据
|
||||
l.svcCtx.DbEngin.Delete(&Task{}, task.Id)
|
||||
l.svcCtx.DbEngin.Delete(&Cloud{}, task.Id).Where("task_id = ?", task.Id)
|
||||
resp.Code = 200
|
||||
resp.Msg = "succeed"
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
|
||||
server.AddRoutes(
|
||||
{{.routes}} {{.jwt}}{{.signature}} {{.prefix}} {{.timeout}}
|
||||
)
|
|
@ -1,6 +0,0 @@
|
|||
func new{{.upperStartCamelObject}}Model(conn sqlx.SqlConn{{if .withCache}}, c cache.CacheConf{{end}}) *default{{.upperStartCamelObject}}Model {
|
||||
return &default{{.upperStartCamelObject}}Model{
|
||||
{{if .withCache}}CachedConn: sqlc.NewConn(conn, c){{else}}conn:conn{{end}},
|
||||
table: {{.table}},
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
server.AddRoutes(
|
||||
{{.routes}} {{.jwt}}{{.signature}} {{.prefix}} {{.timeout}} {{.maxBytes}}
|
||||
)
|
|
@ -0,0 +1,18 @@
|
|||
Name: gateway-example # gateway name
|
||||
Host: localhost # gateway host
|
||||
Port: 8888 # gateway port
|
||||
Upstreams: # upstreams
|
||||
- Grpc: # grpc upstream
|
||||
Target: 0.0.0.0:8080 # grpc target,the direct grpc server address,for only one node
|
||||
# Endpoints: [0.0.0.0:8080,192.168.120.1:8080] # grpc endpoints, the grpc server address list, for multiple nodes
|
||||
# Etcd: # etcd config, if you want to use etcd to discover the grpc server address
|
||||
# Hosts: [127.0.0.1:2378,127.0.0.1:2379] # etcd hosts
|
||||
# Key: greet.grpc # the discovery key
|
||||
# protoset mode
|
||||
ProtoSets:
|
||||
- hello.pb
|
||||
# Mappings can also be written in proto options
|
||||
# Mappings: # routes mapping
|
||||
# - Method: get
|
||||
# Path: /ping
|
||||
# RpcPath: hello.Hello/Ping
|
|
@ -0,0 +1,20 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/gateway"
|
||||
)
|
||||
|
||||
var configFile = flag.String("f", "etc/gateway.yaml", "config file")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c gateway.GatewayConf
|
||||
conf.MustLoad(*configFile, &c)
|
||||
gw := gateway.MustNewServer(c)
|
||||
defer gw.Stop()
|
||||
gw.Start()
|
||||
}
|
|
@ -70,7 +70,7 @@ spec:
|
|||
|
||||
---
|
||||
|
||||
apiVersion: autoscaling/v2beta1
|
||||
apiVersion: autoscaling/v2beta2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: {{.Name}}-hpa-c
|
||||
|
@ -88,11 +88,13 @@ spec:
|
|||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
targetAverageUtilization: 80
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
||||
|
||||
---
|
||||
|
||||
apiVersion: autoscaling/v2beta1
|
||||
apiVersion: autoscaling/v2beta2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: {{.Name}}-hpa-m
|
||||
|
@ -110,4 +112,6 @@ spec:
|
|||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
targetAverageUtilization: 80
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: 80
|
|
@ -1,8 +1,8 @@
|
|||
func (m *default{{.upperStartCamelObject}}Model) formatPrimary(primary interface{}) string {
|
||||
func (m *default{{.upperStartCamelObject}}Model) formatPrimary(primary any) string {
|
||||
return fmt.Sprintf("%s%v", {{.primaryKeyLeft}}, primary)
|
||||
}
|
||||
|
||||
func (m *default{{.upperStartCamelObject}}Model) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error {
|
||||
func (m *default{{.upperStartCamelObject}}Model) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
|
||||
query := fmt.Sprintf("select %s from %s where {{.originalPrimaryField}} = {{if .postgreSql}}$1{{else}}?{{end}} limit 1", {{.lowerStartCamelObject}}Rows, m.table )
|
||||
return conn.QueryRowCtx(ctx, v, query, primary)
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
func (m *default{{.upperStartCamelObject}}Model) FindOneBy{{.upperField}}(ctx context.Context, {{.in}}) (*{{.upperStartCamelObject}}, error) {
|
||||
{{if .withCache}}{{.cacheKey}}
|
||||
var resp {{.upperStartCamelObject}}
|
||||
err := m.QueryRowIndexCtx(ctx, &resp, {{.cacheKeyVariable}}, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) {
|
||||
err := m.QueryRowIndexCtx(ctx, &resp, {{.cacheKeyVariable}}, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v any) (i any, e error) {
|
||||
query := fmt.Sprintf("select %s from %s where {{.originalField}} limit 1", {{.lowerStartCamelObject}}Rows, m.table)
|
||||
if err := conn.QueryRowCtx(ctx, &resp, query, {{.lowerStartCamelField}}); err != nil {
|
||||
return nil, err
|
|
@ -1,7 +1,7 @@
|
|||
func (m *default{{.upperStartCamelObject}}Model) FindOne(ctx context.Context, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) (*{{.upperStartCamelObject}}, error) {
|
||||
{{if .withCache}}{{.cacheKey}}
|
||||
var resp {{.upperStartCamelObject}}
|
||||
err := m.QueryRowCtx(ctx, &resp, {{.cacheKeyVariable}}, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error {
|
||||
err := m.QueryRowCtx(ctx, &resp, {{.cacheKeyVariable}}, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
|
||||
query := fmt.Sprintf("select %s from %s where {{.originalPrimaryKey}} = {{if .postgreSql}}$1{{else}}?{{end}} limit 1", {{.lowerStartCamelObject}}Rows, m.table)
|
||||
return conn.QueryRowCtx(ctx, v, query, {{.lowerStartCamelPrimaryKey}})
|
||||
})
|
|
@ -0,0 +1,7 @@
|
|||
func new{{.upperStartCamelObject}}Model(conn sqlx.SqlConn{{if .withCache}}, c cache.CacheConf, opts ...cache.Option{{end}}) *default{{.upperStartCamelObject}}Model {
|
||||
return &default{{.upperStartCamelObject}}Model{
|
||||
{{if .withCache}}CachedConn: sqlc.NewConn(conn, c, opts...){{else}}conn:conn{{end}},
|
||||
table: {{.table}},
|
||||
}
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ type (
|
|||
// and implement the added methods in custom{{.upperStartCamelObject}}Model.
|
||||
{{.upperStartCamelObject}}Model interface {
|
||||
{{.lowerStartCamelObject}}Model
|
||||
{{if not .withCache}}withSession(session sqlx.Session) {{.upperStartCamelObject}}Model{{end}}
|
||||
}
|
||||
|
||||
custom{{.upperStartCamelObject}}Model struct {
|
||||
|
@ -23,8 +24,15 @@ type (
|
|||
)
|
||||
|
||||
// New{{.upperStartCamelObject}}Model returns a model for the database table.
|
||||
func New{{.upperStartCamelObject}}Model(conn sqlx.SqlConn{{if .withCache}}, c cache.CacheConf{{end}}) {{.upperStartCamelObject}}Model {
|
||||
func New{{.upperStartCamelObject}}Model(conn sqlx.SqlConn{{if .withCache}}, c cache.CacheConf, opts ...cache.Option{{end}}) {{.upperStartCamelObject}}Model {
|
||||
return &custom{{.upperStartCamelObject}}Model{
|
||||
default{{.upperStartCamelObject}}Model: new{{.upperStartCamelObject}}Model(conn{{if .withCache}}, c{{end}}),
|
||||
default{{.upperStartCamelObject}}Model: new{{.upperStartCamelObject}}Model(conn{{if .withCache}}, c, opts...{{end}}),
|
||||
}
|
||||
}
|
||||
|
||||
{{if not .withCache}}
|
||||
func (m *custom{{.upperStartCamelObject}}Model) withSession(session sqlx.Session) {{.upperStartCamelObject}}Model {
|
||||
return New{{.upperStartCamelObject}}Model(sqlx.NewSqlConnFromSession(session))
|
||||
}
|
||||
{{end}}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
syntax = "v1"
|
||||
|
||||
type Request {
|
||||
Name string `path:"name,options=you|me"`
|
||||
}
|
|
@ -62,6 +62,8 @@ type (
|
|||
ListTenant(ctx context.Context, in *TenantInfo, opts ...grpc.CallOption) (*ListTenantResp, error)
|
||||
// applyList 执行任务列表
|
||||
ApplyList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error)
|
||||
// DeleteList 删除任务列表
|
||||
DeleteList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error)
|
||||
}
|
||||
|
||||
defaultParticipantService struct {
|
||||
|
@ -128,3 +130,9 @@ func (m *defaultParticipantService) ApplyList(ctx context.Context, in *ApplyList
|
|||
client := pcmCore.NewParticipantServiceClient(m.cli.Conn())
|
||||
return client.ApplyList(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// DeleteList 删除任务列表
|
||||
func (m *defaultParticipantService) DeleteList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) {
|
||||
client := pcmCore.NewParticipantServiceClient(m.cli.Conn())
|
||||
return client.DeleteList(ctx, in, opts...)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package participantservicelogic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/internal/svc"
|
||||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/pcmCore"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteListLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewDeleteListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteListLogic {
|
||||
return &DeleteListLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteList 删除任务列表
|
||||
func (l *DeleteListLogic) DeleteList(in *pcmCore.ApplyListReq) (*pcmCore.ApplyListResp, error) {
|
||||
result := pcmCore.ApplyListResp{
|
||||
InfoList: make([]*pcmCore.ApplyInfo, 0),
|
||||
}
|
||||
l.svcCtx.DbEngin.Raw("SELECT sppi.`name` as ParticipantName,c.yaml_string as YamlString FROM cloud c,sc_participant_phy_info sppi where c.`status` = 'WaitDelete' and sppi.id = c.participant_id").Scan(&result.InfoList)
|
||||
if len(result.InfoList) != 0 {
|
||||
l.svcCtx.DbEngin.Exec("update cloud set status = ? where status = ?", "Deleted", "WaitDelete")
|
||||
}
|
||||
return &result, nil
|
||||
}
|
|
@ -75,3 +75,9 @@ func (s *ParticipantServiceServer) ApplyList(ctx context.Context, in *pcmCore.Ap
|
|||
l := participantservicelogic.NewApplyListLogic(ctx, s.svcCtx)
|
||||
return l.ApplyList(in)
|
||||
}
|
||||
|
||||
// DeleteList 删除任务列表
|
||||
func (s *ParticipantServiceServer) DeleteList(ctx context.Context, in *pcmCore.ApplyListReq) (*pcmCore.ApplyListResp, error) {
|
||||
l := participantservicelogic.NewDeleteListLogic(ctx, s.svcCtx)
|
||||
return l.DeleteList(in)
|
||||
}
|
||||
|
|
|
@ -326,4 +326,7 @@ service participantService {
|
|||
|
||||
// applyList 执行任务列表
|
||||
rpc applyList(ApplyListReq) returns (ApplyListResp) {};
|
||||
|
||||
// DeleteList 删除任务列表
|
||||
rpc deleteList(ApplyListReq) returns (ApplyListResp) {};
|
||||
}
|
|
@ -3045,7 +3045,7 @@ var file_pb_pcmCore_proto_rawDesc = []byte{
|
|||
0x08, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x14, 0x2e, 0x70, 0x63, 0x6d, 0x43,
|
||||
0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a,
|
||||
0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x4c, 0x69,
|
||||
0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x32, 0xba, 0x05, 0x0a, 0x12, 0x70, 0x61, 0x72, 0x74, 0x69,
|
||||
0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x32, 0xf9, 0x05, 0x0a, 0x12, 0x70, 0x61, 0x72, 0x74, 0x69,
|
||||
0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x50, 0x0a,
|
||||
0x13, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69,
|
||||
0x70, 0x61, 0x6e, 0x74, 0x12, 0x1a, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x50,
|
||||
|
@ -3089,8 +3089,12 @@ var file_pb_pcmCore_proto_rawDesc = []byte{
|
|||
0x73, 0x74, 0x12, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70,
|
||||
0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x70, 0x63, 0x6d, 0x43,
|
||||
0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73,
|
||||
0x70, 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2f, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x62,
|
||||
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x70, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x0a, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x4c, 0x69, 0x73,
|
||||
0x74, 0x12, 0x15, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x6c,
|
||||
0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x16, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f,
|
||||
0x72, 0x65, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70,
|
||||
0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2f, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, 0x65, 0x62, 0x06,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -3168,19 +3172,21 @@ var file_pb_pcmCore_proto_depIdxs = []int32{
|
|||
24, // 25: pcmCore.participantService.registerTenant:input_type -> pcmCore.TenantInfo
|
||||
24, // 26: pcmCore.participantService.listTenant:input_type -> pcmCore.TenantInfo
|
||||
27, // 27: pcmCore.participantService.applyList:input_type -> pcmCore.ApplyListReq
|
||||
6, // 28: pcmCore.pcmCore.SyncInfo:output_type -> pcmCore.SyncInfoResp
|
||||
8, // 29: pcmCore.pcmCore.InfoList:output_type -> pcmCore.InfoListResp
|
||||
12, // 30: pcmCore.participantService.registerParticipant:output_type -> pcmCore.ParticipantPhyResp
|
||||
11, // 31: pcmCore.participantService.reportHeartbeat:output_type -> pcmCore.HealthCheckResp
|
||||
21, // 32: pcmCore.participantService.reportAvailable:output_type -> pcmCore.ParticipantResp
|
||||
22, // 33: pcmCore.participantService.listParticipant:output_type -> pcmCore.ParticipantServiceResp
|
||||
20, // 34: pcmCore.participantService.listPhyAvailable:output_type -> pcmCore.ListParticipantAvailResp
|
||||
13, // 35: pcmCore.participantService.listPhyInformation:output_type -> pcmCore.ListParticipantPhyResp
|
||||
25, // 36: pcmCore.participantService.registerTenant:output_type -> pcmCore.TenantResp
|
||||
26, // 37: pcmCore.participantService.listTenant:output_type -> pcmCore.ListTenantResp
|
||||
28, // 38: pcmCore.participantService.applyList:output_type -> pcmCore.ApplyListResp
|
||||
28, // [28:39] is the sub-list for method output_type
|
||||
17, // [17:28] is the sub-list for method input_type
|
||||
27, // 28: pcmCore.participantService.deleteList:input_type -> pcmCore.ApplyListReq
|
||||
6, // 29: pcmCore.pcmCore.SyncInfo:output_type -> pcmCore.SyncInfoResp
|
||||
8, // 30: pcmCore.pcmCore.InfoList:output_type -> pcmCore.InfoListResp
|
||||
12, // 31: pcmCore.participantService.registerParticipant:output_type -> pcmCore.ParticipantPhyResp
|
||||
11, // 32: pcmCore.participantService.reportHeartbeat:output_type -> pcmCore.HealthCheckResp
|
||||
21, // 33: pcmCore.participantService.reportAvailable:output_type -> pcmCore.ParticipantResp
|
||||
22, // 34: pcmCore.participantService.listParticipant:output_type -> pcmCore.ParticipantServiceResp
|
||||
20, // 35: pcmCore.participantService.listPhyAvailable:output_type -> pcmCore.ListParticipantAvailResp
|
||||
13, // 36: pcmCore.participantService.listPhyInformation:output_type -> pcmCore.ListParticipantPhyResp
|
||||
25, // 37: pcmCore.participantService.registerTenant:output_type -> pcmCore.TenantResp
|
||||
26, // 38: pcmCore.participantService.listTenant:output_type -> pcmCore.ListTenantResp
|
||||
28, // 39: pcmCore.participantService.applyList:output_type -> pcmCore.ApplyListResp
|
||||
28, // 40: pcmCore.participantService.deleteList:output_type -> pcmCore.ApplyListResp
|
||||
29, // [29:41] is the sub-list for method output_type
|
||||
17, // [17:29] is the sub-list for method input_type
|
||||
17, // [17:17] is the sub-list for extension type_name
|
||||
17, // [17:17] is the sub-list for extension extendee
|
||||
0, // [0:17] is the sub-list for field type_name
|
||||
|
|
|
@ -159,6 +159,7 @@ const (
|
|||
ParticipantService_RegisterTenant_FullMethodName = "/pcmCore.participantService/registerTenant"
|
||||
ParticipantService_ListTenant_FullMethodName = "/pcmCore.participantService/listTenant"
|
||||
ParticipantService_ApplyList_FullMethodName = "/pcmCore.participantService/applyList"
|
||||
ParticipantService_DeleteList_FullMethodName = "/pcmCore.participantService/deleteList"
|
||||
)
|
||||
|
||||
// ParticipantServiceClient is the client API for ParticipantService service.
|
||||
|
@ -183,6 +184,8 @@ type ParticipantServiceClient interface {
|
|||
ListTenant(ctx context.Context, in *TenantInfo, opts ...grpc.CallOption) (*ListTenantResp, error)
|
||||
// applyList 执行任务列表
|
||||
ApplyList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error)
|
||||
// DeleteList 删除任务列表
|
||||
DeleteList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error)
|
||||
}
|
||||
|
||||
type participantServiceClient struct {
|
||||
|
@ -274,6 +277,15 @@ func (c *participantServiceClient) ApplyList(ctx context.Context, in *ApplyListR
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *participantServiceClient) DeleteList(ctx context.Context, in *ApplyListReq, opts ...grpc.CallOption) (*ApplyListResp, error) {
|
||||
out := new(ApplyListResp)
|
||||
err := c.cc.Invoke(ctx, ParticipantService_DeleteList_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ParticipantServiceServer is the server API for ParticipantService service.
|
||||
// All implementations must embed UnimplementedParticipantServiceServer
|
||||
// for forward compatibility
|
||||
|
@ -296,6 +308,8 @@ type ParticipantServiceServer interface {
|
|||
ListTenant(context.Context, *TenantInfo) (*ListTenantResp, error)
|
||||
// applyList 执行任务列表
|
||||
ApplyList(context.Context, *ApplyListReq) (*ApplyListResp, error)
|
||||
// DeleteList 删除任务列表
|
||||
DeleteList(context.Context, *ApplyListReq) (*ApplyListResp, error)
|
||||
mustEmbedUnimplementedParticipantServiceServer()
|
||||
}
|
||||
|
||||
|
@ -330,6 +344,9 @@ func (UnimplementedParticipantServiceServer) ListTenant(context.Context, *Tenant
|
|||
func (UnimplementedParticipantServiceServer) ApplyList(context.Context, *ApplyListReq) (*ApplyListResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ApplyList not implemented")
|
||||
}
|
||||
func (UnimplementedParticipantServiceServer) DeleteList(context.Context, *ApplyListReq) (*ApplyListResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteList not implemented")
|
||||
}
|
||||
func (UnimplementedParticipantServiceServer) mustEmbedUnimplementedParticipantServiceServer() {}
|
||||
|
||||
// UnsafeParticipantServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
|
@ -505,6 +522,24 @@ func _ParticipantService_ApplyList_Handler(srv interface{}, ctx context.Context,
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _ParticipantService_DeleteList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ApplyListReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(ParticipantServiceServer).DeleteList(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ParticipantService_DeleteList_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(ParticipantServiceServer).DeleteList(ctx, req.(*ApplyListReq))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// ParticipantService_ServiceDesc is the grpc.ServiceDesc for ParticipantService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
|
@ -548,6 +583,10 @@ var ParticipantService_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "applyList",
|
||||
Handler: _ParticipantService_ApplyList_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "deleteList",
|
||||
Handler: _ParticipantService_DeleteList_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "pb/pcmCore.proto",
|
||||
|
|
Loading…
Reference in New Issue