作者 tangxvhui

更新模型

@@ -2,30 +2,33 @@ package models @@ -2,30 +2,33 @@ package models
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "time"
5 6
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
7 "gorm.io/gorm" 8 "gorm.io/gorm"
  9 + "gorm.io/plugin/soft_delete"
8 ) 10 )
9 11
10 type Article struct { 12 type Article struct {
11 - Id int64 // 唯一标识  
12 - CompanyId int64 `json:"companyId"`  
13 - CreatedAt int64 `json:"createdAt,omitempty"`  
14 - UpdatedAt int64 `json:"updatedAt,omitempty"`  
15 - DeletedAt int64 `json:"deletedAt,omitempty"`  
16 - Version int `json:"version,omitempty"`  
17 - AuthorId int64 `json:"authorId"` // 发布人  
18 - Author domain.User `json:"author"` // 发布人  
19 - Title string `json:"title"` // 文章标题  
20 - Images []domain.Image `json:"images"` // 图片  
21 - WhoRead []int64 `json:"whoRead"` // 谁可以看  
22 - WhoReview []int64 `json:"whoReview"` // 评论人  
23 - Location domain.Location `json:"location"` // 坐标  
24 - TargetUser int `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人  
25 - CountLove int `json:"countLove"` // 点赞数量  
26 - CountComment int `json:"countComment"` // 评论数量  
27 - Tags []int `json:"tags"` // 标签  
28 - Show int `json:"showState"` // 评论的展示状态(0显示、1不显示) 13 + Id int64 `gorm:"primaryKey"` // 唯一标识
  14 + CompanyId int64
  15 + CreatedAt int64
  16 + UpdatedAt int64
  17 + DeletedAt int64
  18 + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
  19 + Version int
  20 + AuthorId int64 // 发布人
  21 + Author domain.UserSimple // 发布人
  22 + Title string // 文章标题
  23 + Images []domain.Image // 图片
  24 + WhoRead []int64 // 谁可以看
  25 + WhoReview []int64 // 评论人
  26 + Location domain.Location // 坐标
  27 + TargetUser int // 分发方式 0 分发给所有人 1 分发给指定的人
  28 + CountLove int // 点赞数量
  29 + CountComment int // 评论数量
  30 + Tags []int // 标签
  31 + Show int // 评论的展示状态(0显示、1不显示)
29 } 32 }
30 33
31 func (m *Article) TableName() string { 34 func (m *Article) TableName() string {
@@ -33,13 +36,13 @@ func (m *Article) TableName() string { @@ -33,13 +36,13 @@ func (m *Article) TableName() string {
33 } 36 }
34 37
35 func (m *Article) BeforeCreate(tx *gorm.DB) (err error) { 38 func (m *Article) BeforeCreate(tx *gorm.DB) (err error) {
36 - // m.CreatedAt = time.Now().Unix()  
37 - // m.UpdatedAt = time.Now().Unix() 39 + m.CreatedAt = time.Now().Unix()
  40 + m.UpdatedAt = time.Now().Unix()
38 return 41 return
39 } 42 }
40 43
41 func (m *Article) BeforeUpdate(tx *gorm.DB) (err error) { 44 func (m *Article) BeforeUpdate(tx *gorm.DB) (err error) {
42 - // m.UpdatedAt = time.Now().Unix() 45 + m.UpdatedAt = time.Now().Unix()
43 return 46 return
44 } 47 }
45 48
@@ -2,14 +2,30 @@ package models @@ -2,14 +2,30 @@ package models
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "time"
5 6
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
7 "gorm.io/gorm" 8 "gorm.io/gorm"
  9 + "gorm.io/plugin/soft_delete"
8 ) 10 )
9 11
10 type ArticleBackup struct { 12 type ArticleBackup struct {
11 - Id int64 // 唯一标识  
12 - Version int 13 + Id int64 `gorm:"primaryKey"` // 唯一标识
  14 + CompanyId int64
  15 + CreatedAt int64
  16 + UpdatedAt int64
  17 + DeletedAt int64
  18 + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
  19 + Version int
  20 + Operator domain.UserSimple // 操作人
  21 + Title string // 标题
  22 + Section []domain.ArticleSection // 分段内容
  23 + Images []domain.Image // 图片
  24 + Action string // 操作
  25 + WhoRead []int64 // 谁可以看
  26 + WhoReview []int64 // 评论人
  27 + Tags []int // 标签
  28 + TargetUser int // 分发方式 0 分发给所有人 1 分发给指定的人
13 } 29 }
14 30
15 func (m *ArticleBackup) TableName() string { 31 func (m *ArticleBackup) TableName() string {
@@ -17,13 +33,13 @@ func (m *ArticleBackup) TableName() string { @@ -17,13 +33,13 @@ func (m *ArticleBackup) TableName() string {
17 } 33 }
18 34
19 func (m *ArticleBackup) BeforeCreate(tx *gorm.DB) (err error) { 35 func (m *ArticleBackup) BeforeCreate(tx *gorm.DB) (err error) {
20 - // m.CreatedAt = time.Now().Unix()  
21 - // m.UpdatedAt = time.Now().Unix() 36 + m.CreatedAt = time.Now().Unix()
  37 + m.UpdatedAt = time.Now().Unix()
22 return 38 return
23 } 39 }
24 40
25 func (m *ArticleBackup) BeforeUpdate(tx *gorm.DB) (err error) { 41 func (m *ArticleBackup) BeforeUpdate(tx *gorm.DB) (err error) {
26 - // m.UpdatedAt = time.Now().Unix() 42 + m.UpdatedAt = time.Now().Unix()
27 return 43 return
28 } 44 }
29 45
@@ -2,14 +2,35 @@ package models @@ -2,14 +2,35 @@ package models
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "time"
5 6
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
7 "gorm.io/gorm" 8 "gorm.io/gorm"
  9 + "gorm.io/plugin/soft_delete"
8 ) 10 )
9 11
10 type ArticleComment struct { 12 type ArticleComment struct {
11 - Id int64 // 唯一标识  
12 - Version int 13 + Id int64 `gorm:"primaryKey"` // 唯一标识
  14 + CompanyId int64
  15 + CreatedAt int64
  16 + UpdatedAt int64
  17 + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
  18 + DeletedAt int64
  19 + Version int
  20 + Pid int64 // 对哪个评论进行回复
  21 + TopId int64 // 归属于最上级的哪个评论
  22 + ArticleId int64 // 文章id
  23 + ArticleSectionId int64 // 文本内容id
  24 + SectionContent string // 引用的文章内容文本
  25 + FromUserId int64 // 谁填写的评论
  26 + FromUser domain.UserSimple // 谁填写的评论
  27 + ToUserId int64 // 回复谁的评论
  28 + ToUser domain.UserSimple // 回复谁的评论
  29 + Content string // 评论内容
  30 + CountReply int // 回复数量
  31 + CountUserLove int // 用户点赞数量
  32 + CountAdminLove int // 运营点赞数量
  33 + Show int // 评论的展示状态(0显示、1不显示)
13 } 34 }
14 35
15 func (m *ArticleComment) TableName() string { 36 func (m *ArticleComment) TableName() string {
@@ -17,13 +38,13 @@ func (m *ArticleComment) TableName() string { @@ -17,13 +38,13 @@ func (m *ArticleComment) TableName() string {
17 } 38 }
18 39
19 func (m *ArticleComment) BeforeCreate(tx *gorm.DB) (err error) { 40 func (m *ArticleComment) BeforeCreate(tx *gorm.DB) (err error) {
20 - // m.CreatedAt = time.Now().Unix()  
21 - // m.UpdatedAt = time.Now().Unix() 41 + m.CreatedAt = time.Now().Unix()
  42 + m.UpdatedAt = time.Now().Unix()
22 return 43 return
23 } 44 }
24 45
25 func (m *ArticleComment) BeforeUpdate(tx *gorm.DB) (err error) { 46 func (m *ArticleComment) BeforeUpdate(tx *gorm.DB) (err error) {
26 - // m.UpdatedAt = time.Now().Unix() 47 + m.UpdatedAt = time.Now().Unix()
27 return 48 return
28 } 49 }
29 50
@@ -5,11 +5,25 @@ import ( @@ -5,11 +5,25 @@ import (
5 5
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" 6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
7 "gorm.io/gorm" 7 "gorm.io/gorm"
  8 + "gorm.io/plugin/soft_delete"
8 ) 9 )
9 10
10 type ArticleDraft struct { 11 type ArticleDraft struct {
11 - Id int64 // 唯一标识  
12 - Version int 12 + Id int64 `gorm:"primaryKey"` // 唯一标识
  13 + CompanyId int64
  14 + CreatedAt int64
  15 + UpdatedAt int64
  16 + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
  17 + DeletedAt int64
  18 + Version int
  19 + Template int // 填写内容时用的样板0、无 1、演绎式 2、归纳式
  20 + Content []string // 文章内容
  21 + AuthorId int64 // 发布人
  22 + Title string // 文章标题
  23 + Images []domain.Image // 图片
  24 + WhoRead []int64 // 谁可以看
  25 + WhoReview []int64 // 评论人
  26 + Location domain.Location // 坐标
13 } 27 }
14 28
15 func (m *ArticleDraft) TableName() string { 29 func (m *ArticleDraft) TableName() string {
@@ -2,14 +2,25 @@ package models @@ -2,14 +2,25 @@ package models
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "time"
5 6
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
7 "gorm.io/gorm" 8 "gorm.io/gorm"
  9 + "gorm.io/plugin/soft_delete"
8 ) 10 )
9 11
10 type ArticleSection struct { 12 type ArticleSection struct {
11 - Id int64 // 唯一标识  
12 - Version int 13 + Id int64 `gorm:"primaryKey"` // 唯一标识
  14 + CompanyId int64
  15 + CreatedAt int64
  16 + UpdatedAt int64
  17 + DeletedAt int64
  18 + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
  19 + Version int
  20 + ArticleId int64 // 文章id
  21 + Content string // 文本内容
  22 + SortBy int // 排序
  23 + TotalComment int // 评论的数量
13 } 24 }
14 25
15 func (m *ArticleSection) TableName() string { 26 func (m *ArticleSection) TableName() string {
@@ -17,13 +28,13 @@ func (m *ArticleSection) TableName() string { @@ -17,13 +28,13 @@ func (m *ArticleSection) TableName() string {
17 } 28 }
18 29
19 func (m *ArticleSection) BeforeCreate(tx *gorm.DB) (err error) { 30 func (m *ArticleSection) BeforeCreate(tx *gorm.DB) (err error) {
20 - // m.CreatedAt = time.Now().Unix()  
21 - // m.UpdatedAt = time.Now().Unix() 31 + m.CreatedAt = time.Now().Unix()
  32 + m.UpdatedAt = time.Now().Unix()
22 return 33 return
23 } 34 }
24 35
25 func (m *ArticleSection) BeforeUpdate(tx *gorm.DB) (err error) { 36 func (m *ArticleSection) BeforeUpdate(tx *gorm.DB) (err error) {
26 - // m.UpdatedAt = time.Now().Unix() 37 + m.UpdatedAt = time.Now().Unix()
27 return 38 return
28 } 39 }
29 40
@@ -2,14 +2,23 @@ package models @@ -2,14 +2,23 @@ package models
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "time"
5 6
6 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" 7 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
7 "gorm.io/gorm" 8 "gorm.io/gorm"
  9 + "gorm.io/plugin/soft_delete"
8 ) 10 )
9 11
10 type UserLoveFlag struct { 12 type UserLoveFlag struct {
11 - Id int64 // 唯一标识  
12 - Version int 13 + Id int64 `gorm:"primaryKey"` // 唯一标识
  14 + ArticleId int64 // 点赞文章时,文章id
  15 + CommentId int64 // 点赞评论时,填评论id
  16 + UserId int64
  17 + CreatedAt int64
  18 + UpdatedAt int64
  19 + DeletedAt int64
  20 + Version int
  21 + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
13 } 22 }
14 23
15 func (m *UserLoveFlag) TableName() string { 24 func (m *UserLoveFlag) TableName() string {
@@ -17,13 +26,13 @@ func (m *UserLoveFlag) TableName() string { @@ -17,13 +26,13 @@ func (m *UserLoveFlag) TableName() string {
17 } 26 }
18 27
19 func (m *UserLoveFlag) BeforeCreate(tx *gorm.DB) (err error) { 28 func (m *UserLoveFlag) BeforeCreate(tx *gorm.DB) (err error) {
20 - // m.CreatedAt = time.Now().Unix()  
21 - // m.UpdatedAt = time.Now().Unix() 29 + m.CreatedAt = time.Now().Unix()
  30 + m.UpdatedAt = time.Now().Unix()
22 return 31 return
23 } 32 }
24 33
25 func (m *UserLoveFlag) BeforeUpdate(tx *gorm.DB) (err error) { 34 func (m *UserLoveFlag) BeforeUpdate(tx *gorm.DB) (err error) {
26 - // m.UpdatedAt = time.Now().Unix() 35 + m.UpdatedAt = time.Now().Unix()
27 return 36 return
28 } 37 }
29 38
@@ -3,7 +3,6 @@ package repository @@ -3,7 +3,6 @@ package repository
3 import ( 3 import (
4 "context" 4 "context"
5 5
6 - "github.com/jinzhu/copier"  
7 "github.com/pkg/errors" 6 "github.com/pkg/errors"
8 "github.com/tiptok/gocomm/pkg/cache" 7 "github.com/tiptok/gocomm/pkg/cache"
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models"
@@ -142,15 +141,47 @@ func (repository *ArticleBackupRepository) Find(ctx context.Context, conn transa @@ -142,15 +141,47 @@ func (repository *ArticleBackupRepository) Find(ctx context.Context, conn transa
142 } 141 }
143 142
144 func (repository *ArticleBackupRepository) ModelToDomainModel(from *models.ArticleBackup) (*domain.ArticleBackup, error) { 143 func (repository *ArticleBackupRepository) ModelToDomainModel(from *models.ArticleBackup) (*domain.ArticleBackup, error) {
145 - to := &domain.ArticleBackup{}  
146 - err := copier.Copy(to, from)  
147 - return to, err 144 + to := &domain.ArticleBackup{
  145 + Id: from.Id,
  146 + CompanyId: from.CompanyId,
  147 + CreatedAt: from.CreatedAt,
  148 + UpdatedAt: from.CreatedAt,
  149 + DeletedAt: from.DeletedAt,
  150 + Version: from.Version,
  151 + Operator: from.Operator,
  152 + Title: from.Title,
  153 + Section: from.Section,
  154 + Images: from.Images,
  155 + Action: from.Action,
  156 + WhoRead: from.WhoRead,
  157 + WhoReview: from.WhoReview,
  158 + Tags: from.Tags,
  159 + TargetUser: domain.ArticleTarget(from.TargetUser),
  160 + }
  161 + // err := copier.Copy(to, from)
  162 + return to, nil
148 } 163 }
149 164
150 func (repository *ArticleBackupRepository) DomainModelToModel(from *domain.ArticleBackup) (*models.ArticleBackup, error) { 165 func (repository *ArticleBackupRepository) DomainModelToModel(from *domain.ArticleBackup) (*models.ArticleBackup, error) {
151 - to := &models.ArticleBackup{}  
152 - err := copier.Copy(to, from)  
153 - return to, err 166 + to := &models.ArticleBackup{
  167 + Id: from.Id,
  168 + CompanyId: from.CompanyId,
  169 + CreatedAt: from.CreatedAt,
  170 + UpdatedAt: from.CreatedAt,
  171 + DeletedAt: from.DeletedAt,
  172 + Version: from.Version,
  173 + Operator: from.Operator,
  174 + Title: from.Title,
  175 + Section: from.Section,
  176 + Images: from.Images,
  177 + Action: from.Action,
  178 + WhoRead: from.WhoRead,
  179 + WhoReview: from.WhoReview,
  180 + Tags: from.Tags,
  181 + TargetUser: int(from.TargetUser),
  182 + }
  183 + // err := copier.Copy(to, from)
  184 + return to, nil
154 } 185 }
155 186
156 func NewArticleBackupRepository(cache *cache.CachedRepository) domain.ArticleBackupRepository { 187 func NewArticleBackupRepository(cache *cache.CachedRepository) domain.ArticleBackupRepository {
@@ -3,7 +3,6 @@ package repository @@ -3,7 +3,6 @@ package repository
3 import ( 3 import (
4 "context" 4 "context"
5 5
6 - "github.com/jinzhu/copier"  
7 "github.com/pkg/errors" 6 "github.com/pkg/errors"
8 "github.com/tiptok/gocomm/pkg/cache" 7 "github.com/tiptok/gocomm/pkg/cache"
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models"
@@ -142,15 +141,57 @@ func (repository *ArticleCommentRepository) Find(ctx context.Context, conn trans @@ -142,15 +141,57 @@ func (repository *ArticleCommentRepository) Find(ctx context.Context, conn trans
142 } 141 }
143 142
144 func (repository *ArticleCommentRepository) ModelToDomainModel(from *models.ArticleComment) (*domain.ArticleComment, error) { 143 func (repository *ArticleCommentRepository) ModelToDomainModel(from *models.ArticleComment) (*domain.ArticleComment, error) {
145 - to := &domain.ArticleComment{}  
146 - err := copier.Copy(to, from)  
147 - return to, err 144 + to := &domain.ArticleComment{
  145 + Id: from.Id,
  146 + CompanyId: from.CompanyId,
  147 + CreatedAt: from.CreatedAt,
  148 + UpdatedAt: from.UpdatedAt,
  149 + DeletedAt: from.DeletedAt,
  150 + Version: from.Version,
  151 + Pid: from.Pid,
  152 + TopId: from.TopId,
  153 + ArticleId: from.ArticleId,
  154 + ArticleSectionId: from.ArticleSectionId,
  155 + SectionContent: from.SectionContent,
  156 + FromUserId: from.FromUserId,
  157 + FromUser: from.FromUser,
  158 + ToUserId: from.ToUser.Id,
  159 + ToUser: from.ToUser,
  160 + Content: from.Content,
  161 + CountReply: from.CountReply,
  162 + CountUserLove: from.CountUserLove,
  163 + CountAdminLove: from.CountAdminLove,
  164 + Show: domain.CommentShow(from.Show),
  165 + }
  166 + // err := copier.Copy(to, from)
  167 + return to, nil
148 } 168 }
149 169
150 func (repository *ArticleCommentRepository) DomainModelToModel(from *domain.ArticleComment) (*models.ArticleComment, error) { 170 func (repository *ArticleCommentRepository) DomainModelToModel(from *domain.ArticleComment) (*models.ArticleComment, error) {
151 - to := &models.ArticleComment{}  
152 - err := copier.Copy(to, from)  
153 - return to, err 171 + to := &models.ArticleComment{
  172 + Id: from.Id,
  173 + CompanyId: from.CompanyId,
  174 + CreatedAt: from.CreatedAt,
  175 + UpdatedAt: from.UpdatedAt,
  176 + DeletedAt: from.DeletedAt,
  177 + Version: from.Version,
  178 + Pid: from.Pid,
  179 + TopId: from.TopId,
  180 + ArticleId: from.ArticleId,
  181 + ArticleSectionId: from.ArticleSectionId,
  182 + SectionContent: from.SectionContent,
  183 + FromUserId: from.FromUserId,
  184 + FromUser: from.FromUser,
  185 + ToUserId: from.ToUser.Id,
  186 + ToUser: from.ToUser,
  187 + Content: from.Content,
  188 + CountReply: from.CountReply,
  189 + CountUserLove: from.CountUserLove,
  190 + CountAdminLove: from.CountAdminLove,
  191 + Show: int(from.Show),
  192 + }
  193 + // err := copier.Copy(to, from)
  194 + return to, nil
154 } 195 }
155 196
156 func NewArticleCommentRepository(cache *cache.CachedRepository) domain.ArticleCommentRepository { 197 func NewArticleCommentRepository(cache *cache.CachedRepository) domain.ArticleCommentRepository {
@@ -3,7 +3,6 @@ package repository @@ -3,7 +3,6 @@ package repository
3 import ( 3 import (
4 "context" 4 "context"
5 5
6 - "github.com/jinzhu/copier"  
7 "github.com/pkg/errors" 6 "github.com/pkg/errors"
8 "github.com/tiptok/gocomm/pkg/cache" 7 "github.com/tiptok/gocomm/pkg/cache"
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models"
@@ -142,15 +141,45 @@ func (repository *ArticleDraftRepository) Find(ctx context.Context, conn transac @@ -142,15 +141,45 @@ func (repository *ArticleDraftRepository) Find(ctx context.Context, conn transac
142 } 141 }
143 142
144 func (repository *ArticleDraftRepository) ModelToDomainModel(from *models.ArticleDraft) (*domain.ArticleDraft, error) { 143 func (repository *ArticleDraftRepository) ModelToDomainModel(from *models.ArticleDraft) (*domain.ArticleDraft, error) {
145 - to := &domain.ArticleDraft{}  
146 - err := copier.Copy(to, from)  
147 - return to, err 144 + to := &domain.ArticleDraft{
  145 + Id: from.Id,
  146 + CompanyId: from.CompanyId,
  147 + CreatedAt: from.CreatedAt,
  148 + UpdatedAt: from.UpdatedAt,
  149 + DeletedAt: from.DeletedAt,
  150 + Version: from.Version,
  151 + Template: from.Template,
  152 + Content: from.Content,
  153 + AuthorId: from.AuthorId,
  154 + Title: from.Title,
  155 + Images: from.Images,
  156 + WhoRead: from.WhoRead,
  157 + WhoReview: from.WhoReview,
  158 + Location: from.Location,
  159 + }
  160 + // err := copier.Copy(to, from)
  161 + return to, nil
148 } 162 }
149 163
150 func (repository *ArticleDraftRepository) DomainModelToModel(from *domain.ArticleDraft) (*models.ArticleDraft, error) { 164 func (repository *ArticleDraftRepository) DomainModelToModel(from *domain.ArticleDraft) (*models.ArticleDraft, error) {
151 - to := &models.ArticleDraft{}  
152 - err := copier.Copy(to, from)  
153 - return to, err 165 + to := &models.ArticleDraft{
  166 + Id: from.Id,
  167 + CompanyId: from.CompanyId,
  168 + CreatedAt: from.CreatedAt,
  169 + UpdatedAt: from.UpdatedAt,
  170 + DeletedAt: from.DeletedAt,
  171 + Version: from.Version,
  172 + Template: from.Template,
  173 + Content: from.Content,
  174 + AuthorId: from.AuthorId,
  175 + Title: from.Title,
  176 + Images: from.Images,
  177 + WhoRead: from.WhoRead,
  178 + WhoReview: from.WhoReview,
  179 + Location: from.Location,
  180 + }
  181 + // err := copier.Copy(to, from)
  182 + return to, nil
154 } 183 }
155 184
156 func NewArticleDraftRepository(cache *cache.CachedRepository) domain.ArticleDraftRepository { 185 func NewArticleDraftRepository(cache *cache.CachedRepository) domain.ArticleDraftRepository {
@@ -3,7 +3,6 @@ package repository @@ -3,7 +3,6 @@ package repository
3 import ( 3 import (
4 "context" 4 "context"
5 5
6 - "github.com/jinzhu/copier"  
7 "github.com/pkg/errors" 6 "github.com/pkg/errors"
8 "github.com/tiptok/gocomm/pkg/cache" 7 "github.com/tiptok/gocomm/pkg/cache"
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models"
@@ -142,15 +141,52 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. @@ -142,15 +141,52 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.
142 } 141 }
143 142
144 func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (*domain.Article, error) { 143 func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (*domain.Article, error) {
145 - to := &domain.Article{}  
146 - err := copier.Copy(to, from)  
147 - return to, err 144 + to := &domain.Article{
  145 + Id: from.Id,
  146 + CompanyId: from.CompanyId,
  147 + CreatedAt: from.CreatedAt,
  148 + UpdatedAt: from.UpdatedAt,
  149 + DeletedAt: from.DeletedAt,
  150 + Version: from.Version,
  151 + AuthorId: from.AuthorId,
  152 + Author: from.Author,
  153 + Title: from.Title,
  154 + Images: from.Images,
  155 + WhoRead: from.WhoRead,
  156 + WhoReview: from.WhoReview,
  157 + Location: from.Location,
  158 + TargetUser: domain.ArticleTarget(from.TargetUser),
  159 + CountLove: from.CountLove,
  160 + CountComment: from.CountComment,
  161 + Tags: from.Tags,
  162 + Show: domain.ArticleShow(from.Show),
  163 + }
  164 + return to, nil
148 } 165 }
149 166
150 func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (*models.Article, error) { 167 func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (*models.Article, error) {
151 - to := &models.Article{}  
152 - err := copier.Copy(to, from)  
153 - return to, err 168 + to := &models.Article{
  169 + Id: from.Id,
  170 + CompanyId: from.CompanyId,
  171 + CreatedAt: from.CreatedAt,
  172 + UpdatedAt: from.UpdatedAt,
  173 + DeletedAt: from.DeletedAt,
  174 + Version: from.Version,
  175 + AuthorId: from.AuthorId,
  176 + Author: from.Author,
  177 + Title: from.Title,
  178 + Images: from.Images,
  179 + WhoRead: from.WhoRead,
  180 + WhoReview: from.WhoReview,
  181 + Location: from.Location,
  182 + TargetUser: int(from.TargetUser),
  183 + CountLove: from.CountLove,
  184 + CountComment: from.CountComment,
  185 + Tags: from.Tags,
  186 + Show: int(from.Show),
  187 + }
  188 + // err := copier.Copy(to, from)
  189 + return to, nil
154 } 190 }
155 191
156 func NewArticleRepository(cache *cache.CachedRepository) domain.ArticleRepository { 192 func NewArticleRepository(cache *cache.CachedRepository) domain.ArticleRepository {
@@ -3,7 +3,6 @@ package repository @@ -3,7 +3,6 @@ package repository
3 import ( 3 import (
4 "context" 4 "context"
5 5
6 - "github.com/jinzhu/copier"  
7 "github.com/pkg/errors" 6 "github.com/pkg/errors"
8 "github.com/tiptok/gocomm/pkg/cache" 7 "github.com/tiptok/gocomm/pkg/cache"
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models"
@@ -142,15 +141,37 @@ func (repository *ArticleSectionRepository) Find(ctx context.Context, conn trans @@ -142,15 +141,37 @@ func (repository *ArticleSectionRepository) Find(ctx context.Context, conn trans
142 } 141 }
143 142
144 func (repository *ArticleSectionRepository) ModelToDomainModel(from *models.ArticleSection) (*domain.ArticleSection, error) { 143 func (repository *ArticleSectionRepository) ModelToDomainModel(from *models.ArticleSection) (*domain.ArticleSection, error) {
145 - to := &domain.ArticleSection{}  
146 - err := copier.Copy(to, from)  
147 - return to, err 144 + to := &domain.ArticleSection{
  145 + Id: from.Id,
  146 + CompanyId: from.CompanyId,
  147 + CreatedAt: from.CreatedAt,
  148 + UpdatedAt: from.UpdatedAt,
  149 + DeletedAt: from.DeletedAt,
  150 + Version: from.Version,
  151 + ArticleId: from.ArticleId,
  152 + Content: from.Content,
  153 + SortBy: from.SortBy,
  154 + TotalComment: from.TotalComment,
  155 + }
  156 + // err := copier.Copy(to, from)
  157 + return to, nil
148 } 158 }
149 159
150 func (repository *ArticleSectionRepository) DomainModelToModel(from *domain.ArticleSection) (*models.ArticleSection, error) { 160 func (repository *ArticleSectionRepository) DomainModelToModel(from *domain.ArticleSection) (*models.ArticleSection, error) {
151 - to := &models.ArticleSection{}  
152 - err := copier.Copy(to, from)  
153 - return to, err 161 + to := &models.ArticleSection{
  162 + Id: from.Id,
  163 + CompanyId: from.CompanyId,
  164 + CreatedAt: from.CreatedAt,
  165 + UpdatedAt: from.UpdatedAt,
  166 + DeletedAt: from.DeletedAt,
  167 + Version: from.Version,
  168 + ArticleId: from.ArticleId,
  169 + Content: from.Content,
  170 + SortBy: from.SortBy,
  171 + TotalComment: from.TotalComment,
  172 + }
  173 + // err := copier.Copy(to, from)
  174 + return to, nil
154 } 175 }
155 176
156 func NewArticleSectionRepository(cache *cache.CachedRepository) domain.ArticleSectionRepository { 177 func NewArticleSectionRepository(cache *cache.CachedRepository) domain.ArticleSectionRepository {
@@ -3,7 +3,6 @@ package repository @@ -3,7 +3,6 @@ package repository
3 import ( 3 import (
4 "context" 4 "context"
5 5
6 - "github.com/jinzhu/copier"  
7 "github.com/pkg/errors" 6 "github.com/pkg/errors"
8 "github.com/tiptok/gocomm/pkg/cache" 7 "github.com/tiptok/gocomm/pkg/cache"
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models"
@@ -142,15 +141,33 @@ func (repository *UserLoveFlagRepository) Find(ctx context.Context, conn transac @@ -142,15 +141,33 @@ func (repository *UserLoveFlagRepository) Find(ctx context.Context, conn transac
142 } 141 }
143 142
144 func (repository *UserLoveFlagRepository) ModelToDomainModel(from *models.UserLoveFlag) (*domain.UserLoveFlag, error) { 143 func (repository *UserLoveFlagRepository) ModelToDomainModel(from *models.UserLoveFlag) (*domain.UserLoveFlag, error) {
145 - to := &domain.UserLoveFlag{}  
146 - err := copier.Copy(to, from)  
147 - return to, err 144 + to := &domain.UserLoveFlag{
  145 + Id: from.Id,
  146 + ArticleId: from.ArticleId,
  147 + CommentId: from.CommentId,
  148 + UserId: from.UserId,
  149 + CreatedAt: from.CreatedAt,
  150 + UpdatedAt: from.UpdatedAt,
  151 + DeletedAt: from.DeletedAt,
  152 + Version: from.Version,
  153 + }
  154 + // err := copier.Copy(to, from)
  155 + return to, nil
148 } 156 }
149 157
150 func (repository *UserLoveFlagRepository) DomainModelToModel(from *domain.UserLoveFlag) (*models.UserLoveFlag, error) { 158 func (repository *UserLoveFlagRepository) DomainModelToModel(from *domain.UserLoveFlag) (*models.UserLoveFlag, error) {
151 - to := &models.UserLoveFlag{}  
152 - err := copier.Copy(to, from)  
153 - return to, err 159 + to := &models.UserLoveFlag{
  160 + Id: from.Id,
  161 + ArticleId: from.ArticleId,
  162 + CommentId: from.CommentId,
  163 + UserId: from.UserId,
  164 + CreatedAt: from.CreatedAt,
  165 + UpdatedAt: from.UpdatedAt,
  166 + DeletedAt: from.DeletedAt,
  167 + Version: from.Version,
  168 + }
  169 + // err := copier.Copy(to, from)
  170 + return to, nil
154 } 171 }
155 172
156 func NewUserLoveFlagRepository(cache *cache.CachedRepository) domain.UserLoveFlagRepository { 173 func NewUserLoveFlagRepository(cache *cache.CachedRepository) domain.UserLoveFlagRepository {
@@ -15,7 +15,7 @@ type Article struct { @@ -15,7 +15,7 @@ type Article struct {
15 DeletedAt int64 `json:"deletedAt,omitempty"` 15 DeletedAt int64 `json:"deletedAt,omitempty"`
16 Version int `json:"version,omitempty"` 16 Version int `json:"version,omitempty"`
17 AuthorId int64 `json:"authorId"` // 发布人 17 AuthorId int64 `json:"authorId"` // 发布人
18 - Author User `json:"author"` // 发布人 18 + Author UserSimple `json:"author"` // 发布人
19 Title string `json:"title"` // 文章标题 19 Title string `json:"title"` // 文章标题
20 Images []Image `json:"images"` // 图片 20 Images []Image `json:"images"` // 图片
21 WhoRead []int64 `json:"whoRead"` // 谁可以看 21 WhoRead []int64 `json:"whoRead"` // 谁可以看
@@ -8,20 +8,21 @@ import ( @@ -8,20 +8,21 @@ import (
8 8
9 // 编辑文章后保存的历史记录 9 // 编辑文章后保存的历史记录
10 type ArticleBackup struct { 10 type ArticleBackup struct {
11 - Id int64 `json:"id"`  
12 - CompanyId int64 `json:"companyId"`  
13 - CreatedAt int64 `json:"createdAt,omitempty"`  
14 - UpdatedAt int64 `json:"updatedAt,omitempty"`  
15 - DeletedAt int64 `json:"deletedAt,omitempty"`  
16 - Version int `json:"version,omitempty"`  
17 - Operator UserSimple `json:"operator"` // 操作人  
18 - Title string `json:"title"` // 标题  
19 - Section []ArticleSection `json:"section"` // 分段内容  
20 - Images []Image `json:"images"` // 图片  
21 - Action string `json:"action"` // 操作  
22 - WhoRead []int64 `json:"whoRead"` // 谁可以看  
23 - WhoReview []int64 `json:"whoReview"` // 评论人  
24 - Tags []int `json:"tags"` // 标签 11 + Id int64 `json:"id"`
  12 + CompanyId int64 `json:"companyId"`
  13 + CreatedAt int64 `json:"createdAt,omitempty"`
  14 + UpdatedAt int64 `json:"updatedAt,omitempty"`
  15 + DeletedAt int64 `json:"deletedAt,omitempty"`
  16 + Version int `json:"version,omitempty"`
  17 + Operator UserSimple `json:"operator"` // 操作人
  18 + Title string `json:"title"` // 标题
  19 + Section []ArticleSection `json:"section"` // 分段内容
  20 + Images []Image `json:"images"` // 图片
  21 + Action string `json:"action"` // 操作
  22 + TargetUser ArticleTarget `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人
  23 + WhoRead []int64 `json:"whoRead"` // 谁可以看
  24 + WhoReview []int64 `json:"whoReview"` // 评论人
  25 + Tags []int `json:"tags"` // 标签
25 } 26 }
26 27
27 type ArticleBackupRepository interface { 28 type ArticleBackupRepository interface {
@@ -20,9 +20,9 @@ type ArticleComment struct { @@ -20,9 +20,9 @@ type ArticleComment struct {
20 ArticleSectionId int64 `json:"articleSectionId"` // 文本内容id 20 ArticleSectionId int64 `json:"articleSectionId"` // 文本内容id
21 SectionContent string `json:"sectionContent"` // 引用的文章内容文本 21 SectionContent string `json:"sectionContent"` // 引用的文章内容文本
22 FromUserId int64 `json:"fromUserId"` // 谁填写的评论 22 FromUserId int64 `json:"fromUserId"` // 谁填写的评论
23 - FromUser User `json:"fromUser"` // 谁填写的评论 23 + FromUser UserSimple `json:"fromUser"` // 谁填写的评论
24 ToUserId int64 `json:"toUserId"` // 回复谁的评论 24 ToUserId int64 `json:"toUserId"` // 回复谁的评论
25 - ToUser User `json:"toUser"` // 回复谁的评论 25 + ToUser UserSimple `json:"toUser"` // 回复谁的评论
26 Content string `json:"content"` // 评论内容 26 Content string `json:"content"` // 评论内容
27 CountReply int `json:"countReply"` // 回复数量 27 CountReply int `json:"countReply"` // 回复数量
28 CountUserLove int `json:"countUserLove"` // 用户点赞数量 28 CountUserLove int `json:"countUserLove"` // 用户点赞数量
@@ -29,8 +29,9 @@ type Opinion struct { @@ -29,8 +29,9 @@ type Opinion struct {
29 } 29 }
30 30
31 type UserSimple struct { 31 type UserSimple struct {
32 - Id int64 // 人员id  
33 - Name string // 人员的名字  
34 - Avatar string // 人员头像URL  
35 - Group string // 人员的分组 32 + Id int64 `json:"id"` // 人员id
  33 + Name string `json:"name"` // 人员的名字
  34 + Avatar string `json:"avatar,omitempty"` // 人员头像URL
  35 + Group string `json:"group,omitempty"` // 人员的分组
  36 + Position string `json:"position,omitempty"` // 职位
36 } 37 }
@@ -4,13 +4,13 @@ package domain @@ -4,13 +4,13 @@ package domain
4 // 浏览记录 4 // 浏览记录
5 5
6 type UserReadArticle struct { 6 type UserReadArticle struct {
7 - Id int64 `json:"id"`  
8 - UserId int64 `json:"userId"`  
9 - ArticleId int64 `json:"articleId"`  
10 - Title string `json:"title"`  
11 - Author User `json:"author"` // 发布人  
12 - CreatedAt int64 `json:"createdAt,omitempty"`  
13 - UpdatedAt int64 `json:"updatedAt,omitempty"`  
14 - DeletedAt int64 `json:"deletedAt,omitempty"`  
15 - Version int `json:"version,omitempty"` 7 + Id int64 `json:"id"`
  8 + UserId int64 `json:"userId"`
  9 + ArticleId int64 `json:"articleId"`
  10 + Title string `json:"title"`
  11 + Author UserSimple `json:"author"` // 发布人
  12 + CreatedAt int64 `json:"createdAt,omitempty"`
  13 + UpdatedAt int64 `json:"updatedAt,omitempty"`
  14 + DeletedAt int64 `json:"deletedAt,omitempty"`
  15 + Version int `json:"version,omitempty"`
16 } 16 }