Init All Docs

This commit is contained in:
Aditya Siregar
2025-09-08 12:24:37 +07:00
parent aa662a321f
commit 2319019eb2
68 changed files with 5417 additions and 437 deletions
+22 -2
View File
@@ -67,12 +67,18 @@ type LetterHandler interface {
CreateIncomingLetter(c *gin.Context)
GetIncomingLetter(c *gin.Context)
ListIncomingLetters(c *gin.Context)
GetLetterUnreadCounts(c *gin.Context)
MarkIncomingLetterAsRead(c *gin.Context)
MarkOutgoingLetterAsRead(c *gin.Context)
UpdateIncomingLetter(c *gin.Context)
DeleteIncomingLetter(c *gin.Context)
BulkArchiveIncomingLetters(c *gin.Context)
CreateDispositions(c *gin.Context)
//ListDispositionsByLetter(c *gin.Context)
GetEnhancedDispositionsByLetter(c *gin.Context)
GetDepartmentDispositionStatus(c *gin.Context)
UpdateDispositionStatus(c *gin.Context)
GetLetterCTA(c *gin.Context)
CreateDiscussion(c *gin.Context)
UpdateDiscussion(c *gin.Context)
@@ -103,9 +109,10 @@ type LetterOutgoingHandler interface {
CreateDiscussion(c *gin.Context)
UpdateDiscussion(c *gin.Context)
DeleteDiscussion(c *gin.Context)
GetApprovalDiscussions(c *gin.Context)
GetApprovalTimeline(c *gin.Context)
BulkArchiveOutgoingLetters(c *gin.Context)
}
type AdminApprovalFlowHandler interface {
@@ -122,10 +129,13 @@ type AdminApprovalFlowHandler interface {
type DispositionRouteHandler interface {
Create(c *gin.Context)
BulkCreateOrUpdate(c *gin.Context)
Update(c *gin.Context)
Get(c *gin.Context)
ListByFromDept(c *gin.Context)
SetActive(c *gin.Context)
ListGrouped(c *gin.Context)
ListAll(c *gin.Context)
}
type OnlyOfficeHandler interface {
@@ -146,3 +156,13 @@ type AnalyticsHandler interface {
GetMonthlyTrend(c *gin.Context)
GetApprovalMetrics(c *gin.Context)
}
type NotificationHandler interface {
TriggerNotification(c *gin.Context)
BulkTriggerNotification(c *gin.Context)
GetSubscriber(c *gin.Context)
UpdateSubscriberChannel(c *gin.Context)
TriggerNotificationForCurrentUser(c *gin.Context)
GetCurrentUserSubscriber(c *gin.Context)
UpdateCurrentUserSubscriberChannel(c *gin.Context)
}
+40 -12
View File
@@ -22,6 +22,7 @@ type Router struct {
dispRouteHandler DispositionRouteHandler
onlyOfficeHandler OnlyOfficeHandler
analyticsHandler AnalyticsHandler
notificationHandler NotificationHandler
}
func NewRouter(
@@ -39,6 +40,7 @@ func NewRouter(
dispRouteHandler DispositionRouteHandler,
onlyOfficeHandler OnlyOfficeHandler,
analyticsHandler AnalyticsHandler,
notificationHandler NotificationHandler,
) *Router {
return &Router{
config: cfg,
@@ -55,6 +57,7 @@ func NewRouter(
dispRouteHandler: dispRouteHandler,
onlyOfficeHandler: onlyOfficeHandler,
analyticsHandler: analyticsHandler,
notificationHandler: notificationHandler,
}
}
@@ -89,7 +92,7 @@ func (r *Router) addAppRoutes(rg *gin.Engine) {
users := v1.Group("/users")
users.Use(r.authMiddleware.RequireAuth())
{
users.GET("", r.authMiddleware.RequirePermissions("user.read"), r.userHandler.ListUsers)
users.GET("", r.userHandler.ListUsers)
users.GET("/profile", r.userHandler.GetProfile)
users.GET("/:id/profile", r.userHandler.GetUserProfile)
users.PUT("/profile", r.userHandler.UpdateProfile)
@@ -156,16 +159,22 @@ func (r *Router) addAppRoutes(rg *gin.Engine) {
lettersch := v1.Group("/letters")
lettersch.Use(r.authMiddleware.RequireAuth())
{
lettersch.POST("/incoming", r.letterHandler.CreateIncomingLetter)
lettersch.GET("/incoming/:id", r.letterHandler.GetIncomingLetter)
lettersch.GET("/unread-counts", r.letterHandler.GetLetterUnreadCounts)
lettersch.GET("/incoming", r.letterHandler.ListIncomingLetters)
lettersch.POST("/incoming", r.letterHandler.CreateIncomingLetter)
lettersch.GET("/incoming/cta/:letter_id", r.letterHandler.GetLetterCTA)
lettersch.GET("/incoming/:id", r.letterHandler.GetIncomingLetter)
lettersch.PUT("/incoming/:id", r.letterHandler.UpdateIncomingLetter)
lettersch.PUT("/incoming/:id/read", r.letterHandler.MarkIncomingLetterAsRead)
lettersch.DELETE("/incoming/:id", r.letterHandler.DeleteIncomingLetter)
lettersch.POST("/incoming/archive", r.letterHandler.BulkArchiveIncomingLetters)
lettersch.POST("/outgoing", r.letterOutgoingHandler.CreateOutgoingLetter)
lettersch.GET("/outgoing/:id", r.letterOutgoingHandler.GetOutgoingLetter)
lettersch.GET("/outgoing", r.letterOutgoingHandler.ListOutgoingLetters)
lettersch.PUT("/outgoing/:id", r.letterOutgoingHandler.UpdateOutgoingLetter)
lettersch.PUT("/outgoing/:id/read", r.letterHandler.MarkOutgoingLetterAsRead)
lettersch.DELETE("/outgoing/:id", r.letterOutgoingHandler.DeleteOutgoingLetter)
lettersch.POST("/outgoing/:id/submit", r.letterOutgoingHandler.SubmitForApproval)
@@ -173,6 +182,7 @@ func (r *Router) addAppRoutes(rg *gin.Engine) {
lettersch.POST("/outgoing/:id/reject", r.letterOutgoingHandler.RejectOutgoingLetter)
lettersch.POST("/outgoing/:id/send", r.letterOutgoingHandler.SendOutgoingLetter)
lettersch.POST("/outgoing/:id/archive", r.letterOutgoingHandler.ArchiveOutgoingLetter)
lettersch.POST("/outgoing/archive", r.letterOutgoingHandler.BulkArchiveOutgoingLetters)
lettersch.GET("/outgoing/:id/cta", r.letterOutgoingHandler.GetLetterApprovalInfo)
lettersch.GET("/outgoing/:id/approvals", r.letterOutgoingHandler.GetLetterApprovals)
@@ -192,6 +202,8 @@ func (r *Router) addAppRoutes(rg *gin.Engine) {
lettersch.POST("/dispositions/:letter_id", r.letterHandler.CreateDispositions)
lettersch.GET("/dispositions/:letter_id", r.letterHandler.GetEnhancedDispositionsByLetter)
lettersch.GET("/dispositions/:letter_id/department/status", r.letterHandler.GetDepartmentDispositionStatus)
lettersch.PUT("/dispositions/:letter_id/status", r.letterHandler.UpdateDispositionStatus)
lettersch.POST("/discussions/:letter_id", r.letterHandler.CreateDiscussion)
lettersch.PUT("/discussions/:letter_id/:discussion_id", r.letterHandler.UpdateDiscussion)
@@ -200,11 +212,14 @@ func (r *Router) addAppRoutes(rg *gin.Engine) {
droutes := v1.Group("/disposition-routes")
droutes.Use(r.authMiddleware.RequireAuth())
{
droutes.POST("", r.dispRouteHandler.Create)
droutes.GET(":id", r.dispRouteHandler.Get)
droutes.PUT(":id", r.dispRouteHandler.Update)
droutes.GET("department", r.dispRouteHandler.ListByFromDept)
droutes.PUT(":id/active", r.dispRouteHandler.SetActive)
droutes.POST("", r.dispRouteHandler.Create) // Create with upsert logic
droutes.PUT("/bulk", r.dispRouteHandler.BulkCreateOrUpdate) // Explicit bulk create/update
droutes.GET("", r.dispRouteHandler.ListAll) // List all routes with details
droutes.GET("/grouped", r.dispRouteHandler.ListGrouped) // List grouped by from_department_id
droutes.GET("/department", r.dispRouteHandler.ListByFromDept)
droutes.GET("/:id", r.dispRouteHandler.Get)
droutes.PUT("/:id", r.dispRouteHandler.Update)
droutes.PUT("/:id/active", r.dispRouteHandler.SetActive)
}
admin := v1.Group("/setting")
@@ -224,13 +239,10 @@ func (r *Router) addAppRoutes(rg *gin.Engine) {
}
}
// OnlyOffice routes
onlyoffice := v1.Group("/onlyoffice")
{
// Callback endpoint - no auth required (OnlyOffice will call this)
onlyoffice.POST("/callback/:key", r.onlyOfficeHandler.ProcessCallback)
// Protected endpoints
onlyofficeAuth := onlyoffice.Group("")
onlyofficeAuth.Use(r.authMiddleware.RequireAuth())
{
@@ -242,7 +254,6 @@ func (r *Router) addAppRoutes(rg *gin.Engine) {
}
}
// Analytics routes
analytics := v1.Group("/analytics")
analytics.Use(r.authMiddleware.RequireAuth())
{
@@ -254,5 +265,22 @@ func (r *Router) addAppRoutes(rg *gin.Engine) {
analytics.GET("/monthly-trend", r.analyticsHandler.GetMonthlyTrend)
analytics.GET("/approval-metrics", r.analyticsHandler.GetApprovalMetrics)
}
notifications := v1.Group("/notifications")
notifications.Use(r.authMiddleware.RequireAuth())
{
notifications.POST("/me/trigger", r.notificationHandler.TriggerNotificationForCurrentUser)
notifications.GET("/me/subscriber", r.notificationHandler.GetCurrentUserSubscriber)
notifications.PUT("/me/channel", r.notificationHandler.UpdateCurrentUserSubscriberChannel)
notifAdmin := notifications.Group("")
notifAdmin.Use(r.authMiddleware.RequirePermissions("notification.admin"))
{
notifAdmin.POST("/trigger", r.notificationHandler.TriggerNotification)
notifAdmin.POST("/bulk-trigger", r.notificationHandler.BulkTriggerNotification)
notifAdmin.GET("/subscribers/:userId", r.notificationHandler.GetSubscriber)
notifAdmin.PUT("/subscribers/channel", r.notificationHandler.UpdateSubscriberChannel)
}
}
}
}