You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

hpcmodel_gen.go 4.1 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // Code generated by goctl. DO NOT EDIT.
  2. package models
  3. import (
  4. "context"
  5. "database/sql"
  6. "fmt"
  7. "strings"
  8. "github.com/zeromicro/go-zero/core/stores/builder"
  9. "github.com/zeromicro/go-zero/core/stores/sqlc"
  10. "github.com/zeromicro/go-zero/core/stores/sqlx"
  11. "github.com/zeromicro/go-zero/core/stringx"
  12. "gorm.io/datatypes"
  13. )
  14. var (
  15. hpcFieldNames = builder.RawFieldNames(&Hpc{})
  16. hpcRows = strings.Join(hpcFieldNames, ",")
  17. hpcRowsExpectAutoSet = strings.Join(stringx.Remove(hpcFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
  18. hpcRowsWithPlaceHolder = strings.Join(stringx.Remove(hpcFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
  19. )
  20. type (
  21. hpcModel interface {
  22. Insert(ctx context.Context, data *Hpc) (sql.Result, error)
  23. FindOne(ctx context.Context, id int64) (*Hpc, error)
  24. FindOneByServiceNameName(ctx context.Context, serviceName sql.NullString, name sql.NullString) (*Hpc, error)
  25. Update(ctx context.Context, data *Hpc) error
  26. Delete(ctx context.Context, id int64) error
  27. }
  28. defaultHpcModel struct {
  29. conn sqlx.SqlConn
  30. table string
  31. }
  32. Hpc struct {
  33. Id int64 `db:"id"` // id
  34. TaskId int64 `db:"task_id"` // 任务id
  35. ParticipantId int64 `db:"participant_id"` // 集群静态信息id
  36. JobId string `db:"job_id"` // 作业id
  37. Name string `db:"name"` // 名称
  38. Status string `db:"status"` // 状态
  39. StartTime string `db:"start_time"` // 开始时间
  40. RunningTime int64 `db:"running_time"` // 运行时间
  41. CardCount int64 `db:"card_count"` // 卡数
  42. WorkDir string `db:"work_dir"` // 工作目录
  43. WallTime string `db:"wall_time"` // 最大运行时长
  44. Result string `db:"result"` // 运行结果
  45. YamlString string `db:"yaml_string"`
  46. CmdScript string `db:"cmd_script"`
  47. //DerivedEs string `db:"derived_es"`
  48. //Cluster string `db:"cluster"`
  49. //BlockId string `db:"block_id"`
  50. //AllocNodes uint32 `db:"alloc_nodes"`
  51. //AllocCpu uint32 `db:"alloc_cpu"`
  52. //Version string `db:"version"`
  53. //Account string `db:"account"`
  54. //ExitCode uint32 `db:"exit_code"`
  55. //AssocId uint32 `db:"assoc_id"`
  56. AppType string `db:"app_type"`
  57. AppName string `db:"app_name"`
  58. Queue string `db:"queue"`
  59. SubmitType string `db:"submit_type"`
  60. NNode string `db:"n_node"`
  61. StdOutFile string `db:"std_out_file"`
  62. StdErrFile string `db:"std_err_file"`
  63. StdInput string `db:"std_input"`
  64. //Environment map[string]string `gorm:"type:json;column:environment"`
  65. Environment datatypes.JSON `gorm:"type:json"`
  66. }
  67. )
  68. func newHpcModel(conn sqlx.SqlConn) *defaultHpcModel {
  69. return &defaultHpcModel{
  70. conn: conn,
  71. table: "`hpc`",
  72. }
  73. }
  74. func (m *defaultHpcModel) Delete(ctx context.Context, id int64) error {
  75. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  76. _, err := m.conn.ExecCtx(ctx, query, id)
  77. return err
  78. }
  79. func (m *defaultHpcModel) FindOne(ctx context.Context, id int64) (*Hpc, error) {
  80. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", hpcRows, m.table)
  81. var resp Hpc
  82. err := m.conn.QueryRowCtx(ctx, &resp, query, id)
  83. switch err {
  84. case nil:
  85. return &resp, nil
  86. case sqlc.ErrNotFound:
  87. return nil, ErrNotFound
  88. default:
  89. return nil, err
  90. }
  91. }
  92. func (m *defaultHpcModel) FindOneByServiceNameName(ctx context.Context, serviceName sql.NullString, name sql.NullString) (*Hpc, error) {
  93. var resp Hpc
  94. query := fmt.Sprintf("select %s from %s where `service_name` = ? and `name` = ? limit 1", hpcRows, m.table)
  95. err := m.conn.QueryRowCtx(ctx, &resp, query, serviceName, name)
  96. switch err {
  97. case nil:
  98. return &resp, nil
  99. case sqlc.ErrNotFound:
  100. return nil, ErrNotFound
  101. default:
  102. return nil, err
  103. }
  104. }
  105. func (m *defaultHpcModel) tableName() string {
  106. return m.table
  107. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.