|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- // Code generated by goctl. DO NOT EDIT.
-
- package models
-
- import (
- "context"
- "database/sql"
- "fmt"
- "strings"
-
- "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"
- "gorm.io/datatypes"
- )
-
- var (
- hpcFieldNames = builder.RawFieldNames(&Hpc{})
- hpcRows = strings.Join(hpcFieldNames, ",")
- hpcRowsExpectAutoSet = strings.Join(stringx.Remove(hpcFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
- hpcRowsWithPlaceHolder = strings.Join(stringx.Remove(hpcFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
- )
-
- type (
- hpcModel interface {
- Insert(ctx context.Context, data *Hpc) (sql.Result, error)
- FindOne(ctx context.Context, id int64) (*Hpc, error)
- FindOneByServiceNameName(ctx context.Context, serviceName sql.NullString, name sql.NullString) (*Hpc, error)
- Update(ctx context.Context, data *Hpc) error
- Delete(ctx context.Context, id int64) error
- }
-
- defaultHpcModel struct {
- conn sqlx.SqlConn
- table string
- }
-
- Hpc struct {
- Id int64 `db:"id"` // id
- TaskId int64 `db:"task_id"` // 任务id
- ParticipantId int64 `db:"participant_id"` // 集群静态信息id
- JobId string `db:"job_id"` // 作业id
- Name string `db:"name"` // 名称
- Status string `db:"status"` // 状态
- StartTime string `db:"start_time"` // 开始时间
- RunningTime int64 `db:"running_time"` // 运行时间
- CardCount int64 `db:"card_count"` // 卡数
- WorkDir string `db:"work_dir"` // 工作目录
- WallTime string `db:"wall_time"` // 最大运行时长
- Result string `db:"result"` // 运行结果
- YamlString string `db:"yaml_string"`
- CmdScript string `db:"cmd_script"`
- //DerivedEs string `db:"derived_es"`
- //Cluster string `db:"cluster"`
- //BlockId string `db:"block_id"`
- //AllocNodes uint32 `db:"alloc_nodes"`
- //AllocCpu uint32 `db:"alloc_cpu"`
- //Version string `db:"version"`
- //Account string `db:"account"`
- //ExitCode uint32 `db:"exit_code"`
- //AssocId uint32 `db:"assoc_id"`
- AppType string `db:"app_type"`
- AppName string `db:"app_name"`
- Queue string `db:"queue"`
- SubmitType string `db:"submit_type"`
- NNode string `db:"n_node"`
- StdOutFile string `db:"std_out_file"`
- StdErrFile string `db:"std_err_file"`
- StdInput string `db:"std_input"`
- //Environment map[string]string `gorm:"type:json;column:environment"`
- Environment datatypes.JSON `gorm:"type:json"`
- }
- )
-
- func newHpcModel(conn sqlx.SqlConn) *defaultHpcModel {
- return &defaultHpcModel{
- conn: conn,
- table: "`hpc`",
- }
- }
-
- func (m *defaultHpcModel) 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 *defaultHpcModel) FindOne(ctx context.Context, id int64) (*Hpc, error) {
- query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", hpcRows, m.table)
- var resp Hpc
- 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 *defaultHpcModel) FindOneByServiceNameName(ctx context.Context, serviceName sql.NullString, name sql.NullString) (*Hpc, error) {
- var resp Hpc
- query := fmt.Sprintf("select %s from %s where `service_name` = ? and `name` = ? limit 1", hpcRows, m.table)
- err := m.conn.QueryRowCtx(ctx, &resp, query, serviceName, name)
- switch err {
- case nil:
- return &resp, nil
- case sqlc.ErrNotFound:
- return nil, ErrNotFound
- default:
- return nil, err
- }
- }
-
- func (m *defaultHpcModel) tableName() string {
- return m.table
- }
|