refactor(server): decouple services and improve architecture
- Introduce interfaces for all major services (JWT, PostAI, Comment, Message, Notification, QRCodeLogin, Upload, Vote, etc.) to support dependency inversion.
- Move query parameters from `internal/dto` to a new `internal/query` package to separate request payloads from data transfer objects.
- Refactor `internal/router` to use embedded `RouterDeps` for cleaner dependency management.
- Decouple handlers from repositories by injecting services instead of direct repository access, ensuring proper layering.
- Improve database initialization by moving it from `internal/model` to `internal/database`.
- Optimize message decryption by implementing a more efficient `BatchDecrypt` method in `MessageEncryptor` using a worker pool.
- Enhance error handling and security by implementing fail-fast checks for encryption key length during startup.
- Clean up unused code, including the `avatar` package and several unused DTOs.
2026-06-15 03:41:59 +08:00
|
|
|
|
package wire
|
2026-03-13 09:38:18 +08:00
|
|
|
|
|
|
|
|
|
|
import (
|
2026-04-22 16:01:59 +08:00
|
|
|
|
"with_you/internal/cache"
|
|
|
|
|
|
"with_you/internal/repository"
|
2026-03-13 09:38:18 +08:00
|
|
|
|
|
|
|
|
|
|
"github.com/google/wire"
|
2026-03-14 02:09:38 +08:00
|
|
|
|
"gorm.io/gorm"
|
2026-03-13 09:38:18 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// RepositorySet Repository 层 Provider Set
|
|
|
|
|
|
var RepositorySet = wire.NewSet(
|
|
|
|
|
|
repository.NewUserRepository,
|
|
|
|
|
|
repository.NewPostRepository,
|
|
|
|
|
|
repository.NewCommentRepository,
|
|
|
|
|
|
repository.NewMessageRepository,
|
|
|
|
|
|
repository.NewNotificationRepository,
|
|
|
|
|
|
repository.NewPushRecordRepository,
|
|
|
|
|
|
repository.NewDeviceTokenRepository,
|
|
|
|
|
|
repository.NewSystemNotificationRepository,
|
|
|
|
|
|
repository.NewGroupRepository,
|
2026-03-26 18:14:16 +08:00
|
|
|
|
repository.NewGroupJoinRequestRepository,
|
2026-03-13 09:38:18 +08:00
|
|
|
|
repository.NewStickerRepository,
|
|
|
|
|
|
repository.NewVoteRepository,
|
2026-03-24 22:27:53 +08:00
|
|
|
|
repository.NewChannelRepository,
|
2026-03-13 09:38:18 +08:00
|
|
|
|
repository.NewScheduleRepository,
|
refactor(server): decouple services and improve architecture
- Introduce interfaces for all major services (JWT, PostAI, Comment, Message, Notification, QRCodeLogin, Upload, Vote, etc.) to support dependency inversion.
- Move query parameters from `internal/dto` to a new `internal/query` package to separate request payloads from data transfer objects.
- Refactor `internal/router` to use embedded `RouterDeps` for cleaner dependency management.
- Decouple handlers from repositories by injecting services instead of direct repository access, ensuring proper layering.
- Improve database initialization by moving it from `internal/model` to `internal/database`.
- Optimize message decryption by implementing a more efficient `BatchDecrypt` method in `MessageEncryptor` using a worker pool.
- Enhance error handling and security by implementing fail-fast checks for encryption key length during startup.
- Clean up unused code, including the `avatar` package and several unused DTOs.
2026-06-15 03:41:59 +08:00
|
|
|
|
repository.NewGradeRepository,
|
|
|
|
|
|
repository.NewExamRepository,
|
|
|
|
|
|
repository.NewEmptyClassroomRepository,
|
2026-03-25 20:44:12 +08:00
|
|
|
|
repository.NewMaterialSubjectRepository,
|
|
|
|
|
|
repository.NewMaterialFileRepository,
|
2026-03-27 01:54:34 +08:00
|
|
|
|
repository.NewCallRepository,
|
2026-03-29 20:18:36 +08:00
|
|
|
|
repository.NewReportRepository,
|
2026-03-14 02:09:38 +08:00
|
|
|
|
ProvideUserActivityRepository,
|
2026-03-15 02:25:10 +08:00
|
|
|
|
|
|
|
|
|
|
// 日志相关仓储
|
|
|
|
|
|
repository.NewOperationLogRepository,
|
|
|
|
|
|
repository.NewLoginLogRepository,
|
|
|
|
|
|
repository.NewDataChangeLogRepository,
|
2026-04-05 20:27:03 +08:00
|
|
|
|
|
|
|
|
|
|
// 身份认证相关仓储
|
|
|
|
|
|
repository.NewVerificationRepository,
|
2026-04-07 00:07:40 +08:00
|
|
|
|
|
|
|
|
|
|
// 敏感词相关仓储
|
|
|
|
|
|
repository.NewSensitiveWordRepository,
|
2026-04-15 11:50:47 +08:00
|
|
|
|
|
|
|
|
|
|
// 用户资料审核相关仓储
|
|
|
|
|
|
repository.NewUserProfileAuditRepository,
|
2026-04-26 00:37:20 +08:00
|
|
|
|
|
|
|
|
|
|
// 帖子内链引用关系
|
|
|
|
|
|
repository.NewPostRefRepository,
|
feat(trade): implement second-hand trading/flea market feature
Add complete trade functionality including:
- TradeItem, TradeImage, TradeFavorite models with auto-migration
- TradeRepository with CRUD and favorite operations
- TradeService with business logic for listing, creating, updating, status management
- TradeHandler with RESTful endpoints for trade operations
- DTOs and converters for request/response handling
Routes include: list, get by id, create, update, delete, status update, view recording, favorite/unfavorite.
2026-04-26 15:20:26 +08:00
|
|
|
|
|
|
|
|
|
|
// 二手交易相关
|
|
|
|
|
|
repository.NewTradeRepository,
|
2026-05-17 23:38:04 +08:00
|
|
|
|
|
refactor(server): decouple services and improve architecture
- Introduce interfaces for all major services (JWT, PostAI, Comment, Message, Notification, QRCodeLogin, Upload, Vote, etc.) to support dependency inversion.
- Move query parameters from `internal/dto` to a new `internal/query` package to separate request payloads from data transfer objects.
- Refactor `internal/router` to use embedded `RouterDeps` for cleaner dependency management.
- Decouple handlers from repositories by injecting services instead of direct repository access, ensuring proper layering.
- Improve database initialization by moving it from `internal/model` to `internal/database`.
- Optimize message decryption by implementing a more efficient `BatchDecrypt` method in `MessageEncryptor` using a worker pool.
- Enhance error handling and security by implementing fail-fast checks for encryption key length during startup.
- Clean up unused code, including the `avatar` package and several unused DTOs.
2026-06-15 03:41:59 +08:00
|
|
|
|
// 版本日志同步
|
|
|
|
|
|
repository.NewConversationVersionLogRepository,
|
2026-06-17 20:41:55 +08:00
|
|
|
|
|
|
|
|
|
|
// 文件上传记录(聊天文件 TTL 过期清理)
|
|
|
|
|
|
repository.NewUploadedFileRepository,
|
2026-03-13 09:38:18 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
2026-03-14 02:09:38 +08:00
|
|
|
|
// ProvideUserActivityRepository 提供用户活跃数据仓储
|
2026-03-26 18:14:16 +08:00
|
|
|
|
func ProvideUserActivityRepository(db *gorm.DB, cache cache.Cache) repository.UserActivityRepository {
|
2026-03-14 02:09:38 +08:00
|
|
|
|
return repository.NewUserActivityRepository(db, cache)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-13 09:38:18 +08:00
|
|
|
|
// Note: 以下 Repository 返回接口类型而非指针,需要单独处理
|
|
|
|
|
|
// - ScheduleRepository (repository.ScheduleRepository)
|
|
|
|
|
|
// - StickerRepository (repository.StickerRepository)
|
|
|
|
|
|
// - GroupRepository (repository.GroupRepository)
|
|
|
|
|
|
// 这些已经在各自的 New* 函数中正确返回接口类型,Wire 可以自动处理
|