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.

taskvmmodel_gen.go 4.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. )
  13. var (
  14. taskVmFieldNames = builder.RawFieldNames(&TaskVm{})
  15. taskVmRows = strings.Join(taskVmFieldNames, ",")
  16. taskVmRowsExpectAutoSet = strings.Join(stringx.Remove(taskVmFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
  17. taskVmRowsWithPlaceHolder = strings.Join(stringx.Remove(taskVmFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
  18. )
  19. type (
  20. taskVmModel interface {
  21. Insert(ctx context.Context, data *TaskVm) (sql.Result, error)
  22. FindOne(ctx context.Context, id int64) (*TaskVm, error)
  23. Update(ctx context.Context, data *TaskVm) error
  24. Delete(ctx context.Context, id int64) error
  25. }
  26. defaultTaskVmModel struct {
  27. conn sqlx.SqlConn
  28. table string
  29. }
  30. TaskVm struct {
  31. Id int64 `db:"id"` // id
  32. ParticipantId int64 `db:"participant_id"` // p端id
  33. TaskId int64 `db:"task_id"` // 任务id
  34. Name string `db:"name"` // 虚拟机名称
  35. AdapterId int64 `db:"adapter_id"` // 执行任务的适配器id
  36. ClusterId int64 `db:"cluster_id"` // 执行任务的集群id
  37. FlavorRef string `db:"flavor_ref"` // 规格索引
  38. ImageRef string `db:"image_ref"` // 镜像索引
  39. Status string `db:"status"` // 状态
  40. Platform string `db:"platform"` // 平台
  41. Description string `db:"description"` // 描述
  42. AvailabilityZone string `db:"availability_zone"`
  43. MinCount int64 `db:"min_count"` // 数量
  44. Uuid string `db:"uuid"` // 网络id
  45. StartTime string `db:"start_time"` // 开始时间
  46. RunningTime string `db:"running_time"` // 运行时间
  47. Result string `db:"result"` // 运行结果
  48. DeletedAt string `db:"deleted_at"` // 删除时间
  49. }
  50. )
  51. func newTaskVmModel(conn sqlx.SqlConn) *defaultTaskVmModel {
  52. return &defaultTaskVmModel{
  53. conn: conn,
  54. table: "`task_vm`",
  55. }
  56. }
  57. func (m *defaultTaskVmModel) withSession(session sqlx.Session) *defaultTaskVmModel {
  58. return &defaultTaskVmModel{
  59. conn: sqlx.NewSqlConnFromSession(session),
  60. table: "`task_vm`",
  61. }
  62. }
  63. func (m *defaultTaskVmModel) Delete(ctx context.Context, id int64) error {
  64. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  65. _, err := m.conn.ExecCtx(ctx, query, id)
  66. return err
  67. }
  68. func (m *defaultTaskVmModel) FindOne(ctx context.Context, id int64) (*TaskVm, error) {
  69. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", taskVmRows, m.table)
  70. var resp TaskVm
  71. err := m.conn.QueryRowCtx(ctx, &resp, query, id)
  72. switch err {
  73. case nil:
  74. return &resp, nil
  75. case sqlc.ErrNotFound:
  76. return nil, ErrNotFound
  77. default:
  78. return nil, err
  79. }
  80. }
  81. func (m *defaultTaskVmModel) Insert(ctx context.Context, data *TaskVm) (sql.Result, error) {
  82. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, taskVmRowsExpectAutoSet)
  83. ret, err := m.conn.ExecCtx(ctx, query, data.ParticipantId, data.TaskId, data.Name, data.AdapterId, data.ClusterId, data.FlavorRef, data.ImageRef, data.Status, data.Platform, data.Description, data.AvailabilityZone, data.MinCount, data.Uuid, data.StartTime, data.RunningTime, data.Result, data.DeletedAt)
  84. return ret, err
  85. }
  86. func (m *defaultTaskVmModel) Update(ctx context.Context, data *TaskVm) error {
  87. query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, taskVmRowsWithPlaceHolder)
  88. _, err := m.conn.ExecCtx(ctx, query, data.ParticipantId, data.TaskId, data.Name, data.AdapterId, data.ClusterId, data.FlavorRef, data.ImageRef, data.Status, data.Platform, data.Description, data.AvailabilityZone, data.MinCount, data.Uuid, data.StartTime, data.RunningTime, data.Result, data.DeletedAt, data.Id)
  89. return err
  90. }
  91. func (m *defaultTaskVmModel) tableName() string {
  92. return m.table
  93. }

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.