chore: add first handlers
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/rostpoliplast/backend/internal/storage"
|
||||
)
|
||||
|
||||
type BaleHandlers struct {
|
||||
DB *pgxpool.Pool
|
||||
Repo *storage.Repository
|
||||
}
|
||||
|
||||
func (h *BaleHandlers) RegisterRoutes(g *gin.RouterGroup) {
|
||||
g.GET("/bales", h.GetBales)
|
||||
g.GET("/bales/:id", h.GetBaleByID)
|
||||
g.POST("/bales", h.CreateBale)
|
||||
g.PUT("/bales/:id", h.UpdateBale)
|
||||
g.DELETE("/bales/:id", h.DeleteBale)
|
||||
}
|
||||
|
||||
func (h *BaleHandlers) GetBales(c *gin.Context) {
|
||||
c.JSON(200, gin.H{"message": "GetBales"})
|
||||
}
|
||||
|
||||
func (h *BaleHandlers) GetBaleByID(c *gin.Context) {
|
||||
c.JSON(200, gin.H{"message": "GetBaleByID"})
|
||||
}
|
||||
|
||||
func (h *BaleHandlers) CreateBale(c *gin.Context) {
|
||||
c.JSON(200, gin.H{"message": "CreateBale"})
|
||||
}
|
||||
|
||||
func (h *BaleHandlers) UpdateBale(c *gin.Context) {
|
||||
c.JSON(200, gin.H{"message": "UpdateBale"})
|
||||
}
|
||||
|
||||
func (h *BaleHandlers) DeleteBale(c *gin.Context) {
|
||||
c.JSON(200, gin.H{"message": "DeleteBale"})
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"gitea.d3m0k1d.ru/d3m0k1d/rostpoliplast/backend/internal/storage"
|
||||
)
|
||||
|
||||
type Handlers struct {
|
||||
DB *pgxpool.Pool
|
||||
Repo *storage.Repository
|
||||
}
|
||||
|
||||
func (h *Handlers) RegisterRoutes(r *gin.RouterGroup) {
|
||||
baleHandlers := &BaleHandlers{
|
||||
DB: h.DB,
|
||||
Repo: h.Repo,
|
||||
}
|
||||
baleHandlers.RegisterRoutes(r)
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
)
|
||||
|
||||
type Repository struct {
|
||||
pool *pgxpool.Pool
|
||||
}
|
||||
|
||||
func NewRepository(pool *pgxpool.Pool) *Repository {
|
||||
return &Repository{
|
||||
pool: pool,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package storage
|
||||
|
||||
type BaleType struct {
|
||||
ID int `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Weight float64 `json:"weight"`
|
||||
Height float64 `json:"height"`
|
||||
Width float64 `json:"width"`
|
||||
Length float64 `json:"length"`
|
||||
}
|
||||
|
||||
type Bale struct {
|
||||
ID int `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
Reference in New Issue
Block a user