feat: Implement notification service and integrate with user interactions

- Added notification service to handle sending and listing notifications.
- Integrated notification sending on user follow and order payment events.
- Updated user service to include fetching followed tenants.
- Enhanced content service to manage access control for content assets.
- Implemented logic for listing content topics based on genre.
- Updated creator service to manage content updates and pricing.
- Improved order service to include detailed order information and notifications.
- Added tests for notification CRUD operations and order details.
This commit is contained in:
2025-12-30 09:57:12 +08:00
parent 9ef9642965
commit 5cf2295f91
14 changed files with 741 additions and 52 deletions

View File

@@ -220,6 +220,10 @@ func (r *Routes) Register(router fiber.Router) {
router.Get("/v1/me/favorites"[len(r.Path()):], DataFunc0(
r.user.Favorites,
))
r.log.Debugf("Registering route: Get /v1/me/following -> user.Following")
router.Get("/v1/me/following"[len(r.Path()):], DataFunc0(
r.user.Following,
))
r.log.Debugf("Registering route: Get /v1/me/library -> user.Library")
router.Get("/v1/me/library"[len(r.Path()):], DataFunc0(
r.user.Library,
@@ -229,9 +233,10 @@ func (r *Routes) Register(router fiber.Router) {
r.user.Likes,
))
r.log.Debugf("Registering route: Get /v1/me/notifications -> user.Notifications")
router.Get("/v1/me/notifications"[len(r.Path()):], DataFunc1(
router.Get("/v1/me/notifications"[len(r.Path()):], DataFunc2(
r.user.Notifications,
QueryParam[string]("type"),
QueryParam[int]("page"),
))
r.log.Debugf("Registering route: Get /v1/me/orders -> user.ListOrders")
router.Get("/v1/me/orders"[len(r.Path()):], DataFunc1(

View File

@@ -211,6 +211,19 @@ func (u *User) RemoveLike(ctx fiber.Ctx, contentId string) error {
return services.Content.RemoveLike(ctx.Context(), contentId)
}
// Get following tenants
//
// @Router /v1/me/following [get]
// @Summary Get following
// @Description Get following tenants
// @Tags UserCenter
// @Accept json
// @Produce json
// @Success 200 {array} dto.TenantProfile
func (u *User) Following(ctx fiber.Ctx) ([]dto.TenantProfile, error) {
return services.Tenant.ListFollowed(ctx.Context())
}
// Get notifications
//
// @Router /v1/me/notifications [get]
@@ -220,8 +233,10 @@ func (u *User) RemoveLike(ctx fiber.Ctx, contentId string) error {
// @Accept json
// @Produce json
// @Param type query string false "Type enum(all, system, order, audit, interaction)"
// @Success 200 {array} dto.Notification
// @Param page query int false "Page number"
// @Success 200 {object} requests.Pager{items=[]dto.Notification}
// @Bind typeArg query key(type)
func (u *User) Notifications(ctx fiber.Ctx, typeArg string) ([]dto.Notification, error) {
return services.User.GetNotifications(ctx.Context(), typeArg)
// @Bind page query
func (u *User) Notifications(ctx fiber.Ctx, typeArg string, page int) (*requests.Pager, error) {
return services.Notification.List(ctx.Context(), page, typeArg)
}