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 5.1 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // Code generated by goctl. DO NOT EDIT.
  2. package model
  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. )
  13. var (
  14. hpcFieldNames = builder.RawFieldNames(&Hpc{})
  15. hpcRows = strings.Join(hpcFieldNames, ",")
  16. hpcRowsExpectAutoSet = strings.Join(stringx.Remove(hpcFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
  17. hpcRowsWithPlaceHolder = strings.Join(stringx.Remove(hpcFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
  18. )
  19. type (
  20. hpcModel interface {
  21. Insert(ctx context.Context, data *Hpc) (sql.Result, error)
  22. FindOne(ctx context.Context, id int64) (*Hpc, error)
  23. FindOneByServiceNameName(ctx context.Context, serviceName sql.NullString, name sql.NullString) (*Hpc, error)
  24. Update(ctx context.Context, data *Hpc) error
  25. Delete(ctx context.Context, id int64) error
  26. }
  27. defaultHpcModel struct {
  28. conn sqlx.SqlConn
  29. table string
  30. }
  31. Hpc struct {
  32. Id int64 `db:"id"` // id
  33. TaskId int64 `db:"task_id"` // 任务id
  34. ParticipantId int64 `db:"participant_id"` // 集群静态信息id
  35. JobId string `db:"job_id"` // 作业id
  36. ServiceName string `db:"service_name"` // 服务名称
  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. CreatedBy int64 `db:"created_by"` // 创建人
  43. CreatedTime sql.NullTime `db:"created_time"` // 创建时间
  44. UpdatedBy int64 `db:"updated_by"` // 更新人
  45. UpdatedTime sql.NullTime `db:"updated_time"` // 更新时间
  46. DeletedFlag int64 `db:"deleted_flag"` // 是否删除(0-否,1-是)
  47. WorkDir string `db:"work_dir"`
  48. WallTime string `db:"wall_time"`
  49. Result string `db:"result"`
  50. YamlString string `db:"yaml_string"`
  51. CmdScript string `db:"cmd_script"`
  52. derivedEs string `db:"derived_es"`
  53. cluster string `db:"cluster"`
  54. blockId string `db:"block_id"`
  55. allocNodes uint32 `db:"alloc_nodes"`
  56. allocCpu uint32 `db:"alloc_cpu"`
  57. version string `db:"version"`
  58. account string `db:"account"`
  59. exitCode uint32 `db:"exit_code"`
  60. assocId uint32 `db:"assoc_id"`
  61. }
  62. )
  63. func newHpcModel(conn sqlx.SqlConn) *defaultHpcModel {
  64. return &defaultHpcModel{
  65. conn: conn,
  66. table: "`hpc`",
  67. }
  68. }
  69. func (m *defaultHpcModel) Delete(ctx context.Context, id int64) error {
  70. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  71. _, err := m.conn.ExecCtx(ctx, query, id)
  72. return err
  73. }
  74. func (m *defaultHpcModel) FindOne(ctx context.Context, id int64) (*Hpc, error) {
  75. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", hpcRows, m.table)
  76. var resp Hpc
  77. err := m.conn.QueryRowCtx(ctx, &resp, query, id)
  78. switch err {
  79. case nil:
  80. return &resp, nil
  81. case sqlc.ErrNotFound:
  82. return nil, ErrNotFound
  83. default:
  84. return nil, err
  85. }
  86. }
  87. func (m *defaultHpcModel) FindOneByServiceNameName(ctx context.Context, serviceName sql.NullString, name sql.NullString) (*Hpc, error) {
  88. var resp Hpc
  89. query := fmt.Sprintf("select %s from %s where `service_name` = ? and `name` = ? limit 1", hpcRows, m.table)
  90. err := m.conn.QueryRowCtx(ctx, &resp, query, serviceName, name)
  91. switch err {
  92. case nil:
  93. return &resp, nil
  94. case sqlc.ErrNotFound:
  95. return nil, ErrNotFound
  96. default:
  97. return nil, err
  98. }
  99. }
  100. func (m *defaultHpcModel) Insert(ctx context.Context, data *Hpc) (sql.Result, error) {
  101. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, hpcRowsExpectAutoSet)
  102. ret, err := m.conn.ExecCtx(ctx, query, data.TaskId, data.JobId, data.ServiceName, data.Name, data.Status, data.StartTime, data.RunningTime, data.CardCount, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime, data.DeletedFlag, data.WorkDir, data.WallTime, data.Result, data.YamlString)
  103. return ret, err
  104. }
  105. func (m *defaultHpcModel) Update(ctx context.Context, newData *Hpc) error {
  106. query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, hpcRowsWithPlaceHolder)
  107. _, err := m.conn.ExecCtx(ctx, query, newData.TaskId, newData.JobId, newData.ServiceName, newData.Name, newData.Status, newData.StartTime, newData.RunningTime, newData.CardCount, newData.CreatedBy, newData.CreatedTime, newData.UpdatedBy, newData.UpdatedTime, newData.DeletedFlag, newData.WorkDir, newData.WallTime, newData.Result, newData.YamlString, newData.Id)
  108. return err
  109. }
  110. func (m *defaultHpcModel) tableName() string {
  111. return m.table
  112. }

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.