作者 tangxvhui

更新模型

package models
import (
"time"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gorm.io/gorm"
)
type Article struct {
Id int64
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt
AuthorId int64 // 发布人
Author domain.UserSimple // 发布人
Title string // 文章标题
Images []domain.Image // 图片
WhoRead []int64 // 谁可以看
WhoReview []int64 // 评论人
Location domain.Location // 坐标
CountLove int // 点赞数量
CountComment int // 评论数量
Tags []int // 标签
// ...more
}
func (m *Article) TableName() string {
return "article"
}
func (m *Article) BeforeCreate(tx *gorm.DB) (err error) {
m.CreatedAt = time.Now()
m.UpdatedAt = time.Now()
return
}
func (m *Article) BeforeUpdate(tx *gorm.DB) (err error) {
m.UpdatedAt = time.Now()
return
}
... ...
package models
import (
"time"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gorm.io/gorm"
)
// 编辑文章后保存的历史记录
type ArticleBackup struct {
Id int64
UpdatedAt time.Time // 更新时间
DeletedAt gorm.DeletedAt //
CreatedAt time.Time //
Operator domain.UserSimple // 操作人
Title string // 标题
Section []domain.ArticleSection // 分段内容
Images []domain.Image // 图片
Action string // 操作
WhoRead []int64 // 谁可以看
WhoReview []int64 // 评论人
Tags []int // 标签
}
func (m *ArticleBackup) TableName() string {
return "article_backup"
}
func (m *ArticleBackup) BeforeCreate(tx *gorm.DB) (err error) {
m.CreatedAt = time.Now()
m.UpdatedAt = time.Now()
return
}
func (m *ArticleBackup) BeforeUpdate(tx *gorm.DB) (err error) {
m.UpdatedAt = time.Now()
return
}
... ...
package models
import (
"time"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gorm.io/gorm"
)
// 文章评论
type ArticleComment struct {
Id int64 // 评论id
UpdatedAt time.Time // 更新时间
DeletedAt gorm.DeletedAt //
CreatedAt time.Time //
Pid int64 // 对哪个评论进行回复
TopId int64 // 归属于最上级的哪个评论
ArticleId int64 // 文章id
ArticleSectionId int64 // 文本内容段落id
SectionContent string // 引用的文章内容文本
FromUserId int64 // 谁填写的评论
FromUser domain.UserSimple // 谁填写的评论
ToUserId int64 // 回复谁的评论
ToUser domain.UserSimple // 回复谁的评论
Content string // 评论内容
CountReply int // 回复数量
CountUserLove int // 用户点赞数量
CountAdminLove int // 运营点赞数量
Show int // 评论的展示状态(0显示、1不显示)
// ...more
}
func (m *ArticleComment) TableName() string {
return "article_comment"
}
func (m *ArticleComment) BeforeCreate(tx *gorm.DB) (err error) {
m.CreatedAt = time.Now()
m.UpdatedAt = time.Now()
return
}
func (m *ArticleComment) BeforeUpdate(tx *gorm.DB) (err error) {
m.UpdatedAt = time.Now()
return
}
... ...
package models
import (
"time"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gorm.io/gorm"
)
// 填写文章时保存的草稿
type ArticleDraft struct {
Id int64
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt
Template int // 填写内容时用的样板0、无 1、演绎式 2、归纳式
Content []string // 文章内容
AuthorId int64 // 发布人
Title string // 文章标题
Images []domain.Image // 图片
WhoRead []int64 // 谁可以看
WhoReview []int64 // 评论人
Location domain.Location // 坐标
}
func (m *ArticleDraft) TableName() string {
return "article_draft"
}
func (m *ArticleDraft) BeforeCreate(tx *gorm.DB) (err error) {
m.CreatedAt = time.Now()
m.UpdatedAt = time.Now()
return
}
func (m *ArticleDraft) BeforeUpdate(tx *gorm.DB) (err error) {
m.UpdatedAt = time.Now()
return
}
... ...
package models
import (
"time"
"gorm.io/gorm"
)
// 文章段落
type ArticleSection struct {
Id int64
UpdatedAt time.Time // 更新时间
DeletedAt gorm.DeletedAt //
CreatedAt time.Time //
ArticleId int64 // 文章id
Content string // 文本内容
SortBy int // 排序
TotalComment int // 评论的数量
}
func (m *ArticleSection) TableName() string {
return "article_section"
}
func (m *ArticleSection) BeforeCreate(tx *gorm.DB) (err error) {
m.CreatedAt = time.Now()
m.UpdatedAt = time.Now()
return
}
func (m *ArticleSection) BeforeUpdate(tx *gorm.DB) (err error) {
m.UpdatedAt = time.Now()
return
}
... ...
... ... @@ -7,24 +7,34 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
)
// 文章
type Article struct {
Id int64 `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt"`
AuthorId int64 `json:"authorId"` // 发布人
Author UserSimple `json:"author"` // 发布人
Title string `json:"title"` // 文章标题
Images []Image `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
CountLove int `json:"countLove"` // 点赞数量
CountComment int `json:"countComment"` // 评论数量
Tags []int `json:"tags"` // 标签
Id int64 `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt"`
AuthorId int64 `json:"authorId"` // 发布人
Author UserSimple `json:"author"` // 发布人
Title string `json:"title"` // 文章标题
Images []Image `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
CountLove int `json:"countLove"` // 点赞数量
CountComment int `json:"countComment"` // 评论数量
Tags []int `json:"tags"` // 标签
Show ArticleShow `json:"showState"` // 评论的展示状态(0显示、1不显示)
// ...more
}
// 文章的展示状态(0显示、1不显示)
type ArticleShow int
const (
ArticleShowEnable CommentShow = 0
ArticleShowDisable CommentShow = 1
)
type ArticleRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error)
Update(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error)
... ...
package domain
import "time"
import (
"context"
"time"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
)
// 编辑文章后保存的历史记录
type ArticleBackup struct {
Id int64
Id int64 `json:"id"`
UpdatedAt time.Time `json:"updatedAt"` // 更新时间
DeletedAt *time.Time `json:"deletedAt"` //
CreatedAt time.Time `json:"createdAt"` //
... ... @@ -13,4 +18,15 @@ type ArticleBackup struct {
Section []ArticleSection `json:"section"` // 分段内容
Images []Image `json:"images"` // 图片
Action string `json:"action"` // 操作
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Tags []int `json:"tags"` // 标签
}
type ArticleBackupRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleBackup) (*ArticleBackup, error)
Update(ctx context.Context, conn transaction.Conn, dm *ArticleBackup) (*ArticleBackup, error)
Delete(ctx context.Context, conn transaction.Conn, dm *ArticleBackup) (*ArticleBackup, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleBackup, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleBackup, error)
}
... ...
... ... @@ -9,24 +9,24 @@ import (
// 文章评论
type ArticleComment struct {
Id int64 `json:"id"` // 评论id
UpdatedAt time.Time `json:"updatedAt"` // 更新时间
DeletedAt *time.Time `json:"deletedAt"`
CreatedAt time.Time `json:"createdAt"`
Pid int64 `json:"pid"` // 对哪个评论进行回复
TopId int64 `json:"topId"` // 归属于最上级的哪个评论
ArticleId int64 `json:"articleId"` // 文章id
ArticleSectionId int64 `json:"articleSectionId"` // 文本内容id
SectionContent string `json:"sectionContent"` // 引用的文章内容文本
FromUserId int64 `json:"fromUserId"` // 谁填写的评论
FromUser UserSimple `json:"fromUser"` // 谁填写的评论
ToUserId int64 `json:"toUserId"` // 回复谁的评论
ToUser UserSimple `json:"toUser"` // 回复谁的评论
Content string `json:"content"` // 评论内容
CountReply int `json:"countReply"` // 回复数量
CountUserLove int `json:"countUserLove"` // 用户点赞数量
CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
Show int `json:"showState"` // 评论的展示状态(0显示、1不显示)
Id int64 `json:"id"` // 评论id
UpdatedAt time.Time `json:"updatedAt"` // 更新时间
DeletedAt *time.Time `json:"deletedAt"` //
CreatedAt time.Time `json:"createdAt"` //
Pid int64 `json:"pid"` // 对哪个评论进行回复
TopId int64 `json:"topId"` // 归属于最上级的哪个评论
ArticleId int64 `json:"articleId"` // 文章id
ArticleSectionId int64 `json:"articleSectionId"` // 文本内容id
SectionContent string `json:"sectionContent"` // 引用的文章内容文本
FromUserId int64 `json:"fromUserId"` // 谁填写的评论
FromUser UserSimple `json:"fromUser"` // 谁填写的评论
ToUserId int64 `json:"toUserId"` // 回复谁的评论
ToUser UserSimple `json:"toUser"` // 回复谁的评论
Content string `json:"content"` // 评论内容
CountReply int `json:"countReply"` // 回复数量
CountUserLove int `json:"countUserLove"` // 用户点赞数量
CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
Show CommentShow `json:"showState"` // 评论的展示状态(0显示、1不显示)
// ...more
}
... ...
... ... @@ -2,7 +2,6 @@ package domain
import (
"context"
"time"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
)
... ... @@ -10,18 +9,18 @@ import (
// 填写文章时保存的草稿
type ArticleDraft struct {
Id int64 `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt"`
Template int `json:"template"` // 填写内容时用的样板 1、演绎式 2、归纳式
Content []string `json:"content"` // 文章内容
AuthorId int64 `json:"authorId"` // 发布人
Title string `json:"title"` // 文章标题
Images []Image `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
Id int64 `json:"id"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
DeletedAt uint `json:"-"`
Template int `json:"template"` // 填写内容时用的样板0、无 1、演绎式 2、归纳式
Content []string `json:"content"` // 文章内容
AuthorId int64 `json:"authorId"` // 发布人
Title string `json:"title"` // 文章标题
Images []Image `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
}
type ArticleDraftRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleDraft) (*ArticleDraft, error)
... ...
... ... @@ -11,13 +11,13 @@ import (
type ArticleTag struct {
Id int64 `json:"id"`
UpdatedAt time.Time `json:"updatedAt"` // 更新时间
UpdatedAt int64 `json:"updatedAt"` // 更新时间
DeletedAt *time.Time `json:"deletedAt"` //
CreatedAt time.Time `json:"createdAt"` //
Image Image `json:"image"` //图片
Name string `json:"name"` //标签名称
Group string `json:"group"` //标签分类
Remark string `json:"remark"` //备注
Image Image `json:"image"` // 图片
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Remark string `json:"remark"` // 备注
}
type ArticleTagRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error)
... ...
... ... @@ -6,8 +6,8 @@ import "time"
type UserLoveFlag struct {
Id int64 `json:"id"`
ArticleId int64 `json:"articleId"` //点赞文章时,填文章id
CommentId int64 `json:"commentId"` //点赞评论时,填评论id
ArticleId int64 `json:"articleId"` // 点赞文章时,文章id
CommentId int64 `json:"commentId"` // 点赞评论时,填评论id
UserId int64 `json:"userId"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
... ...
package domain
import "time"
// 人员查看文章详情后,标记一个记录
// 浏览记录
type UserReadArticle struct {
Id int64 `json:"id"`
UserId int64 `json:"userId"`
ArticleId int64 `json:"articleId"`
Title string `json:"title"`
ArticleAuthor UserSimple `json:"author"` // 发布人
Id int64 `json:"id"`
UserId int64 `json:"userId"`
ArticleId int64 `json:"articleId"`
Title string `json:"title"`
Author UserSimple `json:"author"` // 发布人
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt"`
}
... ...