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.

hpcinstancecentermodel_gen.go 4.4 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // Code generated by goctl. DO NOT EDIT.
  2. package models
  3. import (
  4. "context"
  5. "database/sql"
  6. "fmt"
  7. "strings"
  8. "time"
  9. "github.com/zeromicro/go-zero/core/stores/builder"
  10. "github.com/zeromicro/go-zero/core/stores/sqlc"
  11. "github.com/zeromicro/go-zero/core/stores/sqlx"
  12. "github.com/zeromicro/go-zero/core/stringx"
  13. )
  14. var (
  15. hpcInstanceCenterFieldNames = builder.RawFieldNames(&HpcInstanceCenter{})
  16. hpcInstanceCenterRows = strings.Join(hpcInstanceCenterFieldNames, ",")
  17. hpcInstanceCenterRowsExpectAutoSet = strings.Join(stringx.Remove(hpcInstanceCenterFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
  18. hpcInstanceCenterRowsWithPlaceHolder = strings.Join(stringx.Remove(hpcInstanceCenterFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
  19. )
  20. type (
  21. hpcInstanceCenterModel interface {
  22. Insert(ctx context.Context, data *HpcInstanceCenter) (sql.Result, error)
  23. FindOne(ctx context.Context, id int64) (*HpcInstanceCenter, error)
  24. Update(ctx context.Context, data *HpcInstanceCenter) error
  25. Delete(ctx context.Context, id int64) error
  26. }
  27. defaultHpcInstanceCenterModel struct {
  28. conn sqlx.SqlConn
  29. table string
  30. }
  31. HpcInstanceCenter struct {
  32. Id int64 `db:"id" json:"id"` // 平台唯一id
  33. App string `db:"app" json:"app"` // 应用名称
  34. LogoPath string `db:"logo_path" json:"logoPath"` // logo图像的位置
  35. InstanceName string `db:"instance_name" json:"instanceName"` // 实例名称
  36. InstanceType int64 `db:"instance_type" json:"instanceType"` // 实例类型(1是应用实例,2是模型实例)
  37. InstanceClass string `db:"instance_class" json:"instanceClass"` // 实例类别
  38. InstanceClassChinese string `db:"instance_class_chinese" json:"instanceClassChinese"` // 实例类别中文描述
  39. Description string `db:"description" json:"description"` // 描述
  40. Status int64 `db:"status" json:"status"` // 状态状态 0-不可用,1-可用
  41. Version string `db:"version" json:"version"` // 版本
  42. CreatedAt time.Time `db:"created_at" json:"createdAt"` // 创建时间
  43. UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` // 更新时间
  44. }
  45. )
  46. func newHpcInstanceCenterModel(conn sqlx.SqlConn) *defaultHpcInstanceCenterModel {
  47. return &defaultHpcInstanceCenterModel{
  48. conn: conn,
  49. table: "`hpc_instance_center`",
  50. }
  51. }
  52. func (m *defaultHpcInstanceCenterModel) Delete(ctx context.Context, id int64) error {
  53. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  54. _, err := m.conn.ExecCtx(ctx, query, id)
  55. return err
  56. }
  57. func (m *defaultHpcInstanceCenterModel) FindOne(ctx context.Context, id int64) (*HpcInstanceCenter, error) {
  58. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", hpcInstanceCenterRows, m.table)
  59. var resp HpcInstanceCenter
  60. err := m.conn.QueryRowCtx(ctx, &resp, query, id)
  61. switch err {
  62. case nil:
  63. return &resp, nil
  64. case sqlc.ErrNotFound:
  65. return nil, ErrNotFound
  66. default:
  67. return nil, err
  68. }
  69. }
  70. func (m *defaultHpcInstanceCenterModel) Insert(ctx context.Context, data *HpcInstanceCenter) (sql.Result, error) {
  71. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, hpcInstanceCenterRowsExpectAutoSet)
  72. ret, err := m.conn.ExecCtx(ctx, query, data.LogoPath, data.InstanceName, data.InstanceType, data.InstanceClass, data.InstanceClassChinese, data.Description, data.Version)
  73. return ret, err
  74. }
  75. func (m *defaultHpcInstanceCenterModel) Update(ctx context.Context, data *HpcInstanceCenter) error {
  76. query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, hpcInstanceCenterRowsWithPlaceHolder)
  77. _, err := m.conn.ExecCtx(ctx, query, data.LogoPath, data.InstanceName, data.InstanceType, data.InstanceClass, data.InstanceClassChinese, data.Description, data.Version, data.Id)
  78. return err
  79. }
  80. func (m *defaultHpcInstanceCenterModel) tableName() string {
  81. return m.table
  82. }

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.