|
- // Code generated by goctl. DO NOT EDIT.
-
- package model
-
- import (
- "context"
- "database/sql"
- "fmt"
- "strings"
- "time"
-
- "github.com/zeromicro/go-zero/core/stores/builder"
- "github.com/zeromicro/go-zero/core/stores/cache"
- "github.com/zeromicro/go-zero/core/stores/sqlc"
- "github.com/zeromicro/go-zero/core/stores/sqlx"
- "github.com/zeromicro/go-zero/core/stringx"
- )
-
- var (
- scNodePhyInfoFieldNames = builder.RawFieldNames(&ScNodePhyInfo{})
- scNodePhyInfoRows = strings.Join(scNodePhyInfoFieldNames, ",")
- scNodePhyInfoRowsExpectAutoSet = strings.Join(stringx.Remove(scNodePhyInfoFieldNames, "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), ",")
- scNodePhyInfoRowsWithPlaceHolder = strings.Join(stringx.Remove(scNodePhyInfoFieldNames, "`id`", "`create_at`", "`create_time`", "`created_at`", "`update_at`", "`update_time`", "`updated_at`"), "=?,") + "=?"
-
- cachePcmScNodePhyInfoIdPrefix = "cache:pcm:scNodePhyInfo:id:"
- )
-
- type (
- scNodePhyInfoModel interface {
- Insert(ctx context.Context, data *ScNodePhyInfo) (sql.Result, error)
- FindOne(ctx context.Context, id int64) (*ScNodePhyInfo, error)
- Update(ctx context.Context, data *ScNodePhyInfo) error
- Delete(ctx context.Context, id int64) error
- }
-
- defaultScNodePhyInfoModel struct {
- sqlc.CachedConn
- table string
- }
-
- ScNodePhyInfo struct {
- Id int64 `db:"id"` // id
- NodeName string `db:"node_name"` // 节点名称
- OsName string `db:"os_name"` // 系统名称
- OsVersion int64 `db:"os_version"` // 系统版本
- ArchType string `db:"arch_type"` // 架构类型
- ArchName string `db:"arch_name"` // 架构名称
- ArchFreq string `db:"arch_freq"` // 架构频率
- ParticipantId int64 `db:"participant_id"` // 集群静态信息id
- DeletedFlag int64 `db:"deleted_flag"` // 是否删除
- CreatedBy int64 `db:"created_by"` // 创建人
- CreatedTime time.Time `db:"created_time"` // 创建时间
- UpdatedBy int64 `db:"updated_by"` // 更新人
- UpdatedTime time.Time `db:"updated_time"` // 更新时间
- }
- )
-
- func newScNodePhyInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultScNodePhyInfoModel {
- return &defaultScNodePhyInfoModel{
- CachedConn: sqlc.NewConn(conn, c, opts...),
- table: "`sc_node_phy_info`",
- }
- }
-
- func (m *defaultScNodePhyInfoModel) withSession(session sqlx.Session) *defaultScNodePhyInfoModel {
- return &defaultScNodePhyInfoModel{
- CachedConn: m.CachedConn.WithSession(session),
- table: "`sc_node_phy_info`",
- }
- }
-
- func (m *defaultScNodePhyInfoModel) Delete(ctx context.Context, id int64) error {
- pcmScNodePhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodePhyInfoIdPrefix, id)
- _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
- query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
- return conn.ExecCtx(ctx, query, id)
- }, pcmScNodePhyInfoIdKey)
- return err
- }
-
- func (m *defaultScNodePhyInfoModel) FindOne(ctx context.Context, id int64) (*ScNodePhyInfo, error) {
- pcmScNodePhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScNodePhyInfoIdPrefix, id)
- var resp ScNodePhyInfo
- err := m.QueryRowCtx(ctx, &resp, pcmScNodePhyInfoIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
- query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scNodePhyInfoRows, m.table)
- return conn.QueryRowCtx(ctx, v, query, id)
- })
- switch err {
- case nil:
- return &resp, nil
- case sqlc.ErrNotFound:
- return nil, ErrNotFound
- default:
- return nil, err
- }
- }
-
- func (m *defaultScNodePhyInfoModel) tableName() string {
- return m.table
- }
|