feat: import services and standardize Go 1.26.5
This commit is contained in:
80
apps/base/cms/internal/models/cms_post.go
Normal file
80
apps/base/cms/internal/models/cms_post.go
Normal file
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* CMS文章数据模型
|
||||
* @Author: david.yan@qq.com
|
||||
* @Date: 2021-11-29 15:16:26
|
||||
* @LastEditors: david.yan@qq.com
|
||||
* @LastEditTime: 2021-12-08 15:59:00
|
||||
* @Description: 定义文章相关的数据结构和数据库映射
|
||||
*/
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/database"
|
||||
"git.apinb.com/bsm-sdk/core/types"
|
||||
)
|
||||
|
||||
// CmsPost CMS文章数据模型
|
||||
// 包含文章的基本信息、统计数据、关联数据等
|
||||
type CmsPost struct {
|
||||
types.Std_IICUDS // 标准IICUDS字段(Identity、CreatedAt、UpdatedAt等)
|
||||
types.Std_Owner // 标准所有者字段
|
||||
SiteIdentity string `gorm:"column:site_identity;type:varchar(36);index;" json:"site_identity"`
|
||||
|
||||
// 基本信息
|
||||
Types int32 `gorm:"column:types;type:varchar(255);default:'';" json:"types"` // 文章类型
|
||||
Title string `gorm:"column:title;type:varchar(255);default:'';" json:"title"` // 文章标题
|
||||
Hash string `gorm:"column:hash;type:varchar(255);uniqueIndex;" json:"hash"` // 文章唯一键值,用于URL等
|
||||
Description string `gorm:"column:description;type:varchar(255);default:'';" json:"description"` // 文章描述/摘要
|
||||
CoverPath string `gorm:"column:cover_path;type:varchar(255);default:'';" json:"cover_path"` // 封面图片路径
|
||||
Content string `gorm:"column:content;type:text;default:'';" json:"content"` // 文章正文内容
|
||||
Lang string `gorm:"type:varchar(20);"` // 语言
|
||||
TargetUrl string `gorm:"column:target_url;type:varchar(255);default:''" json:"target_url"` // 目标链接
|
||||
Rights string `gorm:"column:rights;type:varchar(255);default:''" json:"rights"` // 权限
|
||||
|
||||
// 作者信息
|
||||
Author string `gorm:"column:author;type:varchar(255);default:''" json:"author"` // 作者姓名
|
||||
AuthorIdentity string `gorm:"column:author_identity;type:varchar(36);default:'';" json:"author_identity"` // 作者唯一标识
|
||||
|
||||
// 来源方
|
||||
SourceOrigin string `gorm:"type:varchar(255);"` // 简称
|
||||
SourceUrl string `gorm:"column:source_url;type:varchar(255);default:''" json:"source_url"` // 源链接
|
||||
|
||||
// 统计数据
|
||||
Hits int64 `gorm:"column:hits;default:0" json:"hits"` // 点击量/浏览量
|
||||
LikeHits int64 `gorm:"column:like_hits;default:0" json:"like_hits"` // 点赞数量
|
||||
UnlikeHits int64 `gorm:"column:unlike_hits;default:0" json:"unlike_hits"` // 踩赞数量
|
||||
CommentHits int64 `gorm:"column:comment_hits;default:0" json:"comment_hits"` // 评论数量
|
||||
|
||||
// 其他属性
|
||||
HasAccessory bool `gorm:"column:has_accessory;type:bool;default:false" json:"has_accessory"` // 是否有附件
|
||||
|
||||
// 关联数据标识(不存储到数据库,仅用于数据传输)
|
||||
CategoryIdentityArray []string `gorm:"-" json:"category_identity_array"` // 关联的分类标识列表
|
||||
TagsIdentityArray []string `gorm:"-" json:"tags_identity_array"` // 关联的标签标识列表
|
||||
AccessoryIdentityArray []string `gorm:"-" json:"accessory_identity_array"` // 关联的附件标识列表
|
||||
|
||||
// 关联数据对象(通过外键关联)
|
||||
Accessories []*CmsAccessory `gorm:"foreignkey:PostId;references:ID"` // 文章附件列表
|
||||
Categories []*CmsRelateCategory `gorm:"foreignkey:PostIdentity;references:Identity"` // 文章分类关联列表
|
||||
Tags []*CmsRelateTags `gorm:"foreignkey:PostIdentity;references:Identity"` // 文章标签关联列表
|
||||
|
||||
ExtendUrl string // 扩展:URL
|
||||
ExtendData string // 扩展:数据
|
||||
ExtendImg string // 扩展:图片
|
||||
ExtendDesc string // 扩展:描述
|
||||
|
||||
Published time.Time // 事件发生时间
|
||||
}
|
||||
|
||||
// init 初始化函数,将模型注册到数据库迁移表
|
||||
func init() {
|
||||
database.MigrateTables = append(database.MigrateTables, &CmsPost{})
|
||||
}
|
||||
|
||||
// TableName 指定数据库表名
|
||||
// 返回: 数据库表名
|
||||
func (table *CmsPost) TableName() string {
|
||||
return "cms_post"
|
||||
}
|
||||
Reference in New Issue
Block a user