2023-09-04 11:13:21 +02:00
|
|
|
package routes
|
|
|
|
|
|
|
|
|
|
import (
|
2023-09-11 08:08:24 +02:00
|
|
|
"gitlab.com/pactual1/backend/controllers"
|
2023-11-10 17:32:17 +01:00
|
|
|
"gitlab.com/pactual1/backend/middlewares"
|
2023-09-11 08:08:24 +02:00
|
|
|
|
2023-09-06 11:58:33 +02:00
|
|
|
"github.com/gin-gonic/gin"
|
2023-09-04 11:13:21 +02:00
|
|
|
)
|
|
|
|
|
|
2023-09-18 12:27:40 +02:00
|
|
|
func RegisterPublicRoutes(r *gin.Engine) {
|
2023-09-04 11:13:21 +02:00
|
|
|
|
2023-10-13 11:48:14 +02:00
|
|
|
// Health checks
|
|
|
|
|
r.GET("/health", controllers.HealthCheck)
|
|
|
|
|
|
2023-09-27 19:20:44 +02:00
|
|
|
// Map dashboard
|
2023-11-10 17:32:17 +01:00
|
|
|
r.GET("/dashboard/map/contract/devices", middlewares.AuthMiddleware(), controllers.GetDevicesByContract)
|
|
|
|
|
r.GET("/dashboard/map/contracts", middlewares.AuthMiddleware(), controllers.GetLatestContracts)
|
|
|
|
|
r.GET("/dashboard/map/device_data", middlewares.AuthMiddleware(), controllers.GetDeviceData)
|
2023-09-19 08:15:42 +02:00
|
|
|
|
2023-09-27 19:20:44 +02:00
|
|
|
// Invoices
|
2023-11-10 17:32:17 +01:00
|
|
|
r.GET("/invoices", middlewares.AuthMiddleware(), controllers.GetInvoices)
|
|
|
|
|
r.GET("/invoices/:id", middlewares.AuthMiddleware(), controllers.GetInvoiceByID)
|
2023-09-27 19:20:44 +02:00
|
|
|
|
2023-09-27 08:04:50 +02:00
|
|
|
r.POST("/device_data/save", controllers.SaveDeviceInfo)
|
2023-11-10 17:32:17 +01:00
|
|
|
r.GET("/buyers", middlewares.AuthMiddleware(), controllers.ListCompanies)
|
|
|
|
|
r.GET("/products", middlewares.AuthMiddleware(), middlewares.AuthMiddleware(), controllers.ListProductTemplates)
|
|
|
|
|
r.GET("/templates", middlewares.AuthMiddleware(), controllers.ListTextTemplates)
|
|
|
|
|
r.POST("/templates/save", middlewares.AuthMiddleware(), controllers.CreateTextTemplate)
|
|
|
|
|
r.GET("/products/:template_id", middlewares.AuthMiddleware(), controllers.GetProductTemplate)
|
2023-10-03 18:26:57 +02:00
|
|
|
|
|
|
|
|
// Contracts
|
2023-11-10 17:32:17 +01:00
|
|
|
r.GET("/contracts/statuses", middlewares.AuthMiddleware(), controllers.GetContractStatuses)
|
|
|
|
|
r.GET("/contracts", middlewares.AuthMiddleware(), controllers.GetBuyerContracts)
|
|
|
|
|
r.POST("/contracts/create", middlewares.AuthMiddleware(), controllers.CreateContract)
|
2023-10-12 05:23:34 +02:00
|
|
|
|
2023-11-10 17:32:17 +01:00
|
|
|
r.GET("/contracts/:contract_id", middlewares.AuthMiddleware(), controllers.GetContractByID)
|
|
|
|
|
r.PATCH("/contracts/:contract_id", middlewares.AuthMiddleware(), controllers.UpdateContract)
|
2023-10-12 05:23:34 +02:00
|
|
|
|
|
|
|
|
// Locations
|
2023-11-10 17:32:17 +01:00
|
|
|
r.GET("/locations", middlewares.AuthMiddleware(), controllers.SearchPlace)
|
2023-10-09 18:23:44 +02:00
|
|
|
|
|
|
|
|
// Notifications
|
2023-11-10 17:32:17 +01:00
|
|
|
r.GET("/notifications", middlewares.AuthMiddleware(), controllers.GetNotifications)
|
2023-10-20 12:03:59 +02:00
|
|
|
|
|
|
|
|
// Stats
|
2023-11-10 17:32:17 +01:00
|
|
|
r.GET("/stats/measurements", middlewares.AuthMiddleware(), controllers.GetCompanyRelatedDeviceInfoCount)
|
|
|
|
|
r.GET("/stats/devices", middlewares.AuthMiddleware(), controllers.GetCompanyRelatedDeviceInfoCountWithTempRange)
|
|
|
|
|
r.GET("/stats/contracts", middlewares.AuthMiddleware(), controllers.GetContractCountByStatus)
|
|
|
|
|
r.GET("/stats/contracts/total", middlewares.AuthMiddleware(), controllers.GetTotalContractCount)
|
|
|
|
|
r.GET("/stats/invoices", middlewares.AuthMiddleware(), controllers.GetInvoiceCountByStatus)
|
|
|
|
|
r.GET("/stats/milestones", middlewares.AuthMiddleware(), controllers.GetContractsMatchingDeviceLocation)
|
2023-10-30 19:21:43 +01:00
|
|
|
|
|
|
|
|
//Users
|
|
|
|
|
r.POST("/user/reset/password", controllers.ResetPassword)
|
|
|
|
|
r.POST("/user/set/password", controllers.UpdatePassword)
|
2023-11-06 11:22:51 +01:00
|
|
|
r.POST("/user/login", controllers.Login)
|
|
|
|
|
r.POST("/user/logout", controllers.Logout)
|
2023-09-04 11:13:21 +02:00
|
|
|
}
|