model层添加delete_at

Former-commit-id: 0a598defa8565e0f0cf63fc0e14d14fa141cfd40
This commit is contained in:
zhangwei 2023-09-15 15:01:35 +08:00
parent a91b93ad73
commit 65b8f21dd7
5 changed files with 36 additions and 42 deletions

View File

@ -25,10 +25,15 @@ func NewDeleteTaskLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Delete
}
func (l *DeleteTaskLogic) DeleteTask(req *types.DeleteTaskReq) error {
// todo: add your logic here and delete this line
// 删除主任务信息
tx := l.svcCtx.DbEngin.Delete(&model.Task{}, req.Id)
if tx.Error != nil {
return tx.Error
}
// 将子任务信息修改为待删除
tx = l.svcCtx.DbEngin.Model(&model.Task{}).Where("task_id", req.Id).Update("status", "WaitDelete")
if tx.Error != nil {
return tx.Error
}
return nil
}

View File

@ -1,13 +0,0 @@
package model
type (
// CloudModel is an interface to be customized, add more methods here,
// and implement the added methods in customCloudModel.
CloudModel interface {
cloudModel
}
customCloudModel struct {
*defaultCloudModel
}
)

View File

@ -5,6 +5,7 @@ package model
import (
"context"
"database/sql"
"gorm.io/gorm"
"strings"
"github.com/zeromicro/go-zero/core/stores/builder"
@ -34,19 +35,19 @@ 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"` // 运行时长
DeletedFlag int64 `db:"deleted_flag"` // 是否删除0-否1-是)
YamlString string `db:"yaml_string"`
Result string `db:"result"` // 运行结果
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"` // 运行结果
}
)

View File

@ -5,6 +5,7 @@ package model
import (
"context"
"database/sql"
"gorm.io/gorm"
"strings"
"time"
@ -34,18 +35,18 @@ type (
}
Task struct {
Id int64 `db:"id"` // id
Name string `db:"name"` // 作业名称
Description string `db:"description"` // 作业描述
Status string `db:"status"` // 作业状态
Strategy int64 `db:"strategy"` // 策略
SynergyStatus int64 `db:"synergy_status"` // 协同状态0-未协同、1-已协同)
StartTime time.Time `db:"start_time"` // 开始运行时间
EndTime string `db:"end_time"` // 结束运行时间
RunningTime int64 `db:"running_time"` // 已运行时间(单位秒)
YamlString string `db:"yaml_string"`
Result string `db:"result"` // 作业结果
Deleted_flag int64 `gorm:"softDelete:flag"`
Id int64 `db:"id"` // id
Name string `db:"name"` // 作业名称
Description string `db:"description"` // 作业描述
Status string `db:"status"` // 作业状态
Strategy int64 `db:"strategy"` // 策略
SynergyStatus int64 `db:"synergy_status"` // 协同状态0-未协同、1-已协同)
StartTime time.Time `db:"start_time"` // 开始运行时间
EndTime string `db:"end_time"` // 结束运行时间
RunningTime int64 `db:"running_time"` // 已运行时间(单位秒)
YamlString string `db:"yaml_string"`
Result string `db:"result"` // 作业结果
DeletedAt gorm.DeletedAt `gorm:"index"`
}
)

View File

@ -31,7 +31,7 @@ func (l *InfoListLogic) InfoList(in *pcmCore.InfoListReq) (*pcmCore.InfoListResp
switch in.Kind {
case "hpc":
var hpcModelList []model.Hpc
tx := l.svcCtx.DbEngin.Where("participant_id = ? AND status NOT IN ?", in.ParticipantId, []string{"Succeed", "Completed"}).Find(&hpcModelList)
tx := l.svcCtx.DbEngin.Where("participant_id = ? AND status NOT IN ?", in.ParticipantId, []string{"Deleted", "Succeed", "Completed"}).Find(&hpcModelList)
if tx.Error != nil {
return nil, tx.Error
}
@ -40,7 +40,7 @@ func (l *InfoListLogic) InfoList(in *pcmCore.InfoListReq) (*pcmCore.InfoListResp
result.HpcInfoList = hpcInfoList
case "cloud":
var cloudModelList []model.Cloud
tx := l.svcCtx.DbEngin.Where("participant_id = ? AND status NOT IN ?", in.ParticipantId, []string{"Succeed", "Completed"}).Find(&cloudModelList)
tx := l.svcCtx.DbEngin.Where("participant_id = ? AND status NOT IN ?", in.ParticipantId, []string{"Deleted", "Succeed", "Completed"}).Find(&cloudModelList)
if tx.Error != nil {
return nil, tx.Error
}
@ -49,7 +49,7 @@ func (l *InfoListLogic) InfoList(in *pcmCore.InfoListReq) (*pcmCore.InfoListResp
result.CloudInfoList = cloudInfoList
case "ai":
var aiModelList []model.Ai
tx := l.svcCtx.DbEngin.Where("participant_id = ? AND status NOT IN ?", in.ParticipantId, []string{"Succeed", "Completed"}).Find(&aiModelList)
tx := l.svcCtx.DbEngin.Where("participant_id = ? AND status NOT IN ?", in.ParticipantId, []string{"Deleted", "Succeed", "Completed"}).Find(&aiModelList)
if tx.Error != nil {
return nil, tx.Error
}