format
This commit is contained in:
@@ -2,8 +2,8 @@ package controllers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
@@ -12,14 +12,12 @@ import(
|
|||||||
"example.com/gin/test/services"
|
"example.com/gin/test/services"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
type UserController struct{}
|
type UserController struct{}
|
||||||
|
|
||||||
func NewUserController() UserController {
|
func NewUserController() UserController {
|
||||||
return UserController{}
|
return UserController{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (uc *UserController) Register(c *gin.Context) {
|
func (uc *UserController) Register(c *gin.Context) {
|
||||||
//Get the email/passwd off req body
|
//Get the email/passwd off req body
|
||||||
var body struct {
|
var body struct {
|
||||||
@@ -53,7 +51,6 @@ func (uc *UserController) Register(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, gin.H{})
|
c.JSON(http.StatusOK, gin.H{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (uc *UserController) Login(c *gin.Context) {
|
func (uc *UserController) Login(c *gin.Context) {
|
||||||
//Get the email/passwd off req body
|
//Get the email/passwd off req body
|
||||||
var body struct {
|
var body struct {
|
||||||
@@ -116,7 +113,6 @@ func (rc *UserController) LoginView(c *gin.Context) {
|
|||||||
c.HTML(http.StatusOK, "login.html", CreateSessionData(c, data))
|
c.HTML(http.StatusOK, "login.html", CreateSessionData(c, data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (rc *UserController) LoginHandler(c *gin.Context) {
|
func (rc *UserController) LoginHandler(c *gin.Context) {
|
||||||
email := c.PostForm("email")
|
email := c.PostForm("email")
|
||||||
password := c.PostForm("password")
|
password := c.PostForm("password")
|
||||||
@@ -147,7 +143,6 @@ func CreateSessionData(c *gin.Context, extra any) gin.H {
|
|||||||
_, exists := c.Get("user")
|
_, exists := c.Get("user")
|
||||||
|
|
||||||
return gin.H{
|
return gin.H{
|
||||||
"test": "HEllo World",
|
|
||||||
"loggedIn": exists,
|
"loggedIn": exists,
|
||||||
"data": extra,
|
"data": extra,
|
||||||
}
|
}
|
||||||
@@ -236,10 +231,9 @@ func (rc *UserController) CalendarView(c *gin.Context) {
|
|||||||
shopItems, _ := repositories.ShopItems.GetAll()
|
shopItems, _ := repositories.ShopItems.GetAll()
|
||||||
fmt.Println(len(shopItems))
|
fmt.Println(len(shopItems))
|
||||||
|
|
||||||
|
|
||||||
generateBookings := func(amountShopItems int) []calendarbooking {
|
generateBookings := func(amountShopItems int) []calendarbooking {
|
||||||
var result []calendarbooking
|
var result []calendarbooking
|
||||||
time := 6;
|
time := 6
|
||||||
for _ = range 18 {
|
for _ = range 18 {
|
||||||
book := calendarbooking{
|
book := calendarbooking{
|
||||||
Time: fmt.Sprintf("%d:00", time),
|
Time: fmt.Sprintf("%d:00", time),
|
||||||
|
|||||||
Reference in New Issue
Block a user