This commit is contained in:
2025-12-02 19:57:10 +08:00
parent 3440744179
commit 08ff223ff8
188 changed files with 12337 additions and 7212 deletions

View File

@@ -21,9 +21,9 @@ type ServiceContext struct {
Redis *redis.Redis
// 中间件
AuthInterceptor rest.Middleware
UserAuthInterceptor rest.Middleware
AdminAuthInterceptor rest.Middleware
AuthInterceptor rest.Middleware
UserAuthInterceptor rest.Middleware
AdminAuthInterceptor rest.Middleware
// 用户相关模型
UserModel model.UserModel
@@ -44,56 +44,53 @@ type ServiceContext struct {
QueryCleanupConfigModel model.QueryCleanupConfigModel
// 代理相关模型(新系统)
AgentModel model.AgentModel
AgentWalletModel model.AgentWalletModel
AgentRelationModel model.AgentRelationModel
AgentLinkModel model.AgentLinkModel
AgentOrderModel model.AgentOrderModel
AgentCommissionModel model.AgentCommissionModel
AgentRebateModel model.AgentRebateModel
AgentUpgradeModel model.AgentUpgradeModel
AgentWithdrawalModel model.AgentWithdrawalModel
AgentConfigModel model.AgentConfigModel
AgentProductConfigModel model.AgentProductConfigModel
AgentRealNameModel model.AgentRealNameModel
AgentWithdrawalTaxModel model.AgentWithdrawalTaxModel
AgentInviteCodeModel model.AgentInviteCodeModel
AgentModel model.AgentModel
AgentWalletModel model.AgentWalletModel
AgentRelationModel model.AgentRelationModel
AgentLinkModel model.AgentLinkModel
AgentOrderModel model.AgentOrderModel
AgentCommissionModel model.AgentCommissionModel
AgentRebateModel model.AgentRebateModel
AgentUpgradeModel model.AgentUpgradeModel
AgentWithdrawalModel model.AgentWithdrawalModel
AgentConfigModel model.AgentConfigModel
AgentProductConfigModel model.AgentProductConfigModel
AgentRealNameModel model.AgentRealNameModel
AgentWithdrawalTaxModel model.AgentWithdrawalTaxModel
AgentInviteCodeModel model.AgentInviteCodeModel
AgentInviteCodeUsageModel model.AgentInviteCodeUsageModel
AgentFreezeTaskModel model.AgentFreezeTaskModel
AgentShortLinkModel model.AgentShortLinkModel
// 管理后台相关模型
AdminApiModel model.AdminApiModel
AdminMenuModel model.AdminMenuModel
AdminRoleModel model.AdminRoleModel
AdminRoleApiModel model.AdminRoleApiModel
AdminRoleMenuModel model.AdminRoleMenuModel
AdminUserModel model.AdminUserModel
AdminUserRoleModel model.AdminUserRoleModel
AdminDictDataModel model.AdminDictDataModel
AdminDictTypeModel model.AdminDictTypeModel
AdminPromotionLinkModel model.AdminPromotionLinkModel
AdminPromotionLinkStatsTotalModel model.AdminPromotionLinkStatsTotalModel
AdminPromotionLinkStatsHistoryModel model.AdminPromotionLinkStatsHistoryModel
AdminPromotionOrderModel model.AdminPromotionOrderModel
AdminApiModel model.AdminApiModel
AdminMenuModel model.AdminMenuModel
AdminRoleModel model.AdminRoleModel
AdminRoleApiModel model.AdminRoleApiModel
AdminRoleMenuModel model.AdminRoleMenuModel
AdminUserModel model.AdminUserModel
AdminUserRoleModel model.AdminUserRoleModel
AdminDictDataModel model.AdminDictDataModel
AdminDictTypeModel model.AdminDictTypeModel
// 其他模型
ExampleModel model.ExampleModel
GlobalNotificationsModel model.GlobalNotificationsModel
ExampleModel model.ExampleModel
GlobalNotificationsModel model.GlobalNotificationsModel
AuthorizationDocumentModel model.AuthorizationDocumentModel
// 服务
AlipayService *service.AliPayService
WechatPayService *service.WechatPayService
ApplePayService *service.ApplePayService
ApiRequestService *service.ApiRequestService
AsynqServer *asynq.Server
AsynqService *service.AsynqService
VerificationService *service.VerificationService
AgentService *service.AgentService
UserService *service.UserService
DictService *service.DictService
AdminPromotionLinkStatsService *service.AdminPromotionLinkStatsService
ImageService *service.ImageService
AuthorizationService *service.AuthorizationService
AlipayService *service.AliPayService
WechatPayService *service.WechatPayService
ApplePayService *service.ApplePayService
ApiRequestService *service.ApiRequestService
AsynqServer *asynq.Server
AsynqService *service.AsynqService
VerificationService *service.VerificationService
AgentService *service.AgentService
UserService *service.UserService
DictService *service.DictService
ImageService *service.ImageService
AuthorizationService *service.AuthorizationService
}
// NewServiceContext 创建服务上下文
@@ -143,6 +140,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
agentRealNameModel := model.NewAgentRealNameModel(db, cacheConf)
agentWithdrawalTaxModel := model.NewAgentWithdrawalTaxModel(db, cacheConf)
agentInviteCodeModel := model.NewAgentInviteCodeModel(db, cacheConf)
agentInviteCodeUsageModel := model.NewAgentInviteCodeUsageModel(db, cacheConf)
agentFreezeTaskModel := model.NewAgentFreezeTaskModel(db, cacheConf)
agentShortLinkModel := model.NewAgentShortLinkModel(db, cacheConf)
// ============================== 管理后台相关模型 ==============================
adminApiModel := model.NewAdminApiModel(db, cacheConf)
adminMenuModel := model.NewAdminMenuModel(db, cacheConf)
@@ -153,17 +153,12 @@ func NewServiceContext(c config.Config) *ServiceContext {
adminUserRoleModel := model.NewAdminUserRoleModel(db, cacheConf)
adminDictDataModel := model.NewAdminDictDataModel(db, cacheConf)
adminDictTypeModel := model.NewAdminDictTypeModel(db, cacheConf)
adminPromotionLinkModel := model.NewAdminPromotionLinkModel(db, cacheConf)
adminPromotionLinkStatsTotalModel := model.NewAdminPromotionLinkStatsTotalModel(db, cacheConf)
adminPromotionLinkStatsHistoryModel := model.NewAdminPromotionLinkStatsHistoryModel(db, cacheConf)
adminPromotionOrderModel := model.NewAdminPromotionOrderModel(db, cacheConf)
// ============================== 其他模型 ==============================
exampleModel := model.NewExampleModel(db, cacheConf)
globalNotificationsModel := model.NewGlobalNotificationsModel(db, cacheConf)
authorizationDocumentModel := model.NewAuthorizationDocumentModel(db, cacheConf)
// ============================== 第三方服务初始化 ==============================
tianyuanapi, err := tianyuanapi.NewClient(tianyuanapi.Config{
AccessID: c.Tianyuanapi.AccessID,
@@ -185,11 +180,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
agentService := service.NewAgentService(c, orderModel, agentModel, agentWalletModel,
agentRelationModel, agentLinkModel, agentOrderModel, agentCommissionModel, agentRebateModel,
agentUpgradeModel, agentWithdrawalModel, agentConfigModel, agentProductConfigModel,
agentRealNameModel, agentWithdrawalTaxModel)
agentRealNameModel, agentWithdrawalTaxModel, agentFreezeTaskModel)
userService := service.NewUserService(&c, userModel, userAuthModel, userTempModel, agentModel)
dictService := service.NewDictService(adminDictTypeModel, adminDictDataModel)
adminPromotionLinkStatsService := service.NewAdminPromotionLinkStatsService(adminPromotionLinkModel,
adminPromotionLinkStatsTotalModel, adminPromotionLinkStatsHistoryModel)
imageService := service.NewImageService()
authorizationService := service.NewAuthorizationService(c, authorizationDocumentModel)
@@ -209,9 +202,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
return &ServiceContext{
Config: c,
Redis: redisClient,
AuthInterceptor: middleware.NewAuthInterceptorMiddleware(c).Handle,
UserAuthInterceptor: middleware.NewUserAuthInterceptorMiddleware().Handle,
AdminAuthInterceptor: middleware.NewAdminAuthInterceptorMiddleware(c,
AuthInterceptor: middleware.NewAuthInterceptorMiddleware(c).Handle,
UserAuthInterceptor: middleware.NewUserAuthInterceptorMiddleware().Handle,
AdminAuthInterceptor: middleware.NewAdminAuthInterceptorMiddleware(c,
adminUserModel, adminUserRoleModel, adminRoleModel, adminApiModel, adminRoleApiModel).Handle,
// 用户相关模型
@@ -233,56 +226,53 @@ func NewServiceContext(c config.Config) *ServiceContext {
QueryCleanupConfigModel: queryCleanupConfigModel,
// 代理相关模型(新系统)
AgentModel: agentModel,
AgentWalletModel: agentWalletModel,
AgentRelationModel: agentRelationModel,
AgentLinkModel: agentLinkModel,
AgentOrderModel: agentOrderModel,
AgentCommissionModel: agentCommissionModel,
AgentRebateModel: agentRebateModel,
AgentUpgradeModel: agentUpgradeModel,
AgentWithdrawalModel: agentWithdrawalModel,
AgentConfigModel: agentConfigModel,
AgentProductConfigModel: agentProductConfigModel,
AgentRealNameModel: agentRealNameModel,
AgentWithdrawalTaxModel: agentWithdrawalTaxModel,
AgentInviteCodeModel: agentInviteCodeModel,
AgentModel: agentModel,
AgentWalletModel: agentWalletModel,
AgentRelationModel: agentRelationModel,
AgentLinkModel: agentLinkModel,
AgentOrderModel: agentOrderModel,
AgentCommissionModel: agentCommissionModel,
AgentRebateModel: agentRebateModel,
AgentUpgradeModel: agentUpgradeModel,
AgentWithdrawalModel: agentWithdrawalModel,
AgentConfigModel: agentConfigModel,
AgentProductConfigModel: agentProductConfigModel,
AgentRealNameModel: agentRealNameModel,
AgentWithdrawalTaxModel: agentWithdrawalTaxModel,
AgentInviteCodeModel: agentInviteCodeModel,
AgentInviteCodeUsageModel: agentInviteCodeUsageModel,
AgentFreezeTaskModel: agentFreezeTaskModel,
AgentShortLinkModel: agentShortLinkModel,
// 管理后台相关模型
AdminApiModel: adminApiModel,
AdminMenuModel: adminMenuModel,
AdminRoleModel: adminRoleModel,
AdminRoleApiModel: adminRoleApiModel,
AdminRoleMenuModel: adminRoleMenuModel,
AdminUserModel: adminUserModel,
AdminUserRoleModel: adminUserRoleModel,
AdminDictDataModel: adminDictDataModel,
AdminDictTypeModel: adminDictTypeModel,
AdminPromotionLinkModel: adminPromotionLinkModel,
AdminPromotionLinkStatsTotalModel: adminPromotionLinkStatsTotalModel,
AdminPromotionLinkStatsHistoryModel: adminPromotionLinkStatsHistoryModel,
AdminPromotionOrderModel: adminPromotionOrderModel,
AdminApiModel: adminApiModel,
AdminMenuModel: adminMenuModel,
AdminRoleModel: adminRoleModel,
AdminRoleApiModel: adminRoleApiModel,
AdminRoleMenuModel: adminRoleMenuModel,
AdminUserModel: adminUserModel,
AdminUserRoleModel: adminUserRoleModel,
AdminDictDataModel: adminDictDataModel,
AdminDictTypeModel: adminDictTypeModel,
// 其他模型
ExampleModel: exampleModel,
GlobalNotificationsModel: globalNotificationsModel,
ExampleModel: exampleModel,
GlobalNotificationsModel: globalNotificationsModel,
AuthorizationDocumentModel: authorizationDocumentModel,
// 服务
AlipayService: alipayService,
WechatPayService: wechatPayService,
ApplePayService: applePayService,
ApiRequestService: apiRequestService,
AsynqServer: asynqServer,
AsynqService: asynqService,
VerificationService: verificationService,
AgentService: agentService,
UserService: userService,
DictService: dictService,
AdminPromotionLinkStatsService: adminPromotionLinkStatsService,
ImageService: imageService,
AuthorizationService: authorizationService,
AlipayService: alipayService,
WechatPayService: wechatPayService,
ApplePayService: applePayService,
ApiRequestService: apiRequestService,
AsynqServer: asynqServer,
AsynqService: asynqService,
VerificationService: verificationService,
AgentService: agentService,
UserService: userService,
DictService: dictService,
ImageService: imageService,
AuthorizationService: authorizationService,
}
}