Browse Source

容器删除

pull/540/head
zhangwei 2 months ago
parent
commit
a4bf41dae1
1 changed files with 7 additions and 10 deletions
  1. +7
    -10
      internal/logic/cloud/containerdeletelogic.go

+ 7
- 10
internal/logic/cloud/containerdeletelogic.go View File

@@ -17,13 +17,11 @@ package cloud
import (
"context"
"errors"
"fmt"
"github.com/zeromicro/go-zero/core/logx"
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
container "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types/cloud"
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
"net/http"
"strconv"
)

type ContainerDeleteLogic struct {
@@ -41,7 +39,11 @@ func NewContainerDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *C
}

func (l *ContainerDeleteLogic) ContainerDelete(req *container.DeleteParam) (resp interface{}, err error) {

taskCloud := models.TaskCloud{}
l.svcCtx.DbEngin.Model(models.TaskAi{}).Where("id", req.Id).Scan(&taskCloud)
if taskCloud.Name == "" {
return nil, errors.New("任务不存在")
}
create, err := l.svcCtx.Cloud.ContainerDelete(req.ClusterId, req)
if err != nil {
return nil, err
@@ -49,12 +51,7 @@ func (l *ContainerDeleteLogic) ContainerDelete(req *container.DeleteParam) (resp
if create.Code != http.StatusOK {
return nil, errors.New(create.Message)
}
resp = create.Data
id, err := strconv.ParseInt(req.Id, 10, 64)
tx := l.svcCtx.DbEngin.Delete(&models.TaskCloud{}, id)
if tx.Error != nil {
fmt.Println()
return nil, tx.Error
}
taskCloud.Status = "Deleted"
l.svcCtx.DbEngin.Updates(taskCloud)
return
}

Loading…
Cancel
Save