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.

scnodephyinfomodel_gen.go 3.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Code generated by goctl. DO NOT EDIT.
  2. package model
  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. scNodePhyInfoFieldNames = builder.RawFieldNames(&ScNodePhyInfo{})
  17. scNodePhyInfoRows = strings.Join(scNodePhyInfoFieldNames, ",")
  18. scNodePhyInfoRowsExpectAutoSet = strings.Join(stringx.Remove(scNodePhyInfoFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
  19. scNodePhyInfoRowsWithPlaceHolder = strings.Join(stringx.Remove(scNodePhyInfoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
  20. cachePcmScNodePhyInfoIdPrefix = "cache:pcm:scNodePhyInfo:id:"
  21. )
  22. type (
  23. scNodePhyInfoModel interface {
  24. Insert(ctx context.Context, data *ScNodePhyInfo) (sql.Result, error)
  25. FindOne(ctx context.Context, id int64) (*ScNodePhyInfo, error)
  26. Update(ctx context.Context, data *ScNodePhyInfo) error
  27. Delete(ctx context.Context, id int64) error
  28. }
  29. defaultScNodePhyInfoModel struct {
  30. sqlc.CachedConn
  31. table string
  32. }
  33. ScNodePhyInfo struct {
  34. Id int64 `db:"id"` // id
  35. NodeName string `db:"node_name"` // 节点名称
  36. OsName string `db:"os_name"` // 系统名称
  37. OsVersion int64 `db:"os_version"` // 系统版本
  38. ArchType string `db:"arch_type"` // 架构类型
  39. ArchName string `db:"arch_name"` // 架构名称
  40. ArchFreq string `db:"arch_freq"` // 架构频率
  41. ParticipantId int64 `db:"participant_id"` // 集群静态信息id
  42. DeletedFlag int64 `db:"deleted_flag"` // 是否删除
  43. CreatedBy int64 `db:"created_by"` // 创建人
  44. CreatedTime time.Time `db:"created_time"` // 创建时间
  45. UpdatedBy int64 `db:"updated_by"` // 更新人
  46. UpdatedTime time.Time `db:"updated_time"` // 更新时间
  47. }
  48. )
  49. func newScNodePhyInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultScNodePhyInfoModel {
  50. return &defaultScNodePhyInfoModel{
  51. CachedConn: sqlc.NewConn(conn, c, opts...),
  52. table: "`sc_node_phy_info`",
  53. }
  54. }
  55. func (m *defaultScNodePhyInfoModel) withSession(session sqlx.Session) *defaultScNodePhyInfoModel {
  56. return &defaultScNodePhyInfoModel{
  57. CachedConn: m.CachedConn.WithSession(session),
  58. table: "`sc_node_phy_info`",
  59. }
  60. }
  61. func (m *defaultScNodePhyInfoModel) Delete(ctx context.Context, id int64) error {
  62. pcmScNodePhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodePhyInfoIdPrefix, id)
  63. _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
  64. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  65. return conn.ExecCtx(ctx, query, id)
  66. }, pcmScNodePhyInfoIdKey)
  67. return err
  68. }
  69. func (m *defaultScNodePhyInfoModel) FindOne(ctx context.Context, id int64) (*ScNodePhyInfo, error) {
  70. pcmScNodePhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodePhyInfoIdPrefix, id)
  71. var resp ScNodePhyInfo
  72. err := m.QueryRowCtx(ctx, &resp, pcmScNodePhyInfoIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
  73. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scNodePhyInfoRows, m.table)
  74. return conn.QueryRowCtx(ctx, v, query, id)
  75. })
  76. switch err {
  77. case nil:
  78. return &resp, nil
  79. case sqlc.ErrNotFound:
  80. return nil, ErrNotFound
  81. default:
  82. return nil, err
  83. }
  84. }
  85. func (m *defaultScNodePhyInfoModel) tableName() string {
  86. return m.table
  87. }

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.