service

package
v1.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 44 Imported by: 0

README

Service

Documentation

Index

Constants

View Source
const (
	UserIDKeyPrefix      = "user:%d"
	UserBalanceKeyPrefix = "user_balance:%d"
	UserEmailKeyPrefix   = "user_email:%s"
	OrderNoKeyPrefix     = "order:%s"
	UserOrdersPrefix     = "user_orders:%d:%s"
)

缓存键前缀

Variables

ProviderSet is service providers

Functions

This section is empty.

Types

type CacheService

type CacheService struct {
	// contains filtered or unexported fields
}

CacheService 缓存服务

func NewCacheService

func NewCacheService(redisClient *redis.Client, db *ent.Client, logger log.Logger) *CacheService

NewCacheService 创建缓存服务

func (*CacheService) BatchClearRelatedCache

func (cs *CacheService) BatchClearRelatedCache(ctx context.Context, userID int64) error

BatchClearRelatedCache 批量清理相关缓存

func (*CacheService) ClearCache

func (cs *CacheService) ClearCache(ctx context.Context, key string) error

ClearCache 清理通用缓存

func (*CacheService) ClearOrderCache

func (cs *CacheService) ClearOrderCache(ctx context.Context, orderNo string) error

ClearOrderCache 清理订单相关缓存

func (*CacheService) ClearUserCache

func (cs *CacheService) ClearUserCache(ctx context.Context, userID int64) error

ClearUserCache 清理用户相关缓存

func (*CacheService) GetCache

func (cs *CacheService) GetCache(ctx context.Context, key string, dest interface{}) error

GetCache 获取通用缓存

func (*CacheService) GetOrderFromCache

func (cs *CacheService) GetOrderFromCache(ctx context.Context, orderNo string) (*OrderCacheModel, error)

GetOrderFromCache 从缓存获取订单信息

func (*CacheService) GetUserFromCache

func (cs *CacheService) GetUserFromCache(ctx context.Context, userID int64) (*UserCacheModel, error)

GetUserFromCache 从缓存获取用户信息

func (*CacheService) SetCache

func (cs *CacheService) SetCache(ctx context.Context, key string, value interface{}, expiry time.Duration) error

SetCache 设置通用缓存

func (*CacheService) SetOrderCache

func (cs *CacheService) SetOrderCache(ctx context.Context, order *ent.ProxyOrder) error

SetOrderCache 设置订单缓存

func (*CacheService) SetUserCache

func (cs *CacheService) SetUserCache(ctx context.Context, user *ent.ProxyUser) error

SetUserCache 设置用户缓存

func (*CacheService) UpdateUserBalanceCache

func (cs *CacheService) UpdateUserBalanceCache(ctx context.Context, userID int64, balance, giftAmount int64) error

UpdateUserBalanceCache 更新用户余额缓存

type OrderCacheModel

type OrderCacheModel struct {
	ID         int64  `json:"id"`
	OrderNo    string `json:"order_no"`
	UserID     int64  `json:"user_id"`
	Status     int8   `json:"status"`
	Amount     int64  `json:"amount"`
	GiftAmount int64  `json:"gift_amount"`
}

OrderCacheModel 订单缓存模型

func (*OrderCacheModel) GetCacheKeys

func (o *OrderCacheModel) GetCacheKeys() []string

GetCacheKeys 实现CacheKeyGenerator接口

type UserAuthMethod

type UserAuthMethod struct {
	UserID         int64  `json:"user_id"`
	AuthType       string `json:"auth_type"`
	AuthIdentifier string `json:"auth_identifier"`
}

UserAuthMethod 用户认证方法

type UserCacheModel

type UserCacheModel struct {
	ID          int64            `json:"id"`
	Email       string           `json:"email"`
	Balance     *int64           `json:"balance,omitempty"`
	GiftAmount  *int64           `json:"gift_amount,omitempty"`
	AuthMethods []UserAuthMethod `json:"auth_methods,omitempty"`
}

UserCacheModel 用户缓存模型

func (*UserCacheModel) GetCacheKeys

func (u *UserCacheModel) GetCacheKeys() []string

GetCacheKeys 实现CacheKeyGenerator接口

type UserServiceService

type UserServiceService struct {
	pb.UnimplementedUserServiceServer
}

func NewUserServiceService

func NewUserServiceService() *UserServiceService

func (*UserServiceService) BatchDeleteUser

func (*UserServiceService) CreateUser

func (*UserServiceService) CurrentUser

func (*UserServiceService) DeleteUser

func (*UserServiceService) GetUserDetail

func (*UserServiceService) GetUserList

func (*UserServiceService) GetUserLoginLogs

func (*UserServiceService) UpdateUserBasicInfo

func (*UserServiceService) UpdateUserNotifySettings

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL