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.
89 lines
2.9 KiB
Go
89 lines
2.9 KiB
Go
3 years ago
|
// Code generated by goctl. DO NOT EDIT!
|
||
|
|
||
|
package model
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc"
|
||
|
"time"
|
||
|
|
||
|
"gorm.io/gorm"
|
||
|
)
|
||
|
|
||
|
type (
|
||
|
statisticsPvpModel interface {
|
||
|
Insert(ctx context.Context, data *StatisticsPvp) error
|
||
|
FindOne(ctx context.Context, userId int64) (*StatisticsPvp, error)
|
||
|
Update(ctx context.Context, data *StatisticsPvp) error
|
||
|
Delete(ctx context.Context, userId int64) error
|
||
|
}
|
||
|
|
||
|
defaultStatisticsPvpModel struct {
|
||
|
conn *gorm.DB
|
||
|
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"`
|
||
|
}
|
||
|
)
|
||
|
|
||
|
func newStatisticsPvpModel(conn *gorm.DB) *defaultStatisticsPvpModel {
|
||
|
return &defaultStatisticsPvpModel{
|
||
|
conn: conn,
|
||
|
table: "`statistics_pvp`",
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (m *defaultStatisticsPvpModel) Insert(ctx context.Context, data *StatisticsPvp) error {
|
||
|
err := m.conn.WithContext(ctx).Create(&data).Error
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
func (m *defaultStatisticsPvpModel) FindOne(ctx context.Context, userId int64) (*StatisticsPvp, error) {
|
||
|
var resp StatisticsPvp
|
||
|
err := m.conn.WithContext(ctx).Model(&StatisticsPvp{}).Where("`user_id` = ?", userId).Take(&resp).Error
|
||
|
switch err {
|
||
|
case nil:
|
||
|
return &resp, nil
|
||
|
case gormc.ErrNotFound:
|
||
|
return nil, ErrNotFound
|
||
|
default:
|
||
|
return nil, err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (m *defaultStatisticsPvpModel) Update(ctx context.Context, data *StatisticsPvp) error {
|
||
|
err := m.conn.WithContext(ctx).Save(data).Error
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
func (m *defaultStatisticsPvpModel) Delete(ctx context.Context, userId int64) error {
|
||
|
err := m.conn.WithContext(ctx).Delete(&StatisticsPvp{}, userId).Error
|
||
|
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
func (m *defaultStatisticsPvpModel) tableName() string {
|
||
|
return m.table
|
||
|
}
|
||
|
|
||
|
func (StatisticsPvp) TableName() string {
|
||
|
model := newStatisticsPvpModel(nil)
|
||
|
return model.tableName()
|
||
|
}
|