package repository import ( "context" "github.com/go-nunu/nunu-layout-advanced/internal/model" ) type GameShieldUserIpRepository interface { GetGameShieldUserIp(ctx context.Context, id int64) (*model.GameShieldUserIp, error) GetGameShieldUserIpByUid(ctx context.Context, uid int64) (int, error) AddGameShieldUserIp(ctx context.Context, req *model.GameShieldUserIp) error UpdateGameShieldUserIp(ctx context.Context, req *model.GameShieldUserIp) error DeleteGameShieldUserIp(ctx context.Context, id int64) error } func NewGameShieldUserIpRepository( repository *Repository, ) GameShieldUserIpRepository { return &gameShieldUserIpRepository{ Repository: repository, } } type gameShieldUserIpRepository struct { *Repository } func (r *gameShieldUserIpRepository) GetGameShieldUserIp(ctx context.Context, id int64) (*model.GameShieldUserIp, error) { var gameShieldUserIp model.GameShieldUserIp return &gameShieldUserIp, nil } func (r *gameShieldUserIpRepository) GetGameShieldUserIpByUid(ctx context.Context, uid int64) (int, error) { var ipId int if err := r.DB(ctx).Model(&model.GameShieldUserIp{}).Select("ip_id").Where("uid = ?", uid).Scan(&ipId).Error; err != nil { return 0, err } return ipId, nil } func (r *gameShieldUserIpRepository) AddGameShieldUserIp(ctx context.Context, req *model.GameShieldUserIp) error { if err := r.DB(ctx).Create(req).Error; err != nil { return err } return nil } func (r *gameShieldUserIpRepository) UpdateGameShieldUserIp(ctx context.Context, req *model.GameShieldUserIp) error { if err := r.DB(ctx).Updates(req).Error; err != nil { return err } return nil } func (r *gameShieldUserIpRepository) DeleteGameShieldUserIp(ctx context.Context, id int64) error { if err := r.DB(ctx).Where("id = ?", id).Delete(&model.GameShieldUserIp{}).Error; err != nil { return err } return nil }