feat: update fixing error

This commit is contained in:
hanif salafi 2025-09-17 02:02:10 +07:00
parent faecc65a46
commit 64ec492df4
6 changed files with 9 additions and 14 deletions

View File

@ -15,7 +15,4 @@ type ActivityLogs struct {
UserId *uint `json:"user_id" gorm:"type:int4"` UserId *uint `json:"user_id" gorm:"type:int4"`
ClientId *uuid.UUID `json:"client_id" gorm:"type:UUID"` ClientId *uuid.UUID `json:"client_id" gorm:"type:UUID"`
CreatedAt time.Time `json:"created_at" gorm:"default:now()"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
// Relations
Article *Articles `json:"article" gorm:"foreignKey:ArticleId;constraint:OnDelete:CASCADE"`
} }

View File

@ -15,7 +15,4 @@ type ArticleApprovals struct {
ApprovalAtLevel *int `json:"approval_at_level" gorm:"type:int4"` ApprovalAtLevel *int `json:"approval_at_level" gorm:"type:int4"`
ClientId *uuid.UUID `json:"client_id" gorm:"type:UUID"` ClientId *uuid.UUID `json:"client_id" gorm:"type:UUID"`
CreatedAt time.Time `json:"created_at" gorm:"default:now()"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
// Relations
Article Articles `json:"article" gorm:"foreignKey:ArticleId;constraint:OnDelete:CASCADE"`
} }

View File

@ -21,7 +21,7 @@ type ArticleComments struct {
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
// Relations // Relations
Article Articles `json:"article" gorm:"foreignKey:ArticleId;constraint:OnDelete:CASCADE"` Article Articles `json:"article" gorm:"foreignKey:ArticleId"`
} }
// statusId => 0: waiting, 1: accepted, 2: replied, 3: rejected // statusId => 0: waiting, 1: accepted, 2: replied, 3: rejected

View File

@ -29,5 +29,5 @@ type ArticleFiles struct {
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
// Relations // Relations
Article Articles `json:"article" gorm:"foreignKey:ArticleId;constraint:OnDelete:CASCADE"` Article Articles `json:"article" gorm:"foreignKey:ArticleId"`
} }

View File

@ -8,14 +8,13 @@ import (
type Bookmarks struct { type Bookmarks struct {
ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
UserId uint `json:"user_id" gorm:"type:int4;not null"` UserId uint `json:"user_id" gorm:"type:int4"`
ArticleId uint `json:"article_id" gorm:"type:int4;not null"` ArticleId uint `json:"article_id" gorm:"type:int4"`
ClientId *uuid.UUID `json:"client_id" gorm:"type:UUID"` ClientId *uuid.UUID `json:"client_id" gorm:"type:UUID"`
IsActive *bool `json:"is_active" gorm:"type:bool;default:true"` IsActive *bool `json:"is_active" gorm:"type:bool;default:true"`
CreatedAt time.Time `json:"created_at" gorm:"default:now()"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
// Relations // Relations
User Users `json:"user" gorm:"foreignKey:UserId;references:ID"` Article Articles `json:"article" gorm:"foreignKey:ArticleId"`
Article Articles `json:"article" gorm:"foreignKey:ArticleId;references:ID"`
} }

View File

@ -1,11 +1,12 @@
package middleware package middleware
import ( import (
"strings"
"web-medols-be/app/database/entity"
"github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2"
"github.com/google/uuid" "github.com/google/uuid"
"gorm.io/gorm" "gorm.io/gorm"
"strings"
"web-medols-be/app/database/entity"
) )
const ( const (
@ -22,6 +23,7 @@ var excludedPaths = []string{
"/clients", "/clients",
"/clients/*", "/clients/*",
"*/viewer/*", "*/viewer/*",
"/bookmarks/test-table",
} }
// isPathExcluded checks if the given path should be excluded from client key validation // isPathExcluded checks if the given path should be excluded from client key validation