72 lines
2.5 KiB
Go
72 lines
2.5 KiB
Go
package models
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Ressource struct {
|
|
gorm.Model
|
|
Category Category
|
|
Tag string
|
|
Region string
|
|
Image string
|
|
SpokenLanguages string
|
|
|
|
Translations []RessourceTranslation `gorm:"foreignKey:RessourceID"`
|
|
Feedback []RessourceFeedback `gorm:"foreignKey:RessourceID"`
|
|
}
|
|
|
|
type RessourceLocalizedResponse struct {
|
|
ID uint `json:"id" binding:"required"`
|
|
CategoryName string `json:"categoryName" binding:"required"`
|
|
Language string `json:"language" binding:"required"`
|
|
Tag string `json:"tag"`
|
|
Region string `json:"region" binding:"required"`
|
|
Image string `json:"image"`
|
|
SpokenLanguages string `json:"spokenLanguages"`
|
|
Name string `json:"name" binding:"required"`
|
|
Text string `json:"text" binding:"required"`
|
|
Metadata string `json:"metadata"`
|
|
Translations []RessourceTranslation `json:"translations"`
|
|
Category Category `json:"category"`
|
|
}
|
|
|
|
type RessourceRequest struct {
|
|
CategoryID uint `json:"categoryId" binding:"required"`
|
|
Tag string `json:"tag"`
|
|
Region string `json:"region" binding:"required"`
|
|
Image string `json:"image"`
|
|
SpokenLanguages string `json:"spokenLanguages"`
|
|
Translations []RessourceTranslationRequest `json:"translations" binding:"required"`
|
|
}
|
|
|
|
type RessourceTranslationRequest struct {
|
|
RessourceID uint `json:"ressourceId" binding:"required"`
|
|
LanguageID uint `json:"languageId" binding:"required"`
|
|
Name string `json:"name" binding:"required"`
|
|
Text string `json:"text" binding:"required"`
|
|
Metadata string `json:"metadata"`
|
|
}
|
|
|
|
type RessourceTranslation struct {
|
|
gorm.Model
|
|
RessourceID uint `gorm:"uniqueIndex:idx_post_language"`
|
|
LanguageID uint `gorm:"uniqueIndex:idx_post_language"`
|
|
Name string
|
|
Text string
|
|
Metadata string
|
|
}
|
|
|
|
type RessourceFeedbackRequest struct {
|
|
RessourceID uint `json:"ressourceId" binding:"required"`
|
|
Name string `json:"name" binding:"required"`
|
|
Text string `json:"text" binding:"required"`
|
|
}
|
|
|
|
type RessourceFeedback struct {
|
|
gorm.Model
|
|
RessourceID uint `gorm:"uniqueIndex:idx_post_language"`
|
|
Name string
|
|
Text string
|
|
}
|