wip: 新版优化,开发中。

main
NorthLan 2 years ago
parent c75301aa86
commit f32e82fe1c

@ -9,6 +9,7 @@ enum Platform {
huya = 1; // huya = 1; //
douyu = 2; // douyu = 2; //
douyin = 3; // douyin = 3; //
//
} }
message MqDanmaku { message MqDanmaku {

@ -1,20 +1,18 @@
@echo off @echo off
@echo ?????????????? chcp 65001
@echo 开始代码生成
set tables=user_check_in set tables=user_integral
set targetDir=.\model set targetDir=.\model
set templateDir=..\..\doc\template set templateDir=..\..\doc\template
set host=127.0.0.1 set host=127.0.0.1
set port=3306 set port=3306
::set host=192.168.1.100
::set port=3306
::set dbname=dcg
set dbname=dmgame set dbname=dmgame
set username=root set username=root
set password=root set password=root
for %%i in (%tables%) do ( for %%i in (%tables%) do (
echo ????????? %dbname% ??? %%i echo 正在生成数据库 %dbname% 的表 %%i 的golang代码
goctl model mysql datasource --url "%username%:%password%@tcp(%host%:%port%)/%dbname%" -t %%i -d %targetDir% --style go_zero --home %templateDir% goctl model mysql datasource --url "%username%:%password%@tcp(%host%:%port%)/%dbname%" -t %%i -d %targetDir% --style go_zero --home %templateDir%
) )

@ -2,7 +2,7 @@ package model
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc" "git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"gorm.io/gorm" "gorm.io/gorm"
) )
@ -13,12 +13,6 @@ type (
// and implement the added methods in customGiftModel. // and implement the added methods in customGiftModel.
GiftModel interface { GiftModel interface {
giftModel giftModel
// Transaction 开启事务,传入方法即可
Transaction(ctx context.Context, tx *gorm.DB, fn func(tx *gorm.DB) error) error
// InsertTx 事务插入
InsertTx(ctx context.Context, tx *gorm.DB, data *Gift) error
// UpdateTx 事务更新
UpdateTx(ctx context.Context, tx *gorm.DB, data *Gift) error
FindByPlatformGift(ctx context.Context, platform string, giftId string) (*Gift, error) FindByPlatformGift(ctx context.Context, platform string, giftId string) (*Gift, error)
} }
@ -34,32 +28,16 @@ func NewGiftModel(conn *gorm.DB) GiftModel {
} }
} }
func (m *customGiftModel) Transaction(ctx context.Context, tx *gorm.DB, fn func(tx *gorm.DB) error) error {
return withTx(ctx, m.conn, tx).Transaction(func(tx *gorm.DB) error {
return fn(tx)
})
}
func (m *customGiftModel) InsertTx(ctx context.Context, tx *gorm.DB, data *Gift) error {
err := withTx(ctx, m.conn, tx).Create(&data).Error
return err
}
func (m *customGiftModel) UpdateTx(ctx context.Context, tx *gorm.DB, data *Gift) error {
err := withTx(ctx, m.conn, tx).Save(data).Error
return err
}
func (m *customGiftModel) FindByPlatformGift(ctx context.Context, platform string, giftId string) (*Gift, error) { func (m *customGiftModel) FindByPlatformGift(ctx context.Context, platform string, giftId string) (*Gift, error) {
var resp Gift var resp Gift
db := m.conn.WithContext(ctx) db := m.DB.WithContext(ctx)
err := db.Model(&Gift{}). err := db.Model(&Gift{}).
Where("platform = ? AND gift_id = ?", platform, giftId). Where("platform = ? AND gift_id = ?", platform, giftId).
Take(&resp).Error Take(&resp).Error
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err

@ -4,22 +4,34 @@ package model
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc" "strings"
"time" "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" "gorm.io/gorm"
) )
var (
giftFieldNames = builder.RawFieldNames(&Gift{})
giftRows = strings.Join(giftFieldNames, ",")
giftRowsExpectAutoSet = strings.Join(stringx.Remove(giftFieldNames, "`create_time`", "`update_time`"), ",")
giftRowsWithPlaceHolder = strings.Join(stringx.Remove(giftFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
)
type ( type (
giftModel interface { giftModel interface {
Insert(ctx context.Context, data *Gift) error gormx.TxModel
FindOne(ctx context.Context, id int64) (*Gift, error) Insert(ctx context.Context, tx *gorm.DB, data *Gift) error
Update(ctx context.Context, data *Gift) error FindOne(ctx context.Context, tx *gorm.DB, id int64) (*Gift, error)
Delete(ctx context.Context, id int64) error FindOneByGiftIdPlatform(ctx context.Context, tx *gorm.DB, giftId string, platform string) (*Gift, error)
Update(ctx context.Context, tx *gorm.DB, data *Gift) error
Delete(ctx context.Context, tx *gorm.DB, id int64) error
} }
defaultGiftModel struct { defaultGiftModel struct {
conn *gorm.DB gormx.GormConn
table string table string
} }
@ -35,38 +47,53 @@ type (
} }
) )
var GiftTableName = "`gift`"
func newGiftModel(conn *gorm.DB) *defaultGiftModel { func newGiftModel(conn *gorm.DB) *defaultGiftModel {
return &defaultGiftModel{ return &defaultGiftModel{
conn: conn, GormConn: gormx.NewConn(conn),
table: "`gift`", table: GiftTableName,
} }
} }
func (m *defaultGiftModel) Insert(ctx context.Context, data *Gift) error { func (m *defaultGiftModel) Insert(ctx context.Context, tx *gorm.DB, data *Gift) error {
err := m.conn.WithContext(ctx).Create(&data).Error err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
return err return err
} }
func (m *defaultGiftModel) FindOne(ctx context.Context, id int64) (*Gift, error) { func (m *defaultGiftModel) FindOne(ctx context.Context, tx *gorm.DB, id int64) (*Gift, error) {
var resp Gift
err := gormx.WithTx(ctx, m.DB, tx).Model(&Gift{}).Where("`id` = ?", id).Take(&resp).Error
switch err {
case nil:
return &resp, nil
case gormx.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultGiftModel) FindOneByGiftIdPlatform(ctx context.Context, tx *gorm.DB, giftId string, platform string) (*Gift, error) {
var resp Gift var resp Gift
err := m.conn.WithContext(ctx).Model(&Gift{}).Where("`id` = ?", id).Take(&resp).Error err := gormx.WithTx(ctx, m.DB, tx).Model(&Gift{}).Where("`gift_id` = ? and `platform` = ?", giftId, platform).Take(&resp).Error
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
} }
} }
func (m *defaultGiftModel) Update(ctx context.Context, data *Gift) error { func (m *defaultGiftModel) Update(ctx context.Context, tx *gorm.DB, data *Gift) error {
err := m.conn.WithContext(ctx).Save(data).Error err := gormx.WithTx(ctx, m.DB, tx).Save(data).Error
return err return err
} }
func (m *defaultGiftModel) Delete(ctx context.Context, id int64) error { func (m *defaultGiftModel) Delete(ctx context.Context, tx *gorm.DB, id int64) error {
err := m.conn.WithContext(ctx).Delete(&Gift{}, id).Error err := gormx.WithTx(ctx, m.DB, tx).Delete(&Gift{}, id).Error
return err return err
} }
@ -76,6 +103,5 @@ func (m *defaultGiftModel) tableName() string {
} }
func (Gift) TableName() string { func (Gift) TableName() string {
model := newGiftModel(nil) return GiftTableName
return model.tableName()
} }

@ -0,0 +1,21 @@
package model
import "live-service/app/user_center/rpc/pb"
var rankAndScoreMap map[pb.RankType]ScoreType
func init() {
rankAndScoreMap = map[pb.RankType]ScoreType{
pb.RankType_Damage: ScoreTypeDamage,
pb.RankType_DeDamage: ScoreTypeDeDamage,
pb.RankType_Damage: ScoreTypeDamage,
pb.RankType_Damage: ScoreTypeDamage,
pb.RankType_Damage: ScoreTypeDamage,
pb.RankType_Damage: ScoreTypeDamage,
pb.RankType_Damage: ScoreTypeDamage,
pb.RankType_Damage: ScoreTypeDamage,
pb.RankType_Damage: ScoreTypeDamage,
pb.RankType_Damage: ScoreTypeDamage,
pb.RankType_Damage: ScoreTypeDamage,
}
}

@ -3,7 +3,7 @@ package model
import ( import (
"context" "context"
"fmt" "fmt"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc" "git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"gorm.io/gorm" "gorm.io/gorm"
) )
@ -55,7 +55,7 @@ func NewRankPvpModel(conn *gorm.DB) RankPvpModel {
} }
func (m *customRankPvpModel) RankListByType(ctx context.Context, rankType, topN int32) ([]RankPvpWithPlatformUser, error) { func (m *customRankPvpModel) RankListByType(ctx context.Context, rankType, topN int32) ([]RankPvpWithPlatformUser, error) {
db := m.conn.WithContext(ctx) db := m.DB.WithContext(ctx)
limit := topN limit := topN
if limit > MaxRankN { if limit > MaxRankN {
limit = MaxRankN limit = MaxRankN
@ -70,7 +70,7 @@ func (m *customRankPvpModel) RankListByType(ctx context.Context, rankType, topN
switch err { switch err {
case nil: case nil:
return result, nil return result, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
@ -78,7 +78,7 @@ func (m *customRankPvpModel) RankListByType(ctx context.Context, rankType, topN
} }
func (m *customRankPvpModel) UpdateRank(ctx context.Context, rankType int32, data []RankPvp) error { func (m *customRankPvpModel) UpdateRank(ctx context.Context, rankType int32, data []RankPvp) error {
db := m.conn.WithContext(ctx) db := m.DB.WithContext(ctx)
return db.Transaction(func(tx *gorm.DB) error { return db.Transaction(func(tx *gorm.DB) error {
var err error var err error
// delete all by rank_type // delete all by rank_type

@ -4,28 +4,39 @@ package model
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc" "strings"
"time" "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" "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 ( type (
rankPvpModel interface { rankPvpModel interface {
Insert(ctx context.Context, data *RankPvp) error gormx.TxModel
FindOne(ctx context.Context, id int64) (*RankPvp, error) Insert(ctx context.Context, tx *gorm.DB, data *RankPvp) error
FindOneByUserIdRankType(ctx context.Context, userId int64, rankType int64) (*RankPvp, error) FindOne(ctx context.Context, tx *gorm.DB, id int64) (*RankPvp, error)
Update(ctx context.Context, data *RankPvp) error FindOneByUserIdRankType(ctx context.Context, tx *gorm.DB, userId int64, rankType int64) (*RankPvp, error)
Delete(ctx context.Context, id int64) error Update(ctx context.Context, tx *gorm.DB, data *RankPvp) error
Delete(ctx context.Context, tx *gorm.DB, id int64) error
} }
defaultRankPvpModel struct { defaultRankPvpModel struct {
conn *gorm.DB gormx.GormConn
table string table string
} }
RankPvp struct { RankPvp struct {
Id int64 `gorm:"column:id"` // 主键 Id int64 `gorm:"column:id;primaryKey"` // 主键
UserId int64 `gorm:"column:user_id"` // 用户ID UserId int64 `gorm:"column:user_id"` // 用户ID
RankType int64 `gorm:"column:rank_type"` // 类型 1: 伤害 2: 名将次数 3: 击杀单位 4: 击杀玩家 RankType int64 `gorm:"column:rank_type"` // 类型 1: 伤害 2: 名将次数 3: 击杀单位 4: 击杀玩家
Score int64 `gorm:"column:score"` // 伤害量 Score int64 `gorm:"column:score"` // 伤害量
@ -34,51 +45,53 @@ type (
} }
) )
var RankPvpTableName = "`rank_pvp`"
func newRankPvpModel(conn *gorm.DB) *defaultRankPvpModel { func newRankPvpModel(conn *gorm.DB) *defaultRankPvpModel {
return &defaultRankPvpModel{ return &defaultRankPvpModel{
conn: conn, GormConn: gormx.NewConn(conn),
table: "`rank_pvp`", table: RankPvpTableName,
} }
} }
func (m *defaultRankPvpModel) Insert(ctx context.Context, data *RankPvp) error { func (m *defaultRankPvpModel) Insert(ctx context.Context, tx *gorm.DB, data *RankPvp) error {
err := m.conn.WithContext(ctx).Create(&data).Error err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
return err return err
} }
func (m *defaultRankPvpModel) FindOne(ctx context.Context, id int64) (*RankPvp, error) { func (m *defaultRankPvpModel) FindOne(ctx context.Context, tx *gorm.DB, id int64) (*RankPvp, error) {
var resp RankPvp var resp RankPvp
err := m.conn.WithContext(ctx).Model(&RankPvp{}).Where("`id` = ?", id).Take(&resp).Error err := gormx.WithTx(ctx, m.DB, tx).Model(&RankPvp{}).Where("`id` = ?", id).Take(&resp).Error
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
} }
} }
func (m *defaultRankPvpModel) FindOneByUserIdRankType(ctx context.Context, userId int64, rankType int64) (*RankPvp, error) { func (m *defaultRankPvpModel) FindOneByUserIdRankType(ctx context.Context, tx *gorm.DB, userId int64, rankType int64) (*RankPvp, error) {
var resp RankPvp var resp RankPvp
err := m.conn.WithContext(ctx).Model(&RankPvp{}).Where("`user_id` = ? and `rank_type` = ?", userId, rankType).Take(&resp).Error err := gormx.WithTx(ctx, m.DB, tx).Model(&RankPvp{}).Where("`user_id` = ? and `rank_type` = ?", userId, rankType).Take(&resp).Error
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
} }
} }
func (m *defaultRankPvpModel) Update(ctx context.Context, data *RankPvp) error { func (m *defaultRankPvpModel) Update(ctx context.Context, tx *gorm.DB, data *RankPvp) error {
err := m.conn.WithContext(ctx).Save(data).Error err := gormx.WithTx(ctx, m.DB, tx).Save(data).Error
return err return err
} }
func (m *defaultRankPvpModel) Delete(ctx context.Context, id int64) error { func (m *defaultRankPvpModel) Delete(ctx context.Context, tx *gorm.DB, id int64) error {
err := m.conn.WithContext(ctx).Delete(&RankPvp{}, id).Error err := gormx.WithTx(ctx, m.DB, tx).Delete(&RankPvp{}, id).Error
return err return err
} }
@ -88,6 +101,5 @@ func (m *defaultRankPvpModel) tableName() string {
} }
func (RankPvp) TableName() string { func (RankPvp) TableName() string {
model := newRankPvpModel(nil) return RankPvpTableName
return model.tableName()
} }

@ -3,7 +3,7 @@ package model
import ( import (
"context" "context"
"fmt" "fmt"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc" "git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"gorm.io/gorm" "gorm.io/gorm"
) )
@ -31,14 +31,12 @@ type (
// and implement the added methods in customStatisticsPvpModel. // and implement the added methods in customStatisticsPvpModel.
StatisticsPvpModel interface { StatisticsPvpModel interface {
statisticsPvpModel statisticsPvpModel
// Transaction 开启事务,传入方法即可
Transaction(ctx context.Context, tx *gorm.DB, fn func(tx *gorm.DB) error) error
// InsertTx 插入事务
InsertTx(ctx context.Context, tx *gorm.DB, data *StatisticsPvp) error
// UpdateRecord 更新记录 // UpdateRecord 更新记录
UpdateRecord(ctx context.Context, tx *gorm.DB, userId int64, props *UpdateRecordProps) error UpdateRecord(ctx context.Context, tx *gorm.DB, userId int64, props *UpdateRecordProps) error
// FindGreaterByScore 找到比给定分数大的用户id以及具体分数 // FindGreaterByScore 找到比给定分数大的用户id以及具体分数
FindGreaterByScore(ctx context.Context, score int64, scoreType ScoreType, limit int) ([]UserAndScore, error) FindGreaterByScore(ctx context.Context, score int64, scoreType ScoreType, limit int) ([]UserAndScore, error)
// FindScoreByType 根据类型获取分数
FindScoreByType()
} }
UserAndScore struct { UserAndScore struct {
@ -73,19 +71,9 @@ func NewStatisticsPvpModel(conn *gorm.DB) StatisticsPvpModel {
} }
} }
func (m *customStatisticsPvpModel) InsertTx(ctx context.Context, tx *gorm.DB, data *StatisticsPvp) error {
return withTx(ctx, m.conn, tx).Create(data).Error
}
func (m *customStatisticsPvpModel) Transaction(ctx context.Context, tx *gorm.DB, fn func(tx *gorm.DB) error) error {
return withTx(ctx, m.conn, tx).Transaction(func(tx *gorm.DB) error {
return fn(tx)
})
}
func (m *customStatisticsPvpModel) UpdateRecord(ctx context.Context, tx *gorm.DB, userId int64, props *UpdateRecordProps) error { func (m *customStatisticsPvpModel) UpdateRecord(ctx context.Context, tx *gorm.DB, userId int64, props *UpdateRecordProps) error {
// 条件构建 // 条件构建
db := withTx(ctx, m.conn, tx) db := gormx.WithTx(ctx, m.DB, tx)
db = db.Model(&StatisticsPvp{}).Where("user_id = ?", userId) db = db.Model(&StatisticsPvp{}).Where("user_id = ?", userId)
data := make(map[string]interface{}) data := make(map[string]interface{})
@ -130,13 +118,13 @@ func (m *customStatisticsPvpModel) UpdateRecord(ctx context.Context, tx *gorm.DB
return result.Error return result.Error
} }
if result.RowsAffected == 0 { if result.RowsAffected == 0 {
return ErrRowsAffectedZero return gormx.ErrRowsAffectedZero
} }
return nil return nil
} }
func (m *customStatisticsPvpModel) FindGreaterByScore(ctx context.Context, score int64, scoreType ScoreType, limit int) ([]UserAndScore, error) { func (m *customStatisticsPvpModel) FindGreaterByScore(ctx context.Context, score int64, scoreType ScoreType, limit int) ([]UserAndScore, error) {
db := m.conn.WithContext(ctx) db := m.DB.WithContext(ctx)
if limit > MaxRankN { if limit > MaxRankN {
limit = MaxRankN limit = MaxRankN
@ -160,7 +148,7 @@ func (m *customStatisticsPvpModel) FindGreaterByScore(ctx context.Context, score
switch err { switch err {
case nil: case nil:
return result, nil return result, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err

@ -4,22 +4,33 @@ package model
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc" "strings"
"time" "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" "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 ( type (
statisticsPvpModel interface { statisticsPvpModel interface {
Insert(ctx context.Context, data *StatisticsPvp) error gormx.TxModel
FindOne(ctx context.Context, userId int64) (*StatisticsPvp, error) Insert(ctx context.Context, tx *gorm.DB, data *StatisticsPvp) error
Update(ctx context.Context, data *StatisticsPvp) error FindOne(ctx context.Context, tx *gorm.DB, userId int64) (*StatisticsPvp, error)
Delete(ctx context.Context, userId int64) error Update(ctx context.Context, tx *gorm.DB, data *StatisticsPvp) error
Delete(ctx context.Context, tx *gorm.DB, userId int64) error
} }
defaultStatisticsPvpModel struct { defaultStatisticsPvpModel struct {
conn *gorm.DB gormx.GormConn
table string table string
} }
@ -42,38 +53,40 @@ type (
} }
) )
var StatisticsPvpTableName = "`statistics_pvp`"
func newStatisticsPvpModel(conn *gorm.DB) *defaultStatisticsPvpModel { func newStatisticsPvpModel(conn *gorm.DB) *defaultStatisticsPvpModel {
return &defaultStatisticsPvpModel{ return &defaultStatisticsPvpModel{
conn: conn, GormConn: gormx.NewConn(conn),
table: "`statistics_pvp`", table: StatisticsPvpTableName,
} }
} }
func (m *defaultStatisticsPvpModel) Insert(ctx context.Context, data *StatisticsPvp) error { func (m *defaultStatisticsPvpModel) Insert(ctx context.Context, tx *gorm.DB, data *StatisticsPvp) error {
err := m.conn.WithContext(ctx).Create(&data).Error err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
return err return err
} }
func (m *defaultStatisticsPvpModel) FindOne(ctx context.Context, userId int64) (*StatisticsPvp, error) { func (m *defaultStatisticsPvpModel) FindOne(ctx context.Context, tx *gorm.DB, userId int64) (*StatisticsPvp, error) {
var resp StatisticsPvp var resp StatisticsPvp
err := m.conn.WithContext(ctx).Model(&StatisticsPvp{}).Where("`user_id` = ?", userId).Take(&resp).Error err := gormx.WithTx(ctx, m.DB, tx).Model(&StatisticsPvp{}).Where("`user_id` = ?", userId).Take(&resp).Error
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
} }
} }
func (m *defaultStatisticsPvpModel) Update(ctx context.Context, data *StatisticsPvp) error { func (m *defaultStatisticsPvpModel) Update(ctx context.Context, tx *gorm.DB, data *StatisticsPvp) error {
err := m.conn.WithContext(ctx).Save(data).Error err := gormx.WithTx(ctx, m.DB, tx).Save(data).Error
return err return err
} }
func (m *defaultStatisticsPvpModel) Delete(ctx context.Context, userId int64) error { func (m *defaultStatisticsPvpModel) Delete(ctx context.Context, tx *gorm.DB, userId int64) error {
err := m.conn.WithContext(ctx).Delete(&StatisticsPvp{}, userId).Error err := gormx.WithTx(ctx, m.DB, tx).Delete(&StatisticsPvp{}, userId).Error
return err return err
} }
@ -83,6 +96,5 @@ func (m *defaultStatisticsPvpModel) tableName() string {
} }
func (StatisticsPvp) TableName() string { func (StatisticsPvp) TableName() string {
model := newStatisticsPvpModel(nil) return StatisticsPvpTableName
return model.tableName()
} }

@ -2,7 +2,7 @@ package model
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc" "git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"github.com/jinzhu/now" "github.com/jinzhu/now"
"gorm.io/gorm" "gorm.io/gorm"
"time" "time"
@ -15,7 +15,6 @@ type (
// and implement the added methods in customUserCheckInModel. // and implement the added methods in customUserCheckInModel.
UserCheckInModel interface { UserCheckInModel interface {
userCheckInModel userCheckInModel
InsertTx(ctx context.Context, tx *gorm.DB, data *UserCheckIn) error
// FindThisWeek 查询用户本周签到记录 // FindThisWeek 查询用户本周签到记录
FindThisWeek(ctx context.Context, tx *gorm.DB, userId int64) ([]UserCheckIn, error) FindThisWeek(ctx context.Context, tx *gorm.DB, userId int64) ([]UserCheckIn, error)
// CheckInToday 查询用户本日是否已签到 // CheckInToday 查询用户本日是否已签到
@ -34,13 +33,8 @@ func NewUserCheckInModel(conn *gorm.DB) UserCheckInModel {
} }
} }
func (m *customUserCheckInModel) InsertTx(ctx context.Context, tx *gorm.DB, data *UserCheckIn) error {
err := withTx(ctx, m.conn, tx).Create(&data).Error
return err
}
func (m *customUserCheckInModel) FindThisWeek(ctx context.Context, tx *gorm.DB, userId int64) ([]UserCheckIn, error) { func (m *customUserCheckInModel) FindThisWeek(ctx context.Context, tx *gorm.DB, userId int64) ([]UserCheckIn, error) {
db := withTx(ctx, m.conn, tx) db := gormx.WithTx(ctx, m.DB, tx)
// 取签到时间大于本周一的所有该用户签到记录,按签到时间升序排列 // 取签到时间大于本周一的所有该用户签到记录,按签到时间升序排列
var resp []UserCheckIn var resp []UserCheckIn
err := db.Model(&UserCheckIn{}). err := db.Model(&UserCheckIn{}).
@ -49,7 +43,7 @@ func (m *customUserCheckInModel) FindThisWeek(ctx context.Context, tx *gorm.DB,
switch err { switch err {
case nil: case nil:
return resp, nil return resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return []UserCheckIn{}, nil return []UserCheckIn{}, nil
default: default:
return nil, err return nil, err
@ -57,7 +51,7 @@ func (m *customUserCheckInModel) FindThisWeek(ctx context.Context, tx *gorm.DB,
} }
func (m *customUserCheckInModel) CheckInToday(ctx context.Context, tx *gorm.DB, userId int64) (bool, error) { func (m *customUserCheckInModel) CheckInToday(ctx context.Context, tx *gorm.DB, userId int64) (bool, error) {
db := withTx(ctx, m.conn, tx) db := gormx.WithTx(ctx, m.DB, tx)
n := time.Now() n := time.Now()
var count int64 var count int64
@ -68,7 +62,7 @@ func (m *customUserCheckInModel) CheckInToday(ctx context.Context, tx *gorm.DB,
switch err { switch err {
case nil: case nil:
return count > 0, nil return count > 0, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return false, nil return false, nil
default: default:
return false, err return false, err

@ -4,10 +4,10 @@ package model
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc"
"strings" "strings"
"time" "time"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"github.com/zeromicro/go-zero/core/stores/builder" "github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stringx" "github.com/zeromicro/go-zero/core/stringx"
"gorm.io/gorm" "gorm.io/gorm"
@ -22,14 +22,15 @@ var (
type ( type (
userCheckInModel interface { userCheckInModel interface {
Insert(ctx context.Context, data *UserCheckIn) error gormx.TxModel
FindOne(ctx context.Context, id int64) (*UserCheckIn, error) Insert(ctx context.Context, tx *gorm.DB, data *UserCheckIn) error
Update(ctx context.Context, data *UserCheckIn) error FindOne(ctx context.Context, tx *gorm.DB, id int64) (*UserCheckIn, error)
Delete(ctx context.Context, id int64) error Update(ctx context.Context, tx *gorm.DB, data *UserCheckIn) error
Delete(ctx context.Context, tx *gorm.DB, id int64) error
} }
defaultUserCheckInModel struct { defaultUserCheckInModel struct {
conn *gorm.DB gormx.GormConn
table string table string
} }
@ -40,38 +41,40 @@ type (
} }
) )
var UserCheckInTableName = "`user_check_in`"
func newUserCheckInModel(conn *gorm.DB) *defaultUserCheckInModel { func newUserCheckInModel(conn *gorm.DB) *defaultUserCheckInModel {
return &defaultUserCheckInModel{ return &defaultUserCheckInModel{
conn: conn, GormConn: gormx.NewConn(conn),
table: "`user_check_in`", table: UserCheckInTableName,
} }
} }
func (m *defaultUserCheckInModel) Insert(ctx context.Context, data *UserCheckIn) error { func (m *defaultUserCheckInModel) Insert(ctx context.Context, tx *gorm.DB, data *UserCheckIn) error {
err := m.conn.WithContext(ctx).Create(&data).Error err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
return err return err
} }
func (m *defaultUserCheckInModel) FindOne(ctx context.Context, id int64) (*UserCheckIn, error) { func (m *defaultUserCheckInModel) FindOne(ctx context.Context, tx *gorm.DB, id int64) (*UserCheckIn, error) {
var resp UserCheckIn var resp UserCheckIn
err := m.conn.WithContext(ctx).Model(&UserCheckIn{}).Where("`id` = ?", id).Take(&resp).Error err := gormx.WithTx(ctx, m.DB, tx).Model(&UserCheckIn{}).Where("`id` = ?", id).Take(&resp).Error
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
} }
} }
func (m *defaultUserCheckInModel) Update(ctx context.Context, data *UserCheckIn) error { func (m *defaultUserCheckInModel) Update(ctx context.Context, tx *gorm.DB, data *UserCheckIn) error {
err := m.conn.WithContext(ctx).Save(data).Error err := gormx.WithTx(ctx, m.DB, tx).Save(data).Error
return err return err
} }
func (m *defaultUserCheckInModel) Delete(ctx context.Context, id int64) error { func (m *defaultUserCheckInModel) Delete(ctx context.Context, tx *gorm.DB, id int64) error {
err := m.conn.WithContext(ctx).Delete(&UserCheckIn{}, id).Error err := gormx.WithTx(ctx, m.DB, tx).Delete(&UserCheckIn{}, id).Error
return err return err
} }
@ -81,6 +84,5 @@ func (m *defaultUserCheckInModel) tableName() string {
} }
func (UserCheckIn) TableName() string { func (UserCheckIn) TableName() string {
model := newUserCheckInModel(nil) return UserCheckInTableName
return model.tableName()
} }

@ -4,22 +4,33 @@ package model
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc" "strings"
"time" "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" "gorm.io/gorm"
) )
var (
userGiftFieldNames = builder.RawFieldNames(&UserGift{})
userGiftRows = strings.Join(userGiftFieldNames, ",")
userGiftRowsExpectAutoSet = strings.Join(stringx.Remove(userGiftFieldNames, "`create_time`", "`update_time`"), ",")
userGiftRowsWithPlaceHolder = strings.Join(stringx.Remove(userGiftFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
)
type ( type (
userGiftModel interface { userGiftModel interface {
Insert(ctx context.Context, data *UserGift) error gormx.TxModel
FindOne(ctx context.Context, id int64) (*UserGift, error) Insert(ctx context.Context, tx *gorm.DB, data *UserGift) error
Update(ctx context.Context, data *UserGift) error FindOne(ctx context.Context, tx *gorm.DB, id int64) (*UserGift, error)
Delete(ctx context.Context, id int64) error Update(ctx context.Context, tx *gorm.DB, data *UserGift) error
Delete(ctx context.Context, tx *gorm.DB, id int64) error
} }
defaultUserGiftModel struct { defaultUserGiftModel struct {
conn *gorm.DB gormx.GormConn
table string table string
} }
@ -37,38 +48,40 @@ type (
} }
) )
var UserGiftTableName = "`user_gift`"
func newUserGiftModel(conn *gorm.DB) *defaultUserGiftModel { func newUserGiftModel(conn *gorm.DB) *defaultUserGiftModel {
return &defaultUserGiftModel{ return &defaultUserGiftModel{
conn: conn, GormConn: gormx.NewConn(conn),
table: "`user_gift`", table: UserGiftTableName,
} }
} }
func (m *defaultUserGiftModel) Insert(ctx context.Context, data *UserGift) error { func (m *defaultUserGiftModel) Insert(ctx context.Context, tx *gorm.DB, data *UserGift) error {
err := m.conn.WithContext(ctx).Create(&data).Error err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
return err return err
} }
func (m *defaultUserGiftModel) FindOne(ctx context.Context, id int64) (*UserGift, error) { func (m *defaultUserGiftModel) FindOne(ctx context.Context, tx *gorm.DB, id int64) (*UserGift, error) {
var resp UserGift var resp UserGift
err := m.conn.WithContext(ctx).Model(&UserGift{}).Where("`id` = ?", id).Take(&resp).Error err := gormx.WithTx(ctx, m.DB, tx).Model(&UserGift{}).Where("`id` = ?", id).Take(&resp).Error
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
} }
} }
func (m *defaultUserGiftModel) Update(ctx context.Context, data *UserGift) error { func (m *defaultUserGiftModel) Update(ctx context.Context, tx *gorm.DB, data *UserGift) error {
err := m.conn.WithContext(ctx).Save(data).Error err := gormx.WithTx(ctx, m.DB, tx).Save(data).Error
return err return err
} }
func (m *defaultUserGiftModel) Delete(ctx context.Context, id int64) error { func (m *defaultUserGiftModel) Delete(ctx context.Context, tx *gorm.DB, id int64) error {
err := m.conn.WithContext(ctx).Delete(&UserGift{}, id).Error err := gormx.WithTx(ctx, m.DB, tx).Delete(&UserGift{}, id).Error
return err return err
} }
@ -78,6 +91,5 @@ func (m *defaultUserGiftModel) tableName() string {
} }
func (UserGift) TableName() string { func (UserGift) TableName() string {
model := newUserGiftModel(nil) return UserGiftTableName
return model.tableName()
} }

@ -0,0 +1,51 @@
package model
import (
"context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"gorm.io/gorm"
)
var _ UserGiftPackModel = (*customUserGiftPackModel)(nil)
type (
// UserGiftPackModel is an interface to be customized, add more methods here,
// and implement the added methods in customUserGiftPackModel.
UserGiftPackModel interface {
userGiftPackModel
// FindOneByUserPack 获取用户领取的礼包
FindOneByUserPack(ctx context.Context, tx *gorm.DB, userId int64, packType string) (*UserGiftPack, error)
// AddDrawCount 新增领取次数
AddDrawCount(ctx context.Context, tx *gorm.DB, userId int64, packType string) error
}
PackContent struct {
Integral int64 `json:"integral"` // 奖励积分数量
Title []string `json:"title,optional"` // 称号列表
}
customUserGiftPackModel struct {
*defaultUserGiftPackModel
}
)
// NewUserGiftPackModel returns a model for the database table.
func NewUserGiftPackModel(conn *gorm.DB) UserGiftPackModel {
return &customUserGiftPackModel{
defaultUserGiftPackModel: newUserGiftPackModel(conn),
}
}
func (m *customUserGiftPackModel) FindOneByUserPack(ctx context.Context, tx *gorm.DB, userId int64, packType string) (*UserGiftPack, error) {
var resp UserGiftPack
err := withTx(ctx, m.conn, tx).Model(&UserGiftPack{}).
Where("user_id = ? AND pack_type = ?", userId, packType).Take(&resp).Error
switch err {
case nil:
return &resp, nil
case gormx.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}

@ -0,0 +1,91 @@
// Code generated by goctl. DO NOT EDIT!
package model
import (
"context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc"
"gorm.io/plugin/optimisticlock"
"strings"
"time"
"github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stringx"
"gorm.io/gorm"
)
var (
userGiftPackFieldNames = builder.RawFieldNames(&UserGiftPack{})
userGiftPackRows = strings.Join(userGiftPackFieldNames, ",")
userGiftPackRowsExpectAutoSet = strings.Join(stringx.Remove(userGiftPackFieldNames, "`create_time`", "`update_time`"), ",")
userGiftPackRowsWithPlaceHolder = strings.Join(stringx.Remove(userGiftPackFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
)
type (
userGiftPackModel interface {
Insert(ctx context.Context, data *UserGiftPack) error
FindOne(ctx context.Context, id int64) (*UserGiftPack, error)
Update(ctx context.Context, data *UserGiftPack) error
Delete(ctx context.Context, id int64) error
}
defaultUserGiftPackModel struct {
conn *gorm.DB
table string
}
UserGiftPack struct {
Id int64 `gorm:"column:id;primaryKey"` // 主键
UserId int64 `gorm:"column:user_id"` // 用户ID
PackType string `gorm:"column:pack_type"` // 礼包类型
PackContent string `gorm:"column:pack_content"` // 礼包内容(冗余)
DrawCount int64 `gorm:"column:draw_count"` // 已领取数目
DrawTime time.Time `gorm:"column:draw_time;default:null"` // 领取时间
Version optimisticlock.Version `gorm:"column:version"` // 乐观锁,版本号
}
)
func newUserGiftPackModel(conn *gorm.DB) *defaultUserGiftPackModel {
return &defaultUserGiftPackModel{
conn: conn,
table: "`user_gift_pack`",
}
}
func (m *defaultUserGiftPackModel) Insert(ctx context.Context, data *UserGiftPack) error {
err := m.conn.WithContext(ctx).Create(&data).Error
return err
}
func (m *defaultUserGiftPackModel) FindOne(ctx context.Context, id int64) (*UserGiftPack, error) {
var resp UserGiftPack
err := m.conn.WithContext(ctx).Model(&UserGiftPack{}).Where("`id` = ?", id).Take(&resp).Error
switch err {
case nil:
return &resp, nil
case gormc.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultUserGiftPackModel) Update(ctx context.Context, data *UserGiftPack) error {
err := m.conn.WithContext(ctx).Save(data).Error
return err
}
func (m *defaultUserGiftPackModel) Delete(ctx context.Context, id int64) error {
err := m.conn.WithContext(ctx).Delete(&UserGiftPack{}, id).Error
return err
}
func (m *defaultUserGiftPackModel) tableName() string {
return m.table
}
func (UserGiftPack) TableName() string {
model := newUserGiftPackModel(nil)
return model.tableName()
}

@ -2,7 +2,7 @@ package model
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc" "git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"github.com/pkg/errors" "github.com/pkg/errors"
"gorm.io/gorm" "gorm.io/gorm"
"gorm.io/plugin/optimisticlock" "gorm.io/plugin/optimisticlock"
@ -16,10 +16,7 @@ type (
// and implement the added methods in customUserIntegralModel. // and implement the added methods in customUserIntegralModel.
UserIntegralModel interface { UserIntegralModel interface {
userIntegralModel userIntegralModel
Transact(ctx context.Context, tx *gorm.DB, fn func(tx *gorm.DB) error) error UpdateIntegral(ctx context.Context, tx *gorm.DB, integral *UserIntegral) error
InsertTx(ctx context.Context, tx *gorm.DB, data *UserIntegral) error
FindOneTx(ctx context.Context, tx *gorm.DB, userId int64) (*UserIntegral, error)
UpdateTx(ctx context.Context, tx *gorm.DB, integral *UserIntegral) error
// ChangeIntegral 用户积分变动 // ChangeIntegral 用户积分变动
ChangeIntegral(ctx context.Context, tx *gorm.DB, userId int64, change int64) (int64, error) ChangeIntegral(ctx context.Context, tx *gorm.DB, userId int64, change int64) (int64, error)
} }
@ -36,58 +33,34 @@ func NewUserIntegralModel(conn *gorm.DB) UserIntegralModel {
} }
} }
func (m *customUserIntegralModel) Transact(ctx context.Context, tx *gorm.DB, fn func(tx *gorm.DB) error) error { func (m *customUserIntegralModel) UpdateIntegral(ctx context.Context, tx *gorm.DB, integral *UserIntegral) error {
return withTx(ctx, m.conn, tx).Transaction(fn)
}
func (m *customUserIntegralModel) InsertTx(ctx context.Context, tx *gorm.DB, data *UserIntegral) error {
err := withTx(ctx, m.conn, tx).Create(&data).Error
return err
}
func (m *customUserIntegralModel) UpdateTx(ctx context.Context, tx *gorm.DB, integral *UserIntegral) error {
if integral.Integral < 0 { if integral.Integral < 0 {
return errors.New("无法将积分更新至负数") return errors.New("无法将积分更新至负数")
} }
db := withTx(ctx, m.conn, tx) db := gormx.WithTx(ctx, m.DB, tx)
result := db.Model(&integral).Updates(&UserIntegral{Integral: integral.Integral, Version: optimisticlock.Version{Int64: 1}}) result := db.Model(&integral).Updates(&UserIntegral{Integral: integral.Integral, Version: optimisticlock.Version{Int64: 1}})
if result.Error != nil { if result.Error != nil {
return result.Error return result.Error
} }
if result.RowsAffected == 0 { if result.RowsAffected == 0 {
return ErrRowsAffectedZero return gormx.ErrRowsAffectedZero
} }
return nil return nil
} }
func (m *customUserIntegralModel) FindOneTx(ctx context.Context, tx *gorm.DB, userId int64) (*UserIntegral, error) {
var resp UserIntegral
err := withTx(ctx, m.conn, tx).Model(&UserIntegral{}).
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 *customUserIntegralModel) ChangeIntegral(ctx context.Context, tx *gorm.DB, userId int64, change int64) (int64, error) { func (m *customUserIntegralModel) ChangeIntegral(ctx context.Context, tx *gorm.DB, userId int64, change int64) (int64, error) {
resp := change resp := change
var err error err := gormx.WithRetry(VersionRetryCount, func() error {
for i := VersionRetryCount; i > 0; i-- { return m.Transact(tx, func(tx *gorm.DB) error {
err = withTx(ctx, m.conn, tx).Transaction(func(tx *gorm.DB) error { data, err := m.FindOne(ctx, tx, userId)
data, err := m.FindOneTx(ctx, tx, userId)
if err != nil { if err != nil {
if errors.Is(err, ErrNotFound) { if errors.Is(err, ErrNotFound) {
if change < 0 { if change < 0 {
return nerr.NewWithCode(nerr.UserIntegralNotEnoughError) return nerr.NewWithCode(nerr.UserIntegralNotEnoughError)
} }
// 用户积分记录不存在,进行插入 // 用户积分记录不存在,进行插入
if err = m.InsertTx(ctx, tx, &UserIntegral{ if err = m.Insert(ctx, tx, &UserIntegral{
UserId: userId, UserId: userId,
Integral: change, Integral: change,
}); err != nil { }); err != nil {
@ -102,8 +75,8 @@ func (m *customUserIntegralModel) ChangeIntegral(ctx context.Context, tx *gorm.D
return errors.New("用户积分不足") return errors.New("用户积分不足")
} }
data.Integral += change data.Integral += change
if err = m.UpdateTx(ctx, tx, data); err != nil { if err = m.UpdateIntegral(ctx, tx, data); err != nil {
if errors.Is(err, ErrRowsAffectedZero) { if errors.Is(err, gormx.ErrRowsAffectedZero) {
return err return err
} }
return errors.Wrap(err, "更新用户积分失败") return errors.Wrap(err, "更新用户积分失败")
@ -111,14 +84,8 @@ func (m *customUserIntegralModel) ChangeIntegral(ctx context.Context, tx *gorm.D
resp = data.Integral resp = data.Integral
return nil return nil
}) })
if err != nil && errors.Is(err, ErrRowsAffectedZero) { }, func(err error) bool {
// 未能正确更新,直接重试 return errors.Is(err, gormx.ErrRowsAffectedZero)
continue })
} else {
// 其它错误退出循环
break
}
}
return resp, err return resp, err
} }

@ -4,23 +4,34 @@ package model
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc"
"gorm.io/plugin/optimisticlock" "gorm.io/plugin/optimisticlock"
"strings"
"time" "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" "gorm.io/gorm"
) )
var (
userIntegralFieldNames = builder.RawFieldNames(&UserIntegral{})
userIntegralRows = strings.Join(userIntegralFieldNames, ",")
userIntegralRowsExpectAutoSet = strings.Join(stringx.Remove(userIntegralFieldNames, "`create_time`", "`update_time`"), ",")
userIntegralRowsWithPlaceHolder = strings.Join(stringx.Remove(userIntegralFieldNames, "`user_id`", "`create_time`", "`update_time`"), "=?,") + "=?"
)
type ( type (
userIntegralModel interface { userIntegralModel interface {
Insert(ctx context.Context, data *UserIntegral) error gormx.TxModel
FindOne(ctx context.Context, integral int64) (*UserIntegral, error) Insert(ctx context.Context, tx *gorm.DB, data *UserIntegral) error
Update(ctx context.Context, data *UserIntegral) error FindOne(ctx context.Context, tx *gorm.DB, userId int64) (*UserIntegral, error)
Delete(ctx context.Context, integral int64) error Update(ctx context.Context, tx *gorm.DB, data *UserIntegral) error
Delete(ctx context.Context, tx *gorm.DB, userId int64) error
} }
defaultUserIntegralModel struct { defaultUserIntegralModel struct {
conn *gorm.DB gormx.GormConn
table string table string
} }
@ -33,38 +44,48 @@ type (
} }
) )
var UserIntegralTableName = "`user_integral`"
func newUserIntegralModel(conn *gorm.DB) *defaultUserIntegralModel { func newUserIntegralModel(conn *gorm.DB) *defaultUserIntegralModel {
return &defaultUserIntegralModel{ return &defaultUserIntegralModel{
conn: conn, GormConn: gormx.NewConn(conn),
table: "`user_integral`", table: UserIntegralTableName,
} }
} }
func (m *defaultUserIntegralModel) Insert(ctx context.Context, data *UserIntegral) error { func (m *defaultUserIntegralModel) Insert(ctx context.Context, tx *gorm.DB, data *UserIntegral) error {
err := m.conn.WithContext(ctx).Create(&data).Error err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
return err return err
} }
func (m *defaultUserIntegralModel) FindOne(ctx context.Context, integral int64) (*UserIntegral, error) { func (m *defaultUserIntegralModel) FindOne(ctx context.Context, tx *gorm.DB, userId int64) (*UserIntegral, error) {
var resp UserIntegral var resp UserIntegral
err := m.conn.WithContext(ctx).Model(&UserIntegral{}).Where("`integral` = ?", integral).Take(&resp).Error err := gormx.WithTx(ctx, m.DB, tx).Model(&UserIntegral{}).Where("`user_id` = ?", userId).Take(&resp).Error
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
} }
} }
func (m *defaultUserIntegralModel) Update(ctx context.Context, data *UserIntegral) error { func (m *defaultUserIntegralModel) Update(ctx context.Context, tx *gorm.DB, data *UserIntegral) error {
err := m.conn.WithContext(ctx).Save(data).Error
return err result := gormx.WithTx(ctx, m.DB, tx).Save(data)
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return gormx.ErrRowsAffectedZero
}
return nil
} }
func (m *defaultUserIntegralModel) Delete(ctx context.Context, integral int64) error { func (m *defaultUserIntegralModel) Delete(ctx context.Context, tx *gorm.DB, userId int64) error {
err := m.conn.WithContext(ctx).Delete(&UserIntegral{}, integral).Error err := gormx.WithTx(ctx, m.DB, tx).Delete(&UserIntegral{}, userId).Error
return err return err
} }
@ -74,6 +95,5 @@ func (m *defaultUserIntegralModel) tableName() string {
} }
func (UserIntegral) TableName() string { func (UserIntegral) TableName() string {
model := newUserIntegralModel(nil) return UserIntegralTableName
return model.tableName()
} }

@ -1,8 +1,6 @@
package model package model
import ( import (
"context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc"
"gorm.io/gorm" "gorm.io/gorm"
) )
@ -13,10 +11,6 @@ type (
// and implement the added methods in customUserModel. // and implement the added methods in customUserModel.
UserModel interface { UserModel interface {
userModel userModel
Transact(ctx context.Context, tx *gorm.DB, fn func(tx *gorm.DB) error) error
// InsertTx 插入事务
InsertTx(ctx context.Context, tx *gorm.DB, data *User) error
FindOneTx(ctx context.Context, tx *gorm.DB, id int64) (*User, error)
} }
customUserModel struct { customUserModel struct {
@ -30,25 +24,3 @@ func NewUserModel(conn *gorm.DB) UserModel {
defaultUserModel: newUserModel(conn), defaultUserModel: newUserModel(conn),
} }
} }
func (m *customUserModel) Transact(ctx context.Context, tx *gorm.DB, fn func(tx *gorm.DB) error) error {
return withTx(ctx, m.conn, tx).Transaction(fn)
}
func (m *customUserModel) InsertTx(ctx context.Context, tx *gorm.DB, data *User) error {
return withTx(ctx, m.conn, tx).Create(data).Error
}
func (m *customUserModel) FindOneTx(ctx context.Context, tx *gorm.DB, id int64) (*User, error) {
db := withTx(ctx, m.conn, tx)
var resp User
err := db.Model(&User{}).Where("`id` = ?", id).Take(&resp).Error
switch err {
case nil:
return &resp, nil
case gormc.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}

@ -4,10 +4,10 @@ package model
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc"
"strings" "strings"
"time" "time"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"github.com/zeromicro/go-zero/core/stores/builder" "github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stringx" "github.com/zeromicro/go-zero/core/stringx"
"gorm.io/gorm" "gorm.io/gorm"
@ -22,57 +22,60 @@ var (
type ( type (
userModel interface { userModel interface {
Insert(ctx context.Context, data *User) error gormx.TxModel
FindOne(ctx context.Context, id int64) (*User, error) Insert(ctx context.Context, tx *gorm.DB, data *User) error
Update(ctx context.Context, data *User) error FindOne(ctx context.Context, tx *gorm.DB, id int64) (*User, error)
Delete(ctx context.Context, id int64) error Update(ctx context.Context, tx *gorm.DB, data *User) error
Delete(ctx context.Context, tx *gorm.DB, id int64) error
} }
defaultUserModel struct { defaultUserModel struct {
conn *gorm.DB gormx.GormConn
table string table string
} }
User struct { User struct {
Id int64 `gorm:"primaryKey"` // 用户ID Id int64 `gorm:"column:id;primaryKey"` // 用户ID
Username string `gorm:"column:username"` // 用户名 Username string `gorm:"column:username"` // 用户名
CreateTime time.Time `gorm:"column:create_time;default:null"` // 创建时间 CreateTime time.Time `gorm:"column:create_time;default:null"` // 创建时间
UpdateTime time.Time `gorm:"column:update_time;default:null"` // 更新时间 UpdateTime time.Time `gorm:"column:update_time;default:null"` // 更新时间
} }
) )
var UserTableName = "`user`"
func newUserModel(conn *gorm.DB) *defaultUserModel { func newUserModel(conn *gorm.DB) *defaultUserModel {
return &defaultUserModel{ return &defaultUserModel{
conn: conn, GormConn: gormx.NewConn(conn),
table: "`user`", table: UserTableName,
} }
} }
func (m *defaultUserModel) Insert(ctx context.Context, data *User) error { func (m *defaultUserModel) Insert(ctx context.Context, tx *gorm.DB, data *User) error {
err := m.conn.WithContext(ctx).Create(data).Error err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
return err return err
} }
func (m *defaultUserModel) FindOne(ctx context.Context, id int64) (*User, error) { func (m *defaultUserModel) FindOne(ctx context.Context, tx *gorm.DB, id int64) (*User, error) {
var resp User var resp User
err := m.conn.WithContext(ctx).Model(&User{}).Where("`id` = ?", id).Take(&resp).Error err := gormx.WithTx(ctx, m.DB, tx).Model(&User{}).Where("`id` = ?", id).Take(&resp).Error
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
} }
} }
func (m *defaultUserModel) Update(ctx context.Context, data *User) error { func (m *defaultUserModel) Update(ctx context.Context, tx *gorm.DB, data *User) error {
err := m.conn.WithContext(ctx).Save(data).Error err := gormx.WithTx(ctx, m.DB, tx).Save(data).Error
return err return err
} }
func (m *defaultUserModel) Delete(ctx context.Context, id int64) error { func (m *defaultUserModel) Delete(ctx context.Context, tx *gorm.DB, id int64) error {
err := m.conn.WithContext(ctx).Delete(&User{}, id).Error err := gormx.WithTx(ctx, m.DB, tx).Delete(&User{}, id).Error
return err return err
} }
@ -82,6 +85,5 @@ func (m *defaultUserModel) tableName() string {
} }
func (User) TableName() string { func (User) TableName() string {
model := newUserModel(nil) return UserTableName
return model.tableName()
} }

@ -4,72 +4,81 @@ package model
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc" "strings"
"time" "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" "gorm.io/gorm"
) )
const ( var (
TableNameUserNobility = "`user_nobility`" userNobilityFieldNames = builder.RawFieldNames(&UserNobility{})
userNobilityRows = strings.Join(userNobilityFieldNames, ",")
userNobilityRowsExpectAutoSet = strings.Join(stringx.Remove(userNobilityFieldNames, "`create_time`", "`update_time`"), ",")
userNobilityRowsWithPlaceHolder = strings.Join(stringx.Remove(userNobilityFieldNames, "`user_id`", "`create_time`", "`update_time`"), "=?,") + "=?"
) )
type ( type (
userNobilityModel interface { userNobilityModel interface {
Insert(ctx context.Context, data *UserNobility) error gormx.TxModel
FindOne(ctx context.Context, userId int64) (*UserNobility, error) Insert(ctx context.Context, tx *gorm.DB, data *UserNobility) error
Update(ctx context.Context, data *UserNobility) error FindOne(ctx context.Context, tx *gorm.DB, userId int64) (*UserNobility, error)
Delete(ctx context.Context, userId int64) error Update(ctx context.Context, tx *gorm.DB, data *UserNobility) error
Delete(ctx context.Context, tx *gorm.DB, userId int64) error
} }
defaultUserNobilityModel struct { defaultUserNobilityModel struct {
conn *gorm.DB gormx.GormConn
table string table string
} }
UserNobility struct { UserNobility struct {
UserId int64 `gorm:"column:user_id;primaryKey"` // 用户ID UserId int64 `gorm:"column:user_id;primaryKey"` // 用户ID
NobilityLevel int64 `gorm:"column:nobility_level"` // 贵族等级0表示非贵族 NobilityLevel int64 `gorm:"column:nobility_level"` // 贵族等级0表示非贵族
Forever BitBool `gorm:"forever"` // 是否永久贵族 Forever BitBool `gorm:"column:forever"` // 是否永久贵族
StartTime time.Time `gorm:"start_time"` // 开始时间 StartTime time.Time `gorm:"column:start_time;default:null"` // 开始时间
EndTime time.Time `gorm:"end_time"` // 结束时间 EndTime time.Time `gorm:"column:end_time;default:null"` // 结束时间
CreateTime time.Time `gorm:"column:create_time;default:null"` // 创建时间 CreateTime time.Time `gorm:"column:create_time;default:null"` // 创建时间
UpdateTime time.Time `gorm:"column:update_time;default:null"` // 更新时间 UpdateTime time.Time `gorm:"column:update_time;default:null"` // 更新时间
} }
) )
var UserNobilityTableName = "`user_nobility`"
func newUserNobilityModel(conn *gorm.DB) *defaultUserNobilityModel { func newUserNobilityModel(conn *gorm.DB) *defaultUserNobilityModel {
return &defaultUserNobilityModel{ return &defaultUserNobilityModel{
conn: conn, GormConn: gormx.NewConn(conn),
table: TableNameUserNobility, table: UserNobilityTableName,
} }
} }
func (m *defaultUserNobilityModel) Insert(ctx context.Context, data *UserNobility) error { func (m *defaultUserNobilityModel) Insert(ctx context.Context, tx *gorm.DB, data *UserNobility) error {
err := m.conn.WithContext(ctx).Create(&data).Error err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
return err return err
} }
func (m *defaultUserNobilityModel) FindOne(ctx context.Context, userId int64) (*UserNobility, error) { func (m *defaultUserNobilityModel) FindOne(ctx context.Context, tx *gorm.DB, userId int64) (*UserNobility, error) {
var resp UserNobility var resp UserNobility
err := m.conn.WithContext(ctx).Model(&UserNobility{}).Where("`user_id` = ?", userId).Take(&resp).Error err := gormx.WithTx(ctx, m.DB, tx).Model(&UserNobility{}).Where("`user_id` = ?", userId).Take(&resp).Error
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
} }
} }
func (m *defaultUserNobilityModel) Update(ctx context.Context, data *UserNobility) error { func (m *defaultUserNobilityModel) Update(ctx context.Context, tx *gorm.DB, data *UserNobility) error {
err := m.conn.WithContext(ctx).Save(data).Error err := gormx.WithTx(ctx, m.DB, tx).Save(data).Error
return err return err
} }
func (m *defaultUserNobilityModel) Delete(ctx context.Context, userId int64) error { func (m *defaultUserNobilityModel) Delete(ctx context.Context, tx *gorm.DB, userId int64) error {
err := m.conn.WithContext(ctx).Delete(&UserNobility{}, userId).Error err := gormx.WithTx(ctx, m.DB, tx).Delete(&UserNobility{}, userId).Error
return err return err
} }
@ -79,5 +88,5 @@ func (m *defaultUserNobilityModel) tableName() string {
} }
func (UserNobility) TableName() string { func (UserNobility) TableName() string {
return TableNameUserNobility return UserNobilityTableName
} }

@ -3,7 +3,7 @@ package model
import ( import (
"context" "context"
"fmt" "fmt"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc" "git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"gorm.io/gorm" "gorm.io/gorm"
) )
@ -14,10 +14,6 @@ type (
// and implement the added methods in customUserPlatformModel. // and implement the added methods in customUserPlatformModel.
UserPlatformModel interface { UserPlatformModel interface {
userPlatformModel userPlatformModel
// Transaction 开启事务,传入方法即可
Transaction(ctx context.Context, tx *gorm.DB, fn func(tx *gorm.DB) error) error
// InsertTx 事务插入
InsertTx(ctx context.Context, tx *gorm.DB, data *UserPlatform) error
// FindOneByPlatformAndPUid 查询平台用户 // FindOneByPlatformAndPUid 查询平台用户
FindOneByPlatformAndPUid(ctx context.Context, tx *gorm.DB, platform, pUid string) (*UserPlatform, error) FindOneByPlatformAndPUid(ctx context.Context, tx *gorm.DB, platform, pUid string) (*UserPlatform, error)
// FindFullByPlatform 查询系统用户信息(包括平台用户) // FindFullByPlatform 查询系统用户信息(包括平台用户)
@ -58,25 +54,15 @@ func NewUserPlatformModel(conn *gorm.DB) UserPlatformModel {
} }
} }
func (m *customUserPlatformModel) Transaction(ctx context.Context, tx *gorm.DB, fn func(tx *gorm.DB) error) error {
return withTx(ctx, m.conn, tx).Transaction(func(tx *gorm.DB) error {
return fn(tx)
})
}
func (m *customUserPlatformModel) InsertTx(ctx context.Context, tx *gorm.DB, data *UserPlatform) error {
return withTx(ctx, m.conn, tx).Create(data).Error
}
func (m *customUserPlatformModel) FindOneByPlatformAndPUid(ctx context.Context, tx *gorm.DB, platform, pUid string) (*UserPlatform, error) { func (m *customUserPlatformModel) FindOneByPlatformAndPUid(ctx context.Context, tx *gorm.DB, platform, pUid string) (*UserPlatform, error) {
db := withTx(ctx, m.conn, tx) db := gormx.WithTx(ctx, m.DB, tx)
var resp UserPlatform var resp UserPlatform
err := db.Model(&UserPlatform{}).Where("`platform` = ? AND `p_uid` = ?", platform, pUid).Take(&resp).Error err := db.Model(&UserPlatform{}).Where("`platform` = ? AND `p_uid` = ?", platform, pUid).Take(&resp).Error
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
@ -84,7 +70,7 @@ func (m *customUserPlatformModel) FindOneByPlatformAndPUid(ctx context.Context,
} }
func (m *customUserPlatformModel) FindFullByPlatform(ctx context.Context, tx *gorm.DB, platform, pUid string) (*FullUser, error) { func (m *customUserPlatformModel) FindFullByPlatform(ctx context.Context, tx *gorm.DB, platform, pUid string) (*FullUser, error) {
db := withTx(ctx, m.conn, tx) db := gormx.WithTx(ctx, m.DB, tx)
var resp FullUser var resp FullUser
err := db. err := db.
Joins("UserNobility"). Joins("UserNobility").
@ -94,7 +80,7 @@ func (m *customUserPlatformModel) FindFullByPlatform(ctx context.Context, tx *go
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
@ -103,14 +89,14 @@ func (m *customUserPlatformModel) FindFullByPlatform(ctx context.Context, tx *go
func (m *customUserPlatformModel) FindEmptyList(ctx context.Context, num int64) ([]UserPlatform, error) { func (m *customUserPlatformModel) FindEmptyList(ctx context.Context, num int64) ([]UserPlatform, error) {
var resp []UserPlatform var resp []UserPlatform
err := m.conn.WithContext(ctx). err := gormx.WithTx(ctx, m.DB, nil).
Table(m.tableName()). Table(m.tableName()).
Where("JSON_LENGTH(`p_info`) = 0 LIMIT ?", num). Where("JSON_LENGTH(`p_info`) = 0 LIMIT ?", num).
Find(&resp).Error Find(&resp).Error
switch err { switch err {
case nil: case nil:
return resp, nil return resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
@ -119,14 +105,14 @@ func (m *customUserPlatformModel) FindEmptyList(ctx context.Context, num int64)
func (m *customUserPlatformModel) FindUpdatableList(ctx context.Context, duration int64, num int64) ([]UserPlatform, error) { func (m *customUserPlatformModel) FindUpdatableList(ctx context.Context, duration int64, num int64) ([]UserPlatform, error) {
var resp []UserPlatform var resp []UserPlatform
err := m.conn.WithContext(ctx). err := gormx.WithTx(ctx, m.DB, nil).
Table(m.tableName()). Table(m.tableName()).
Where("`update_time` < (NOW() - INTERVAL ? HOUR) LIMIT ?", duration, num). Where("`update_time` < (NOW() - INTERVAL ? HOUR) LIMIT ?", duration, num).
Find(&resp).Error Find(&resp).Error
switch err { switch err {
case nil: case nil:
return resp, nil return resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
@ -135,7 +121,7 @@ func (m *customUserPlatformModel) FindUpdatableList(ctx context.Context, duratio
func (m *customUserPlatformModel) FindOneForRankByUserId(ctx context.Context, uid int64) (*UserPlatformForRank, error) { func (m *customUserPlatformModel) FindOneForRankByUserId(ctx context.Context, uid int64) (*UserPlatformForRank, error) {
var resp UserPlatformForRank var resp UserPlatformForRank
err := m.conn.WithContext(ctx). err := gormx.WithTx(ctx, m.DB, nil).
Table(m.table). Table(m.table).
Select(fmt.Sprintf("%s.user_id, %s.p_uname, %s.p_avatar", m.table, m.table, m.table)). Select(fmt.Sprintf("%s.user_id, %s.p_uname, %s.p_avatar", m.table, m.table, m.table)).
Where("user_id = ?", uid). Where("user_id = ?", uid).
@ -143,7 +129,7 @@ func (m *customUserPlatformModel) FindOneForRankByUserId(ctx context.Context, ui
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
@ -151,7 +137,7 @@ func (m *customUserPlatformModel) FindOneForRankByUserId(ctx context.Context, ui
} }
func (m *customUserPlatformModel) UpdateNobilityByPUid(ctx context.Context, pUid int64, nobility int64) error { func (m *customUserPlatformModel) UpdateNobilityByPUid(ctx context.Context, pUid int64, nobility int64) error {
return m.conn.WithContext(ctx). return gormx.WithTx(ctx, m.DB, nil).
Model(&UserPlatform{}). Model(&UserPlatform{}).
Where("p_uid", pUid). Where("p_uid", pUid).
Update("p_nobility_level", nobility).Error Update("p_nobility_level", nobility).Error
@ -159,14 +145,14 @@ func (m *customUserPlatformModel) UpdateNobilityByPUid(ctx context.Context, pUid
func (m *customUserPlatformModel) FindUserIdByPlatform(ctx context.Context, platform, pUid string) (int64, error) { func (m *customUserPlatformModel) FindUserIdByPlatform(ctx context.Context, platform, pUid string) (int64, error) {
var resp int64 var resp int64
err := m.conn.WithContext(ctx). err := gormx.WithTx(ctx, m.DB, nil).
Table(m.table). Table(m.table).
Select(fmt.Sprintf("%s.user_id", m.table)). Select(fmt.Sprintf("%s.user_id", m.table)).
Where("platform = ? AND p_uid = ?", platform, pUid).Take(&resp).Error Where("platform = ? AND p_uid = ?", platform, pUid).Take(&resp).Error
switch err { switch err {
case nil: case nil:
return resp, nil return resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return 0, ErrNotFound return 0, ErrNotFound
default: default:
return 0, err return 0, err

@ -4,31 +4,39 @@ package model
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc" "strings"
"time" "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" "gorm.io/gorm"
) )
const ( var (
TableNameUserPlatform = "`user_platform`" userPlatformFieldNames = builder.RawFieldNames(&UserPlatform{})
userPlatformRows = strings.Join(userPlatformFieldNames, ",")
userPlatformRowsExpectAutoSet = strings.Join(stringx.Remove(userPlatformFieldNames, "`create_time`", "`update_time`"), ",")
userPlatformRowsWithPlaceHolder = strings.Join(stringx.Remove(userPlatformFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
) )
type ( type (
userPlatformModel interface { userPlatformModel interface {
Insert(ctx context.Context, data *UserPlatform) error gormx.TxModel
FindOne(ctx context.Context, id int64) (*UserPlatform, error) Insert(ctx context.Context, tx *gorm.DB, data *UserPlatform) error
Update(ctx context.Context, data *UserPlatform) error FindOne(ctx context.Context, tx *gorm.DB, id int64) (*UserPlatform, error)
Delete(ctx context.Context, id int64) error FindOneByPlatformPUid(ctx context.Context, tx *gorm.DB, platform string, pUid string) (*UserPlatform, error)
Update(ctx context.Context, tx *gorm.DB, data *UserPlatform) error
Delete(ctx context.Context, tx *gorm.DB, id int64) error
} }
defaultUserPlatformModel struct { defaultUserPlatformModel struct {
conn *gorm.DB gormx.GormConn
table string table string
} }
UserPlatform struct { UserPlatform struct {
Id int64 `gorm:"primaryKey"` // 主键 Id int64 `gorm:"column:id;primaryKey"` // 主键
UserId int64 `gorm:"column:user_id"` // 用户ID UserId int64 `gorm:"column:user_id"` // 用户ID
Platform string `gorm:"column:platform"` // 平台类型 Platform string `gorm:"column:platform"` // 平台类型
POpenid string `gorm:"column:p_openid"` // 平台用户openid POpenid string `gorm:"column:p_openid"` // 平台用户openid
@ -36,44 +44,59 @@ type (
PUname string `gorm:"column:p_uname"` // 平台用户名 PUname string `gorm:"column:p_uname"` // 平台用户名
PInfo string `gorm:"column:p_info"` // 平台用户原始信息(json) PInfo string `gorm:"column:p_info"` // 平台用户原始信息(json)
PAvatar string `gorm:"column:p_avatar"` // 平台用户头像地址 PAvatar string `gorm:"column:p_avatar"` // 平台用户头像地址
PNobilityLevel int32 `gorm:"p_nobility_level"` // 平台贵族等级 根据平台不同等级有所不同,代码逻辑判断 0代表不是贵族 PNobilityLevel int64 `gorm:"column:p_nobility_level"` // 平台贵族等级
CreateTime time.Time `gorm:"column:create_time;default:null"` // 创建时间 CreateTime time.Time `gorm:"column:create_time;default:null"` // 创建时间
UpdateTime time.Time `gorm:"column:update_time;default:null"` // 更新时间 UpdateTime time.Time `gorm:"column:update_time;default:null"` // 更新时间
} }
) )
var UserPlatformTableName = "`user_platform`"
func newUserPlatformModel(conn *gorm.DB) *defaultUserPlatformModel { func newUserPlatformModel(conn *gorm.DB) *defaultUserPlatformModel {
return &defaultUserPlatformModel{ return &defaultUserPlatformModel{
conn: conn, GormConn: gormx.NewConn(conn),
table: TableNameUserPlatform, table: UserPlatformTableName,
} }
} }
func (m *defaultUserPlatformModel) Insert(ctx context.Context, data *UserPlatform) error { func (m *defaultUserPlatformModel) Insert(ctx context.Context, tx *gorm.DB, data *UserPlatform) error {
err := m.conn.WithContext(ctx).Create(data).Error err := gormx.WithTx(ctx, m.DB, tx).Create(&data).Error
return err return err
} }
func (m *defaultUserPlatformModel) FindOne(ctx context.Context, id int64) (*UserPlatform, error) { func (m *defaultUserPlatformModel) FindOne(ctx context.Context, tx *gorm.DB, id int64) (*UserPlatform, error) {
var resp UserPlatform
err := gormx.WithTx(ctx, m.DB, tx).Model(&UserPlatform{}).Where("`id` = ?", id).Take(&resp).Error
switch err {
case nil:
return &resp, nil
case gormx.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}
func (m *defaultUserPlatformModel) FindOneByPlatformPUid(ctx context.Context, tx *gorm.DB, platform string, pUid string) (*UserPlatform, error) {
var resp UserPlatform var resp UserPlatform
err := m.conn.WithContext(ctx).Model(&UserPlatform{}).Where("`id` = ?", id).Take(&resp).Error err := gormx.WithTx(ctx, m.DB, tx).Model(&UserPlatform{}).Where("`platform` = ? and `p_uid` = ?", platform, pUid).Take(&resp).Error
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
} }
} }
func (m *defaultUserPlatformModel) Update(ctx context.Context, data *UserPlatform) error { func (m *defaultUserPlatformModel) Update(ctx context.Context, tx *gorm.DB, data *UserPlatform) error {
err := m.conn.WithContext(ctx).Save(data).Error err := gormx.WithTx(ctx, m.DB, tx).Save(data).Error
return err return err
} }
func (m *defaultUserPlatformModel) Delete(ctx context.Context, id int64) error { func (m *defaultUserPlatformModel) Delete(ctx context.Context, tx *gorm.DB, id int64) error {
err := m.conn.WithContext(ctx).Delete(&UserPlatform{}, id).Error err := gormx.WithTx(ctx, m.DB, tx).Delete(&UserPlatform{}, id).Error
return err return err
} }
@ -83,5 +106,5 @@ func (m *defaultUserPlatformModel) tableName() string {
} }
func (UserPlatform) TableName() string { func (UserPlatform) TableName() string {
return TableNameUserPlatform return UserPlatformTableName
} }

@ -1,14 +0,0 @@
package model
import (
"context"
"gorm.io/gorm"
)
func withTx(ctx context.Context, conn, tx *gorm.DB) *gorm.DB {
if tx != nil {
return tx
} else {
return conn.WithContext(ctx)
}
}

@ -7,9 +7,8 @@ import (
) )
var ErrNotFound = gorm.ErrRecordNotFound var ErrNotFound = gorm.ErrRecordNotFound
var ErrRowsAffectedZero = errors.New("RowsAffected zero")
const VersionRetryCount = 5 // 乐观锁重试次数 const VersionRetryCount = 10 // 乐观锁重试次数
// BitBool is an implementation of a bool for the MySQL type BIT(1). // BitBool is an implementation of a bool for the MySQL type BIT(1).
// This type allows you to avoid wasting an entire byte for MySQL's boolean type TINYINT. // This type allows you to avoid wasting an entire byte for MySQL's boolean type TINYINT.

@ -61,4 +61,23 @@ Integral:
bilibili: 0.001 bilibili: 0.001
# 平台免费礼物到积分的转换 # 平台免费礼物到积分的转换
FreeToIntegral: FreeToIntegral:
bilibili: 0.00025 bilibili: 0.00025
GiftPack:
- PackType: starter
PackName: 新手礼包
Condition:
UserLimit: 1
UserResetType: unset
StartTime: "2022-05-21 09:00:00"
EndTime: "2022-05-21 09:00:00"
Content:
Integral: 50000
- PackType: subsistence
PackName: 低保
Condition:
UserLimit: 3
UserResetType: daily
StartTime: "2022-05-21 09:00:00"
EndTime: "2022-05-21 09:00:00"
Content:
Integrals: [ 10000, 8000, 4000 ]

@ -10,6 +10,28 @@ type (
Addr []string // 连接地址 Addr []string // 连接地址
Topic string Topic string
} }
GiftPack struct {
PackType string // 礼包类型
PackName string // 礼包名称
// Condition 领取条件
Condition struct {
UserLimit int32 // 单人可领取数量
UserResetType string `json:",optional"` // 用户礼包重置类型: 不重置(unset)|每天(daily)|每周(weekly)|每月(monthly)
StartTime string // 可领取时间(开始) 两个时间相等则不限期领取
EndTime string // 可领取时间(结束)
}
// Content 礼包内容
Content struct {
Integral int64 `json:",default=0"` // 积分数
Integrals []int64 `json:",optional"` // 积分数(多次领取,每次不同)
// Title 奖励称号列表
Title []struct {
Id int64 // 称号ID
Duration int64 // 持续时长,单位: 秒 -1无限
} `json:",optional"`
}
}
// Config 配置 // Config 配置
Config struct { Config struct {
@ -69,5 +91,7 @@ type (
GiftToRMB map[string]float64 // 平台礼物到RMB的转换 GiftToRMB map[string]float64 // 平台礼物到RMB的转换
FreeToIntegral map[string]float64 // 平台免费礼物到积分的转换 FreeToIntegral map[string]float64 // 平台免费礼物到积分的转换
} }
// GiftPack 礼包配置
GiftPackMap []GiftPack
} }
) )

@ -0,0 +1,30 @@
package gift
import (
"context"
"live-service/app/user_center/rpc/internal/svc"
"live-service/app/user_center/rpc/pb"
"github.com/zeromicro/go-zero/core/logx"
)
type DrawGiftPackLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDrawGiftPackLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DrawGiftPackLogic {
return &DrawGiftPackLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *DrawGiftPackLogic) DrawGiftPack(in *pb.DrawGiftPackReq) (*pb.DrawGiftPackResp, error) {
// todo: add your logic here and delete this line
return &pb.DrawGiftPackResp{}, nil
}

@ -2,7 +2,6 @@ package gift
import ( import (
"context" "context"
"live-service/app/user_center/rpc/internal/svc" "live-service/app/user_center/rpc/internal/svc"
"live-service/app/user_center/rpc/pb" "live-service/app/user_center/rpc/pb"
@ -26,7 +25,28 @@ func NewUserBuyNobilityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *U
// UserBuyNobility 用户购买贵族 // UserBuyNobility 用户购买贵族
// 1. 记录送礼 // 1. 记录送礼
// 2. 新增积分 // 2. 新增积分
// 3. 修改贵族
func (l *UserBuyNobilityLogic) UserBuyNobility(in *pb.UserBuyNobilityReq) (*pb.UserBuyNobilityResp, error) { func (l *UserBuyNobilityLogic) UserBuyNobility(in *pb.UserBuyNobilityReq) (*pb.UserBuyNobilityResp, error) {
// TODO 未完成 // TODO 未完成
//// 记录送礼信息
//{
// dbUserGift := &model.UserGift{
// Id: uuid.NextId(),
// UserId: in.UserId,
// Platform: in.Platform,
// RoomId: in.RoomId,
// GiftId: strconv.FormatInt(in.GiftId, 10),
// GiftName: in.GiftName,
// Num: in.Num,
// }
// if in.IsPaid {
// dbUserGift.Price = in.Price
// } else {
// dbUserGift.FreePrice = in.Price
// }
// if err := l.svcCtx.UserGiftModel.Insert(l.ctx, nil, dbUserGift); err != nil {
// l.Logger.Errorf("记录用户[%d]送礼信息 [%d:%s:%d] 失败,操作继续...", in.UserId, in.GiftId, in.GiftName, in.Num)
// }
//}
return &pb.UserBuyNobilityResp{}, nil return &pb.UserBuyNobilityResp{}, nil
} }

@ -47,7 +47,7 @@ func (l *UserSendGiftLogic) UserSendGift(in *pb.UserSendGiftReq) (*pb.UserSendGi
} else { } else {
dbUserGift.FreePrice = in.Price dbUserGift.FreePrice = in.Price
} }
if err := l.svcCtx.UserGiftModel.Insert(l.ctx, dbUserGift); err != nil { if err := l.svcCtx.UserGiftModel.Insert(l.ctx, nil, dbUserGift); err != nil {
l.Logger.Errorf("记录用户[%d]送礼信息 [%d:%s:%d] 失败,操作继续...", in.UserId, in.GiftId, in.GiftName, in.Num) l.Logger.Errorf("记录用户[%d]送礼信息 [%d:%s:%d] 失败,操作继续...", in.UserId, in.GiftId, in.GiftName, in.Num)
} }
} }

@ -3,6 +3,7 @@ package gift_collect
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"git.noahlan.cn/northlan/ntools-go/uuid" "git.noahlan.cn/northlan/ntools-go/uuid"
"github.com/pkg/errors" "github.com/pkg/errors"
"gorm.io/gorm" "gorm.io/gorm"
@ -70,8 +71,7 @@ func GiftCollectorBilibili(ctx context.Context, svcCtx *svc.ServiceContext) (ret
} }
ret = make(map[int64]GiftData) ret = make(map[int64]GiftData)
for i := 0; i < batches; i++ { for i := 0; i < batches; i++ {
// TODO 错误处理 _ = svcCtx.GiftModel.TransactCtx(ctx, nil, func(tx *gorm.DB) error {
_ = svcCtx.GiftModel.Transaction(ctx, nil, func(tx *gorm.DB) error {
lenJ := (i + 1) * batchSize lenJ := (i + 1) * batchSize
if lenJ > dataLen { if lenJ > dataLen {
lenJ = dataLen lenJ = dataLen
@ -103,10 +103,10 @@ func GiftCollectorBilibili(ctx context.Context, svcCtx *svc.ServiceContext) (ret
} }
ret[giftData.Id] = giftData ret[giftData.Id] = giftData
if err = svcCtx.GiftModel.UpdateTx(ctx, tx, dbGift); err != nil { if err = svcCtx.GiftModel.Update(ctx, tx, dbGift); err != nil {
if errors.Is(err, model.ErrRowsAffectedZero) { if errors.Is(err, gormx.ErrRowsAffectedZero) {
err = nil err = nil
_ = svcCtx.GiftModel.InsertTx(ctx, tx, dbGift) _ = svcCtx.GiftModel.Insert(ctx, tx, dbGift)
} }
} }
} }

@ -28,7 +28,7 @@ func NewGetUserIntegralLogic(ctx context.Context, svcCtx *svc.ServiceContext) *G
// GetUserIntegral 获取用户积分 // GetUserIntegral 获取用户积分
func (l *GetUserIntegralLogic) GetUserIntegral(in *pb.UserIdReq) (*pb.UserIntegralResp, error) { func (l *GetUserIntegralLogic) GetUserIntegral(in *pb.UserIdReq) (*pb.UserIntegralResp, error) {
// 查询当前用户积分 // 查询当前用户积分
integral, err := l.svcCtx.UserIntegralModel.FindOneTx(l.ctx, nil, in.UserId) integral, err := l.svcCtx.UserIntegralModel.FindOne(l.ctx, nil, in.UserId)
if err != nil { if err != nil {
return nil, errors.Wrapf(nerr.NewWithCode(nerr.DBError), "查询用户积分失败, err:%+v", err) return nil, errors.Wrapf(nerr.NewWithCode(nerr.DBError), "查询用户积分失败, err:%+v", err)
} }

@ -121,7 +121,7 @@ func (r *UserRetriever) retrieveList(list []model.UserPlatform) {
dbModel.PAvatar = pUser.PAvatar dbModel.PAvatar = pUser.PAvatar
dbModel.PInfo = pUser.PInfo dbModel.PInfo = pUser.PInfo
dbModel.UpdateTime = time.Now() dbModel.UpdateTime = time.Now()
_ = r.svcCtx.UserPlatformModel.Update(r.ctx, &dbModel) _ = r.svcCtx.UserPlatformModel.Update(r.ctx, nil, &dbModel)
} }
} }

@ -0,0 +1,30 @@
package rank
import (
"context"
"live-service/app/user_center/rpc/internal/svc"
"live-service/app/user_center/rpc/pb"
"github.com/zeromicro/go-zero/core/logx"
)
type RankPvpSubmitLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewRankPvpSubmitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RankPvpSubmitLogic {
return &RankPvpSubmitLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *RankPvpSubmitLogic) RankPvpSubmit(in *pb.RankPvpSubmitReq) (*pb.RankPvpSubmitResp, error) {
// todo: add your logic here and delete this line
return &pb.RankPvpSubmitResp{}, nil
}

@ -0,0 +1,37 @@
package rank
import (
"context"
"live-service/app/user_center/rpc/internal/svc"
"live-service/app/user_center/rpc/pb"
"github.com/zeromicro/go-zero/core/logx"
)
type UserRankPvpLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewUserRankPvpLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserRankPvpLogic {
return &UserRankPvpLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *UserRankPvpLogic) UserRankPvp(in *pb.UserRankReq) (*pb.UserRankResp, error) {
// 1. 查询用户自己当前分数
// 2. 获取排名
// 3. 所有排名信息(需要首先判断)
if in.AllRankType {
//in.UserId
} else {
// 只查询一种类型
}
return &pb.UserRankResp{}, nil
}

@ -2,6 +2,7 @@ package statistics
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"github.com/pkg/errors" "github.com/pkg/errors"
"gorm.io/gorm" "gorm.io/gorm"
"live-service/app/user_center/model" "live-service/app/user_center/model"
@ -36,7 +37,7 @@ func (l *StatPvpFirstBloodLogic) StatPvpFirstBlood(in *pb.StatPvPFirstBloodReq)
if in.Uid <= 0 { if in.Uid <= 0 {
return &pb.Empty{}, nil return &pb.Empty{}, nil
} }
err := l.svcCtx.StatisticsPvpModel.Transaction(l.ctx, nil, func(tx *gorm.DB) error { err := l.svcCtx.StatisticsPvpModel.TransactCtx(l.ctx, nil, func(tx *gorm.DB) error {
// 直接更新,提高效率 // 直接更新,提高效率
props := model.UpdateRecordProps{} props := model.UpdateRecordProps{}
if in.Type == TypeFirstBlood { if in.Type == TypeFirstBlood {
@ -47,7 +48,7 @@ func (l *StatPvpFirstBloodLogic) StatPvpFirstBlood(in *pb.StatPvPFirstBloodReq)
if err := l.svcCtx.StatisticsPvpModel.UpdateRecord(l.ctx, tx, in.Uid, if err := l.svcCtx.StatisticsPvpModel.UpdateRecord(l.ctx, tx, in.Uid,
&props); err != nil { &props); err != nil {
if errors.Is(err, model.ErrRowsAffectedZero) { if errors.Is(err, gormx.ErrRowsAffectedZero) {
// insert // insert
dbModel := model.StatisticsPvp{ dbModel := model.StatisticsPvp{
UserId: in.Uid, UserId: in.Uid,
@ -57,7 +58,7 @@ func (l *StatPvpFirstBloodLogic) StatPvpFirstBlood(in *pb.StatPvPFirstBloodReq)
} else if in.Type == TypeDeFirstBlood { } else if in.Type == TypeDeFirstBlood {
dbModel.DeFirstBloodCount = 1 dbModel.DeFirstBloodCount = 1
} }
if err = l.svcCtx.StatisticsPvpModel.InsertTx(l.ctx, tx, &dbModel); err != nil { if err = l.svcCtx.StatisticsPvpModel.Insert(l.ctx, tx, &dbModel); err != nil {
return errors.Wrapf(err, ErrInsertErr, err) return errors.Wrapf(err, ErrInsertErr, err)
} }
} else { } else {

@ -2,6 +2,7 @@ package statistics
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"github.com/pkg/errors" "github.com/pkg/errors"
"gorm.io/gorm" "gorm.io/gorm"
"live-service/app/user_center/model" "live-service/app/user_center/model"
@ -33,18 +34,18 @@ func (l *StatPvpKillLogic) StatPvpKill(in *pb.StatPvPKillReq) (*pb.Empty, error)
return &pb.Empty{}, nil return &pb.Empty{}, nil
} }
err := l.svcCtx.StatisticsPvpModel.Transaction(l.ctx, nil, func(tx *gorm.DB) error { err := l.svcCtx.StatisticsPvpModel.TransactCtx(l.ctx, nil, func(tx *gorm.DB) error {
// 击杀 // 击杀
props := model.UpdateRecordProps{ props := model.UpdateRecordProps{
KillPlayer: true, KillPlayer: true,
} }
if err := l.svcCtx.StatisticsPvpModel.UpdateRecord(l.ctx, tx, in.Uid, &props); err != nil { if err := l.svcCtx.StatisticsPvpModel.UpdateRecord(l.ctx, tx, in.Uid, &props); err != nil {
if errors.Is(err, model.ErrRowsAffectedZero) { if errors.Is(err, gormx.ErrRowsAffectedZero) {
dbModel := &model.StatisticsPvp{ dbModel := &model.StatisticsPvp{
UserId: in.Uid, UserId: in.Uid,
KillPlayerCount: 1, KillPlayerCount: 1,
} }
if err := l.svcCtx.StatisticsPvpModel.InsertTx(l.ctx, tx, dbModel); err != nil { if err := l.svcCtx.StatisticsPvpModel.Insert(l.ctx, tx, dbModel); err != nil {
return errors.Wrapf(err, ErrInsertErr, err) return errors.Wrapf(err, ErrInsertErr, err)
} }
} else { } else {
@ -61,7 +62,7 @@ func (l *StatPvpKillLogic) StatPvpKill(in *pb.StatPvPKillReq) (*pb.Empty, error)
DeGeneral: in.IsGeneral, DeGeneral: in.IsGeneral,
} }
if err := l.svcCtx.StatisticsPvpModel.UpdateRecord(l.ctx, tx, in.TargetUid, &props); err != nil { if err := l.svcCtx.StatisticsPvpModel.UpdateRecord(l.ctx, tx, in.TargetUid, &props); err != nil {
if errors.Is(err, model.ErrRowsAffectedZero) { if errors.Is(err, gormx.ErrRowsAffectedZero) {
dbModel := &model.StatisticsPvp{ dbModel := &model.StatisticsPvp{
UserId: in.TargetUid, UserId: in.TargetUid,
DeKillUnitCount: 1, DeKillUnitCount: 1,
@ -69,7 +70,7 @@ func (l *StatPvpKillLogic) StatPvpKill(in *pb.StatPvPKillReq) (*pb.Empty, error)
if in.IsGeneral { if in.IsGeneral {
dbModel.DeGeneralCount = 1 dbModel.DeGeneralCount = 1
} }
if err := l.svcCtx.StatisticsPvpModel.InsertTx(l.ctx, tx, dbModel); err != nil { if err := l.svcCtx.StatisticsPvpModel.Insert(l.ctx, tx, dbModel); err != nil {
return errors.Wrapf(err, ErrInsertErr, err) return errors.Wrapf(err, ErrInsertErr, err)
} }
} else { } else {

@ -2,6 +2,7 @@ package statistics
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/logx" "github.com/zeromicro/go-zero/core/logx"
"gorm.io/gorm" "gorm.io/gorm"
@ -30,12 +31,12 @@ func (l *StatPvpReportLogic) StatPvpReport(in *pb.StatPvPReportReq) (*pb.StatPvP
{ {
general := in.General general := in.General
if general.Uid > 0 { if general.Uid > 0 {
if err := l.svcCtx.Db.Transaction(func(tx *gorm.DB) error { if err := l.svcCtx.StatisticsPvpModel.TransactCtx(l.ctx, nil, func(tx *gorm.DB) error {
if err := l.svcCtx.StatisticsPvpModel.UpdateRecord(l.ctx, tx, general.Uid, if err := l.svcCtx.StatisticsPvpModel.UpdateRecord(l.ctx, tx, general.Uid,
&model.UpdateRecordProps{General: true}); err != nil { &model.UpdateRecordProps{General: true}); err != nil {
if errors.Is(err, model.ErrRowsAffectedZero) { if errors.Is(err, gormx.ErrRowsAffectedZero) {
// insert // insert
if err = l.svcCtx.StatisticsPvpModel.InsertTx(l.ctx, tx, &model.StatisticsPvp{ if err = l.svcCtx.StatisticsPvpModel.Insert(l.ctx, tx, &model.StatisticsPvp{
UserId: general.Uid, UserId: general.Uid,
GeneralCount: 1, GeneralCount: 1,
}); err != nil { }); err != nil {
@ -80,7 +81,7 @@ func (l *StatPvpReportLogic) StatPvpReport(in *pb.StatPvPReportReq) (*pb.StatPvP
winItemResp := make([]*pb.StatPvPReportResp_Item, 0, len(in.WinItems)) winItemResp := make([]*pb.StatPvPReportResp_Item, 0, len(in.WinItems))
lostItemResp := make([]*pb.StatPvPReportResp_Item, 0, len(in.LostItems)) lostItemResp := make([]*pb.StatPvPReportResp_Item, 0, len(in.LostItems))
if err := l.svcCtx.Db.Transaction(func(tx *gorm.DB) error { if err := l.svcCtx.UserIntegralModel.TransactCtx(l.ctx, nil, func(tx *gorm.DB) error {
for _, item := range in.WinItems { for _, item := range in.WinItems {
uid, damage := item.Uid, item.Damage uid, damage := item.Uid, item.Damage
addIntegral := int64(float64(damage) * battleReportCfg.WinRadio) addIntegral := int64(float64(damage) * battleReportCfg.WinRadio)
@ -119,7 +120,7 @@ func (l *StatPvpReportLogic) StatPvpReport(in *pb.StatPvPReportReq) (*pb.StatPvP
} }
func (l *StatPvpReportLogic) reports(win bool, items []*pb.StatPvPReportReq_Item) error { func (l *StatPvpReportLogic) reports(win bool, items []*pb.StatPvPReportReq_Item) error {
return l.svcCtx.Db.Transaction(func(tx *gorm.DB) error { return l.svcCtx.StatisticsPvpModel.TransactCtx(l.ctx, nil, func(tx *gorm.DB) error {
for _, item := range items { for _, item := range items {
if err := l.svcCtx.StatisticsPvpModel.UpdateRecord(l.ctx, tx, item.Uid, if err := l.svcCtx.StatisticsPvpModel.UpdateRecord(l.ctx, tx, item.Uid,
&model.UpdateRecordProps{ &model.UpdateRecordProps{
@ -130,7 +131,7 @@ func (l *StatPvpReportLogic) reports(win bool, items []*pb.StatPvPReportReq_Item
KillUnitCount: &item.KillUnit, KillUnitCount: &item.KillUnit,
DeKillUnitCount: &item.DeKillUnit, DeKillUnitCount: &item.DeKillUnit,
}); err != nil { }); err != nil {
if errors.Is(err, model.ErrRowsAffectedZero) { if errors.Is(err, gormx.ErrRowsAffectedZero) {
// insert // insert
var winCount int64 var winCount int64
var lostCount int64 var lostCount int64
@ -139,7 +140,7 @@ func (l *StatPvpReportLogic) reports(win bool, items []*pb.StatPvPReportReq_Item
} else { } else {
lostCount = 1 lostCount = 1
} }
if err = l.svcCtx.StatisticsPvpModel.InsertTx(l.ctx, tx, &model.StatisticsPvp{ if err = l.svcCtx.StatisticsPvpModel.Insert(l.ctx, tx, &model.StatisticsPvp{
UserId: item.Uid, UserId: item.Uid,
WinCount: winCount, WinCount: winCount,
LostCount: lostCount, LostCount: lostCount,

@ -33,7 +33,7 @@ func (l *RetrievePlatformUserLogic) RetrievePlatformUser(in *pb.PlatformUserReq)
var dbFullUser *model.FullUser var dbFullUser *model.FullUser
var username string var username string
if err := l.svcCtx.UserPlatformModel.Transaction(l.ctx, nil, func(tx *gorm.DB) error { if err := l.svcCtx.Db.Transaction(func(tx *gorm.DB) error {
var err error var err error
if dbFullUser, err = l.svcCtx.UserPlatformModel.FindFullByPlatform(l.ctx, tx, in.Platform, in.PUid); err != nil { if dbFullUser, err = l.svcCtx.UserPlatformModel.FindFullByPlatform(l.ctx, tx, in.Platform, in.PUid); err != nil {
if !errors.Is(err, model.ErrNotFound) { if !errors.Is(err, model.ErrNotFound) {
@ -41,7 +41,7 @@ func (l *RetrievePlatformUserLogic) RetrievePlatformUser(in *pb.PlatformUserReq)
} }
} }
if dbFullUser != nil { if dbFullUser != nil {
if one, err := l.svcCtx.UserModel.FindOneTx(l.ctx, tx, dbFullUser.UserId); err != nil { if one, err := l.svcCtx.UserModel.FindOne(l.ctx, tx, dbFullUser.UserId); err != nil {
username = one.Username username = one.Username
} }
return nil return nil
@ -50,7 +50,7 @@ func (l *RetrievePlatformUserLogic) RetrievePlatformUser(in *pb.PlatformUserReq)
// insert // insert
newId := uuid.NextId() newId := uuid.NextId()
if err := l.svcCtx.UserModel.InsertTx(l.ctx, tx, &model.User{Id: newId}); err != nil { if err := l.svcCtx.UserModel.Insert(l.ctx, tx, &model.User{Id: newId}); err != nil {
return errors.Wrap(nerr.NewWithCode(nerr.DBError), "插入用户数据失败") return errors.Wrap(nerr.NewWithCode(nerr.DBError), "插入用户数据失败")
} }
dbPlatformUser := &model.UserPlatform{ dbPlatformUser := &model.UserPlatform{
@ -60,7 +60,7 @@ func (l *RetrievePlatformUserLogic) RetrievePlatformUser(in *pb.PlatformUserReq)
PUid: in.PUid, PUid: in.PUid,
PInfo: "{}", PInfo: "{}",
} }
if err := l.svcCtx.UserPlatformModel.InsertTx(l.ctx, tx, dbPlatformUser); err != nil { if err := l.svcCtx.UserPlatformModel.Insert(l.ctx, tx, dbPlatformUser); err != nil {
return errors.Wrap(nerr.NewWithCode(nerr.DBError), "插入平台用户数据失败") return errors.Wrap(nerr.NewWithCode(nerr.DBError), "插入平台用户数据失败")
} }
dbFullUser = &model.FullUser{ dbFullUser = &model.FullUser{

@ -54,7 +54,7 @@ func (l *UserCheckInLogic) UserCheckIn(in *pb.UserIdReq) (*pb.UserCheckInResp, e
return ErrAlreadyCheckIn return ErrAlreadyCheckIn
} }
// 打卡记录 // 打卡记录
if err = l.svcCtx.UserCheckInModel.InsertTx(l.ctx, tx, &model.UserCheckIn{ if err = l.svcCtx.UserCheckInModel.Insert(l.ctx, tx, &model.UserCheckIn{
Id: uuid.NextId(), Id: uuid.NextId(),
UserId: in.UserId, UserId: in.UserId,
CheckInTime: time.Now(), CheckInTime: time.Now(),

@ -82,8 +82,23 @@ func (s *UserCenterServer) StatPvpReport(ctx context.Context, in *pb.StatPvPRepo
return l.StatPvpReport(in) return l.StatPvpReport(in)
} }
func (s *UserCenterServer) DrawGiftPack(ctx context.Context, in *pb.DrawGiftPackReq) (*pb.DrawGiftPackResp, error) {
l := gift.NewDrawGiftPackLogic(ctx, s.svcCtx)
return l.DrawGiftPack(in)
}
// rankPvp pvp排行 // rankPvp pvp排行
func (s *UserCenterServer) RankPvp(ctx context.Context, in *pb.RankPvpReq) (*pb.RankPvpResp, error) { func (s *UserCenterServer) RankPvp(ctx context.Context, in *pb.RankPvpReq) (*pb.RankPvpResp, error) {
l := rank.NewRankPvpLogic(ctx, s.svcCtx) l := rank.NewRankPvpLogic(ctx, s.svcCtx)
return l.RankPvp(in) return l.RankPvp(in)
} }
func (s *UserCenterServer) RankPvpSubmit(ctx context.Context, in *pb.RankPvpSubmitReq) (*pb.RankPvpSubmitResp, error) {
l := rank.NewRankPvpSubmitLogic(ctx, s.svcCtx)
return l.RankPvpSubmit(in)
}
func (s *UserCenterServer) UserRankPvp(ctx context.Context, in *pb.UserRankReq) (*pb.UserRankResp, error) {
l := rank.NewUserRankPvpLogic(ctx, s.svcCtx)
return l.UserRankPvp(in)
}

@ -21,6 +21,7 @@ type ServiceContext struct {
UserIntegralModel model.UserIntegralModel UserIntegralModel model.UserIntegralModel
UserNobilityModel model.UserNobilityModel UserNobilityModel model.UserNobilityModel
UserCheckInModel model.UserCheckInModel UserCheckInModel model.UserCheckInModel
UserGiftPackModel model.UserGiftPackModel
StatisticsPvpModel model.StatisticsPvpModel StatisticsPvpModel model.StatisticsPvpModel
RankPvpModel model.RankPvpModel RankPvpModel model.RankPvpModel
@ -58,6 +59,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
UserIntegralModel: model.NewUserIntegralModel(gormDb), UserIntegralModel: model.NewUserIntegralModel(gormDb),
UserNobilityModel: model.NewUserNobilityModel(gormDb), UserNobilityModel: model.NewUserNobilityModel(gormDb),
UserCheckInModel: model.NewUserCheckInModel(gormDb), UserCheckInModel: model.NewUserCheckInModel(gormDb),
UserGiftPackModel: model.NewUserGiftPackModel(gormDb),
StatisticsPvpModel: model.NewStatisticsPvpModel(gormDb), StatisticsPvpModel: model.NewStatisticsPvpModel(gormDb),
RankPvpModel: model.NewRankPvpModel(gormDb), RankPvpModel: model.NewRankPvpModel(gormDb),
GiftModel: model.NewGiftModel(gormDb), GiftModel: model.NewGiftModel(gormDb),

File diff suppressed because it is too large Load Diff

@ -150,7 +150,50 @@ message StatPvPReportResp {
repeated Item lostItems = 11; // repeated Item lostItems = 11; //
} }
// rank ////////////////////
enum GiftType {
starter = 0; //
subsistence = 1; //
}
message GiftPackItem {
string giftType = 1; // starter:
int64 integral = 2; //
repeated string title = 3; //
}
message DrawGiftPackReq {
int64 uid = 1;
string uname = 2;
string giftType = 3;
}
message DrawGiftPackResp {
int64 uid = 1;
string uname = 2;
int32 code = 3; // 200: 201100: 201101:
string msg = 4; // [||||]
GiftPackItem item = 10;
}
////////////////////// rank
enum RankType {
Unknown = 0;
Damage = 1; //
DeDamage = 2; //
General = 3; //
DeGeneral = 4; //
KillUnit = 5; //
DeKillUnit = 6; //
KillPlayer = 7; //
DeKillPlayer = 8; //
Win = 9; //
Lost = 10; //
FirstBlood = 11; //
DeFirstBlood = 12; //
}
message RankPvpReq { message RankPvpReq {
int32 type = 1; // rank int32 type = 1; // rank
int32 topN = 2; // TopN int32 topN = 2; // TopN
@ -167,6 +210,45 @@ message RankPvpResp {
repeated Item items = 2; // rank repeated Item items = 2; // rank
} }
// RankPvpSubmitReq
message RankPvpSubmitReq {
int32 rankType = 1; //
bool allRankType = 2; //
}
message RankPvpSubmitResp {
message Result {
int64 userId = 1;
string username = 2;
string avatar = 3;
int64 integral = 4; //
string title = 5; //
int64 titleDuration = 6; // (: ,)
}
message Item {
int32 rankType = 1; //
repeated Result results = 2; //
}
repeated Item items = 1;
}
// UserRankReq
message UserRankReq {
int64 userId = 1; // ID
string username = 2; //
int32 rankType = 3; //
bool allRankType = 4; //
}
message UserRankResp {
message Item {
int32 rankType = 1; //
int32 pos = 2; //
}
repeated Item items = 1;
}
service userCenter { service userCenter {
/// @ZeroGroup: platform_user /// @ZeroGroup: platform_user
@ -196,8 +278,14 @@ service userCenter {
rpc statPvpFirstBlood(StatPvPFirstBloodReq) returns (Empty); rpc statPvpFirstBlood(StatPvPFirstBloodReq) returns (Empty);
rpc statPvpReport(StatPvPReportReq) returns (StatPvPReportResp); rpc statPvpReport(StatPvPReportReq) returns (StatPvPReportResp);
/// @ZeroGroup: giftPack
rpc drawGiftPack(DrawGiftPackReq) returns(DrawGiftPackResp);
/// @ZeroGroup: rank /// @ZeroGroup: rank
// rankPvp pvp // rankPvp pvp
rpc rankPvp(RankPvpReq) returns(RankPvpResp); rpc rankPvp(RankPvpReq) returns(RankPvpResp);
rpc rankPvpSubmit(RankPvpSubmitReq) returns(RankPvpSubmitResp);
rpc userRankPvp(UserRankReq) returns (UserRankResp);
} }

@ -38,8 +38,11 @@ type UserCenterClient interface {
StatPvpKill(ctx context.Context, in *StatPvPKillReq, opts ...grpc.CallOption) (*Empty, error) StatPvpKill(ctx context.Context, in *StatPvPKillReq, opts ...grpc.CallOption) (*Empty, error)
StatPvpFirstBlood(ctx context.Context, in *StatPvPFirstBloodReq, opts ...grpc.CallOption) (*Empty, error) StatPvpFirstBlood(ctx context.Context, in *StatPvPFirstBloodReq, opts ...grpc.CallOption) (*Empty, error)
StatPvpReport(ctx context.Context, in *StatPvPReportReq, opts ...grpc.CallOption) (*StatPvPReportResp, error) StatPvpReport(ctx context.Context, in *StatPvPReportReq, opts ...grpc.CallOption) (*StatPvPReportResp, error)
DrawGiftPack(ctx context.Context, in *DrawGiftPackReq, opts ...grpc.CallOption) (*DrawGiftPackResp, error)
// rankPvp pvp排行 // rankPvp pvp排行
RankPvp(ctx context.Context, in *RankPvpReq, opts ...grpc.CallOption) (*RankPvpResp, error) RankPvp(ctx context.Context, in *RankPvpReq, opts ...grpc.CallOption) (*RankPvpResp, error)
RankPvpSubmit(ctx context.Context, in *RankPvpSubmitReq, opts ...grpc.CallOption) (*RankPvpSubmitResp, error)
UserRankPvp(ctx context.Context, in *UserRankReq, opts ...grpc.CallOption) (*UserRankResp, error)
} }
type userCenterClient struct { type userCenterClient struct {
@ -140,6 +143,15 @@ func (c *userCenterClient) StatPvpReport(ctx context.Context, in *StatPvPReportR
return out, nil return out, nil
} }
func (c *userCenterClient) DrawGiftPack(ctx context.Context, in *DrawGiftPackReq, opts ...grpc.CallOption) (*DrawGiftPackResp, error) {
out := new(DrawGiftPackResp)
err := c.cc.Invoke(ctx, "/pb.userCenter/drawGiftPack", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userCenterClient) RankPvp(ctx context.Context, in *RankPvpReq, opts ...grpc.CallOption) (*RankPvpResp, error) { func (c *userCenterClient) RankPvp(ctx context.Context, in *RankPvpReq, opts ...grpc.CallOption) (*RankPvpResp, error) {
out := new(RankPvpResp) out := new(RankPvpResp)
err := c.cc.Invoke(ctx, "/pb.userCenter/rankPvp", in, out, opts...) err := c.cc.Invoke(ctx, "/pb.userCenter/rankPvp", in, out, opts...)
@ -149,6 +161,24 @@ func (c *userCenterClient) RankPvp(ctx context.Context, in *RankPvpReq, opts ...
return out, nil return out, nil
} }
func (c *userCenterClient) RankPvpSubmit(ctx context.Context, in *RankPvpSubmitReq, opts ...grpc.CallOption) (*RankPvpSubmitResp, error) {
out := new(RankPvpSubmitResp)
err := c.cc.Invoke(ctx, "/pb.userCenter/rankPvpSubmit", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userCenterClient) UserRankPvp(ctx context.Context, in *UserRankReq, opts ...grpc.CallOption) (*UserRankResp, error) {
out := new(UserRankResp)
err := c.cc.Invoke(ctx, "/pb.userCenter/userRankPvp", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// UserCenterServer is the server API for UserCenter service. // UserCenterServer is the server API for UserCenter service.
// All implementations must embed UnimplementedUserCenterServer // All implementations must embed UnimplementedUserCenterServer
// for forward compatibility // for forward compatibility
@ -169,8 +199,11 @@ type UserCenterServer interface {
StatPvpKill(context.Context, *StatPvPKillReq) (*Empty, error) StatPvpKill(context.Context, *StatPvPKillReq) (*Empty, error)
StatPvpFirstBlood(context.Context, *StatPvPFirstBloodReq) (*Empty, error) StatPvpFirstBlood(context.Context, *StatPvPFirstBloodReq) (*Empty, error)
StatPvpReport(context.Context, *StatPvPReportReq) (*StatPvPReportResp, error) StatPvpReport(context.Context, *StatPvPReportReq) (*StatPvPReportResp, error)
DrawGiftPack(context.Context, *DrawGiftPackReq) (*DrawGiftPackResp, error)
// rankPvp pvp排行 // rankPvp pvp排行
RankPvp(context.Context, *RankPvpReq) (*RankPvpResp, error) RankPvp(context.Context, *RankPvpReq) (*RankPvpResp, error)
RankPvpSubmit(context.Context, *RankPvpSubmitReq) (*RankPvpSubmitResp, error)
UserRankPvp(context.Context, *UserRankReq) (*UserRankResp, error)
mustEmbedUnimplementedUserCenterServer() mustEmbedUnimplementedUserCenterServer()
} }
@ -208,9 +241,18 @@ func (UnimplementedUserCenterServer) StatPvpFirstBlood(context.Context, *StatPvP
func (UnimplementedUserCenterServer) StatPvpReport(context.Context, *StatPvPReportReq) (*StatPvPReportResp, error) { func (UnimplementedUserCenterServer) StatPvpReport(context.Context, *StatPvPReportReq) (*StatPvPReportResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method StatPvpReport not implemented") return nil, status.Errorf(codes.Unimplemented, "method StatPvpReport not implemented")
} }
func (UnimplementedUserCenterServer) DrawGiftPack(context.Context, *DrawGiftPackReq) (*DrawGiftPackResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method DrawGiftPack not implemented")
}
func (UnimplementedUserCenterServer) RankPvp(context.Context, *RankPvpReq) (*RankPvpResp, error) { func (UnimplementedUserCenterServer) RankPvp(context.Context, *RankPvpReq) (*RankPvpResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method RankPvp not implemented") return nil, status.Errorf(codes.Unimplemented, "method RankPvp not implemented")
} }
func (UnimplementedUserCenterServer) RankPvpSubmit(context.Context, *RankPvpSubmitReq) (*RankPvpSubmitResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method RankPvpSubmit not implemented")
}
func (UnimplementedUserCenterServer) UserRankPvp(context.Context, *UserRankReq) (*UserRankResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method UserRankPvp not implemented")
}
func (UnimplementedUserCenterServer) mustEmbedUnimplementedUserCenterServer() {} func (UnimplementedUserCenterServer) mustEmbedUnimplementedUserCenterServer() {}
// UnsafeUserCenterServer may be embedded to opt out of forward compatibility for this service. // UnsafeUserCenterServer may be embedded to opt out of forward compatibility for this service.
@ -404,6 +446,24 @@ func _UserCenter_StatPvpReport_Handler(srv interface{}, ctx context.Context, dec
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _UserCenter_DrawGiftPack_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DrawGiftPackReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserCenterServer).DrawGiftPack(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.userCenter/drawGiftPack",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserCenterServer).DrawGiftPack(ctx, req.(*DrawGiftPackReq))
}
return interceptor(ctx, in, info, handler)
}
func _UserCenter_RankPvp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { func _UserCenter_RankPvp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RankPvpReq) in := new(RankPvpReq)
if err := dec(in); err != nil { if err := dec(in); err != nil {
@ -422,6 +482,42 @@ func _UserCenter_RankPvp_Handler(srv interface{}, ctx context.Context, dec func(
return interceptor(ctx, in, info, handler) return interceptor(ctx, in, info, handler)
} }
func _UserCenter_RankPvpSubmit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RankPvpSubmitReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserCenterServer).RankPvpSubmit(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.userCenter/rankPvpSubmit",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserCenterServer).RankPvpSubmit(ctx, req.(*RankPvpSubmitReq))
}
return interceptor(ctx, in, info, handler)
}
func _UserCenter_UserRankPvp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UserRankReq)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserCenterServer).UserRankPvp(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.userCenter/userRankPvp",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserCenterServer).UserRankPvp(ctx, req.(*UserRankReq))
}
return interceptor(ctx, in, info, handler)
}
// UserCenter_ServiceDesc is the grpc.ServiceDesc for UserCenter service. // UserCenter_ServiceDesc is the grpc.ServiceDesc for UserCenter service.
// It's only intended for direct use with grpc.RegisterService, // It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy) // and not to be introspected or modified (even as a copy)
@ -469,10 +565,22 @@ var UserCenter_ServiceDesc = grpc.ServiceDesc{
MethodName: "statPvpReport", MethodName: "statPvpReport",
Handler: _UserCenter_StatPvpReport_Handler, Handler: _UserCenter_StatPvpReport_Handler,
}, },
{
MethodName: "drawGiftPack",
Handler: _UserCenter_DrawGiftPack_Handler,
},
{ {
MethodName: "rankPvp", MethodName: "rankPvp",
Handler: _UserCenter_RankPvp_Handler, Handler: _UserCenter_RankPvp_Handler,
}, },
{
MethodName: "rankPvpSubmit",
Handler: _UserCenter_RankPvpSubmit_Handler,
},
{
MethodName: "userRankPvp",
Handler: _UserCenter_UserRankPvp_Handler,
},
}, },
Streams: []grpc.StreamDesc{}, Streams: []grpc.StreamDesc{},
Metadata: "user_center.proto", Metadata: "user_center.proto",

@ -15,12 +15,19 @@ import (
type ( type (
ChangeIntegralReq = pb.ChangeIntegralReq ChangeIntegralReq = pb.ChangeIntegralReq
ChangeIntegralResp = pb.ChangeIntegralResp ChangeIntegralResp = pb.ChangeIntegralResp
DrawGiftPackReq = pb.DrawGiftPackReq
DrawGiftPackResp = pb.DrawGiftPackResp
Empty = pb.Empty Empty = pb.Empty
GiftPackItem = pb.GiftPackItem
PlatformUserReq = pb.PlatformUserReq PlatformUserReq = pb.PlatformUserReq
PlatformUserResp = pb.PlatformUserResp PlatformUserResp = pb.PlatformUserResp
RankPvpReq = pb.RankPvpReq RankPvpReq = pb.RankPvpReq
RankPvpResp = pb.RankPvpResp RankPvpResp = pb.RankPvpResp
RankPvpResp_Item = pb.RankPvpResp_Item RankPvpResp_Item = pb.RankPvpResp_Item
RankPvpSubmitReq = pb.RankPvpSubmitReq
RankPvpSubmitResp = pb.RankPvpSubmitResp
RankPvpSubmitResp_Item = pb.RankPvpSubmitResp_Item
RankPvpSubmitResp_Result = pb.RankPvpSubmitResp_Result
StatPvPFirstBloodReq = pb.StatPvPFirstBloodReq StatPvPFirstBloodReq = pb.StatPvPFirstBloodReq
StatPvPKillReq = pb.StatPvPKillReq StatPvPKillReq = pb.StatPvPKillReq
StatPvPReportReq = pb.StatPvPReportReq StatPvPReportReq = pb.StatPvPReportReq
@ -35,6 +42,9 @@ type (
UserIdReq = pb.UserIdReq UserIdReq = pb.UserIdReq
UserIdResp = pb.UserIdResp UserIdResp = pb.UserIdResp
UserIntegralResp = pb.UserIntegralResp UserIntegralResp = pb.UserIntegralResp
UserRankReq = pb.UserRankReq
UserRankResp = pb.UserRankResp
UserRankResp_Item = pb.UserRankResp_Item
UserSendGiftReq = pb.UserSendGiftReq UserSendGiftReq = pb.UserSendGiftReq
UserSendGiftResp = pb.UserSendGiftResp UserSendGiftResp = pb.UserSendGiftResp
@ -55,8 +65,11 @@ type (
StatPvpKill(ctx context.Context, in *StatPvPKillReq, opts ...grpc.CallOption) (*Empty, error) StatPvpKill(ctx context.Context, in *StatPvPKillReq, opts ...grpc.CallOption) (*Empty, error)
StatPvpFirstBlood(ctx context.Context, in *StatPvPFirstBloodReq, opts ...grpc.CallOption) (*Empty, error) StatPvpFirstBlood(ctx context.Context, in *StatPvPFirstBloodReq, opts ...grpc.CallOption) (*Empty, error)
StatPvpReport(ctx context.Context, in *StatPvPReportReq, opts ...grpc.CallOption) (*StatPvPReportResp, error) StatPvpReport(ctx context.Context, in *StatPvPReportReq, opts ...grpc.CallOption) (*StatPvPReportResp, error)
DrawGiftPack(ctx context.Context, in *DrawGiftPackReq, opts ...grpc.CallOption) (*DrawGiftPackResp, error)
// rankPvp pvp排行 // rankPvp pvp排行
RankPvp(ctx context.Context, in *RankPvpReq, opts ...grpc.CallOption) (*RankPvpResp, error) RankPvp(ctx context.Context, in *RankPvpReq, opts ...grpc.CallOption) (*RankPvpResp, error)
RankPvpSubmit(ctx context.Context, in *RankPvpSubmitReq, opts ...grpc.CallOption) (*RankPvpSubmitResp, error)
UserRankPvp(ctx context.Context, in *UserRankReq, opts ...grpc.CallOption) (*UserRankResp, error)
} }
defaultUserCenter struct { defaultUserCenter struct {
@ -126,8 +139,23 @@ func (m *defaultUserCenter) StatPvpReport(ctx context.Context, in *StatPvPReport
return client.StatPvpReport(ctx, in, opts...) return client.StatPvpReport(ctx, in, opts...)
} }
func (m *defaultUserCenter) DrawGiftPack(ctx context.Context, in *DrawGiftPackReq, opts ...grpc.CallOption) (*DrawGiftPackResp, error) {
client := pb.NewUserCenterClient(m.cli.Conn())
return client.DrawGiftPack(ctx, in, opts...)
}
// rankPvp pvp排行 // rankPvp pvp排行
func (m *defaultUserCenter) RankPvp(ctx context.Context, in *RankPvpReq, opts ...grpc.CallOption) (*RankPvpResp, error) { func (m *defaultUserCenter) RankPvp(ctx context.Context, in *RankPvpReq, opts ...grpc.CallOption) (*RankPvpResp, error) {
client := pb.NewUserCenterClient(m.cli.Conn()) client := pb.NewUserCenterClient(m.cli.Conn())
return client.RankPvp(ctx, in, opts...) return client.RankPvp(ctx, in, opts...)
} }
func (m *defaultUserCenter) RankPvpSubmit(ctx context.Context, in *RankPvpSubmitReq, opts ...grpc.CallOption) (*RankPvpSubmitResp, error) {
client := pb.NewUserCenterClient(m.cli.Conn())
return client.RankPvpSubmit(ctx, in, opts...)
}
func (m *defaultUserCenter) UserRankPvp(ctx context.Context, in *UserRankReq, opts ...grpc.CallOption) (*UserRankResp, error) {
client := pb.NewUserCenterClient(m.cli.Conn())
return client.UserRankPvp(ctx, in, opts...)
}

@ -22,3 +22,10 @@ const (
const ( const (
UserIntegralNotEnoughError uint32 = 200100 // 用户积分不足 UserIntegralNotEnoughError uint32 = 200100 // 用户积分不足
) )
// 礼包相关 GiftPack
const (
GiftPackHasDrawError = 201100 // 该礼包已经领取过
GiftPackDrawCountLimitedError = 201101 // 该礼包已领取完
)

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
{{.imports}} {{.imports}}
"live-service/common/interceptor/rpcserver"
"github.com/zeromicro/go-zero/core/conf" "github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/service" "github.com/zeromicro/go-zero/core/service"
@ -30,6 +31,7 @@ func main() {
reflection.Register(grpcServer) reflection.Register(grpcServer)
} }
}) })
s.AddUnaryInterceptors(rpcserver.LoggerInterceptor)
defer s.Stop() defer s.Stop()
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn) fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)

@ -0,0 +1,9 @@
package config
import {{.authImport}}
type Config struct {
rest.RestConf
{{.auth}}
{{.jwtTrans}}
}

@ -0,0 +1,17 @@
package svc
import (
{{.configImport}}
)
type ServiceContext struct {
Config {{.config}}
{{.middleware}}
}
func NewServiceContext(c {{.config}}) *ServiceContext {
return &ServiceContext{
Config: c,
{{.middlewareAssignment}}
}
}

@ -0,0 +1,3 @@
Name: {{.serviceName}}
Host: {{.host}}
Port: {{.port}}

@ -0,0 +1,26 @@
package {{.PkgName}}
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
{{.ImportPackages}}
)
func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
{{if .HasRequest}}var req types.{{.RequestType}}
if err := httpx.Parse(r, &req); err != nil {
httpx.Error(w, err)
return
}
{{end}}l := {{.LogicName}}.New{{.LogicType}}(r.Context(), svcCtx)
{{if .HasResp}}resp, {{end}}err := l.{{.Call}}({{if .HasRequest}}&req{{end}})
if err != nil {
httpx.Error(w, err)
} else {
{{if .HasResp}}httpx.OkJson(w, resp){{else}}httpx.Ok(w){{end}}
}
}
}

@ -0,0 +1,25 @@
package {{.pkgName}}
import (
{{.imports}}
)
type {{.logic}} struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func New{{.logic}}(ctx context.Context, svcCtx *svc.ServiceContext) *{{.logic}} {
return &{{.logic}}{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *{{.logic}}) {{.function}}({{.request}}) {{.responseType}} {
// todo: add your logic here and delete this line
{{.returnString}}
}

@ -0,0 +1,26 @@
package main
import (
"flag"
"fmt"
{{.importPackages}}
)
var configFile = flag.String("f", "etc/{{.serviceName}}.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
ctx := svc.NewServiceContext(c)
server := rest.MustNewServer(c.RestConf)
defer server.Stop()
handler.RegisterHandlers(server, ctx)
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
server.Start()
}

@ -0,0 +1,19 @@
package middleware
import "net/http"
type {{.name}} struct {
}
func New{{.name}}() *{{.name}} {
return &{{.name}}{}
}
func (m *{{.name}})Handle(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// TODO generate middleware implement function, delete after code implementation
// Passthrough to next handler if need
next(w, r)
}
}

@ -0,0 +1,4 @@
server.AddRoutes(
{{.routes}} {{.jwt}}{{.signature}} {{.prefix}} {{.timeout}}
)

@ -0,0 +1,13 @@
// Code generated by goctl. DO NOT EDIT.
package handler
import (
"net/http"{{if .hasTimeout}}
"time"{{end}}
{{.importPackages}}
)
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
{{.routesAdditions}}
}

@ -0,0 +1,24 @@
syntax = "v1"
info (
title: // TODO: add title
desc: // TODO: add description
author: "{{.gitUser}}"
email: "{{.gitEmail}}"
)
type request {
// TODO: add members here and delete this comment
}
type response {
// TODO: add members here and delete this comment
}
service {{.serviceName}} {
@handler GetUser // TODO: set handler name and delete this comment
get /users/id/:userId(request) returns(response)
@handler CreateUser // TODO: set handler name and delete this comment
post /users/create(request)
}

@ -0,0 +1,6 @@
// Code generated by goctl. DO NOT EDIT.
package types{{if .containsTime}}
import (
"time"
){{end}}
{{.types}}

@ -0,0 +1,32 @@
FROM golang:{{.Version}}alpine AS builder
LABEL stage=gobuilder
ENV CGO_ENABLED 0
{{if .Chinese}}ENV GOPROXY https://goproxy.cn,direct
{{end}}{{if .HasTimezone}}
RUN apk update --no-cache && apk add --no-cache tzdata
{{end}}
WORKDIR /build
ADD go.mod .
ADD go.sum .
RUN go mod download
COPY . .
{{if .Argument}}COPY {{.GoRelPath}}/etc /app/etc
{{end}}RUN go build -ldflags="-s -w" -o /app/{{.ExeFile}} {{.GoRelPath}}/{{.GoFile}}
FROM {{.BaseImage}}
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
{{if .HasTimezone}}COPY --from=builder /usr/share/zoneinfo/{{.Timezone}} /usr/share/zoneinfo/{{.Timezone}}
ENV TZ {{.Timezone}}
{{end}}
WORKDIR /app
COPY --from=builder /app/{{.ExeFile}} /app/{{.ExeFile}}{{if .Argument}}
COPY --from=builder /app/etc /app/etc{{end}}
{{if .HasPort}}
EXPOSE {{.Port}}
{{end}}
CMD ["./{{.ExeFile}}"{{.Argument}}]

@ -0,0 +1,115 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{.Name}}
namespace: {{.Namespace}}
labels:
app: {{.Name}}
spec:
replicas: {{.Replicas}}
revisionHistoryLimit: {{.Revisions}}
selector:
matchLabels:
app: {{.Name}}
template:
metadata:
labels:
app: {{.Name}}
spec:{{if .ServiceAccount}}
serviceAccountName: {{.ServiceAccount}}{{end}}
containers:
- name: {{.Name}}
image: {{.Image}}
lifecycle:
preStop:
exec:
command: ["sh","-c","sleep 5"]
ports:
- containerPort: {{.Port}}
readinessProbe:
tcpSocket:
port: {{.Port}}
initialDelaySeconds: 5
periodSeconds: 10
livenessProbe:
tcpSocket:
port: {{.Port}}
initialDelaySeconds: 15
periodSeconds: 20
resources:
requests:
cpu: {{.RequestCpu}}m
memory: {{.RequestMem}}Mi
limits:
cpu: {{.LimitCpu}}m
memory: {{.LimitMem}}Mi
volumeMounts:
- name: timezone
mountPath: /etc/localtime
{{if .Secret}}imagePullSecrets:
- name: {{.Secret}}
{{end}}volumes:
- name: timezone
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai
---
apiVersion: v1
kind: Service
metadata:
name: {{.Name}}-svc
namespace: {{.Namespace}}
spec:
ports:
{{if .UseNodePort}}- nodePort: {{.NodePort}}
port: {{.Port}}
protocol: TCP
targetPort: {{.Port}}
type: NodePort{{else}}- port: {{.Port}}{{end}}
selector:
app: {{.Name}}
---
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{.Name}}-hpa-c
namespace: {{.Namespace}}
labels:
app: {{.Name}}-hpa-c
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{.Name}}
minReplicas: {{.MinReplicas}}
maxReplicas: {{.MaxReplicas}}
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 80
---
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{.Name}}-hpa-m
namespace: {{.Namespace}}
labels:
app: {{.Name}}-hpa-m
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{.Name}}
minReplicas: {{.MinReplicas}}
maxReplicas: {{.MaxReplicas}}
metrics:
- type: Resource
resource:
name: memory
targetAverageUtilization: 80

@ -0,0 +1,37 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{.Name}}
namespace: {{.Namespace}}
spec:
successfulJobsHistoryLimit: {{.SuccessfulJobsHistoryLimit}}
schedule: "{{.Schedule}}"
jobTemplate:
spec:
template:
spec:{{if .ServiceAccount}}
serviceAccountName: {{.ServiceAccount}}{{end}}
{{end}}containers:
- name: {{.Name}}
image: # todo image url
resources:
requests:
cpu: {{.RequestCpu}}m
memory: {{.RequestMem}}Mi
limits:
cpu: {{.LimitCpu}}m
memory: {{.LimitMem}}Mi
command:
- ./{{.ServiceName}}
- -f
- ./{{.Name}}.yaml
volumeMounts:
- name: timezone
mountPath: /etc/localtime
imagePullSecrets:
- name: # registry secret, if no, remove this
restartPolicy: OnFailure
volumes:
- name: timezone
hostPath:
path: /usr/share/zoneinfo/Asia/Shanghai

@ -1,14 +1,14 @@
func (m *default{{.upperStartCamelObject}}Model) Delete(ctx context.Context, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) error { func (m *default{{.upperStartCamelObject}}Model) Delete(ctx context.Context, tx *gorm.DB, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) error {
{{if .withCache}}{{if .containsIndexCache}}data, err:=m.FindOne(ctx, {{.lowerStartCamelPrimaryKey}}) {{if .withCache}}{{if .containsIndexCache}}data, err:=m.FindOne(ctx, {{.lowerStartCamelPrimaryKey}})
if err!=nil{ if err != nil {
return err return err
} }
{{end}} {{.keys}} {{end}} {{.keys}}
err {{if .containsIndexCache}}={{else}}:={{end}} m.ExecCtx(ctx, func(conn *gorm.DB) *gorm.DB { err {{if .containsIndexCache}}={{else}}:={{end}} m.ExecCtx(ctx, func(conn *gorm.DB) error {
return conn.Delete(&{{.upperStartCamelObject}}{}, {{.lowerStartCamelPrimaryKey}}) return gormx.WithTx(ctx, conn, tx).Delete(&{{.upperStartCamelObject}}{}, {{.lowerStartCamelPrimaryKey}}).Error
}, {{.keyValues}}){{else}} err:= m.conn.WithContext(ctx).Delete(&{{.upperStartCamelObject}}{}, {{.lowerStartCamelPrimaryKey}}).Error }, {{.keyValues}}){{else}} err:= gormx.WithTx(ctx, m.DB, tx).Delete(&{{.upperStartCamelObject}}{}, {{.lowerStartCamelPrimaryKey}}).Error
{{end}} {{end}}
return err return err
} }

@ -1,9 +1,9 @@
func (m *default{{.upperStartCamelObject}}Model) FindOneBy{{.upperField}}(ctx context.Context, {{.in}}) (*{{.upperStartCamelObject}}, error) { func (m *default{{.upperStartCamelObject}}Model) FindOneBy{{.upperField}}(ctx context.Context, tx *gorm.DB, {{.in}}) (*{{.upperStartCamelObject}}, error) {
{{if .withCache}}{{.cacheKey}} {{if .withCache}}{{.cacheKey}}
var resp {{.upperStartCamelObject}} var resp {{.upperStartCamelObject}}
err := m.QueryRowIndexCtx(ctx, &resp, {{.cacheKeyVariable}}, m.formatPrimary, func(conn *gorm.DB, v interface{}) (interface{}, error) { err := m.QueryRowIndexCtx(ctx, &resp, {{.cacheKeyVariable}}, m.formatPrimary, func(conn *gorm.DB, v interface{}) (interface{}, error) {
if err := conn.Model(&{{.upperStartCamelObject}}{}).Where("{{.originalField}}", {{.lowerStartCamelField}}).Take(&resp).Error; err != nil { if err := gormx.WithTx(ctx, conn, tx).Model(&{{.upperStartCamelObject}}{}).Where("{{.originalField}}", {{.lowerStartCamelField}}).Take(&resp).Error; err != nil {
return nil, err return nil, err
} }
return resp.{{.upperStartCamelPrimaryKey}}, nil return resp.{{.upperStartCamelPrimaryKey}}, nil
@ -11,17 +11,17 @@ func (m *default{{.upperStartCamelObject}}Model) FindOneBy{{.upperField}}(ctx co
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
} }
}{{else}}var resp {{.upperStartCamelObject}} }{{else}}var resp {{.upperStartCamelObject}}
err := m.conn.WithContext(ctx).Model(&{{.upperStartCamelObject}}{}).Where("{{.originalField}}", {{.lowerStartCamelField}}).Take(&resp).Error err := gormx.WithTx(ctx, m.DB, tx).Model(&{{.upperStartCamelObject}}{}).Where("{{.originalField}}", {{.lowerStartCamelField}}).Take(&resp).Error
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err

@ -1,23 +1,23 @@
func (m *default{{.upperStartCamelObject}}Model) FindOne(ctx context.Context, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) (*{{.upperStartCamelObject}}, error) { func (m *default{{.upperStartCamelObject}}Model) FindOne(ctx context.Context, tx *gorm.DB, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) (*{{.upperStartCamelObject}}, error) {
{{if .withCache}}{{.cacheKey}} {{if .withCache}}{{.cacheKey}}
var resp {{.upperStartCamelObject}} var resp {{.upperStartCamelObject}}
err := m.QueryRowCtx(ctx, &resp, {{.cacheKeyVariable}}, func(conn *gorm.DB) *gorm.DB { err := m.QueryCtx(ctx, &resp, {{.cacheKeyVariable}}, func(conn *gorm.DB, v interface{}) error {
return conn.Where("id = ?", {{.lowerStartCamelPrimaryKey}}) return gormx.WithTx(ctx, conn, tx).Model(&{{.upperStartCamelObject}}{}).Where("{{.originalPrimaryKey}} = ?", {{.lowerStartCamelPrimaryKey}}).First(&resp).Error
}) })
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err
}{{else}}var resp {{.upperStartCamelObject}} }{{else}}var resp {{.upperStartCamelObject}}
err := m.conn.WithContext(ctx).Model(&{{.upperStartCamelObject}}{}).Where("{{.originalPrimaryKey}} = ?", {{.lowerStartCamelPrimaryKey}}).Take(&resp).Error err := gormx.WithTx(ctx, m.DB, tx).Model(&{{.upperStartCamelObject}}{}).Where("{{.originalPrimaryKey}} = ?", {{.lowerStartCamelPrimaryKey}}).Take(&resp).Error
switch err { switch err {
case nil: case nil:
return &resp, nil return &resp, nil
case gormc.ErrNotFound: case gormx.ErrNotFound:
return nil, ErrNotFound return nil, ErrNotFound
default: default:
return nil, err return nil, err

@ -1,9 +1,9 @@
import ( import (
"context" "context"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc"
"strings" "strings"
{{if .time}}"time"{{end}} {{if .time}}"time"{{end}}
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"github.com/zeromicro/go-zero/core/stores/builder" "github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stringx" "github.com/zeromicro/go-zero/core/stringx"
"gorm.io/gorm" "gorm.io/gorm"

@ -5,6 +5,7 @@ import (
{{if .time}}"time"{{end}} {{if .time}}"time"{{end}}
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc" "git.noahlan.cn/northlan/ntools-go/gorm-zero/gormc"
"git.noahlan.cn/northlan/ntools-go/gorm-zero/gormx"
"github.com/zeromicro/go-zero/core/stores/builder" "github.com/zeromicro/go-zero/core/stores/builder"
"github.com/zeromicro/go-zero/core/stores/cache" "github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/core/stringx" "github.com/zeromicro/go-zero/core/stringx"

@ -1,8 +1,8 @@
func (m *default{{.upperStartCamelObject}}Model) Insert(ctx context.Context, data *{{.upperStartCamelObject}}) error { func (m *default{{.upperStartCamelObject}}Model) Insert(ctx context.Context, tx *gorm.DB, data *{{.upperStartCamelObject}}) error {
{{if .withCache}}{{.keys}} {{if .withCache}}{{.keys}}
err := m.ExecCtx(ctx, func(conn *gorm.DB) *gorm.DB { err := m.ExecCtx(ctx, func(conn *gorm.DB) error {
return conn.Create(&data) return gormx.WithTx(ctx, conn, tx).Create(&data).Error
}, {{.keyValues}}){{else}}err:=m.conn.WithContext(ctx).Create(&data).Error{{end}} }, {{.keyValues}}){{else}}err:=gormx.WithTx(ctx, m.DB, tx).Create(&data).Error{{end}}
return err return err
} }

@ -1 +1 @@
Delete(ctx context.Context, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) error Delete(ctx context.Context, tx *gorm.DB, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) error

@ -1 +1 @@
FindOneBy{{.upperField}}(ctx context.Context, {{.in}}) (*{{.upperStartCamelObject}}, error) FindOneBy{{.upperField}}(ctx context.Context, tx *gorm.DB, {{.in}}) (*{{.upperStartCamelObject}}, error)

@ -1 +1 @@
FindOne(ctx context.Context, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) (*{{.upperStartCamelObject}}, error) FindOne(ctx context.Context, tx *gorm.DB, {{.lowerStartCamelPrimaryKey}} {{.dataType}}) (*{{.upperStartCamelObject}}, error)

@ -1 +1 @@
Insert(ctx context.Context, data *{{.upperStartCamelObject}}) error Insert(ctx context.Context, tx *gorm.DB, data *{{.upperStartCamelObject}}) error

@ -1 +1 @@
Update(ctx context.Context, data *{{.upperStartCamelObject}}) error Update(ctx context.Context, tx *gorm.DB, data *{{.upperStartCamelObject}}) error

@ -1,7 +1,9 @@
var {{.upperStartCamelObject}}TableName = {{.table}}
func new{{.upperStartCamelObject}}Model(conn *gorm.DB{{if .withCache}}, c cache.CacheConf{{end}}) *default{{.upperStartCamelObject}}Model { func new{{.upperStartCamelObject}}Model(conn *gorm.DB{{if .withCache}}, c cache.CacheConf{{end}}) *default{{.upperStartCamelObject}}Model {
return &default{{.upperStartCamelObject}}Model{ return &default{{.upperStartCamelObject}}Model{
{{if .withCache}}CachedConn: gormc.NewConn(conn, c){{else}}conn:conn{{end}}, {{if .withCache}}CachedConn: gormc.NewConn(conn, c){{else}}GormConn: gormx.NewConn(conn){{end}},
table: {{.table}}, table: {{.upperStartCamelObject}}TableName,
} }
} }

@ -2,7 +2,6 @@ package {{.pkg}}
{{if .withCache}} {{if .withCache}}
import ( import (
"github.com/zeromicro/go-zero/core/stores/cache" "github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"gorm.io/gorm" "gorm.io/gorm"
) )
{{else}} {{else}}

@ -4,6 +4,5 @@ func (m *default{{.upperStartCamelObject}}Model) tableName() string {
} }
func ({{.upperStartCamelObject}}) TableName() string { func ({{.upperStartCamelObject}}) TableName() string {
model := new{{.upperStartCamelObject}}Model(nil) return {{.upperStartCamelObject}}TableName
return model.tableName()
} }

@ -1,11 +1,12 @@
type ( type (
{{.lowerStartCamelObject}}Model interface{ {{.lowerStartCamelObject}}Model interface{
gormx.TxModel
{{.method}} {{.method}}
} }
default{{.upperStartCamelObject}}Model struct { default{{.upperStartCamelObject}}Model struct {
{{if .withCache}}gormc.CachedConn{{else}}conn *gorm.DB{{end}} {{if .withCache}}gormc.CachedConn{{else}}gormx.GormConn{{end}}
table string table string
} }

@ -1,8 +1,23 @@
func (m *default{{.upperStartCamelObject}}Model) Update(ctx context.Context, data *{{.upperStartCamelObject}}) error { func (m *default{{.upperStartCamelObject}}Model) Update(ctx context.Context, tx *gorm.DB, data *{{.upperStartCamelObject}}) error {
{{if .withCache}}{{.keys}} {{if .withCache}}{{.keys}}
err := m.ExecCtx(ctx, func(conn *gorm.DB) *gorm.DB { return m.ExecCtx(ctx, func(conn *gorm.DB) error {
return conn.Save(data) result := gormx.WithTx(ctx, conn, tx).Save(data)
}, {{.keyValues}}){{else}}err:=m.conn.WithContext(ctx).Save(data).Error{{end}} if result.Error != nil {
return err return result.Error
}
if result.RowsAffected == 0 {
return gormx.ErrRowsAffectedZero
}
return nil
}, {{.keyValues}}){{else}}
result:=gormx.WithTx(ctx, m.DB, tx).Save(data)
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return gormx.ErrRowsAffectedZero
}
return nil
{{end}}
} }

@ -0,0 +1,6 @@
package model
import "errors"
var ErrNotFound = errors.New("not found")
var ErrInvalidObjectId = errors.New("invalid objectId")

@ -0,0 +1,98 @@
package model
import (
"context"
"github.com/globalsign/mgo/bson"
{{if .Cache}}cachec "github.com/zeromicro/go-zero/core/stores/cache"
"github.com/zeromicro/go-zero/core/stores/mongoc"{{else}}"github.com/zeromicro/go-zero/core/stores/mongo"{{end}}
)
{{if .Cache}}var prefix{{.Type}}CacheKey = "cache:{{.Type}}:"{{end}}
type {{.Type}}Model interface{
Insert(ctx context.Context,data *{{.Type}}) error
FindOne(ctx context.Context,id string) (*{{.Type}}, error)
Update(ctx context.Context,data *{{.Type}}) error
Delete(ctx context.Context,id string) error
}
type default{{.Type}}Model struct {
{{if .Cache}}*mongoc.Model{{else}}*mongo.Model{{end}}
}
func New{{.Type}}Model(url, collection string{{if .Cache}}, c cachec.CacheConf{{end}}) {{.Type}}Model {
return &default{{.Type}}Model{
Model: {{if .Cache}}mongoc.MustNewModel(url, collection, c){{else}}mongo.MustNewModel(url, collection){{end}},
}
}
func (m *default{{.Type}}Model) Insert(ctx context.Context, data *{{.Type}}) error {
if !data.ID.Valid() {
data.ID = bson.NewObjectId()
}
session, err := m.TakeSession()
if err != nil {
return err
}
defer m.PutSession(session)
return m.GetCollection(session).Insert(data)
}
func (m *default{{.Type}}Model) FindOne(ctx context.Context, id string) (*{{.Type}}, error) {
if !bson.IsObjectIdHex(id) {
return nil, ErrInvalidObjectId
}
session, err := m.TakeSession()
if err != nil {
return nil, err
}
defer m.PutSession(session)
var data {{.Type}}
{{if .Cache}}key := prefix{{.Type}}CacheKey + id
err = m.GetCollection(session).FindOneId(&data, key, bson.ObjectIdHex(id))
{{- else}}
err = m.GetCollection(session).FindId(bson.ObjectIdHex(id)).One(&data)
{{- end}}
switch err {
case nil:
return &data,nil
case {{if .Cache}}mongoc.ErrNotFound{{else}}mongo.ErrNotFound{{end}}:
return nil,ErrNotFound
default:
return nil,err
}
}
func (m *default{{.Type}}Model) Update(ctx context.Context, data *{{.Type}}) error {
session, err := m.TakeSession()
if err != nil {
return err
}
defer m.PutSession(session)
{{if .Cache}}key := prefix{{.Type}}CacheKey + data.ID.Hex()
return m.GetCollection(session).UpdateId(data.ID, data, key)
{{- else}}
return m.GetCollection(session).UpdateId(data.ID, data)
{{- end}}
}
func (m *default{{.Type}}Model) Delete(ctx context.Context, id string) error {
session, err := m.TakeSession()
if err != nil {
return err
}
defer m.PutSession(session)
{{if .Cache}}key := prefix{{.Type}}CacheKey + id
return m.GetCollection(session).RemoveId(bson.ObjectIdHex(id), key)
{{- else}}
return m.GetCollection(session).RemoveId(bson.ObjectIdHex(id))
{{- end}}
}

@ -0,0 +1,12 @@
type Request {
Name string `path:"name,options=you|me"`
}
type Response {
Message string `json:"message"`
}
service {{.name}}-api {
@handler {{.handler}}Handler
get /from/:name(Request) returns (Response)
}

@ -0,0 +1,6 @@
{{if .hasComment}}{{.comment}}{{end}}
func (m *default{{.serviceName}}) {{.method}}(ctx context.Context{{if .hasReq}}, in *{{.pbRequest}}{{end}}, opts ...grpc.CallOption) ({{if .notStream}}*{{.pbResponse}}, {{else}}{{.streamBody}},{{end}} error) {
client := {{if .isCallPkgSameToGrpcPkg}}{{else}}{{.package}}.{{end}}New{{.rpcServiceName}}Client(m.cli.Conn())
return client.{{.method}}(ctx{{if .hasReq}}, in{{end}}, opts...)
}

@ -0,0 +1,2 @@
{{if .hasComment}}{{.comment}}
{{end}}{{.method}}(ctx context.Context{{if .hasReq}}, in *{{.pbRequest}}{{end}}, opts ...grpc.CallOption) ({{if .notStream}}*{{.pbResponse}}, {{else}}{{.streamBody}},{{end}} error)

@ -0,0 +1,33 @@
{{.head}}
package {{.filePackage}}
import (
"context"
{{.pbPackage}}
{{if ne .pbPackage .protoGoPackage}}{{.protoGoPackage}}{{end}}
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
)
type (
{{.alias}}
{{.serviceName}} interface {
{{.interface}}
}
default{{.serviceName}} struct {
cli zrpc.Client
}
)
func New{{.serviceName}}(cli zrpc.Client) {{.serviceName}} {
return &default{{.serviceName}}{
cli: cli,
}
}
{{.functions}}

@ -0,0 +1,7 @@
package config
import "github.com/zeromicro/go-zero/zrpc"
type Config struct {
zrpc.RpcServerConf
}

@ -0,0 +1,6 @@
Name: {{.serviceName}}.rpc
ListenOn: 127.0.0.1:8080
Etcd:
Hosts:
- 127.0.0.1:2379
Key: {{.serviceName}}.rpc

@ -0,0 +1,6 @@
{{if .hasComment}}{{.comment}}{{end}}
func (l *{{.logicName}}) {{.method}} ({{if .hasReq}}in {{.request}}{{if .stream}},stream {{.streamBody}}{{end}}{{else}}stream {{.streamBody}}{{end}}) ({{if .hasReply}}{{.response}},{{end}} error) {
// todo: add your logic here and delete this line
return {{if .hasReply}}&{{.responseType}}{},{{end}} nil
}

@ -0,0 +1,24 @@
package logic
import (
"context"
{{.imports}}
"github.com/zeromicro/go-zero/core/logx"
)
type {{.logicName}} struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func New{{.logicName}}(ctx context.Context,svcCtx *svc.ServiceContext) *{{.logicName}} {
return &{{.logicName}}{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
{{.functions}}

@ -0,0 +1,39 @@
package main
import (
"flag"
"fmt"
{{.imports}}
"live-service/common/interceptor/rpcserver"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/service"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
var configFile = flag.String("f", "etc/{{.serviceName}}.yaml", "the config file")
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
ctx := svc.NewServiceContext(c)
svr := server.New{{.serviceNew}}Server(ctx)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
{{.pkg}}.Register{{.service}}Server(grpcServer, svr)
if c.Mode == service.DevMode || c.Mode == service.TestMode {
reflection.Register(grpcServer)
}
})
s.AddUnaryInterceptors(rpcserver.LoggerInterceptor)
defer s.Stop()
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
s.Start()
}

@ -0,0 +1,6 @@
{{if .hasComment}}{{.comment}}{{end}}
func (s *{{.server}}Server) {{.method}} ({{if .notStream}}ctx context.Context,{{if .hasReq}} in {{.request}}{{end}}{{else}}{{if .hasReq}} in {{.request}},{{end}}stream {{.streamBody}}{{end}}) ({{if .notStream}}{{.response}},{{end}}error) {
l := logic.New{{.logicName}}({{if .notStream}}ctx,{{else}}stream.Context(),{{end}}s.svcCtx)
return l.{{.method}}({{if .hasReq}}in{{if .stream}} ,stream{{end}}{{else}}{{if .stream}}stream{{end}}{{end}})
}

@ -0,0 +1,22 @@
{{.head}}
package server
import (
{{if .notStream}}"context"{{end}}
{{.imports}}
)
type {{.server}}Server struct {
svcCtx *svc.ServiceContext
{{.unimplementedServer}}
}
func New{{.server}}Server(svcCtx *svc.ServiceContext) *{{.server}}Server {
return &{{.server}}Server{
svcCtx: svcCtx,
}
}
{{.funcs}}

@ -0,0 +1,13 @@
package svc
import {{.imports}}
type ServiceContext struct {
Config config.Config
}
func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{
Config:c,
}
}

@ -0,0 +1,16 @@
syntax = "proto3";
package {{.package}};
option go_package="./{{.package}}";
message Request {
string ping = 1;
}
message Response {
string pong = 1;
}
service {{.serviceName}} {
rpc Ping(Request) returns(Response);
}

@ -3,21 +3,25 @@ module live-service
go 1.18 go 1.18
require ( require (
git.noahlan.cn/northlan/ntools-go/gorm-zero v1.0.1 git.noahlan.cn/northlan/ntools-go/gorm-zero v1.0.4
git.noahlan.cn/northlan/ntools-go/kafka v1.0.1 git.noahlan.cn/northlan/ntools-go/kafka v1.0.1
git.noahlan.cn/northlan/ntools-go/uuid v1.0.0 git.noahlan.cn/northlan/ntools-go/uuid v1.0.0
github.com/Shopify/sarama v1.33.0
github.com/hashicorp/golang-lru v0.5.1
github.com/jinzhu/now v1.1.5
github.com/longzhiri/gozset v0.0.0-20210113140059-91f2d281daf1
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/robfig/cron/v3 v3.0.0 github.com/robfig/cron/v3 v3.0.0
github.com/zeromicro/go-zero v1.3.2 github.com/shopspring/decimal v1.3.1
google.golang.org/grpc v1.45.0 github.com/zeromicro/go-zero v1.3.3
google.golang.org/protobuf v1.27.1 google.golang.org/grpc v1.46.0
google.golang.org/protobuf v1.28.0
gorm.io/driver/mysql v1.3.3 gorm.io/driver/mysql v1.3.3
gorm.io/gorm v1.23.5 gorm.io/gorm v1.23.5
gorm.io/plugin/optimisticlock v1.0.7
) )
require ( require (
github.com/Shopify/sarama v1.33.0 // indirect
github.com/VividCortex/mysqlerr v1.0.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-semver v0.3.0 // indirect
@ -41,17 +45,14 @@ require (
github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.0.0 // indirect github.com/jcmturner/gofork v1.0.0 // indirect
github.com/jcmturner/gokrb5/v8 v8.4.2 // indirect github.com/jcmturner/gokrb5/v8 v8.4.2 // indirect
github.com/jcmturner/rpc/v2 v2.0.3 // indirect github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.4 // indirect github.com/klauspost/compress v1.15.4 // indirect
github.com/longzhiri/gozset v0.0.0-20210113140059-91f2d281daf1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect
@ -62,7 +63,6 @@ require (
github.com/prometheus/common v0.30.0 // indirect github.com/prometheus/common v0.30.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect github.com/prometheus/procfs v0.7.3 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect
go.etcd.io/etcd/api/v3 v3.5.2 // indirect go.etcd.io/etcd/api/v3 v3.5.2 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.2 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.2 // indirect
@ -84,10 +84,9 @@ require (
golang.org/x/text v0.3.7 // indirect golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect
google.golang.org/appengine v1.6.7 // indirect google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7 // indirect google.golang.org/genproto v0.0.0-20220422154200-b37d22cd5731 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
gorm.io/plugin/optimisticlock v1.0.7 // indirect
k8s.io/api v0.20.12 // indirect k8s.io/api v0.20.12 // indirect
k8s.io/apimachinery v0.20.12 // indirect k8s.io/apimachinery v0.20.12 // indirect
k8s.io/client-go v0.20.12 // indirect k8s.io/client-go v0.20.12 // indirect

@ -31,8 +31,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
git.noahlan.cn/northlan/ntools-go/gorm-zero v1.0.1 h1:c/vZx96FPV4xyZEsSvWAXzQH+S3QZ9ixMBv3faQzXSY= git.noahlan.cn/northlan/ntools-go/gorm-zero v1.0.4 h1:r9jH+tJ1YoeX0gtt26lWeW2hxJGbKH1DksnIrjrLaMk=
git.noahlan.cn/northlan/ntools-go/gorm-zero v1.0.1/go.mod h1:fDeW2GCJEU5OEPMisWH9wyA/BiPZg6tK5FegDIaMURg= git.noahlan.cn/northlan/ntools-go/gorm-zero v1.0.4/go.mod h1:ExV9s96axCdMcaXqsezoUxnbTptkMqwvNWvON05uzjE=
git.noahlan.cn/northlan/ntools-go/kafka v1.0.1 h1:SDUwYRzksZ3Vcu7PTZxk+TEMF2f3gBiQEboKOhi1yfI= git.noahlan.cn/northlan/ntools-go/kafka v1.0.1 h1:SDUwYRzksZ3Vcu7PTZxk+TEMF2f3gBiQEboKOhi1yfI=
git.noahlan.cn/northlan/ntools-go/kafka v1.0.1/go.mod h1:RxX9JSUIr3Gbk+cvUwE5k+i08AgIK3TA9ayDJCMn2n8= git.noahlan.cn/northlan/ntools-go/kafka v1.0.1/go.mod h1:RxX9JSUIr3Gbk+cvUwE5k+i08AgIK3TA9ayDJCMn2n8=
git.noahlan.cn/northlan/ntools-go/uuid v1.0.0 h1:C0PazSzG3+e/Hfh2C6Qf8R46sNZmZKTOcWS990yUmrE= git.noahlan.cn/northlan/ntools-go/uuid v1.0.0 h1:C0PazSzG3+e/Hfh2C6Qf8R46sNZmZKTOcWS990yUmrE=
@ -54,15 +54,11 @@ github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb0
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/Shopify/sarama v1.30.0/go.mod h1:zujlQQx1kzHsh4jfV1USnptCQrHAEZ2Hk8fTKCulPVs= github.com/Shopify/sarama v1.30.0/go.mod h1:zujlQQx1kzHsh4jfV1USnptCQrHAEZ2Hk8fTKCulPVs=
github.com/Shopify/sarama v1.32.0 h1:P+RUjEaRU0GMMbYexGMDyrMkLhbbBVUVISDywi+IlFU=
github.com/Shopify/sarama v1.32.0/go.mod h1:+EmJJKZWVT/faR9RcOxJerP+LId4iWdQPBGLy1Y1Njs=
github.com/Shopify/sarama v1.33.0 h1:2K4mB9M4fo46sAM7t6QTsmSO8dLX1OqznLM7vn3OjZ8= github.com/Shopify/sarama v1.33.0 h1:2K4mB9M4fo46sAM7t6QTsmSO8dLX1OqznLM7vn3OjZ8=
github.com/Shopify/sarama v1.33.0/go.mod h1:lYO7LwEBkE0iAeTl94UfPSrDaavFzSFlmn+5isARATQ= github.com/Shopify/sarama v1.33.0/go.mod h1:lYO7LwEBkE0iAeTl94UfPSrDaavFzSFlmn+5isARATQ=
github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae/go.mod h1:/cvHQkZ1fst0EmZnA5dFtiQdWCNCFYzb+uE2vqVgvx0= github.com/Shopify/toxiproxy/v2 v2.1.6-0.20210914104332-15ea381dcdae/go.mod h1:/cvHQkZ1fst0EmZnA5dFtiQdWCNCFYzb+uE2vqVgvx0=
github.com/Shopify/toxiproxy/v2 v2.3.0 h1:62YkpiP4bzdhKMH+6uC5E95y608k3zDwdzuBMsnn3uQ= github.com/Shopify/toxiproxy/v2 v2.3.0 h1:62YkpiP4bzdhKMH+6uC5E95y608k3zDwdzuBMsnn3uQ=
github.com/Shopify/toxiproxy/v2 v2.3.0/go.mod h1:KvQTtB6RjCJY4zqNJn7C7JDFgsG5uoHYDirfUfpIm0c= github.com/Shopify/toxiproxy/v2 v2.3.0/go.mod h1:KvQTtB6RjCJY4zqNJn7C7JDFgsG5uoHYDirfUfpIm0c=
github.com/VividCortex/mysqlerr v1.0.0 h1:5pZ2TZA+YnzPgzBfiUWGqWmKDVNBdrkf9g+DNe1Tiq8=
github.com/VividCortex/mysqlerr v1.0.0/go.mod h1:xERx8E4tBhLvpjzdUyQiSfUxeMcATEQrflDAfXsqcAE=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
@ -95,6 +91,7 @@ github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnht
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
@ -125,6 +122,7 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
@ -210,6 +208,7 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
@ -271,6 +270,14 @@ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
github.com/jackc/pgconn v1.10.1 h1:DzdIHIjG1AxGwoEEqS+mGsURyjt4enSmqzACXvVzOT8=
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgproto3/v2 v2.2.0 h1:r7JypeP2D3onoQTCxWdTpCtJ4D+qpKr0TxvoyMhZ5ns=
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg=
github.com/jackc/pgtype v1.9.1 h1:MJc2s0MFS8C3ok1wQTdQxWuXQcB6+HwAm5x1CzW7mf0=
github.com/jackc/pgx/v4 v4.14.1 h1:71oo1KAGI6mXhLiTMn6iDFcp3e7+zon/capWjl2OEFU=
github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8= github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8=
github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs=
github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo= github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo=
@ -303,10 +310,7 @@ github.com/justinas/alice v1.2.0/go.mod h1:fN5HRH/reO/zrUflLfTN43t3vXvKzvZIENsNE
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.14.4/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A=
github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.4 h1:1kn4/7MepF/CHmYub99/nNX8az0IJjfSOU/jbnTVfqQ= github.com/klauspost/compress v1.15.4 h1:1kn4/7MepF/CHmYub99/nNX8az0IJjfSOU/jbnTVfqQ=
github.com/klauspost/compress v1.15.4/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= github.com/klauspost/compress v1.15.4/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
@ -333,6 +337,7 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.14.9 h1:10HX2Td0ocZpYEjhilsuo6WWtUqttj2Kb0KtD86/KYA=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
@ -344,6 +349,7 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
@ -419,8 +425,6 @@ github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPx
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sniperHW/rank v0.0.0-20210526024650-8d7b0052d89e h1:Ex3Pju8BLLoYUU3cVRRmkg9PiBor7deKJZT1IqjTzH8=
github.com/sniperHW/rank v0.0.0-20210526024650-8d7b0052d89e/go.mod h1:WdhKwu4WacRJmjPwKlRKXGrRDcH6teZqpa7QtRPirsw=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
@ -439,13 +443,14 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
github.com/xdg-go/scram v1.1.0/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM=
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@ -453,14 +458,15 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da h1:NimzV1aGyq29m5ukMK0AMWEhFaL/lrEOaephfuoiARg= github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da h1:NimzV1aGyq29m5ukMK0AMWEhFaL/lrEOaephfuoiARg=
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA= github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da/go.mod h1:E1AXubJBdNmFERAOucpDIxNzeGfLzg0mYh+UfMWdChA=
github.com/zeromicro/go-zero v1.3.2 h1:2HcmceZDEGwZWvofCG+0GXyh+Gtz/wKCW4Fq8Mb7KIg= github.com/zeromicro/go-zero v1.3.3 h1:6qv9PcfqfB1tMgp1FJlP1LfWSZ4XD+FwojvA2h5LL2k=
github.com/zeromicro/go-zero v1.3.2/go.mod h1:DEj3Fwj1Ui1ltsgf6YqwTL9nD4+tYzIRX0c1pWtQo1E= github.com/zeromicro/go-zero v1.3.3/go.mod h1:LwuYc2V04ZHhWPWGJYQ+kJ5DT4QSkeaZGqXiQcpkfks=
go.etcd.io/etcd/api/v3 v3.5.2 h1:tXok5yLlKyuQ/SXSjtqHc4uzNaMqZi2XsoSPr/LlJXI= go.etcd.io/etcd/api/v3 v3.5.2 h1:tXok5yLlKyuQ/SXSjtqHc4uzNaMqZi2XsoSPr/LlJXI=
go.etcd.io/etcd/api/v3 v3.5.2/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= go.etcd.io/etcd/api/v3 v3.5.2/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A=
go.etcd.io/etcd/client/pkg/v3 v3.5.2 h1:4hzqQ6hIb3blLyQ8usCU4h3NghkqcsohEQ3o3VetYxE= go.etcd.io/etcd/client/pkg/v3 v3.5.2 h1:4hzqQ6hIb3blLyQ8usCU4h3NghkqcsohEQ3o3VetYxE=
go.etcd.io/etcd/client/pkg/v3 v3.5.2/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/pkg/v3 v3.5.2/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
go.etcd.io/etcd/client/v3 v3.5.2 h1:WdnejrUtQC4nCxK0/dLTMqKOB+U5TP/2Ya0BJL+1otA= go.etcd.io/etcd/client/v3 v3.5.2 h1:WdnejrUtQC4nCxK0/dLTMqKOB+U5TP/2Ya0BJL+1otA=
go.etcd.io/etcd/client/v3 v3.5.2/go.mod h1:kOOaWFFgHygyT0WlSmL8TJiXmMysO/nNUlEsSsN6W4o= go.etcd.io/etcd/client/v3 v3.5.2/go.mod h1:kOOaWFFgHygyT0WlSmL8TJiXmMysO/nNUlEsSsN6W4o=
go.mongodb.org/mongo-driver v1.9.0/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
@ -503,10 +509,9 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201112155050-0c6587e931a9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201216223049-8b5274cf687f/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210920023735-84f357641f63/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167 h1:O8uGbHCqlTp2P6QJSLmCojM4mN6UemYv8K+dCnmHmu0= golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167 h1:O8uGbHCqlTp2P6QJSLmCojM4mN6UemYv8K+dCnmHmu0=
golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220517005047-85d78b3ac167/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@ -580,9 +585,7 @@ golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220421235706-1d1ef9303861 h1:yssD99+7tqHWO5Gwh81phT+67hg+KttniBr6UnEXOY8=
golang.org/x/net v0.0.0-20220421235706-1d1ef9303861/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220421235706-1d1ef9303861/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220516155154-20f960328961 h1:+W/iTMPG0EL7aW+/atntZwZrvSRIj3m3yX414dSULUU= golang.org/x/net v0.0.0-20220516155154-20f960328961 h1:+W/iTMPG0EL7aW+/atntZwZrvSRIj3m3yX414dSULUU=
golang.org/x/net v0.0.0-20220516155154-20f960328961/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220516155154-20f960328961/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
@ -648,6 +651,7 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201112073958-5cba982894dd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -657,9 +661,9 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc= golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc=
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@ -687,6 +691,7 @@ golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
@ -785,8 +790,8 @@ google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7 h1:ntPPoHzFW6Xp09ueznmahONZufyoSakK/piXnr2BU3I= google.golang.org/genproto v0.0.0-20220422154200-b37d22cd5731 h1:nquqdM9+ps0JZcIiI70+tqoaIFS5Ql4ZuK8UXnz3HfE=
google.golang.org/genproto v0.0.0-20220228195345-15d65a4533f7/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220422154200-b37d22cd5731/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
@ -803,9 +808,9 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k=
google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU=
google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M=
google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ=
google.golang.org/grpc v1.46.0 h1:oCjezcn6g6A75TGoKYBPgKmVBLexhYLM6MebdrPApP8=
google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@ -818,8 +823,9 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@ -849,9 +855,9 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/mysql v1.3.3 h1:jXG9ANrwBc4+bMvBcSl8zCfPBaVoPyBEBshA8dA93X8= gorm.io/driver/mysql v1.3.3 h1:jXG9ANrwBc4+bMvBcSl8zCfPBaVoPyBEBshA8dA93X8=
gorm.io/driver/mysql v1.3.3/go.mod h1:ChK6AHbHgDCFZyJp0F+BmVGb06PSIoh9uVYKAlRbb2U= gorm.io/driver/mysql v1.3.3/go.mod h1:ChK6AHbHgDCFZyJp0F+BmVGb06PSIoh9uVYKAlRbb2U=
gorm.io/driver/postgres v1.3.1 h1:Pyv+gg1Gq1IgsLYytj/S2k7ebII3CzEdpqQkPOdH24g=
gorm.io/driver/sqlite v1.2.6 h1:SStaH/b+280M7C8vXeZLz/zo9cLQmIGwwj3cSj7p6l4=
gorm.io/gorm v1.23.1/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= gorm.io/gorm v1.23.1/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.23.4 h1:1BKWM67O6CflSLcwGQR7ccfmC4ebOxQrTfOQGRE9wjg=
gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/gorm v1.23.5 h1:TnlF26wScKSvknUC/Rn8t0NLLM22fypYBlvj1+aH6dM= gorm.io/gorm v1.23.5 h1:TnlF26wScKSvknUC/Rn8t0NLLM22fypYBlvj1+aH6dM=
gorm.io/gorm v1.23.5/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= gorm.io/gorm v1.23.5/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
gorm.io/plugin/optimisticlock v1.0.7 h1:H+UltfbM3twsgMj4WrRLB2YYVdAcVFegj6DdmIuiA7M= gorm.io/plugin/optimisticlock v1.0.7 h1:H+UltfbM3twsgMj4WrRLB2YYVdAcVFegj6DdmIuiA7M=

Loading…
Cancel
Save