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

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

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.