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.

aimodel_gen.go 3.9 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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. aiFieldNames = builder.RawFieldNames(&Ai{})
  15. aiRows = strings.Join(aiFieldNames, ",")
  16. aiRowsExpectAutoSet = strings.Join(stringx.Remove(aiFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
  17. aiRowsWithPlaceHolder = strings.Join(stringx.Remove(aiFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
  18. )
  19. type (
  20. aiModel interface {
  21. Insert(ctx context.Context, data *Ai) (sql.Result, error)
  22. FindOne(ctx context.Context, id int64) (*Ai, error)
  23. FindOneByServiceNameProjectIdName(ctx context.Context, serviceName sql.NullString, projectId sql.NullString, name sql.NullString) (*Ai, error)
  24. Update(ctx context.Context, data *Ai) error
  25. Delete(ctx context.Context, id int64) error
  26. }
  27. defaultAiModel struct {
  28. conn sqlx.SqlConn
  29. table string
  30. }
  31. Ai struct {
  32. Id int64 `db:"id"` // id
  33. TaskId int64 `db:"task_id"` // 任务id
  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. ProjectId string `db:"project_id"` // 项目id
  39. Name string `db:"name"` // 名称
  40. Status string `db:"status"` // 状态
  41. StartTime string `db:"start_time"` // 开始时间
  42. RunningTime int64 `db:"running_time"` // 运行时间
  43. CreatedBy int64 `db:"created_by"` // 创建人
  44. CreatedTime sql.NullTime `db:"created_time"` // 创建时间
  45. UpdatedBy int64 `db:"updated_by"` // 更新人
  46. UpdatedTime sql.NullTime `db:"updated_time"` // 更新时间
  47. DeletedFlag int64 `db:"deleted_flag"` // 是否删除(0-否,1-是)
  48. Result string `db:"result"`
  49. YamlString string `db:"yaml_string"`
  50. JobId string `db:"job_id"`
  51. Command string `db:"command"`
  52. FlavorId string `db:"flavor_id"`
  53. ImageUrl string `db:"image_url"`
  54. SubscriptionId string `db:"subscription_id"`
  55. ItemVersionId string `db:"itemVersion_id"`
  56. }
  57. )
  58. func newAiModel(conn sqlx.SqlConn) *defaultAiModel {
  59. return &defaultAiModel{
  60. conn: conn,
  61. table: "`ai`",
  62. }
  63. }
  64. func (m *defaultAiModel) Delete(ctx context.Context, id int64) error {
  65. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  66. _, err := m.conn.ExecCtx(ctx, query, id)
  67. return err
  68. }
  69. func (m *defaultAiModel) FindOne(ctx context.Context, id int64) (*Ai, error) {
  70. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", aiRows, m.table)
  71. var resp Ai
  72. err := m.conn.QueryRowCtx(ctx, &resp, query, id)
  73. switch err {
  74. case nil:
  75. return &resp, nil
  76. case sqlc.ErrNotFound:
  77. return nil, ErrNotFound
  78. default:
  79. return nil, err
  80. }
  81. }
  82. func (m *defaultAiModel) FindOneByServiceNameProjectIdName(ctx context.Context, serviceName sql.NullString, projectId sql.NullString, name sql.NullString) (*Ai, error) {
  83. var resp Ai
  84. query := fmt.Sprintf("select %s from %s where `service_name` = ? and `project_id` = ? and `name` = ? limit 1", aiRows, m.table)
  85. err := m.conn.QueryRowCtx(ctx, &resp, query, serviceName, projectId, name)
  86. switch err {
  87. case nil:
  88. return &resp, nil
  89. case sqlc.ErrNotFound:
  90. return nil, ErrNotFound
  91. default:
  92. return nil, err
  93. }
  94. }
  95. func (m *defaultAiModel) tableName() string {
  96. return m.table
  97. }

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.