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.

scparticipantphyinfomodel_gen.go 6.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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/cache"
  11. "github.com/zeromicro/go-zero/core/stores/sqlc"
  12. "github.com/zeromicro/go-zero/core/stores/sqlx"
  13. "github.com/zeromicro/go-zero/core/stringx"
  14. )
  15. var (
  16. scParticipantPhyInfoFieldNames = builder.RawFieldNames(&ScParticipantPhyInfo{})
  17. scParticipantPhyInfoRows = strings.Join(scParticipantPhyInfoFieldNames, ",")
  18. scParticipantPhyInfoRowsExpectAutoSet = strings.Join(stringx.Remove(scParticipantPhyInfoFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
  19. scParticipantPhyInfoRowsWithPlaceHolder = strings.Join(stringx.Remove(scParticipantPhyInfoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
  20. cachePcmScParticipantPhyInfoIdPrefix = "cache:pcm:scParticipantPhyInfo:id:"
  21. )
  22. type (
  23. scParticipantPhyInfoModel interface {
  24. Insert(ctx context.Context, data *ScParticipantPhyInfo) (sql.Result, error)
  25. FindOne(ctx context.Context, id int64) (*ScParticipantPhyInfo, error)
  26. Update(ctx context.Context, data *ScParticipantPhyInfo) error
  27. Delete(ctx context.Context, id int64) error
  28. }
  29. defaultScParticipantPhyInfoModel struct {
  30. sqlc.CachedConn
  31. table string
  32. }
  33. ScParticipantPhyInfo struct {
  34. Id int64 `db:"id"` // id
  35. Name string `db:"name"` // 名称
  36. Address string `db:"address"` // 集群p端地址
  37. Token string `db:"token"` // 数算集群token
  38. MetricsUrl string `db:"metrics_url"` // 监控url
  39. RpcAddress string `db:"rpc_address"` // rpc服务链接地址
  40. NetworkType string `db:"network_type"` // 集群网络类型
  41. NetworkBandwidth string `db:"network_bandwidth"` // 集群网络带宽
  42. StorageType string `db:"storage_type"` // 集群存储类型
  43. StorageSpace string `db:"storage_space"` // 集群存储空间
  44. StorageAvailSpace string `db:"storage_avail_space"` // 集群存储可用空间
  45. StorageBandwidth string `db:"storage_bandwidth"` // 集群存储带宽
  46. TenantId int64 `db:"tenant_id"` // 租户信息id
  47. Type string `db:"type"` // 类型:0-数算集群;1-智算集群;2-超算集群
  48. DeletedFlag int64 `db:"deleted_flag"` // 是否删除
  49. CreatedBy int64 `db:"created_by"` // 创建人
  50. CreatedTime time.Time `db:"created_time"` // 创建时间
  51. UpdatedBy int64 `db:"updated_by"` // 更新人
  52. UpdatedTime time.Time `db:"updated_time"` // 更新时间
  53. }
  54. )
  55. func newScParticipantPhyInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultScParticipantPhyInfoModel {
  56. return &defaultScParticipantPhyInfoModel{
  57. CachedConn: sqlc.NewConn(conn, c, opts...),
  58. table: "`sc_participant_phy_info`",
  59. }
  60. }
  61. func (m *defaultScParticipantPhyInfoModel) withSession(session sqlx.Session) *defaultScParticipantPhyInfoModel {
  62. return &defaultScParticipantPhyInfoModel{
  63. CachedConn: m.CachedConn.WithSession(session),
  64. table: "`sc_participant_phy_info`",
  65. }
  66. }
  67. func (m *defaultScParticipantPhyInfoModel) Delete(ctx context.Context, id int64) error {
  68. pcmScParticipantPhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantPhyInfoIdPrefix, id)
  69. _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
  70. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  71. return conn.ExecCtx(ctx, query, id)
  72. }, pcmScParticipantPhyInfoIdKey)
  73. return err
  74. }
  75. func (m *defaultScParticipantPhyInfoModel) FindOne(ctx context.Context, id int64) (*ScParticipantPhyInfo, error) {
  76. pcmScParticipantPhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantPhyInfoIdPrefix, id)
  77. var resp ScParticipantPhyInfo
  78. err := m.QueryRowCtx(ctx, &resp, pcmScParticipantPhyInfoIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
  79. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scParticipantPhyInfoRows, m.table)
  80. return conn.QueryRowCtx(ctx, v, query, id)
  81. })
  82. switch err {
  83. case nil:
  84. return &resp, nil
  85. case sqlc.ErrNotFound:
  86. return nil, ErrNotFound
  87. default:
  88. return nil, err
  89. }
  90. }
  91. func (m *defaultScParticipantPhyInfoModel) Insert(ctx context.Context, data *ScParticipantPhyInfo) (sql.Result, error) {
  92. pcmScParticipantPhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantPhyInfoIdPrefix, data.Id)
  93. ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
  94. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, scParticipantPhyInfoRowsExpectAutoSet)
  95. return conn.ExecCtx(ctx, query, data.Id, data.Name, data.Address, data.Token, data.MetricsUrl, data.RpcAddress, data.NetworkType, data.NetworkBandwidth, data.StorageType, data.StorageSpace, data.StorageAvailSpace, data.StorageBandwidth, data.TenantId, data.Type, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime)
  96. }, pcmScParticipantPhyInfoIdKey)
  97. return ret, err
  98. }
  99. func (m *defaultScParticipantPhyInfoModel) Update(ctx context.Context, data *ScParticipantPhyInfo) error {
  100. pcmScParticipantPhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantPhyInfoIdPrefix, data.Id)
  101. _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
  102. query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, scParticipantPhyInfoRowsWithPlaceHolder)
  103. return conn.ExecCtx(ctx, query, data.Name, data.Address, data.Token, data.MetricsUrl, data.RpcAddress, data.NetworkType, data.NetworkBandwidth, data.StorageType, data.StorageSpace, data.StorageAvailSpace, data.StorageBandwidth, data.TenantId, data.Type, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime, data.Id)
  104. }, pcmScParticipantPhyInfoIdKey)
  105. return err
  106. }
  107. func (m *defaultScParticipantPhyInfoModel) formatPrimary(primary any) string {
  108. return fmt.Sprintf("%s%v", cachePcmScParticipantPhyInfoIdPrefix, primary)
  109. }
  110. func (m *defaultScParticipantPhyInfoModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
  111. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scParticipantPhyInfoRows, m.table)
  112. return conn.QueryRowCtx(ctx, v, query, primary)
  113. }
  114. func (m *defaultScParticipantPhyInfoModel) tableName() string {
  115. return m.table
  116. }

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.