You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.6 KiB
Go

// 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 (
statisticsPvpFieldNames = builder.RawFieldNames(&StatisticsPvp{})
statisticsPvpRows = strings.Join(statisticsPvpFieldNames, ",")
statisticsPvpRowsExpectAutoSet = strings.Join(stringx.Remove(statisticsPvpFieldNames, "`create_time`", "`update_time`"), ",")
statisticsPvpRowsWithPlaceHolder = strings.Join(stringx.Remove(statisticsPvpFieldNames, "`user_id`", "`create_time`", "`update_time`"), "=?,") + "=?"
)
type (
statisticsPvpModel interface {
gormx.TxModel
Insert(ctx context.Context, tx *gorm.DB, data *StatisticsPvp) error
FindOne(ctx context.Context, tx *gorm.DB, userId int64) (*StatisticsPvp, error)
Update(ctx context.Context, tx *gorm.DB, data *StatisticsPvp) error
Delete(ctx context.Context, tx *gorm.DB, userId int64) error
}
defaultStatisticsPvpModel struct {
gormx.GormConn
table string
}
StatisticsPvp struct {
UserId int64 `gorm:"column:user_id;primaryKey"` // 用户ID
WinCount int64 `gorm:"column:win_count"` // 胜利次数
LostCount int64 `gorm:"column:lost_count"` // 失败次数
Damage int64 `gorm:"column:damage"` // 伤害量
DeDamage int64 `gorm:"column:de_damage"` // 承受伤害量
KillUnitCount int64 `gorm:"column:kill_unit_count"` // 击杀单位数量
DeKillUnitCount int64 `gorm:"column:de_kill_unit_count"` // 被击杀单位数量
KillPlayerCount int64 `gorm:"column:kill_player_count"` // 击杀玩家兵营数量
DeKillPlayerCount int64 `gorm:"column:de_kill_player_count"` // 被击杀次数
GeneralCount int64 `gorm:"column:general_count"` // 获得名将次数
DeGeneralCount int64 `gorm:"column:de_general_count"` // 名将落马次数
FirstBloodCount int64 `gorm:"column:first_blood_count"` // 一血次数
DeFirstBloodCount int64 `gorm:"column:de_first_blood_count"` // 被拿一血次数
CreateTime time.Time `gorm:"column:create_time;default:null"`
UpdateTime time.Time `gorm:"column:update_time;default:null"`
}
)
var StatisticsPvpTableName = "`statistics_pvp`"
func newStatisticsPvpModel(conn *gorm.DB) *defaultStatisticsPvpModel {
return &defaultStatisticsPvpModel{
GormConn: gormx.NewConn(conn),
table: StatisticsPvpTableName,
}
}
func (m *defaultStatisticsPvpModel) Insert(ctx context.Context, tx *gorm.DB, data *StatisticsPvp) error {
err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
return err
}
func (m *defaultStatisticsPvpModel) FindOne(ctx context.Context, tx *gorm.DB, userId int64) (*StatisticsPvp, error) {
var resp StatisticsPvp
err := gormx.WithTx(ctx, m.DB, tx).Model(&StatisticsPvp{}).Where("`user_id` = ?", userId).Take(&resp).Error
err = gormx.WrapSelectErr(err)
if err != nil {
return nil, err
}
return &resp, nil
}
func (m *defaultStatisticsPvpModel) Update(ctx context.Context, tx *gorm.DB, data *StatisticsPvp) error {
result := gormx.WithTx(ctx, m.DB, tx).Save(data)
return gormx.WrapUpdateErr(result.Error, result.RowsAffected)
}
func (m *defaultStatisticsPvpModel) Delete(ctx context.Context, tx *gorm.DB, userId int64) error {
err := gormx.WithTx(ctx, m.DB, tx).Delete(&StatisticsPvp{}, userId).Error
return err
}
func (m *defaultStatisticsPvpModel) tableName() string {
return m.table
}
func (StatisticsPvp) TableName() string {
return StatisticsPvpTableName
}