作者 tangxvhui

更新模型

... ... @@ -20,6 +20,7 @@ type ServiceContext struct {
ArticleCommentRepository domain.ArticleCommentRepository
ArticleDraftRepository domain.ArticleDraftRepository
ArticleRepository domain.ArticleRepository
ArticleSectionRepository domain.ArticleSectionRepository
CompanyRepository domain.CompanyRepository
CommentRepository domain.CommentRepository // 待移除
... ... @@ -47,6 +48,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
ArticleCommentRepository: repository.NewArticleCommentRepository(cache.NewCachedRepository(mlCache)),
ArticleDraftRepository: repository.NewArticleDraftRepository(cache.NewCachedRepository(mlCache)),
ArticleRepository: repository.NewArticleRepository(cache.NewCachedRepository(mlCache)),
ArticleSectionRepository: repository.NewArticleSectionRepository(cache.NewCachedRepository(mlCache)),
CompanyRepository: repository.NewCompanyRepository(cache.NewCachedRepository(mlCache)),
DepartmentRepository: repository.NewDepartmentRepository(cache.NewCachedRepository(mlCache)),
MessageBusinessRepository: repository.NewMessageBusinessRepository(cache.NewCachedRepository(mlCache)),
... ...
package db
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models"
"gorm.io/gorm"
)
func Migrate(db *gorm.DB) {
db.AutoMigrate()
modelsList := []interface{}{
&models.Article{},
&models.ArticleSection{},
&models.ArticleBackup{},
&models.ArticleDraft{},
&models.ArticleComment{},
&models.UserLoveFlag{},
}
db.AutoMigrate(modelsList...)
}
... ...
... ... @@ -18,16 +18,16 @@ type Article struct {
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
Version int
AuthorId int64 // 发布人
Author domain.UserSimple // 发布人
Author domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 发布人
Title string // 文章标题
Images []domain.Image // 图片
WhoRead []int64 // 谁可以看
WhoReview []int64 // 评论人
Location domain.Location // 坐标
Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片
WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看
WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人
Location domain.Location `gorm:"type:jsonb;serializer:json"` // 坐标
TargetUser int // 分发方式 0 分发给所有人 1 分发给指定的人
CountLove int // 点赞数量
CountComment int // 评论数量
Tags []int // 标签
Tags []int `gorm:"type:jsonb;serializer:json"` // 标签
Show int // 评论的展示状态(0显示、1不显示)
}
... ...
... ... @@ -17,14 +17,14 @@ type ArticleBackup struct {
DeletedAt int64
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
Version int
Operator domain.UserSimple // 操作人
Operator domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 操作人
Title string // 标题
Section []domain.ArticleSection // 分段内容
Images []domain.Image // 图片
Section []domain.ArticleSection `gorm:"type:jsonb;serializer:json"` // 分段内容
Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片
Action string // 操作
WhoRead []int64 // 谁可以看
WhoReview []int64 // 评论人
Tags []int // 标签
WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看
WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人
Tags []int `gorm:"type:jsonb;serializer:json"` // 标签
TargetUser int // 分发方式 0 分发给所有人 1 分发给指定的人
}
... ...
... ... @@ -23,9 +23,9 @@ type ArticleComment struct {
ArticleSectionId int64 // 文本内容id
SectionContent string // 引用的文章内容文本
FromUserId int64 // 谁填写的评论
FromUser domain.UserSimple // 谁填写的评论
FromUser domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 谁填写的评论
ToUserId int64 // 回复谁的评论
ToUser domain.UserSimple // 回复谁的评论
ToUser domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 回复谁的评论
Content string // 评论内容
CountReply int // 回复数量
CountUserLove int // 用户点赞数量
... ...
... ... @@ -17,13 +17,13 @@ type ArticleDraft struct {
DeletedAt int64
Version int
Template int // 填写内容时用的样板0、无 1、演绎式 2、归纳式
Content []string // 文章内容
Content []string `gorm:"type:jsonb;serializer:json"` // 文章内容
AuthorId int64 // 发布人
Title string // 文章标题
Images []domain.Image // 图片
WhoRead []int64 // 谁可以看
WhoReview []int64 // 评论人
Location domain.Location // 坐标
Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片
WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看
WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人
Location domain.Location `gorm:"type:jsonb;serializer:json"` // 坐标
}
func (m *ArticleDraft) TableName() string {
... ...
... ... @@ -68,6 +68,7 @@ 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)
Delete(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*Article, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*Article, error)
}
... ...
... ... @@ -28,6 +28,7 @@ type ArticleBackup struct {
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)
UpdateWithVersion(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)
... ...
... ... @@ -42,6 +42,7 @@ const (
type ArticleCommentRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error)
Update(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error)
Delete(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleComment, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleComment, error)
... ...
... ... @@ -27,6 +27,7 @@ type ArticleDraft struct {
type ArticleDraftRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleDraft) (*ArticleDraft, error)
Update(ctx context.Context, conn transaction.Conn, dm *ArticleDraft) (*ArticleDraft, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleDraft) (*ArticleDraft, error)
Delete(ctx context.Context, conn transaction.Conn, dm *ArticleDraft) (*ArticleDraft, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleDraft, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleDraft, error)
... ...
... ... @@ -6,7 +6,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
)
// 文章段落
// 文章段落内容
type ArticleSection struct {
Id int64 `json:"id"`
CompanyId int64 `json:"companyId"`
... ... @@ -23,6 +23,7 @@ type ArticleSection struct {
type ArticleSectionRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleSection) (*ArticleSection, error)
Update(ctx context.Context, conn transaction.Conn, dm *ArticleSection) (*ArticleSection, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleSection) (*ArticleSection, error)
Delete(ctx context.Context, conn transaction.Conn, dm *ArticleSection) (*ArticleSection, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleSection, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleSection, error)
... ...
... ... @@ -6,7 +6,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
)
// 文章的标签
// 文章全部的标签
type ArticleTag struct {
Id int64 `json:"id"`
... ... @@ -22,8 +22,9 @@ type ArticleTag struct {
}
type ArticleTagRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error)
Update(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleSection, error)
Update(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error)
Delete(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleTag, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleTag, error)
}
... ...
package domain
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
)
// 人员查看文章详情后,标记一个记录
// 浏览记录
... ... @@ -14,3 +20,12 @@ type UserReadArticle struct {
DeletedAt int64 `json:"deletedAt,omitempty"`
Version int `json:"version,omitempty"`
}
type UserReadArticleRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *UserReadArticle) (*UserReadArticle, error)
Update(ctx context.Context, conn transaction.Conn, dm *UserReadArticle) (*UserReadArticle, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *UserReadArticle) (*UserReadArticle, error)
Delete(ctx context.Context, conn transaction.Conn, dm *UserReadArticle) (*UserReadArticle, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*UserReadArticle, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*UserReadArticle, error)
}
... ...