59 lines
1.8 KiB
Go
59 lines
1.8 KiB
Go
package models
|
||
|
||
import (
|
||
"time"
|
||
|
||
"gorm.io/gorm"
|
||
)
|
||
|
||
// PptTemplate PPT 演示模板
|
||
type PptTemplate struct {
|
||
ID uint `json:"id" gorm:"primaryKey;column:id"`
|
||
Name string `json:"name" gorm:"column:name"`
|
||
Slug string `json:"slug" gorm:"column:slug;uniqueIndex"`
|
||
Description string `json:"description" gorm:"column:description;type:text"`
|
||
Config string `json:"-" gorm:"column:config;type:longtext"`
|
||
IsSystem bool `json:"isSystem" gorm:"column:is_system;default:0"`
|
||
IsDefault bool `json:"isDefault" gorm:"column:is_default;default:0"`
|
||
SortOrder int `json:"sortOrder" gorm:"column:sort_order;default:0"`
|
||
IsActive bool `json:"isActive" gorm:"column:is_active;default:1"`
|
||
CreatedAt int64 `json:"createdAt" gorm:"column:created_at"`
|
||
UpdatedAt int64 `json:"updatedAt" gorm:"column:updated_at"`
|
||
DeletedAt int64 `json:"deletedAt" gorm:"column:deleted_at;default:0"`
|
||
}
|
||
|
||
func (PptTemplate) TableName() string {
|
||
return "ppt_templates"
|
||
}
|
||
|
||
func (t *PptTemplate) BeforeCreate(tx *gorm.DB) error {
|
||
now := time.Now().Unix()
|
||
if t.CreatedAt == 0 {
|
||
t.CreatedAt = now
|
||
}
|
||
if t.UpdatedAt == 0 {
|
||
t.UpdatedAt = now
|
||
}
|
||
return nil
|
||
}
|
||
|
||
func (t *PptTemplate) BeforeUpdate(tx *gorm.DB) error {
|
||
t.UpdatedAt = time.Now().Unix()
|
||
return nil
|
||
}
|
||
|
||
// PptTemplatePayload API 请求/响应载荷(config 为 JSON 对象)
|
||
type PptTemplatePayload struct {
|
||
ID uint `json:"id"`
|
||
Name string `json:"name"`
|
||
Slug string `json:"slug"`
|
||
Description string `json:"description"`
|
||
Config interface{} `json:"config"`
|
||
IsSystem bool `json:"isSystem"`
|
||
IsDefault bool `json:"isDefault"`
|
||
SortOrder int `json:"sortOrder"`
|
||
IsActive bool `json:"isActive"`
|
||
CreatedAt int64 `json:"createdAt,omitempty"`
|
||
UpdatedAt int64 `json:"updatedAt,omitempty"`
|
||
}
|