forked from JointCloud/pcm-coordinator
114 lines
4.3 KiB
Go
114 lines
4.3 KiB
Go
// Code generated by goctl. DO NOT EDIT.
|
||
|
||
package models
|
||
|
||
import (
|
||
"context"
|
||
"database/sql"
|
||
"fmt"
|
||
"strings"
|
||
"time"
|
||
|
||
"github.com/zeromicro/go-zero/core/stores/builder"
|
||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||
"github.com/zeromicro/go-zero/core/stringx"
|
||
)
|
||
|
||
var (
|
||
taskHpcFieldNames = builder.RawFieldNames(&TaskHpc{})
|
||
taskHpcRows = strings.Join(taskHpcFieldNames, ",")
|
||
taskHpcRowsExpectAutoSet = strings.Join(stringx.Remove(taskHpcFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
|
||
taskHpcRowsWithPlaceHolder = strings.Join(stringx.Remove(taskHpcFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
|
||
)
|
||
|
||
type (
|
||
taskHpcModel interface {
|
||
Insert(ctx context.Context, data *TaskHpc) (sql.Result, error)
|
||
FindOne(ctx context.Context, id int64) (*TaskHpc, error)
|
||
Update(ctx context.Context, data *TaskHpc) error
|
||
Delete(ctx context.Context, id int64) error
|
||
}
|
||
|
||
defaultTaskHpcModel struct {
|
||
conn sqlx.SqlConn
|
||
table string
|
||
}
|
||
|
||
TaskHpc struct {
|
||
Id int64 `db:"id"` // id
|
||
TaskId int64 `db:"task_id"` // 任务id
|
||
JobId string `db:"job_id"` // 作业id(在第三方系统中的作业id)
|
||
AdapterId int64 `db:"adapter_d"` // 适配器id
|
||
AdapterName string `db:"adapter_name"` //适配器名称
|
||
ClusterId int64 `db:"cluster_id"` //集群id
|
||
ClusterName string `db:"cluster_name"` //集群名称
|
||
Name string `db:"name"` // 名称
|
||
Status string `db:"status"` // 状态
|
||
CmdScript string `db:"cmd_script"`
|
||
StartTime string `db:"start_time"` // 开始时间
|
||
RunningTime int64 `db:"running_time"` // 运行时间
|
||
DerivedEs string `db:"derived_es"`
|
||
Cluster string `db:"cluster"`
|
||
BlockId int64 `db:"block_id"`
|
||
AllocNodes int64 `db:"alloc_nodes"`
|
||
AllocCpu int64 `db:"alloc_cpu"`
|
||
CardCount int64 `db:"card_count"` // 卡数
|
||
Version string `db:"version"`
|
||
Account string `db:"account"`
|
||
WorkDir string `db:"work_dir"` // 工作路径
|
||
AssocId int64 `db:"assoc_id"`
|
||
ExitCode int64 `db:"exit_code"`
|
||
WallTime string `db:"wall_time"` // 最大运行时间
|
||
Result string `db:"result"` // 运行结果
|
||
DeletedAt sql.NullTime `db:"deleted_at"` // 删除时间
|
||
YamlString string `db:"yaml_string"`
|
||
AppType string `db:"app_type"` // 应用类型
|
||
AppName string `db:"app_name"` // 应用名称
|
||
Queue string `db:"queue"` // 队列名称
|
||
SubmitType string `db:"submit_type"` // cmd(命令行模式)
|
||
NNode string `db:"n_node"` // 节点个数(当指定该参数时,GAP_NODE_STRING必须为"")
|
||
StdOutFile string `db:"std_out_file"` // 工作路径/std.err.%j
|
||
StdErrFile string `db:"std_err_file"` // 工作路径/std.err.%j
|
||
StdInput string `db:"std_input"`
|
||
Partition string `db:"partition"`
|
||
DeletedFlag int64 `db:"deleted_flag"` // 是否删除(0-否,1-是)
|
||
CreatedBy int64 `db:"created_by"` // 创建人
|
||
CreatedTime time.Time `db:"created_time"` // 创建时间
|
||
UpdatedBy int64 `db:"updated_by"` // 更新人
|
||
UpdatedTime time.Time `db:"updated_time"` // 更新时间
|
||
|
||
}
|
||
)
|
||
|
||
func newTaskHpcModel(conn sqlx.SqlConn) *defaultTaskHpcModel {
|
||
return &defaultTaskHpcModel{
|
||
conn: conn,
|
||
table: "`task_hpc`",
|
||
}
|
||
}
|
||
|
||
func (m *defaultTaskHpcModel) Delete(ctx context.Context, id int64) error {
|
||
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||
_, err := m.conn.ExecCtx(ctx, query, id)
|
||
return err
|
||
}
|
||
|
||
func (m *defaultTaskHpcModel) FindOne(ctx context.Context, id int64) (*TaskHpc, error) {
|
||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", taskHpcRows, m.table)
|
||
var resp TaskHpc
|
||
err := m.conn.QueryRowCtx(ctx, &resp, query, id)
|
||
switch err {
|
||
case nil:
|
||
return &resp, nil
|
||
case sqlc.ErrNotFound:
|
||
return nil, ErrNotFound
|
||
default:
|
||
return nil, err
|
||
}
|
||
}
|
||
|
||
func (m *defaultTaskHpcModel) tableName() string {
|
||
return m.table
|
||
}
|