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.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. TaskId int64 `db:"task_id"` // 任务id
  33. Name string `db:"name"` // 任务名称
  34. AdapterId int64 `db:"adapter_id"` // 执行任务的适配器id
  35. AdapterName string `db:"adapter_name"` // 适配器名称
  36. ClusterId int64 `db:"cluster_id"` // 执行任务的集群id
  37. ClusterName string `db:"cluster_name"` // 集群名称
  38. FlavorRef string `db:"flavor_ref"` // 规格索引
  39. ImageRef string `db:"image_ref"` // 镜像索引
  40. Status string `db:"status"` // 状态
  41. Platform string `db:"platform"` // 平台
  42. MinCount int64 `db:"min_count"` // 数量
  43. Uuid string `db:"uuid"` // 网络id
  44. StartTime string `db:"start_time"` // 开始时间
  45. RunningTime string `db:"running_time"` // 运行时间
  46. Result string `db:"result"` // 运行结果
  47. Remark string `db:"remark"` // 备注
  48. DeletedAt string `db:"deleted_at"` // 删除时间
  49. VmName string `db:"vm_name"` // 虚拟机名称
  50. Replicas int64 `db:"replicas"` // 副本数
  51. ServerId string `db:"server_id"` // 虚拟机id
  52. }
  53. )
  54. func newTaskVmModel(conn sqlx.SqlConn) *defaultTaskVmModel {
  55. return &defaultTaskVmModel{
  56. conn: conn,
  57. table: "`task_vm`",
  58. }
  59. }
  60. func (m *defaultTaskVmModel) withSession(session sqlx.Session) *defaultTaskVmModel {
  61. return &defaultTaskVmModel{
  62. conn: sqlx.NewSqlConnFromSession(session),
  63. table: "`task_vm`",
  64. }
  65. }
  66. func (m *defaultTaskVmModel) Delete(ctx context.Context, id int64) error {
  67. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  68. _, err := m.conn.ExecCtx(ctx, query, id)
  69. return err
  70. }
  71. func (m *defaultTaskVmModel) FindOne(ctx context.Context, id int64) (*TaskVm, error) {
  72. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", taskVmRows, m.table)
  73. var resp TaskVm
  74. err := m.conn.QueryRowCtx(ctx, &resp, query, id)
  75. switch err {
  76. case nil:
  77. return &resp, nil
  78. case sqlc.ErrNotFound:
  79. return nil, ErrNotFound
  80. default:
  81. return nil, err
  82. }
  83. }
  84. func (m *defaultTaskVmModel) Insert(ctx context.Context, data *TaskVm) (sql.Result, error) {
  85. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, taskVmRowsExpectAutoSet)
  86. ret, err := m.conn.ExecCtx(ctx, query, data.TaskId, data.Name, data.AdapterId, data.AdapterName, data.ClusterId, data.ClusterName, data.FlavorRef, data.ImageRef, data.Status, data.Platform, data.MinCount, data.Uuid, data.StartTime, data.RunningTime, data.Result, data.Remark, data.DeletedAt, data.VmName, data.Replicas, data.ServerId)
  87. return ret, err
  88. }
  89. func (m *defaultTaskVmModel) Update(ctx context.Context, data *TaskVm) error {
  90. query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, taskVmRowsWithPlaceHolder)
  91. _, err := m.conn.ExecCtx(ctx, query, data.TaskId, data.Name, data.AdapterId, data.AdapterName, data.ClusterId, data.ClusterName, data.FlavorRef, data.ImageRef, data.Status, data.Platform, data.MinCount, data.Uuid, data.StartTime, data.RunningTime, data.Result, data.Remark, data.DeletedAt, data.VmName, data.Replicas, data.ServerId, data.Id)
  92. return err
  93. }
  94. func (m *defaultTaskVmModel) tableName() string {
  95. return m.table
  96. }

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.