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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. LogoPath string `db:"logo_path" json:"logoPath"` // logo图像的位置
  34. InstanceName string `db:"instance_name" json:"instanceName"` // 实例名称
  35. InstanceType int64 `db:"instance_type" json:"instanceType"` // 实例类型(1是应用实例,2是模型实例)
  36. InstanceClass string `db:"instance_class" json:"instanceClass"` // 实例类别
  37. InstanceClassChinese string `db:"instance_class_chinese" json:"instanceClassChinese"` // 实例类别中文描述
  38. Description string `db:"description" json:"description"` // 描述
  39. Version string `db:"version" json:"version"` // 版本
  40. CreatedAt time.Time `db:"created_at" json:"createdAt"` // 创建时间
  41. UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` // 更新时间
  42. }
  43. )
  44. func newHpcInstanceCenterModel(conn sqlx.SqlConn) *defaultHpcInstanceCenterModel {
  45. return &defaultHpcInstanceCenterModel{
  46. conn: conn,
  47. table: "`hpc_instance_center`",
  48. }
  49. }
  50. func (m *defaultHpcInstanceCenterModel) Delete(ctx context.Context, id int64) error {
  51. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  52. _, err := m.conn.ExecCtx(ctx, query, id)
  53. return err
  54. }
  55. func (m *defaultHpcInstanceCenterModel) FindOne(ctx context.Context, id int64) (*HpcInstanceCenter, error) {
  56. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", hpcInstanceCenterRows, m.table)
  57. var resp HpcInstanceCenter
  58. err := m.conn.QueryRowCtx(ctx, &resp, query, id)
  59. switch err {
  60. case nil:
  61. return &resp, nil
  62. case sqlc.ErrNotFound:
  63. return nil, ErrNotFound
  64. default:
  65. return nil, err
  66. }
  67. }
  68. func (m *defaultHpcInstanceCenterModel) Insert(ctx context.Context, data *HpcInstanceCenter) (sql.Result, error) {
  69. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, hpcInstanceCenterRowsExpectAutoSet)
  70. ret, err := m.conn.ExecCtx(ctx, query, data.LogoPath, data.InstanceName, data.InstanceType, data.InstanceClass, data.InstanceClassChinese, data.Description, data.Version)
  71. return ret, err
  72. }
  73. func (m *defaultHpcInstanceCenterModel) Update(ctx context.Context, data *HpcInstanceCenter) error {
  74. query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, hpcInstanceCenterRowsWithPlaceHolder)
  75. _, err := m.conn.ExecCtx(ctx, query, data.LogoPath, data.InstanceName, data.InstanceType, data.InstanceClass, data.InstanceClassChinese, data.Description, data.Version, data.Id)
  76. return err
  77. }
  78. func (m *defaultHpcInstanceCenterModel) tableName() string {
  79. return m.table
  80. }

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.