This commit is contained in:
Mrx
2026-01-26 17:35:44 +08:00
parent 1201aab68b
commit f867e603f0
21 changed files with 813 additions and 111 deletions

View File

@@ -39,6 +39,7 @@ type ServiceContext struct {
OrderModel model.OrderModel
OrderRefundModel model.OrderRefundModel
QueryModel model.QueryModel
QueryUserRecordModel model.QueryUserRecordModel
QueryCleanupLogModel model.QueryCleanupLogModel
QueryCleanupDetailModel model.QueryCleanupDetailModel
QueryCleanupConfigModel model.QueryCleanupConfigModel
@@ -108,10 +109,12 @@ func NewServiceContext(c config.Config) *ServiceContext {
cacheConf := c.CacheRedis
// 初始化Redis客户端
// 设置超时时间为30秒解决连接超时问题
redisConf := redis.RedisConf{
Host: cacheConf[0].Host,
Pass: cacheConf[0].Pass,
Type: cacheConf[0].Type,
Host: cacheConf[0].Host,
Pass: cacheConf[0].Pass,
Type: cacheConf[0].Type,
PingTimeout: 30 * time.Second, // 设置30秒超时解决 "context deadline exceeded" 错误
}
redisClient := redis.MustNewRedis(redisConf)
@@ -128,6 +131,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
// ============================== 订单相关模型 ==============================
orderModel := model.NewOrderModel(db, cacheConf)
queryModel := model.NewQueryModel(db, cacheConf)
queryUserRecordModel := model.NewQueryUserRecordModel(db, cacheConf)
orderRefundModel := model.NewOrderRefundModel(db, cacheConf)
queryCleanupLogModel := model.NewQueryCleanupLogModel(db, cacheConf)
queryCleanupDetailModel := model.NewQueryCleanupDetailModel(db, cacheConf)
@@ -238,6 +242,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
// 订单相关模型
OrderModel: orderModel,
QueryModel: queryModel,
QueryUserRecordModel: queryUserRecordModel,
OrderRefundModel: orderRefundModel,
QueryCleanupLogModel: queryCleanupLogModel,
QueryCleanupDetailModel: queryCleanupDetailModel,