Locations added

This commit is contained in:
cdricms
2025-03-10 16:25:12 +01:00
parent 7cb633b4c6
commit 4cf85981eb
32 changed files with 1504 additions and 227 deletions

View File

@@ -17,5 +17,7 @@ type Event struct {
ScheduleEnd time.Time `bun:"schedule_end,notnull" json:"end"`
FullDay bool `bun:"full_day,notnull,default:false" json:"fullDay"`
IsVisible bool `bun:"is_visible,notnull,default:true" json:"isVisible"`
Description *string `bun:"description" json:"description,omitempty"`
Location *string `bun:"location" json:"location,omitempty"`
Rrule string `bun:"rrule" json:"rrule"`
}

View File

@@ -0,0 +1,16 @@
package models
import "github.com/uptrace/bun"
type Location struct {
bun.BaseModel `bun:"table:locations"`
ID int `bun:"id,pk,autoincrement" json:"id"`
Street string `bun:"street,notnull,unique:location" json:"street"`
City string `bun:"city,notnull,unique:location" json:"city"`
PostalCode string `bun:"postal_code,notnull,unique:location" json:"postalCode"`
Latitude *float64 `bun:"latitude" json:"latitude,omitempty"`
Longitude *float64 `bun:"longitude" json:"longitude,omitempty"`
Events *[]Event `bun:"-" json:"events,omitempty"`
}

View File

@@ -10,7 +10,7 @@ import (
type Permissions []models.Permission
func GetAllPermissions() Permissions {
resources := []string{"users", "roles", "media", "events", "permissions", "shortcodes", "blogs"}
resources := []string{"users", "roles", "media", "events", "permissions", "shortcodes", "blogs", "locations"}
var perms Permissions
for _, resource := range resources {
perms = append(perms, Permissions{

View File

@@ -72,6 +72,9 @@ func InitDatabase(dsn DSN) (*bun.DB, error) {
_, err = db.NewCreateTable().
Model((*m.UserToRole)(nil)).IfNotExists().Exec(ctx)
_, err = db.NewCreateTable().
Model((*m.Location)(nil)).IfNotExists().Exec(ctx)
if err != nil {
return nil, err
}