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.

scparticipantlabelinfomodel_gen.go 5.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. scParticipantLabelInfoFieldNames = builder.RawFieldNames(&ScParticipantLabelInfo{})
  17. scParticipantLabelInfoRows = strings.Join(scParticipantLabelInfoFieldNames, ",")
  18. scParticipantLabelInfoRowsExpectAutoSet = strings.Join(stringx.Remove(scParticipantLabelInfoFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
  19. scParticipantLabelInfoRowsWithPlaceHolder = strings.Join(stringx.Remove(scParticipantLabelInfoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
  20. cachePcmScParticipantLabelInfoIdPrefix = "cache:pcm:scParticipantLabelInfo:id:"
  21. )
  22. type (
  23. scParticipantLabelInfoModel interface {
  24. Insert(ctx context.Context, data *ScParticipantLabelInfo) (sql.Result, error)
  25. FindOne(ctx context.Context, id int64) (*ScParticipantLabelInfo, error)
  26. Update(ctx context.Context, data *ScParticipantLabelInfo) error
  27. Delete(ctx context.Context, id int64) error
  28. }
  29. defaultScParticipantLabelInfoModel struct {
  30. sqlc.CachedConn
  31. table string
  32. }
  33. ScParticipantLabelInfo struct {
  34. Id int64 `db:"id"` // id
  35. Key string `db:"key"` // key
  36. Value string `db:"value"` // value
  37. ParticipantId int64 `db:"participant_id"` // participant id
  38. Metadata sql.NullString `db:"metadata"` // 元数据
  39. DeletedFlag int64 `db:"deleted_flag"` // 是否删除
  40. CreatedBy sql.NullInt64 `db:"created_by"` // 创建人
  41. CreatedTime time.Time `db:"created_time"` // 创建时间
  42. UpdatedBy sql.NullInt64 `db:"updated_by"` // 更新人
  43. UpdatedTime sql.NullTime `db:"updated_time"` // 更新时间
  44. }
  45. )
  46. func newScParticipantLabelInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultScParticipantLabelInfoModel {
  47. return &defaultScParticipantLabelInfoModel{
  48. CachedConn: sqlc.NewConn(conn, c, opts...),
  49. table: "`sc_participant_label_info`",
  50. }
  51. }
  52. func (m *defaultScParticipantLabelInfoModel) withSession(session sqlx.Session) *defaultScParticipantLabelInfoModel {
  53. return &defaultScParticipantLabelInfoModel{
  54. CachedConn: m.CachedConn.WithSession(session),
  55. table: "`sc_participant_label_info`",
  56. }
  57. }
  58. func (m *defaultScParticipantLabelInfoModel) Delete(ctx context.Context, id int64) error {
  59. pcmScParticipantLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantLabelInfoIdPrefix, id)
  60. _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
  61. query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
  62. return conn.ExecCtx(ctx, query, id)
  63. }, pcmScParticipantLabelInfoIdKey)
  64. return err
  65. }
  66. func (m *defaultScParticipantLabelInfoModel) FindOne(ctx context.Context, id int64) (*ScParticipantLabelInfo, error) {
  67. pcmScParticipantLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantLabelInfoIdPrefix, id)
  68. var resp ScParticipantLabelInfo
  69. err := m.QueryRowCtx(ctx, &resp, pcmScParticipantLabelInfoIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
  70. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scParticipantLabelInfoRows, m.table)
  71. return conn.QueryRowCtx(ctx, v, query, id)
  72. })
  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 *defaultScParticipantLabelInfoModel) Insert(ctx context.Context, data *ScParticipantLabelInfo) (sql.Result, error) {
  83. pcmScParticipantLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantLabelInfoIdPrefix, data.Id)
  84. ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
  85. query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, scParticipantLabelInfoRowsExpectAutoSet)
  86. return conn.ExecCtx(ctx, query, data.Id, data.Key, data.Value, data.ParticipantId, data.Metadata, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime)
  87. }, pcmScParticipantLabelInfoIdKey)
  88. return ret, err
  89. }
  90. func (m *defaultScParticipantLabelInfoModel) Update(ctx context.Context, data *ScParticipantLabelInfo) error {
  91. pcmScParticipantLabelInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantLabelInfoIdPrefix, data.Id)
  92. _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
  93. query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, scParticipantLabelInfoRowsWithPlaceHolder)
  94. return conn.ExecCtx(ctx, query, data.Key, data.Value, data.ParticipantId, data.Metadata, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime, data.Id)
  95. }, pcmScParticipantLabelInfoIdKey)
  96. return err
  97. }
  98. func (m *defaultScParticipantLabelInfoModel) formatPrimary(primary any) string {
  99. return fmt.Sprintf("%s%v", cachePcmScParticipantLabelInfoIdPrefix, primary)
  100. }
  101. func (m *defaultScParticipantLabelInfoModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
  102. query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scParticipantLabelInfoRows, m.table)
  103. return conn.QueryRowCtx(ctx, v, query, primary)
  104. }
  105. func (m *defaultScParticipantLabelInfoModel) tableName() string {
  106. return m.table
  107. }

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.