first commit
This commit is contained in:
45
internal/models/about.go
Normal file
45
internal/models/about.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// About model structure
|
||||
// Stores public about information with optional media.
|
||||
type About struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Title string `gorm:"type:varchar(254);not null" json:"title"`
|
||||
Image string `gorm:"type:text" json:"image,omitempty"`
|
||||
ImageSub string `gorm:"type:text" json:"image_sub,omitempty"`
|
||||
CV string `gorm:"type:text" json:"cv,omitempty"`
|
||||
Birthday string `gorm:"type:varchar(254)" json:"birthday,omitempty"`
|
||||
City string `gorm:"type:varchar(254)" json:"city,omitempty"`
|
||||
Study string `gorm:"type:varchar(254)" json:"study,omitempty"`
|
||||
Website string `gorm:"type:varchar(254)" json:"website,omitempty"`
|
||||
Phone string `gorm:"type:varchar(254)" json:"phone,omitempty"`
|
||||
Age string `gorm:"type:varchar(5)" json:"age,omitempty"`
|
||||
Interests string `gorm:"type:varchar(254)" json:"interests,omitempty"`
|
||||
Degree string `gorm:"type:varchar(254)" json:"degree,omitempty"`
|
||||
X string `gorm:"type:varchar(254)" json:"x,omitempty"`
|
||||
Mail string `gorm:"type:varchar(254)" json:"mail,omitempty"`
|
||||
Done *int `json:"done,omitempty"`
|
||||
ProjectDone string `gorm:"type:varchar(254)" json:"project_done,omitempty"`
|
||||
UserH *int `json:"user_h,omitempty"`
|
||||
HapyUser string `gorm:"type:varchar(254)" json:"hapy_user,omitempty"`
|
||||
Great *int `json:"great,omitempty"`
|
||||
GreatReviews string `gorm:"type:varchar(254)" json:"great_reviews,omitempty"`
|
||||
Team *int `json:"team,omitempty"`
|
||||
SupportTeam string `gorm:"type:varchar(254)" json:"support_team,omitempty"`
|
||||
Slug string `gorm:"type:varchar(250);uniqueIndex;not null" json:"slug"`
|
||||
IsActive bool `gorm:"default:false" json:"is_active"`
|
||||
CounterActive bool `gorm:"default:false" json:"counter_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by About to `about`
|
||||
func (About) TableName() string {
|
||||
return "about"
|
||||
}
|
||||
30
internal/models/banner.go
Normal file
30
internal/models/banner.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Banner model structure
|
||||
// Represents a banner item with optional thumbnail.
|
||||
type Banner struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Color string `gorm:"type:varchar(32);not null" json:"color"`
|
||||
Title string `gorm:"type:varchar(254)" json:"title,omitempty"`
|
||||
Text1 string `gorm:"type:varchar(254)" json:"text1,omitempty"`
|
||||
Text2 string `gorm:"type:varchar(254)" json:"text2,omitempty"`
|
||||
Text4 string `gorm:"type:varchar(254)" json:"text4,omitempty"`
|
||||
Text5 string `gorm:"type:varchar(254)" json:"text5,omitempty"`
|
||||
Image string `gorm:"type:text;not null" json:"image"`
|
||||
ImageK string `gorm:"type:text" json:"image_k,omitempty"`
|
||||
ImageKTxt string `gorm:"type:varchar(254)" json:"image_k_txt,omitempty"`
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by Banner to `banners`
|
||||
func (Banner) TableName() string {
|
||||
return "banners"
|
||||
}
|
||||
21
internal/models/contact.go
Normal file
21
internal/models/contact.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Contact model structure
|
||||
type Contact struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Name string `gorm:"not null" json:"name"`
|
||||
Email string `gorm:"not null" json:"email"`
|
||||
Subject string `gorm:"not null" json:"subject"`
|
||||
Message string `gorm:"not null" json:"message"`
|
||||
IP string `json:"ip"`
|
||||
UserID *uuid.UUID `gorm:"type:uuid" json:"user_id,omitempty"` // Optional: if user is logged in
|
||||
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
67
internal/models/cors_setting.go
Normal file
67
internal/models/cors_setting.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// CorsWhitelist - CORS için izin verilen origin'ler
|
||||
type CorsWhitelist struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key" json:"id"`
|
||||
Origin string `gorm:"type:varchar(255);uniqueIndex;not null" json:"origin"`
|
||||
Description string `gorm:"type:text" json:"description"`
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
CreatedBy string `gorm:"type:varchar(255)" json:"created_by,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// BeforeCreate - UUID otomatik oluşturma
|
||||
func (c *CorsWhitelist) BeforeCreate(tx *gorm.DB) error {
|
||||
if c.ID == uuid.Nil {
|
||||
c.ID = uuid.New()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// CorsBlacklist - CORS için yasaklanan origin'ler
|
||||
type CorsBlacklist struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key" json:"id"`
|
||||
Origin string `gorm:"type:varchar(255);uniqueIndex;not null" json:"origin"`
|
||||
Reason string `gorm:"type:text" json:"reason"`
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
CreatedBy string `gorm:"type:varchar(255)" json:"created_by,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// BeforeCreate - UUID otomatik oluşturma
|
||||
func (c *CorsBlacklist) BeforeCreate(tx *gorm.DB) error {
|
||||
if c.ID == uuid.Nil {
|
||||
c.ID = uuid.New()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RateLimitSetting - Rate limit ayarları
|
||||
type RateLimitSetting struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key" json:"id"`
|
||||
Name string `gorm:"type:varchar(100);uniqueIndex;not null" json:"name"` // e.g., "login", "register", "api"
|
||||
Description string `gorm:"type:text" json:"description"`
|
||||
MaxRequests int64 `gorm:"not null" json:"max_requests"` // Max istek sayısı
|
||||
WindowSeconds int `gorm:"not null" json:"window_seconds"` // Zaman penceresi (saniye)
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
UpdatedBy string `gorm:"type:varchar(255)" json:"updated_by,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// BeforeCreate - UUID otomatik oluşturma
|
||||
func (r *RateLimitSetting) BeforeCreate(tx *gorm.DB) error {
|
||||
if r.ID == uuid.Nil {
|
||||
r.ID = uuid.New()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
25
internal/models/education.go
Normal file
25
internal/models/education.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Education model structure
|
||||
// Represents a resume education entry.
|
||||
type Education struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
BetweenYears string `gorm:"type:varchar(50);not null" json:"between_years"`
|
||||
Title string `gorm:"type:varchar(100);not null" json:"title"`
|
||||
Content string `gorm:"type:varchar(150);not null" json:"content"`
|
||||
ResumeID *uuid.UUID `gorm:"type:uuid" json:"resume_id,omitempty"`
|
||||
IsActive bool `gorm:"default:false" json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by Education to `educations`
|
||||
func (Education) TableName() string {
|
||||
return "educations"
|
||||
}
|
||||
25
internal/models/experience.go
Normal file
25
internal/models/experience.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Experience model structure
|
||||
// Represents a resume experience entry.
|
||||
type Experience struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
BetweenYears string `gorm:"type:varchar(50);not null" json:"between_years"`
|
||||
Title string `gorm:"type:varchar(100);not null" json:"title"`
|
||||
Content string `gorm:"type:varchar(150);not null" json:"content"`
|
||||
ResumeID *uuid.UUID `gorm:"type:uuid" json:"resume_id,omitempty"`
|
||||
IsActive bool `gorm:"default:false" json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by Experience to `experience`
|
||||
func (Experience) TableName() string {
|
||||
return "experience"
|
||||
}
|
||||
30
internal/models/home.go
Normal file
30
internal/models/home.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Home model structure
|
||||
// Includes a many-to-many relation with tags via home_tags.
|
||||
type Home struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Name string `gorm:"type:varchar(254);not null" json:"name"`
|
||||
Title string `gorm:"type:varchar(254);not null" json:"title"`
|
||||
Button1 string `gorm:"type:varchar(254);not null" json:"button1"`
|
||||
Button2 string `gorm:"type:varchar(254);not null" json:"button2"`
|
||||
Video string `gorm:"type:text" json:"video,omitempty"`
|
||||
Keywords string `gorm:"type:varchar(254);not null" json:"keywords"`
|
||||
Image string `gorm:"type:text" json:"image,omitempty"`
|
||||
Slug string `gorm:"type:varchar(250);uniqueIndex;not null" json:"slug"`
|
||||
IsActive bool `gorm:"default:false" json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Tags []Tag `gorm:"many2many:home_tags;" json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by Home to `homes`
|
||||
func (Home) TableName() string {
|
||||
return "homes"
|
||||
}
|
||||
23
internal/models/knowledge.go
Normal file
23
internal/models/knowledge.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Knowledge model structure
|
||||
// Represents a resume knowledge entry.
|
||||
type Knowledge struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Title string `gorm:"type:varchar(100);not null" json:"title"`
|
||||
ResumeID *uuid.UUID `gorm:"type:uuid" json:"resume_id,omitempty"`
|
||||
IsActive bool `gorm:"default:false" json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by Knowledge to `knowledges`
|
||||
func (Knowledge) TableName() string {
|
||||
return "knowledges"
|
||||
}
|
||||
27
internal/models/main_menu.go
Normal file
27
internal/models/main_menu.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// MainMenu model structure
|
||||
// Stores main menu labels.
|
||||
type MainMenu struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Home string `gorm:"type:varchar(100);not null" json:"home"`
|
||||
About string `gorm:"type:varchar(100);not null" json:"about"`
|
||||
Services string `gorm:"type:varchar(100);not null" json:"services"`
|
||||
Resume string `gorm:"type:varchar(100);not null" json:"resume"`
|
||||
Portfolio string `gorm:"type:varchar(100);not null" json:"portfolio"`
|
||||
Contact string `gorm:"type:varchar(100);not null" json:"contact"`
|
||||
IsActive bool `gorm:"default:false" json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by MainMenu to `mane_menu`
|
||||
func (MainMenu) TableName() string {
|
||||
return "mane_menu"
|
||||
}
|
||||
33
internal/models/post.go
Normal file
33
internal/models/post.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Post represents a blog post with category and tag relations.
|
||||
type Post struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Title string `gorm:"type:varchar(254);not null" json:"title"`
|
||||
Content string `gorm:"type:text" json:"content,omitempty"`
|
||||
Keywords string `gorm:"type:varchar(254);not null" json:"keywords"`
|
||||
Image string `gorm:"type:text" json:"image,omitempty"`
|
||||
Video string `gorm:"type:varchar(254);default:'none'" json:"video,omitempty"`
|
||||
Slug string `gorm:"type:varchar(250);uniqueIndex;not null" json:"slug"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
IsFront bool `gorm:"default:true" json:"is_front"`
|
||||
ParentID *uuid.UUID `json:"parent_id,omitempty"`
|
||||
Parent *Post `gorm:"foreignKey:ParentID" json:"parent,omitempty"`
|
||||
Children []Post `gorm:"foreignKey:ParentID" json:"children,omitempty"`
|
||||
Categories []PostCategory `gorm:"many2many:post_post_categories;" json:"categories,omitempty"`
|
||||
Tags []PostTag `gorm:"many2many:post_post_tags;" json:"tags,omitempty"`
|
||||
Comments []PostComment `gorm:"foreignKey:PostID" json:"comments,omitempty"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by Post.
|
||||
func (Post) TableName() string {
|
||||
return "posts"
|
||||
}
|
||||
30
internal/models/post_category.go
Normal file
30
internal/models/post_category.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// PostCategory represents a blog post category with optional parent-child hierarchy.
|
||||
type PostCategory struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Title string `gorm:"type:varchar(254);not null" json:"title"`
|
||||
Keywords string `gorm:"type:varchar(254);not null" json:"keywords"`
|
||||
Description string `gorm:"type:varchar(254);not null" json:"description"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
Order int `gorm:"default:1;index" json:"order"`
|
||||
Slug string `gorm:"type:varchar(250);uniqueIndex:idx_post_category_slug_parent;not null" json:"slug"`
|
||||
ParentID *uuid.UUID `gorm:"uniqueIndex:idx_post_category_slug_parent" json:"parent_id,omitempty"`
|
||||
Parent *PostCategory `gorm:"foreignKey:ParentID" json:"parent,omitempty"`
|
||||
Children []PostCategory `gorm:"foreignKey:ParentID" json:"children,omitempty"`
|
||||
Image string `gorm:"type:text" json:"image,omitempty"`
|
||||
Posts []Post `gorm:"many2many:post_post_categories;" json:"posts,omitempty"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by PostCategory.
|
||||
func (PostCategory) TableName() string {
|
||||
return "post_categories"
|
||||
}
|
||||
22
internal/models/post_category_view.go
Normal file
22
internal/models/post_category_view.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// PostCategoryView tracks visits to post categories.
|
||||
type PostCategoryView struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
CategoryID uuid.UUID `gorm:"not null;index:idx_post_category_views,priority:1" json:"category_id"`
|
||||
Category PostCategory `gorm:"foreignKey:CategoryID" json:"category"`
|
||||
IPAddress string `gorm:"type:varchar(64);not null;index:idx_post_category_views,priority:2" json:"ip_address"`
|
||||
UserAgent string `gorm:"type:text" json:"user_agent,omitempty"`
|
||||
CreatedAt time.Time `gorm:"index:idx_post_category_views,priority:3" json:"created_at"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by PostCategoryView.
|
||||
func (PostCategoryView) TableName() string {
|
||||
return "post_category_views"
|
||||
}
|
||||
30
internal/models/post_comment.go
Normal file
30
internal/models/post_comment.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// PostComment represents a comment on a post.
|
||||
type PostComment struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
UserID uuid.UUID `gorm:"not null" json:"user_id"`
|
||||
User User `gorm:"foreignKey:UserID" json:"user"`
|
||||
PostID uuid.UUID `gorm:"not null" json:"post_id"`
|
||||
Post Post `gorm:"foreignKey:PostID" json:"post"`
|
||||
Title string `gorm:"type:varchar(254);not null" json:"title"`
|
||||
Body string `gorm:"type:text;not null" json:"body"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
Slug string `gorm:"type:varchar(250);uniqueIndex:idx_post_comment_slug_parent;not null" json:"slug"`
|
||||
ParentID *uuid.UUID `gorm:"uniqueIndex:idx_post_comment_slug_parent" json:"parent_id,omitempty"`
|
||||
Parent *PostComment `gorm:"foreignKey:ParentID" json:"parent,omitempty"`
|
||||
Children []PostComment `gorm:"foreignKey:ParentID" json:"children,omitempty"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by PostComment.
|
||||
func (PostComment) TableName() string {
|
||||
return "post_comments"
|
||||
}
|
||||
22
internal/models/post_tag.go
Normal file
22
internal/models/post_tag.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// PostTag represents tags used for blog posts.
|
||||
type PostTag struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Tag string `gorm:"type:varchar(254);not null" json:"tag"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
Posts []Post `gorm:"many2many:post_post_tags;" json:"posts,omitempty"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by PostTag.
|
||||
func (PostTag) TableName() string {
|
||||
return "post_tags"
|
||||
}
|
||||
31
internal/models/resume.go
Normal file
31
internal/models/resume.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Resume model structure
|
||||
// Represents resume section headers.
|
||||
type Resume struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Title string `gorm:"type:varchar(254);not null" json:"title"`
|
||||
TitleSub string `gorm:"type:varchar(254);not null" json:"title_sub"`
|
||||
Education string `gorm:"type:varchar(100);default:Education" json:"education"`
|
||||
Experience string `gorm:"type:varchar(100);default:Experience" json:"experience"`
|
||||
CodingSkills string `gorm:"type:varchar(100);default:Coding Skills" json:"coding_skills"`
|
||||
Knowledge string `gorm:"type:varchar(100);default:Knowledge" json:"knowledge"`
|
||||
IsActive bool `gorm:"default:false" json:"is_active"`
|
||||
Educations []Education `gorm:"foreignKey:ResumeID" json:"educations,omitempty"`
|
||||
Experiences []Experience `gorm:"foreignKey:ResumeID" json:"experiences,omitempty"`
|
||||
Skills []Skill `gorm:"foreignKey:ResumeID" json:"skills,omitempty"`
|
||||
Knowledges []Knowledge `gorm:"foreignKey:ResumeID" json:"knowledges,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by Resume to `resumes`
|
||||
func (Resume) TableName() string {
|
||||
return "resumes"
|
||||
}
|
||||
14
internal/models/role.go
Normal file
14
internal/models/role.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package models
|
||||
|
||||
type Role struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"uniqueIndex;not null" json:"name"` // admin, user
|
||||
Description string `json:"description"`
|
||||
Permissions []Permission `gorm:"many2many:role_permissions;" json:"permissions"`
|
||||
}
|
||||
|
||||
type Permission struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
Name string `gorm:"uniqueIndex;not null" json:"name"` // user:read, user:write
|
||||
Description string `json:"description"`
|
||||
}
|
||||
25
internal/models/service.go
Normal file
25
internal/models/service.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Service model structure
|
||||
// Represents a public service item.
|
||||
type Service struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Title string `gorm:"type:varchar(254);not null" json:"title"`
|
||||
Content string `gorm:"type:text" json:"content,omitempty"`
|
||||
Image string `gorm:"type:text" json:"image,omitempty"`
|
||||
Slug string `gorm:"type:varchar(250);uniqueIndex;not null" json:"slug"`
|
||||
IsActive bool `gorm:"default:false" json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by Service to `services`
|
||||
func (Service) TableName() string {
|
||||
return "services"
|
||||
}
|
||||
23
internal/models/service_title.go
Normal file
23
internal/models/service_title.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ServiceTitle model structure
|
||||
// Stores title data for services section.
|
||||
type ServiceTitle struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Title string `gorm:"type:varchar(254);not null" json:"title"`
|
||||
TitleSub string `gorm:"type:varchar(254);not null" json:"title_sub"`
|
||||
IsActive bool `gorm:"default:false" json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by ServiceTitle to `services_title`
|
||||
func (ServiceTitle) TableName() string {
|
||||
return "services_title"
|
||||
}
|
||||
39
internal/models/setting.go
Normal file
39
internal/models/setting.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Setting model structure
|
||||
// Stores site-wide metadata and contact information.
|
||||
type Setting struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Title string `gorm:"type:varchar(254);not null" json:"title"`
|
||||
MetaTitle string `gorm:"type:varchar(254);not null" json:"meta_title"`
|
||||
MetaDescription string `gorm:"type:varchar(254);not null" json:"meta_description"`
|
||||
Phone string `gorm:"type:varchar(254);not null" json:"phone"`
|
||||
URL string `gorm:"type:varchar(254);not null" json:"url"`
|
||||
Email string `gorm:"type:varchar(254);not null" json:"email"`
|
||||
Facebook string `gorm:"type:varchar(254)" json:"facebook,omitempty"`
|
||||
X string `gorm:"type:varchar(254)" json:"x,omitempty"`
|
||||
Instagram string `gorm:"type:varchar(254)" json:"instagram,omitempty"`
|
||||
Whatsapp string `gorm:"type:varchar(254)" json:"whatsapp,omitempty"`
|
||||
Pinterest string `gorm:"type:varchar(254)" json:"pinterest,omitempty"`
|
||||
Linkedin string `gorm:"type:varchar(254)" json:"linkedin,omitempty"`
|
||||
Slogan string `gorm:"type:varchar(254)" json:"slogan,omitempty"`
|
||||
Address string `gorm:"type:text" json:"address,omitempty"`
|
||||
Copyright string `gorm:"type:varchar(254)" json:"copyright,omitempty"`
|
||||
MapEmbed string `gorm:"type:text" json:"map_embed,omitempty"`
|
||||
WLogo string `gorm:"type:text" json:"w_logo,omitempty"`
|
||||
BLogo string `gorm:"type:text" json:"b_logo,omitempty"`
|
||||
IsActive bool `gorm:"default:false" json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by Setting to `settings`
|
||||
func (Setting) TableName() string {
|
||||
return "settings"
|
||||
}
|
||||
22
internal/models/site_settings.go
Normal file
22
internal/models/site_settings.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// SiteSettings model structure
|
||||
// Represents site-wide toggle settings.
|
||||
type SiteSettings struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
SiteActive bool `gorm:"default:true" json:"site_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by SiteSettings to `site_settings`
|
||||
func (SiteSettings) TableName() string {
|
||||
return "site_settings"
|
||||
}
|
||||
24
internal/models/skill.go
Normal file
24
internal/models/skill.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Skill model structure
|
||||
// Represents a resume skill entry.
|
||||
type Skill struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Title string `gorm:"type:varchar(100);not null" json:"title"`
|
||||
Degree int `gorm:"not null" json:"degree"`
|
||||
ResumeID *uuid.UUID `gorm:"type:uuid" json:"resume_id,omitempty"`
|
||||
IsActive bool `gorm:"default:false" json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by Skill to `skills`
|
||||
func (Skill) TableName() string {
|
||||
return "skills"
|
||||
}
|
||||
21
internal/models/tag.go
Normal file
21
internal/models/tag.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Tag model structure
|
||||
type Tag struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
Tag string `gorm:"type:varchar(254);not null" json:"tag"`
|
||||
IsActive bool `gorm:"default:true" json:"is_active"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// TableName overrides the table name used by User to `tags`
|
||||
func (Tag) TableName() string {
|
||||
return "tags"
|
||||
}
|
||||
52
internal/models/user.go
Normal file
52
internal/models/user.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// User model structure
|
||||
type User struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
UserName string `json:"username"`
|
||||
Email string `gorm:"uniqueIndex;not null" json:"email"`
|
||||
Password string `json:"-"` // Password shouldn't be returned in JSON
|
||||
Avatar string `gorm:"type:varchar(500)" json:"avatar,omitempty"` // Avatar URL from OAuth or uploaded
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||||
|
||||
// Email verification: only required for email/password registration; OAuth users are treated as verified
|
||||
// Changed to *bool to handle false values correctly with GORM defaults
|
||||
EmailVerified *bool `gorm:"default:false" json:"email_verified"` // default false for email/password registration
|
||||
EmailVerifyToken string `gorm:"index" json:"-"`
|
||||
EmailVerifiedAt *time.Time `json:"email_verified_at,omitempty"`
|
||||
|
||||
SocialAccounts []SocialAccount `gorm:"foreignKey:UserID" json:"social_accounts,omitempty"`
|
||||
Roles []Role `gorm:"many2many:user_roles;" json:"roles,omitempty"`
|
||||
}
|
||||
|
||||
// Helper to safely get EmailVerified status
|
||||
func (u *User) IsEmailVerified() bool {
|
||||
if u.EmailVerified == nil {
|
||||
return false
|
||||
}
|
||||
return *u.EmailVerified
|
||||
}
|
||||
|
||||
// SocialAccount model structure
|
||||
type SocialAccount struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primaryKey" json:"id"`
|
||||
UserID uuid.UUID `gorm:"not null" json:"user_id"`
|
||||
Provider string `gorm:"not null" json:"provider"` // google, github
|
||||
ProviderID string `gorm:"not null" json:"provider_id"`
|
||||
Email string `json:"email"`
|
||||
Name string `json:"name,omitempty"` // Full name from provider
|
||||
AvatarURL string `json:"avatar_url,omitempty"` // Avatar URL from provider
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
// Hooks can be added here if needed
|
||||
Reference in New Issue
Block a user