|
|
|
// Code generated by goctl. DO NOT EDIT!
|
|
|
|
|
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
|
|
|
|
"github.com/zeromicro/go-zero/core/stores/builder"
|
|
|
|
"github.com/zeromicro/go-zero/core/stringx"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
rankPvpFieldNames = builder.RawFieldNames(&RankPvp{})
|
|
|
|
rankPvpRows = strings.Join(rankPvpFieldNames, ",")
|
|
|
|
rankPvpRowsExpectAutoSet = strings.Join(stringx.Remove(rankPvpFieldNames, "`create_time`", "`update_time`"), ",")
|
|
|
|
rankPvpRowsWithPlaceHolder = strings.Join(stringx.Remove(rankPvpFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
rankPvpModel interface {
|
|
|
|
gormx.TxModel
|
|
|
|
Insert(ctx context.Context, tx *gorm.DB, data *RankPvp) error
|
|
|
|
FindOne(ctx context.Context, tx *gorm.DB, id int64) (*RankPvp, error)
|
|
|
|
FindOneByUserIdRankType(ctx context.Context, tx *gorm.DB, userId int64, rankType int64) (*RankPvp, error)
|
|
|
|
Update(ctx context.Context, tx *gorm.DB, data *RankPvp) error
|
|
|
|
Delete(ctx context.Context, tx *gorm.DB, id int64) error
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultRankPvpModel struct {
|
|
|
|
gormx.GormConn
|
|
|
|
table string
|
|
|
|
}
|
|
|
|
|
|
|
|
RankPvp struct {
|
|
|
|
Id int64 `gorm:"column:id;primaryKey"` // 主键
|
|
|
|
UserId int64 `gorm:"column:user_id"` // 用户ID
|
|
|
|
RankType int64 `gorm:"column:rank_type"` // 类型 1: 伤害 2: 名将次数 3: 击杀单位 4: 击杀玩家
|
|
|
|
Score int64 `gorm:"column:score"` // 伤害量
|
|
|
|
CreateTime time.Time `gorm:"column:create_time;default:null"` // 创建时间
|
|
|
|
UpdateTime time.Time `gorm:"column:update_time;default:null"` // 更新时间
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
var RankPvpTableName = "`rank_pvp`"
|
|
|
|
|
|
|
|
func newRankPvpModel(conn *gorm.DB) *defaultRankPvpModel {
|
|
|
|
return &defaultRankPvpModel{
|
|
|
|
GormConn: gormx.NewConn(conn),
|
|
|
|
table: RankPvpTableName,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultRankPvpModel) Insert(ctx context.Context, tx *gorm.DB, data *RankPvp) error {
|
|
|
|
err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultRankPvpModel) FindOne(ctx context.Context, tx *gorm.DB, id int64) (*RankPvp, error) {
|
|
|
|
var resp RankPvp
|
|
|
|
err := gormx.WithTx(ctx, m.DB, tx).Model(&RankPvp{}).Where("`id` = ?", id).Take(&resp).Error
|
|
|
|
err = gormx.WrapSelectErr(err)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &resp, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultRankPvpModel) FindOneByUserIdRankType(ctx context.Context, tx *gorm.DB, userId int64, rankType int64) (*RankPvp, error) {
|
|
|
|
var resp RankPvp
|
|
|
|
err := gormx.WithTx(ctx, m.DB, tx).Model(&RankPvp{}).Where("`user_id` = ? and `rank_type` = ?", userId, rankType).Take(&resp).Error
|
|
|
|
err = gormx.WrapSelectErr(err)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &resp, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultRankPvpModel) Update(ctx context.Context, tx *gorm.DB, data *RankPvp) error {
|
|
|
|
|
|
|
|
result := gormx.WithTx(ctx, m.DB, tx).Save(data)
|
|
|
|
return gormx.WrapUpdateErr(result.Error, result.RowsAffected)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultRankPvpModel) Delete(ctx context.Context, tx *gorm.DB, id int64) error {
|
|
|
|
err := gormx.WithTx(ctx, m.DB, tx).Delete(&RankPvp{}, id).Error
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *defaultRankPvpModel) tableName() string {
|
|
|
|
return m.table
|
|
|
|
}
|
|
|
|
|
|
|
|
func (RankPvp) TableName() string {
|
|
|
|
return RankPvpTableName
|
|
|
|
}
|