27 lines
599 B
Go
27 lines
599 B
Go
package models
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Category struct {
|
|
gorm.Model
|
|
Translations []CategoryTranslation `gorm:"foreignKey:CategoryID"`
|
|
}
|
|
|
|
type CategoryTranslation struct {
|
|
gorm.Model
|
|
CategoryID uint `gorm:"uniqueIndex:idx_post_language"`
|
|
LanguageID uint `gorm:"uniqueIndex:idx_post_language"`
|
|
Name string
|
|
}
|
|
|
|
type CategoryRequest struct {
|
|
Translations []CategoryTranslationRequest `json:"translations" binding:"required"`
|
|
}
|
|
|
|
type CategoryTranslationRequest struct {
|
|
LanguageID uint `json:"languageId" binding:"required"`
|
|
Name string `json:"name" binding:"required"`
|
|
}
|