表关联关系修改
Former-commit-id: d170dc84c61801686912daf9f53998e8e6977e13
This commit is contained in:
parent
479765110e
commit
f6a956b9e1
|
@ -1,12 +1,5 @@
|
||||||
package model
|
package model
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
|
||||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
||||||
)
|
|
||||||
|
|
||||||
var _ ScParticipantAvailInfoModel = (*customScParticipantAvailInfoModel)(nil)
|
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// ScParticipantAvailInfoModel is an interface to be customized, add more methods here,
|
// ScParticipantAvailInfoModel is an interface to be customized, add more methods here,
|
||||||
// and implement the added methods in customScParticipantAvailInfoModel.
|
// and implement the added methods in customScParticipantAvailInfoModel.
|
||||||
|
@ -18,10 +11,3 @@ type (
|
||||||
*defaultScParticipantAvailInfoModel
|
*defaultScParticipantAvailInfoModel
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewScParticipantAvailInfoModel returns a model for the database table.
|
|
||||||
func NewScParticipantAvailInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) ScParticipantAvailInfoModel {
|
|
||||||
return &customScParticipantAvailInfoModel{
|
|
||||||
defaultScParticipantAvailInfoModel: newScParticipantAvailInfoModel(conn, c, opts...),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ package model
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -46,7 +45,7 @@ type (
|
||||||
UserNum sql.NullInt64 `db:"user_num"` // 用户数量
|
UserNum sql.NullInt64 `db:"user_num"` // 用户数量
|
||||||
PendingJobNum sql.NullInt64 `db:"pending_job_num"` // 待处理作业数量
|
PendingJobNum sql.NullInt64 `db:"pending_job_num"` // 待处理作业数量
|
||||||
RunningJobNum int64 `db:"running_job_num"` // 运行作业数量
|
RunningJobNum int64 `db:"running_job_num"` // 运行作业数量
|
||||||
ClusterLogicId int64 `db:"cluster_logic_id"` // 集群静态信息id
|
ParticipantId int64 `db:"cluster_logic_id"` // 集群静态信息id
|
||||||
DeletedFlag int64 `db:"deleted_flag"` // 是否删除
|
DeletedFlag int64 `db:"deleted_flag"` // 是否删除
|
||||||
CreatedBy sql.NullInt64 `db:"created_by"` // 创建人
|
CreatedBy sql.NullInt64 `db:"created_by"` // 创建人
|
||||||
CreatedTime time.Time `db:"created_time"` // 创建时间
|
CreatedTime time.Time `db:"created_time"` // 创建时间
|
||||||
|
@ -69,59 +68,6 @@ func (m *defaultScParticipantAvailInfoModel) withSession(session sqlx.Session) *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *defaultScParticipantAvailInfoModel) Delete(ctx context.Context, id int64) error {
|
|
||||||
pcmScParticipantAvailInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantAvailInfoIdPrefix, 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)
|
|
||||||
}, pcmScParticipantAvailInfoIdKey)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *defaultScParticipantAvailInfoModel) FindOne(ctx context.Context, id int64) (*ScParticipantAvailInfo, error) {
|
|
||||||
pcmScParticipantAvailInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantAvailInfoIdPrefix, id)
|
|
||||||
var resp ScParticipantAvailInfo
|
|
||||||
err := m.QueryRowCtx(ctx, &resp, pcmScParticipantAvailInfoIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error {
|
|
||||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scParticipantAvailInfoRows, 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 *defaultScParticipantAvailInfoModel) Insert(ctx context.Context, data *ScParticipantAvailInfo) (sql.Result, error) {
|
|
||||||
pcmScParticipantAvailInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantAvailInfoIdPrefix, data.Id)
|
|
||||||
ret, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
|
||||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, scParticipantAvailInfoRowsExpectAutoSet)
|
|
||||||
return conn.ExecCtx(ctx, query, data.Id, data.Host, data.Port, data.AvailStorageSpace, data.UserNum, data.PendingJobNum, data.RunningJobNum, data.ClusterLogicId, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime)
|
|
||||||
}, pcmScParticipantAvailInfoIdKey)
|
|
||||||
return ret, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *defaultScParticipantAvailInfoModel) Update(ctx context.Context, data *ScParticipantAvailInfo) error {
|
|
||||||
pcmScParticipantAvailInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantAvailInfoIdPrefix, data.Id)
|
|
||||||
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
|
||||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, scParticipantAvailInfoRowsWithPlaceHolder)
|
|
||||||
return conn.ExecCtx(ctx, query, data.Host, data.Port, data.AvailStorageSpace, data.UserNum, data.PendingJobNum, data.RunningJobNum, data.ClusterLogicId, data.DeletedFlag, data.CreatedBy, data.CreatedTime, data.UpdatedBy, data.UpdatedTime, data.Id)
|
|
||||||
}, pcmScParticipantAvailInfoIdKey)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *defaultScParticipantAvailInfoModel) formatPrimary(primary any) string {
|
|
||||||
return fmt.Sprintf("%s%v", cachePcmScParticipantAvailInfoIdPrefix, primary)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *defaultScParticipantAvailInfoModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error {
|
|
||||||
query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scParticipantAvailInfoRows, m.table)
|
|
||||||
return conn.QueryRowCtx(ctx, v, query, primary)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *defaultScParticipantAvailInfoModel) tableName() string {
|
func (m *defaultScParticipantAvailInfoModel) tableName() string {
|
||||||
return m.table
|
return m.table
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue