2024-03-05 19:15:53 +00:00
|
|
|
package articles
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
|
"go.uber.org/fx"
|
2025-07-02 06:03:52 +00:00
|
|
|
"web-medols-be/app/module/articles/controller"
|
|
|
|
|
"web-medols-be/app/module/articles/repository"
|
|
|
|
|
"web-medols-be/app/module/articles/service"
|
2024-03-05 19:15:53 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ArticlesRouter struct of ArticlesRouter
|
|
|
|
|
type ArticlesRouter struct {
|
|
|
|
|
App fiber.Router
|
|
|
|
|
Controller *controller.Controller
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NewArticlesModule register bulky of Articles module
|
|
|
|
|
var NewArticlesModule = fx.Options(
|
|
|
|
|
// register repository of Articles module
|
|
|
|
|
fx.Provide(repository.NewArticlesRepository),
|
|
|
|
|
|
|
|
|
|
// register service of Articles module
|
|
|
|
|
fx.Provide(service.NewArticlesService),
|
|
|
|
|
|
|
|
|
|
// register controller of Articles module
|
|
|
|
|
fx.Provide(controller.NewController),
|
|
|
|
|
|
|
|
|
|
// register router of Articles module
|
|
|
|
|
fx.Provide(NewArticlesRouter),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// NewArticlesRouter init ArticlesRouter
|
|
|
|
|
func NewArticlesRouter(fiber *fiber.App, controller *controller.Controller) *ArticlesRouter {
|
|
|
|
|
return &ArticlesRouter{
|
|
|
|
|
App: fiber,
|
|
|
|
|
Controller: controller,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RegisterArticlesRoutes register routes of Articles module
|
|
|
|
|
func (_i *ArticlesRouter) RegisterArticlesRoutes() {
|
|
|
|
|
// define controllers
|
|
|
|
|
articlesController := _i.Controller.Articles
|
|
|
|
|
|
|
|
|
|
// define routes
|
|
|
|
|
_i.App.Route("/articles", func(router fiber.Router) {
|
|
|
|
|
router.Get("/", articlesController.All)
|
2025-05-14 16:54:21 +00:00
|
|
|
router.Get("/old-id/:id", articlesController.ShowByOldId)
|
2024-03-05 19:15:53 +00:00
|
|
|
router.Get("/:id", articlesController.Show)
|
|
|
|
|
router.Post("/", articlesController.Save)
|
|
|
|
|
router.Put("/:id", articlesController.Update)
|
2025-04-07 01:12:02 +00:00
|
|
|
router.Put("/banner/:id", articlesController.UpdateBanner)
|
2024-05-05 09:24:49 +00:00
|
|
|
router.Post("/thumbnail/:id", articlesController.SaveThumbnail)
|
|
|
|
|
router.Get("/thumbnail/viewer/:thumbnailName", articlesController.Viewer)
|
2025-02-24 05:28:06 +00:00
|
|
|
router.Post("/publish-scheduling", articlesController.PublishScheduling)
|
2024-03-05 19:15:53 +00:00
|
|
|
router.Delete("/:id", articlesController.Delete)
|
2025-02-15 01:56:13 +00:00
|
|
|
router.Get("/statistic/summary", articlesController.SummaryStats)
|
2025-02-15 10:23:39 +00:00
|
|
|
router.Get("/statistic/user-levels", articlesController.ArticlePerUserLevelStats)
|
|
|
|
|
router.Get("/statistic/monthly", articlesController.ArticleMonthlyStats)
|
2025-09-08 18:11:06 +00:00
|
|
|
|
|
|
|
|
// Dynamic approval system routes
|
|
|
|
|
router.Post("/:id/submit-approval", articlesController.SubmitForApproval)
|
|
|
|
|
router.Get("/:id/approval-status", articlesController.GetApprovalStatus)
|
|
|
|
|
router.Get("/pending-approval", articlesController.GetPendingApprovals)
|
2024-03-05 19:15:53 +00:00
|
|
|
})
|
|
|
|
|
}
|