Browse Source

goctl生成代码

Former-commit-id: db3fe6a903
pull/9/head
zhangwei 2 years ago
parent
commit
5b04bc6f61
11 changed files with 327 additions and 2 deletions
  1. +20
    -0
      api/internal/handler/routes.go
  2. +28
    -0
      api/internal/handler/storelink/deletelinkimagehandler.go
  3. +28
    -0
      api/internal/handler/storelink/deletelinktaskhandler.go
  4. +28
    -0
      api/internal/handler/storelink/getlinktaskhandler.go
  5. +28
    -0
      api/internal/handler/storelink/submitlinktaskhandler.go
  6. +30
    -0
      api/internal/logic/storelink/deletelinkimagelogic.go
  7. +30
    -0
      api/internal/logic/storelink/deletelinktasklogic.go
  8. +30
    -0
      api/internal/logic/storelink/getlinktasklogic.go
  9. +30
    -0
      api/internal/logic/storelink/submitlinktasklogic.go
  10. +1
    -0
      api/internal/pkg/scheduler/scheduler.go
  11. +74
    -2
      api/internal/types/types.go

+ 20
- 0
api/internal/handler/routes.go View File

@@ -472,6 +472,26 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/storelink/getImageList", Path: "/storelink/getImageList",
Handler: storelink.GetLinkImageListHandler(serverCtx), Handler: storelink.GetLinkImageListHandler(serverCtx),
}, },
{
Method: http.MethodDelete,
Path: "/storelink/deleteImageList",
Handler: storelink.DeleteLinkImageHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/storelink/submitLinkTask",
Handler: storelink.SubmitLinkTaskHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/storelink/getLinkTask",
Handler: storelink.GetLinkTaskHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/storelink/deleteLinkTask",
Handler: storelink.DeleteLinkTaskHandler(serverCtx),
},
}, },
rest.WithPrefix("/pcm/v1"), rest.WithPrefix("/pcm/v1"),
) )


+ 28
- 0
api/internal/handler/storelink/deletelinkimagehandler.go View File

@@ -0,0 +1,28 @@
package storelink

import (
"net/http"

"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/storelink"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
)

func DeleteLinkImageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DeleteLinkImageReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := storelink.NewDeleteLinkImageLogic(r.Context(), svcCtx)
resp, err := l.DeleteLinkImage(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

+ 28
- 0
api/internal/handler/storelink/deletelinktaskhandler.go View File

@@ -0,0 +1,28 @@
package storelink

import (
"net/http"

"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/storelink"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
)

func DeleteLinkTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DeleteLinkTaskReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := storelink.NewDeleteLinkTaskLogic(r.Context(), svcCtx)
resp, err := l.DeleteLinkTask(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

+ 28
- 0
api/internal/handler/storelink/getlinktaskhandler.go View File

@@ -0,0 +1,28 @@
package storelink

import (
"net/http"

"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/storelink"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
)

func GetLinkTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetLinkTaskReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := storelink.NewGetLinkTaskLogic(r.Context(), svcCtx)
resp, err := l.GetLinkTask(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

+ 28
- 0
api/internal/handler/storelink/submitlinktaskhandler.go View File

@@ -0,0 +1,28 @@
package storelink

import (
"net/http"

"github.com/zeromicro/go-zero/rest/httpx"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/logic/storelink"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
)

func SubmitLinkTaskHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SubmitLinkTaskReq
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}

l := storelink.NewSubmitLinkTaskLogic(r.Context(), svcCtx)
resp, err := l.SubmitLinkTask(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}

+ 30
- 0
api/internal/logic/storelink/deletelinkimagelogic.go View File

@@ -0,0 +1,30 @@
package storelink

import (
"context"

"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"

"github.com/zeromicro/go-zero/core/logx"
)

type DeleteLinkImageLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}

func NewDeleteLinkImageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLinkImageLogic {
return &DeleteLinkImageLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}

func (l *DeleteLinkImageLogic) DeleteLinkImage(req *types.DeleteLinkImageReq) (resp *types.DeleteLinkImageResp, err error) {
// todo: add your logic here and delete this line

return
}

+ 30
- 0
api/internal/logic/storelink/deletelinktasklogic.go View File

@@ -0,0 +1,30 @@
package storelink

import (
"context"

"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"

"github.com/zeromicro/go-zero/core/logx"
)

type DeleteLinkTaskLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}

func NewDeleteLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteLinkTaskLogic {
return &DeleteLinkTaskLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}

func (l *DeleteLinkTaskLogic) DeleteLinkTask(req *types.DeleteLinkTaskReq) (resp *types.DeleteLinkTaskResp, err error) {
// todo: add your logic here and delete this line

return
}

+ 30
- 0
api/internal/logic/storelink/getlinktasklogic.go View File

@@ -0,0 +1,30 @@
package storelink

import (
"context"

"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"

"github.com/zeromicro/go-zero/core/logx"
)

type GetLinkTaskLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}

func NewGetLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLinkTaskLogic {
return &GetLinkTaskLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}

func (l *GetLinkTaskLogic) GetLinkTask(req *types.GetLinkTaskReq) (resp *types.GetLinkTaskResp, err error) {
// todo: add your logic here and delete this line

return
}

+ 30
- 0
api/internal/logic/storelink/submitlinktasklogic.go View File

@@ -0,0 +1,30 @@
package storelink

import (
"context"

"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"

"github.com/zeromicro/go-zero/core/logx"
)

type SubmitLinkTaskLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}

func NewSubmitLinkTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SubmitLinkTaskLogic {
return &SubmitLinkTaskLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}

func (l *SubmitLinkTaskLogic) SubmitLinkTask(req *types.SubmitLinkTaskReq) (resp *types.SubmitLinkTaskResp, err error) {
// todo: add your logic here and delete this line

return
}

+ 1
- 0
api/internal/pkg/scheduler/scheduler.go View File

@@ -106,6 +106,7 @@ func (s *scheduler) SaveToDb() error {
} }
tx := s.dbEngin.Create(structForDb) tx := s.dbEngin.Create(structForDb)
if tx.Error != nil { if tx.Error != nil {
// todo 保存失败数据
logx.Error(tx.Error) logx.Error(tx.Error)
return tx.Error return tx.Error
} }


+ 74
- 2
api/internal/types/types.go View File

@@ -2721,9 +2721,20 @@ type Cloud struct {
} }


type UploadLinkImageReq struct { type UploadLinkImageReq struct {
PartId int64 `json:"partId"`
FilePath string `json:"filePath"`
} }


type UploadLinkImageImageResp struct {
type UploadLinkImageResp struct {
Success bool `json:"success"`
Image ImageSl `json:"image"`
ErrorMsg string `json:"errorMsg"`
}

type ImageSl struct {
ImageId string `json:"imageId"`
ImageName string `json:"imageName"`
ImageStatus string `json:"imageStatus"`
} }


type GetLinkImageListReq struct { type GetLinkImageListReq struct {
@@ -2731,5 +2742,66 @@ type GetLinkImageListReq struct {
} }


type GetLinkImageListResp struct { type GetLinkImageListResp struct {
ImageIds []int64 `json:"imageIds"`
Success bool `json:"success"`
Images []ImageSl `json:"images"`
ErrorMsg string `json:"errorMsg"`
}

type DeleteLinkImageReq struct {
PartId int64 `json:"partId"`
ImageId string `json:"imageId"`
}

type DeleteLinkImageResp struct {
Success bool `json:"success"`
Image ImageSl `json:"image"`
ErrorMsg string `json:"errorMsg"`
}

type SubmitLinkTaskReq struct {
PartId int64 `json:"partId"`
ImageId string `json:"imageId"`
Cmd string `json:"cmd"`
Envs []EnvSl `json:"envs"`
}

type EnvSl struct {
Key string `json:"key"`
Val string `json:"value"`
}

type SubmitLinkTaskResp struct {
Success bool `json:"success"`
TaskId string `json:"taskId"`
ErrorMsg string `json:"errorMsg"`
}

type GetLinkTaskReq struct {
PartId int64 `json:"partId"`
TaskId string `json:"taskId"`
}

type GetLinkTaskResp struct {
Success bool `json:"success"`
Task TaskSl `json:"task"`
ErrorMsg string `json:"errorMsg"`
}

type DeleteLinkTaskReq struct {
PartId int64 `json:"partId"`
TaskId string `json:"taskId"`
}

type DeleteLinkTaskResp struct {
Success bool `json:"success"`
TaskId string `json:"taskId"`
ErrorMsg string `json:"errorMsg"`
}

type TaskSl struct {
TaskId string `json:"taskId"`
TaskName string `json:"taskName"`
TaskStatus string `json:"taskStatus"`
StartedAt int64 `json:"startedAt"`
CompletedAt int64 `json:"completedAt"`
} }

Loading…
Cancel
Save