Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss into dev
正在显示
28 个修改的文件
包含
852 行增加
和
85 行删除
| @@ -9,7 +9,7 @@ Timeout: 30000 | @@ -9,7 +9,7 @@ Timeout: 30000 | ||
| 9 | LogRequest: true # 记录详细请求日志 | 9 | LogRequest: true # 记录详细请求日志 |
| 10 | 10 | ||
| 11 | Log: | 11 | Log: |
| 12 | - Mode: file | 12 | + # Mode: file |
| 13 | Encoding: plain | 13 | Encoding: plain |
| 14 | Level: debug # info | 14 | Level: debug # info |
| 15 | MaxSize: 1 # 2MB | 15 | MaxSize: 1 # 2MB |
| @@ -35,15 +35,9 @@ func NewMiniCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) | @@ -35,15 +35,9 @@ func NewMiniCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) | ||
| 35 | // 创建新文章 | 35 | // 创建新文章 |
| 36 | func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateRequest) (resp *types.MiniArticleCreateResponse, err error) { | 36 | func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateRequest) (resp *types.MiniArticleCreateResponse, err error) { |
| 37 | var conn = l.svcCtx.DefaultDBConn() | 37 | var conn = l.svcCtx.DefaultDBConn() |
| 38 | - | ||
| 39 | - // 检查文字数量 | ||
| 40 | - wordNum := 0 | ||
| 41 | - for i := range req.Section { | ||
| 42 | - num := utf8.RuneCountInString(req.Section[i]) | ||
| 43 | - wordNum += num | ||
| 44 | - } | ||
| 45 | - if wordNum >= 1000 { | ||
| 46 | - return nil, xerr.NewErrMsgErr("最多只能输入1000字", err) | 38 | + err = l.validateTextLimit(req) |
| 39 | + if err != nil { | ||
| 40 | + return nil, err | ||
| 47 | } | 41 | } |
| 48 | // 检查发布人 | 42 | // 检查发布人 |
| 49 | author, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.AuthorId) | 43 | author, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.AuthorId) |
| @@ -181,19 +175,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | @@ -181,19 +175,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | ||
| 181 | newArticle.MatchUrl[k] = v | 175 | newArticle.MatchUrl[k] = v |
| 182 | } | 176 | } |
| 183 | //设置内容概要 | 177 | //设置内容概要 |
| 184 | - if len(sectionList) > 0 { | ||
| 185 | - // 截取内容 50个字 | ||
| 186 | - runeNumber := 0 //字数 | ||
| 187 | - stringIndex := 0 //字符串长度 | ||
| 188 | - for i := range sectionList[0].Content { | ||
| 189 | - if runeNumber > 50 { | ||
| 190 | - break | ||
| 191 | - } | ||
| 192 | - runeNumber += 1 | ||
| 193 | - stringIndex = i | ||
| 194 | - } | ||
| 195 | - newArticle.Summary = sectionList[0].Content[0:stringIndex] | ||
| 196 | - } | 178 | + newArticle.SetSummary(sectionList) |
| 197 | 179 | ||
| 198 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | 180 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { |
| 199 | newArticle, err = l.svcCtx.ArticleRepository.Insert(ctx, c, newArticle) | 181 | newArticle, err = l.svcCtx.ArticleRepository.Insert(ctx, c, newArticle) |
| @@ -208,13 +190,6 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | @@ -208,13 +190,6 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | ||
| 208 | return xerr.NewErrMsgErr("创建文章内容失败", err) | 190 | return xerr.NewErrMsgErr("创建文章内容失败", err) |
| 209 | } | 191 | } |
| 210 | } | 192 | } |
| 211 | - // 设置保存备份 | ||
| 212 | - // backup := newArticle.MakeBackup(newArticle.Author, sectionList) | ||
| 213 | - // backup.Action = "新增" | ||
| 214 | - // _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, backup) | ||
| 215 | - // if err != nil { | ||
| 216 | - // return xerr.NewErrMsgErr("创建文章内容失败", err) | ||
| 217 | - // } | ||
| 218 | return nil | 193 | return nil |
| 219 | }, true) | 194 | }, true) |
| 220 | if err != nil { | 195 | if err != nil { |
| @@ -226,3 +201,22 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | @@ -226,3 +201,22 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | ||
| 226 | } | 201 | } |
| 227 | return | 202 | return |
| 228 | } | 203 | } |
| 204 | + | ||
| 205 | +// validateTextLimit 验证输入文本长度 | ||
| 206 | +func (l *MiniCreateArticleLogic) validateTextLimit(req *types.MiniArticleCreateRequest) error { | ||
| 207 | + | ||
| 208 | + titleWordNum := utf8.RuneCountInString(req.Title) | ||
| 209 | + if titleWordNum > 64 { | ||
| 210 | + return xerr.NewErrMsg("标题最多只能输入64字") | ||
| 211 | + } | ||
| 212 | + wordNum := 0 | ||
| 213 | + for i := range req.Section { | ||
| 214 | + num := utf8.RuneCountInString(req.Section[i]) | ||
| 215 | + wordNum += num | ||
| 216 | + } | ||
| 217 | + if wordNum > 1000 { | ||
| 218 | + return xerr.NewErrMsg("内容最多只能输入1000字") | ||
| 219 | + } | ||
| 220 | + | ||
| 221 | + return nil | ||
| 222 | +} |
| @@ -41,6 +41,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | @@ -41,6 +41,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | ||
| 41 | if articleInfo.CompanyId != req.CompanyId { | 41 | if articleInfo.CompanyId != req.CompanyId { |
| 42 | return nil, xerr.NewErrMsg("没有查看权限") | 42 | return nil, xerr.NewErrMsg("没有查看权限") |
| 43 | } | 43 | } |
| 44 | + // 检查文章的可查看人 | ||
| 44 | if articleInfo.AuthorId != int64(req.UserId) { | 45 | if articleInfo.AuthorId != int64(req.UserId) { |
| 45 | if len(articleInfo.WhoRead) > 0 { | 46 | if len(articleInfo.WhoRead) > 0 { |
| 46 | inWhoRead := false | 47 | inWhoRead := false |
| @@ -51,23 +52,25 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | @@ -51,23 +52,25 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | ||
| 51 | } | 52 | } |
| 52 | if !inWhoRead { | 53 | if !inWhoRead { |
| 53 | // 文章内容不显示 | 54 | // 文章内容不显示 |
| 54 | - resp = &types.MiniArticleGetResponse{ | ||
| 55 | - Id: articleInfo.Id, | ||
| 56 | - Title: articleInfo.Title, | ||
| 57 | - Show: int(domain.ArticleShowDisable), | ||
| 58 | - } | ||
| 59 | - return resp, nil | 55 | + // resp = &types.MiniArticleGetResponse{ |
| 56 | + // Id: articleInfo.Id, | ||
| 57 | + // Title: articleInfo.Title, | ||
| 58 | + // Show: int(domain.ArticleShowDisable), | ||
| 59 | + // } | ||
| 60 | + // return resp, nil | ||
| 61 | + return nil, xerr.NewErrMsg("没有查看权限") | ||
| 60 | } | 62 | } |
| 61 | } | 63 | } |
| 62 | } | 64 | } |
| 63 | if articleInfo.Show == domain.ArticleShowDisable { | 65 | if articleInfo.Show == domain.ArticleShowDisable { |
| 64 | // 文章内容不显示 | 66 | // 文章内容不显示 |
| 65 | - resp = &types.MiniArticleGetResponse{ | ||
| 66 | - Id: articleInfo.Id, | ||
| 67 | - Title: articleInfo.Title, | ||
| 68 | - Show: int(domain.ArticleShowDisable), | ||
| 69 | - } | ||
| 70 | - return resp, nil | 67 | + // resp = &types.MiniArticleGetResponse{ |
| 68 | + // Id: articleInfo.Id, | ||
| 69 | + // Title: articleInfo.Title, | ||
| 70 | + // Show: int(domain.ArticleShowDisable), | ||
| 71 | + // } | ||
| 72 | + // return resp, nil | ||
| 73 | + return nil, xerr.NewErrMsg("没有查看权限") | ||
| 71 | } | 74 | } |
| 72 | 75 | ||
| 73 | queryOption := domain.NewQueryOptions(). | 76 | queryOption := domain.NewQueryOptions(). |
| @@ -77,6 +77,8 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl | @@ -77,6 +77,8 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl | ||
| 77 | }) | 77 | }) |
| 78 | }) | 78 | }) |
| 79 | 79 | ||
| 80 | + article.SetSummary(articleSections) | ||
| 81 | + | ||
| 80 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | 82 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { |
| 81 | //保存文章 | 83 | //保存文章 |
| 82 | _, err = l.svcCtx.ArticleRepository.Update(ctx, c, article) | 84 | _, err = l.svcCtx.ArticleRepository.Update(ctx, c, article) |
| @@ -2,11 +2,12 @@ package article | @@ -2,11 +2,12 @@ package article | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | - "github.com/jinzhu/copier" | ||
| 6 | - "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message" | ||
| 7 | "strconv" | 5 | "strconv" |
| 8 | "unicode/utf8" | 6 | "unicode/utf8" |
| 9 | 7 | ||
| 8 | + "github.com/jinzhu/copier" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message" | ||
| 10 | + | ||
| 10 | "strings" | 11 | "strings" |
| 11 | 12 | ||
| 12 | "github.com/samber/lo" | 13 | "github.com/samber/lo" |
| @@ -116,19 +117,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -116,19 +117,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
| 116 | //文章内容 | 117 | //文章内容 |
| 117 | articleSections := l.getSections(req, article) | 118 | articleSections := l.getSections(req, article) |
| 118 | //设置内容概要 | 119 | //设置内容概要 |
| 119 | - if len(req.Section) > 0 { | ||
| 120 | - // 截取内容 50个字 | ||
| 121 | - runeNumber := 0 //字数 | ||
| 122 | - stringIndex := 0 //字符串长度 | ||
| 123 | - for i := range req.Section[0].Content { | ||
| 124 | - if runeNumber > 50 { | ||
| 125 | - break | ||
| 126 | - } | ||
| 127 | - runeNumber += 1 | ||
| 128 | - stringIndex = i | ||
| 129 | - } | ||
| 130 | - article.Summary = req.Section[0].Content[0:stringIndex] | ||
| 131 | - } | 120 | + article.SetSummary(articleSections) |
| 132 | 121 | ||
| 133 | err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, c transaction.Conn) error { | 122 | err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, c transaction.Conn) error { |
| 134 | _, err = l.svcCtx.ArticleRepository.Update(l.ctx, c, article) | 123 | _, err = l.svcCtx.ArticleRepository.Update(l.ctx, c, article) |
| @@ -199,8 +188,8 @@ func (l *SystemUpdateArticleLogic) validateTextLimit(req *types.SystemArticleUpd | @@ -199,8 +188,8 @@ func (l *SystemUpdateArticleLogic) validateTextLimit(req *types.SystemArticleUpd | ||
| 199 | num := utf8.RuneCountInString(req.Section[i].Content) | 188 | num := utf8.RuneCountInString(req.Section[i].Content) |
| 200 | wordNum += num | 189 | wordNum += num |
| 201 | } | 190 | } |
| 202 | - if wordNum >= 1000 { | ||
| 203 | - return xerr.NewErrMsg("最多只能输入1000字") | 191 | + if wordNum > 1000 { |
| 192 | + return xerr.NewErrMsg("内容最多只能输入1000字") | ||
| 204 | } | 193 | } |
| 205 | return nil | 194 | return nil |
| 206 | } | 195 | } |
| @@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
| 5 | 5 | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
| 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
| 10 | 11 | ||
| @@ -13,15 +14,17 @@ import ( | @@ -13,15 +14,17 @@ import ( | ||
| 13 | 14 | ||
| 14 | type MiniTop5ArticleCommentLogic struct { | 15 | type MiniTop5ArticleCommentLogic struct { |
| 15 | logx.Logger | 16 | logx.Logger |
| 16 | - ctx context.Context | ||
| 17 | - svcCtx *svc.ServiceContext | 17 | + ctx context.Context |
| 18 | + svcCtx *svc.ServiceContext | ||
| 19 | + userCache map[int64]types.CommentAuthor | ||
| 18 | } | 20 | } |
| 19 | 21 | ||
| 20 | func NewMiniTop5ArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniTop5ArticleCommentLogic { | 22 | func NewMiniTop5ArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniTop5ArticleCommentLogic { |
| 21 | return &MiniTop5ArticleCommentLogic{ | 23 | return &MiniTop5ArticleCommentLogic{ |
| 22 | - Logger: logx.WithContext(ctx), | ||
| 23 | - ctx: ctx, | ||
| 24 | - svcCtx: svcCtx, | 24 | + Logger: logx.WithContext(ctx), |
| 25 | + ctx: ctx, | ||
| 26 | + svcCtx: svcCtx, | ||
| 27 | + userCache: make(map[int64]types.CommentAuthor), | ||
| 25 | } | 28 | } |
| 26 | } | 29 | } |
| 27 | 30 | ||
| @@ -50,9 +53,15 @@ func (l *MiniTop5ArticleCommentLogic) MiniTop5ArticleComment(req *types.MiniTop5 | @@ -50,9 +53,15 @@ func (l *MiniTop5ArticleCommentLogic) MiniTop5ArticleComment(req *types.MiniTop5 | ||
| 50 | resp = &types.MiniTop5ArticleCommentResponse{ | 53 | resp = &types.MiniTop5ArticleCommentResponse{ |
| 51 | List: make([]types.ArticleCommentItem, len(commentList)), | 54 | List: make([]types.ArticleCommentItem, len(commentList)), |
| 52 | } | 55 | } |
| 56 | + companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, req.CompanyId) | ||
| 57 | + if err != nil { | ||
| 58 | + return nil, xerr.NewErrMsgErr("获取公司信息失败", err) | ||
| 59 | + | ||
| 60 | + } | ||
| 53 | for i, val := range commentList { | 61 | for i, val := range commentList { |
| 54 | item := NewArticleCommentItem(val) | 62 | item := NewArticleCommentItem(val) |
| 55 | - | 63 | + item.FromUser = l.getCommentAuthor(conn, val.FromUserId, companyInfo.Name) |
| 64 | + item.ToUser = l.getCommentAuthor(conn, val.ToUserId, companyInfo.Name) | ||
| 56 | if _, ok := flagMap[val.Id]; ok { | 65 | if _, ok := flagMap[val.Id]; ok { |
| 57 | item.MeLoveFlag = 1 | 66 | item.MeLoveFlag = 1 |
| 58 | } | 67 | } |
| @@ -70,6 +79,25 @@ func (l *MiniTop5ArticleCommentLogic) MiniTop5ArticleComment(req *types.MiniTop5 | @@ -70,6 +79,25 @@ func (l *MiniTop5ArticleCommentLogic) MiniTop5ArticleComment(req *types.MiniTop5 | ||
| 70 | return | 79 | return |
| 71 | } | 80 | } |
| 72 | 81 | ||
| 82 | +func (l *MiniTop5ArticleCommentLogic) getCommentAuthor(conn transaction.Conn, userid int64, companyName string) types.CommentAuthor { | ||
| 83 | + if u, ok := l.userCache[userid]; ok { | ||
| 84 | + return u | ||
| 85 | + } | ||
| 86 | + toUser, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, userid) | ||
| 87 | + if err == nil { | ||
| 88 | + commentToUser := types.CommentAuthor{ | ||
| 89 | + Id: toUser.Id, | ||
| 90 | + Name: toUser.Name, | ||
| 91 | + Avatar: toUser.Avatar, | ||
| 92 | + Position: toUser.Position, | ||
| 93 | + Company: companyName, | ||
| 94 | + } | ||
| 95 | + l.userCache[toUser.Id] = commentToUser | ||
| 96 | + return commentToUser | ||
| 97 | + } | ||
| 98 | + return types.CommentAuthor{} | ||
| 99 | +} | ||
| 100 | + | ||
| 73 | func NewArticleCommentItem(val *domain.ArticleComment) types.ArticleCommentItem { | 101 | func NewArticleCommentItem(val *domain.ArticleComment) types.ArticleCommentItem { |
| 74 | item := types.ArticleCommentItem{ | 102 | item := types.ArticleCommentItem{ |
| 75 | Id: val.Id, | 103 | Id: val.Id, |
| @@ -30,7 +30,7 @@ type Article struct { | @@ -30,7 +30,7 @@ type Article struct { | ||
| 30 | CountRead int // 浏览数量 | 30 | CountRead int // 浏览数量 |
| 31 | CountComment int // 评论数量 | 31 | CountComment int // 评论数量 |
| 32 | Tags []int64 `gorm:"type:jsonb;serializer:json"` //定性标签 | 32 | Tags []int64 `gorm:"type:jsonb;serializer:json"` //定性标签 |
| 33 | - Show int // 评论的展示状态(0显示、1不显示) | 33 | + Show int // 评论的展示状态(1显示、2不显示) |
| 34 | Summary string // 内容概要 | 34 | Summary string // 内容概要 |
| 35 | MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本 | 35 | MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本 |
| 36 | } | 36 | } |
| @@ -44,7 +44,7 @@ func (repository *ArticleAndTagRepository) Update(ctx context.Context, conn tran | @@ -44,7 +44,7 @@ func (repository *ArticleAndTagRepository) Update(ctx context.Context, conn tran | ||
| 44 | return nil, err | 44 | return nil, err |
| 45 | } | 45 | } |
| 46 | queryFunc := func() (interface{}, error) { | 46 | queryFunc := func() (interface{}, error) { |
| 47 | - tx = tx.Model(m).Updates(m) | 47 | + tx = tx.Model(m).Select("*").Updates(m) |
| 48 | return nil, tx.Error | 48 | return nil, tx.Error |
| 49 | } | 49 | } |
| 50 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 50 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -42,7 +42,7 @@ func (repository *ArticleBackupRepository) Update(ctx context.Context, conn tran | @@ -42,7 +42,7 @@ func (repository *ArticleBackupRepository) Update(ctx context.Context, conn tran | ||
| 42 | return nil, err | 42 | return nil, err |
| 43 | } | 43 | } |
| 44 | queryFunc := func() (interface{}, error) { | 44 | queryFunc := func() (interface{}, error) { |
| 45 | - tx = tx.Model(m).Updates(m) | 45 | + tx = tx.Model(m).Select("*").Updates(m) |
| 46 | return nil, tx.Error | 46 | return nil, tx.Error |
| 47 | } | 47 | } |
| 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -46,7 +46,7 @@ func (repository *ArticleCommentRepository) Update(ctx context.Context, conn tra | @@ -46,7 +46,7 @@ func (repository *ArticleCommentRepository) Update(ctx context.Context, conn tra | ||
| 46 | return nil, err | 46 | return nil, err |
| 47 | } | 47 | } |
| 48 | queryFunc := func() (interface{}, error) { | 48 | queryFunc := func() (interface{}, error) { |
| 49 | - tx = tx.Model(m).Updates(m) | 49 | + tx = tx.Model(m).Select("*").Updates(m) |
| 50 | return nil, tx.Error | 50 | return nil, tx.Error |
| 51 | } | 51 | } |
| 52 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 52 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -42,7 +42,7 @@ func (repository *ArticleDraftRepository) Update(ctx context.Context, conn trans | @@ -42,7 +42,7 @@ func (repository *ArticleDraftRepository) Update(ctx context.Context, conn trans | ||
| 42 | return nil, err | 42 | return nil, err |
| 43 | } | 43 | } |
| 44 | queryFunc := func() (interface{}, error) { | 44 | queryFunc := func() (interface{}, error) { |
| 45 | - tx = tx.Model(m).Updates(m) | 45 | + tx = tx.Model(m).Select("*").Updates(m) |
| 46 | return nil, tx.Error | 46 | return nil, tx.Error |
| 47 | } | 47 | } |
| 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -66,7 +66,7 @@ func (repository *ArticleTagRepository) Update(ctx context.Context, conn transac | @@ -66,7 +66,7 @@ func (repository *ArticleTagRepository) Update(ctx context.Context, conn transac | ||
| 66 | return nil, err | 66 | return nil, err |
| 67 | } | 67 | } |
| 68 | queryFunc := func() (interface{}, error) { | 68 | queryFunc := func() (interface{}, error) { |
| 69 | - tx = tx.Model(m).Updates(m) | 69 | + tx = tx.Model(m).Select("*").Updates(m) |
| 70 | return nil, tx.Error | 70 | return nil, tx.Error |
| 71 | } | 71 | } |
| 72 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 72 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -3,6 +3,7 @@ package repository | @@ -3,6 +3,7 @@ package repository | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | "fmt" | 5 | "fmt" |
| 6 | + | ||
| 6 | "github.com/jinzhu/copier" | 7 | "github.com/jinzhu/copier" |
| 7 | "github.com/pkg/errors" | 8 | "github.com/pkg/errors" |
| 8 | "github.com/tiptok/gocomm/pkg/cache" | 9 | "github.com/tiptok/gocomm/pkg/cache" |
| @@ -43,7 +44,7 @@ func (repository *CompanyRepository) Update(ctx context.Context, conn transactio | @@ -43,7 +44,7 @@ func (repository *CompanyRepository) Update(ctx context.Context, conn transactio | ||
| 43 | return nil, err | 44 | return nil, err |
| 44 | } | 45 | } |
| 45 | queryFunc := func() (interface{}, error) { | 46 | queryFunc := func() (interface{}, error) { |
| 46 | - tx = tx.Model(m).Updates(m) | 47 | + tx = tx.Model(m).Select("*").Updates(m) |
| 47 | return nil, tx.Error | 48 | return nil, tx.Error |
| 48 | } | 49 | } |
| 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 50 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + | ||
| 5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
| 6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
| 7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
| @@ -42,7 +43,7 @@ func (repository *DepartmentRepository) Update(ctx context.Context, conn transac | @@ -42,7 +43,7 @@ func (repository *DepartmentRepository) Update(ctx context.Context, conn transac | ||
| 42 | return nil, err | 43 | return nil, err |
| 43 | } | 44 | } |
| 44 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
| 45 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Select("*").Updates(m) |
| 46 | return nil, tx.Error | 47 | return nil, tx.Error |
| 47 | } | 48 | } |
| 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + | ||
| 5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
| 6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
| 7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
| @@ -42,7 +43,7 @@ func (repository *DiscussionAcceptRepository) Update(ctx context.Context, conn t | @@ -42,7 +43,7 @@ func (repository *DiscussionAcceptRepository) Update(ctx context.Context, conn t | ||
| 42 | return nil, err | 43 | return nil, err |
| 43 | } | 44 | } |
| 44 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
| 45 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Select("*").Updates(m) |
| 46 | return nil, tx.Error | 47 | return nil, tx.Error |
| 47 | } | 48 | } |
| 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + | ||
| 5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
| 6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
| 7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
| @@ -42,7 +43,7 @@ func (repository *DiscussionOpinionRepository) Update(ctx context.Context, conn | @@ -42,7 +43,7 @@ func (repository *DiscussionOpinionRepository) Update(ctx context.Context, conn | ||
| 42 | return nil, err | 43 | return nil, err |
| 43 | } | 44 | } |
| 44 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
| 45 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Select("*").Updates(m) |
| 46 | return nil, tx.Error | 47 | return nil, tx.Error |
| 47 | } | 48 | } |
| 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + | ||
| 5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
| 6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
| 7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
| @@ -42,7 +43,7 @@ func (repository *DiscussionRepository) Update(ctx context.Context, conn transac | @@ -42,7 +43,7 @@ func (repository *DiscussionRepository) Update(ctx context.Context, conn transac | ||
| 42 | return nil, err | 43 | return nil, err |
| 43 | } | 44 | } |
| 44 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
| 45 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Select("*").Updates(m) |
| 46 | return nil, tx.Error | 47 | return nil, tx.Error |
| 47 | } | 48 | } |
| 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -43,7 +43,7 @@ func (repository *MessageBusinessRepository) Update(ctx context.Context, conn tr | @@ -43,7 +43,7 @@ func (repository *MessageBusinessRepository) Update(ctx context.Context, conn tr | ||
| 43 | return nil, err | 43 | return nil, err |
| 44 | } | 44 | } |
| 45 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
| 46 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Select("*").Updates(m) |
| 47 | return nil, tx.Error | 47 | return nil, tx.Error |
| 48 | } | 48 | } |
| 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -43,7 +43,7 @@ func (repository *MessageSystemRepository) Update(ctx context.Context, conn tran | @@ -43,7 +43,7 @@ func (repository *MessageSystemRepository) Update(ctx context.Context, conn tran | ||
| 43 | return nil, err | 43 | return nil, err |
| 44 | } | 44 | } |
| 45 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
| 46 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Select("*").Updates(m) |
| 47 | return nil, tx.Error | 47 | return nil, tx.Error |
| 48 | } | 48 | } |
| 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + | ||
| 5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
| 6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
| 7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
| @@ -42,7 +43,7 @@ func (repository *RoleRepository) Update(ctx context.Context, conn transaction.C | @@ -42,7 +43,7 @@ func (repository *RoleRepository) Update(ctx context.Context, conn transaction.C | ||
| 42 | return nil, err | 43 | return nil, err |
| 43 | } | 44 | } |
| 44 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
| 45 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Select("*").Updates(m) |
| 46 | return nil, tx.Error | 47 | return nil, tx.Error |
| 47 | } | 48 | } |
| 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + | ||
| 5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
| 6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
| 7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
| @@ -42,7 +43,7 @@ func (repository *UserFollowRepository) Update(ctx context.Context, conn transac | @@ -42,7 +43,7 @@ func (repository *UserFollowRepository) Update(ctx context.Context, conn transac | ||
| 42 | return nil, err | 43 | return nil, err |
| 43 | } | 44 | } |
| 44 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
| 45 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Select("*").Updates(m) |
| 46 | return nil, tx.Error | 47 | return nil, tx.Error |
| 47 | } | 48 | } |
| 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -42,7 +42,7 @@ func (repository *UserLoveFlagRepository) Update(ctx context.Context, conn trans | @@ -42,7 +42,7 @@ func (repository *UserLoveFlagRepository) Update(ctx context.Context, conn trans | ||
| 42 | return nil, err | 42 | return nil, err |
| 43 | } | 43 | } |
| 44 | queryFunc := func() (interface{}, error) { | 44 | queryFunc := func() (interface{}, error) { |
| 45 | - tx = tx.Model(m).Updates(m) | 45 | + tx = tx.Model(m).Select("*").Updates(m) |
| 46 | return nil, tx.Error | 46 | return nil, tx.Error |
| 47 | } | 47 | } |
| 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -43,7 +43,7 @@ func (repository *UserReadArticleRepository) Update(ctx context.Context, conn tr | @@ -43,7 +43,7 @@ func (repository *UserReadArticleRepository) Update(ctx context.Context, conn tr | ||
| 43 | return nil, err | 43 | return nil, err |
| 44 | } | 44 | } |
| 45 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
| 46 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Select("*").Updates(m) |
| 47 | return nil, tx.Error | 47 | return nil, tx.Error |
| 48 | } | 48 | } |
| 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -3,6 +3,7 @@ package repository | @@ -3,6 +3,7 @@ package repository | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | "fmt" | 5 | "fmt" |
| 6 | + | ||
| 6 | "github.com/jinzhu/copier" | 7 | "github.com/jinzhu/copier" |
| 7 | "github.com/pkg/errors" | 8 | "github.com/pkg/errors" |
| 8 | "github.com/tiptok/gocomm/pkg/cache" | 9 | "github.com/tiptok/gocomm/pkg/cache" |
| @@ -43,7 +44,7 @@ func (repository *UserRepository) Update(ctx context.Context, conn transaction.C | @@ -43,7 +44,7 @@ func (repository *UserRepository) Update(ctx context.Context, conn transaction.C | ||
| 43 | return nil, err | 44 | return nil, err |
| 44 | } | 45 | } |
| 45 | queryFunc := func() (interface{}, error) { | 46 | queryFunc := func() (interface{}, error) { |
| 46 | - tx = tx.Model(m).Updates(m) | 47 | + tx = tx.Model(m).Select("*").Updates(m) |
| 47 | return nil, tx.Error | 48 | return nil, tx.Error |
| 48 | } | 49 | } |
| 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 50 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -2,6 +2,7 @@ package repository | @@ -2,6 +2,7 @@ package repository | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + | ||
| 5 | "github.com/jinzhu/copier" | 6 | "github.com/jinzhu/copier" |
| 6 | "github.com/pkg/errors" | 7 | "github.com/pkg/errors" |
| 7 | "github.com/tiptok/gocomm/pkg/cache" | 8 | "github.com/tiptok/gocomm/pkg/cache" |
| @@ -42,7 +43,7 @@ func (repository *UserRoleRepository) Update(ctx context.Context, conn transacti | @@ -42,7 +43,7 @@ func (repository *UserRoleRepository) Update(ctx context.Context, conn transacti | ||
| 42 | return nil, err | 43 | return nil, err |
| 43 | } | 44 | } |
| 44 | queryFunc := func() (interface{}, error) { | 45 | queryFunc := func() (interface{}, error) { |
| 45 | - tx = tx.Model(m).Updates(m) | 46 | + tx = tx.Model(m).Select("*").Updates(m) |
| 46 | return nil, tx.Error | 47 | return nil, tx.Error |
| 47 | } | 48 | } |
| 48 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | 49 | if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { |
| @@ -2,6 +2,7 @@ package domain | @@ -2,6 +2,7 @@ package domain | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "strings" | ||
| 5 | 6 | ||
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" |
| 7 | ) | 8 | ) |
| @@ -119,6 +120,7 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar | @@ -119,6 +120,7 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar | ||
| 119 | WhoReview: m.WhoReview, | 120 | WhoReview: m.WhoReview, |
| 120 | Tags: m.Tags, | 121 | Tags: m.Tags, |
| 121 | MatchUrl: map[string]string{}, | 122 | MatchUrl: map[string]string{}, |
| 123 | + Location: m.Location, | ||
| 122 | } | 124 | } |
| 123 | copy(b.Videos, m.Videos) | 125 | copy(b.Videos, m.Videos) |
| 124 | copy(b.Images, m.Images) | 126 | copy(b.Images, m.Images) |
| @@ -127,3 +129,30 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar | @@ -127,3 +129,30 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar | ||
| 127 | } | 129 | } |
| 128 | return &b | 130 | return &b |
| 129 | } | 131 | } |
| 132 | + | ||
| 133 | +func (m *Article) SetSummary(sectionList []ArticleSection) { | ||
| 134 | + if len(sectionList) == 0 { | ||
| 135 | + return | ||
| 136 | + } | ||
| 137 | + //设置内容概要 | ||
| 138 | + | ||
| 139 | + // 截取内容 50个字 | ||
| 140 | + runeNumber := 0 //字数 | ||
| 141 | + stringIndex := 0 //字符串长度 | ||
| 142 | + content := "" | ||
| 143 | + for i := range sectionList { | ||
| 144 | + str := strings.TrimSpace(sectionList[i].Content) | ||
| 145 | + if len(str) > 0 { | ||
| 146 | + content = str | ||
| 147 | + break | ||
| 148 | + } | ||
| 149 | + } | ||
| 150 | + for i := range content { | ||
| 151 | + if runeNumber > 50 { | ||
| 152 | + break | ||
| 153 | + } | ||
| 154 | + runeNumber += 1 | ||
| 155 | + stringIndex = i | ||
| 156 | + } | ||
| 157 | + m.Summary = content[0:stringIndex] | ||
| 158 | +} |
| @@ -61,7 +61,7 @@ type ArticleCommentShow struct { | @@ -61,7 +61,7 @@ type ArticleCommentShow struct { | ||
| 61 | CountReply int // 回复数量 | 61 | CountReply int // 回复数量 |
| 62 | CountUserLove int // 用户点赞数量 | 62 | CountUserLove int // 用户点赞数量 |
| 63 | CountAdminLove int // 运营点赞数量 | 63 | CountAdminLove int // 运营点赞数量 |
| 64 | - Show int // 评论的展示状态(0显示、1不显示) | 64 | + Show int // 评论的展示状态(1显示、2不显示) |
| 65 | CreatedAt int64 // 评论的创建时间 | 65 | CreatedAt int64 // 评论的创建时间 |
| 66 | } | 66 | } |
| 67 | 67 |
sql/all_table.sql
0 → 100644
| 1 | +-- public.article definition | ||
| 2 | +-- Drop table | ||
| 3 | +-- DROP TABLE public.article; | ||
| 4 | +CREATE TABLE public.article( | ||
| 5 | + id bigserial NOT NULL, -- ID | ||
| 6 | + company_id int8 NULL, -- 公司ID | ||
| 7 | + created_at int8 NULL, -- 创建时间 | ||
| 8 | + updated_at int8 NULL, -- 更新时间 | ||
| 9 | + deleted_at int8 NULL, -- 删除时间 | ||
| 10 | + is_del int8 NULL, -- 是否删除 | ||
| 11 | + "version" int8 NULL DEFAULT 0, -- 版本 | ||
| 12 | + author_id int8 NULL DEFAULT 0, -- 发布人 | ||
| 13 | + author jsonb NULL DEFAULT '{}' ::jsonb, -- 发布人对象 | ||
| 14 | + title text NULL, -- 文章标题 | ||
| 15 | + images jsonb NULL DEFAULT '[]' ::jsonb, -- 图片 | ||
| 16 | + who_read jsonb NULL DEFAULT '[]' ::jsonb, -- 谁可以看 | ||
| 17 | + who_review jsonb NULL DEFAULT '[]' ::jsonb, -- 评论人 | ||
| 18 | + "location" jsonb NULL DEFAULT '{}' ::jsonb, -- 坐标 | ||
| 19 | + target_user int8 NULL DEFAULT 0, -- 分发方式 0 分发给所有人 1 分发给指定的人 | ||
| 20 | + count_love int8 NULL DEFAULT 0, -- 点赞数量 | ||
| 21 | + count_comment int8 NULL DEFAULT 0, -- 评论数量 | ||
| 22 | + "show" int8 NULL DEFAULT 1, -- 评论的展示状态(1显示、2不显示) | ||
| 23 | + tags jsonb NULL DEFAULT '[]' ::jsonb, -- 标签 | ||
| 24 | + count_read int8 NULL DEFAULT 0, -- 已读数量 | ||
| 25 | + summary text NULL, | ||
| 26 | + match_url jsonb NULL DEFAULT '{}' ::jsonb, | ||
| 27 | + videos jsonb NULL DEFAULT '[]' ::jsonb, | ||
| 28 | + CONSTRAINT article_pkey PRIMARY KEY (id) | ||
| 29 | +); | ||
| 30 | + | ||
| 31 | +CREATE INDEX article_company_id_idx ON public.article USING btree(company_id); | ||
| 32 | + | ||
| 33 | +-- Column comments | ||
| 34 | +COMMENT ON COLUMN public.article.id IS 'ID'; | ||
| 35 | + | ||
| 36 | +COMMENT ON COLUMN public.article.company_id IS '公司ID'; | ||
| 37 | + | ||
| 38 | +COMMENT ON COLUMN public.article.created_at IS '创建时间'; | ||
| 39 | + | ||
| 40 | +COMMENT ON COLUMN public.article.updated_at IS '更新时间'; | ||
| 41 | + | ||
| 42 | +COMMENT ON COLUMN public.article.deleted_at IS '删除时间'; | ||
| 43 | + | ||
| 44 | +COMMENT ON COLUMN public.article.is_del IS '是否删除'; | ||
| 45 | + | ||
| 46 | +COMMENT ON COLUMN public.article. "version" IS '版本'; | ||
| 47 | + | ||
| 48 | +COMMENT ON COLUMN public.article.author_id IS '发布人'; | ||
| 49 | + | ||
| 50 | +COMMENT ON COLUMN public.article.author IS '发布人对象'; | ||
| 51 | + | ||
| 52 | +COMMENT ON COLUMN public.article.title IS '文章标题'; | ||
| 53 | + | ||
| 54 | +COMMENT ON COLUMN public.article.images IS '图片'; | ||
| 55 | + | ||
| 56 | +COMMENT ON COLUMN public.article.who_read IS '谁可以看'; | ||
| 57 | + | ||
| 58 | +COMMENT ON COLUMN public.article.who_review IS '评论人'; | ||
| 59 | + | ||
| 60 | +COMMENT ON COLUMN public.article. "location" IS '坐标'; | ||
| 61 | + | ||
| 62 | +COMMENT ON COLUMN public.article.target_user IS '分发方式 0 分发给所有人 1 分发给指定的人'; | ||
| 63 | + | ||
| 64 | +COMMENT ON COLUMN public.article.count_love IS '点赞数量'; | ||
| 65 | + | ||
| 66 | +COMMENT ON COLUMN public.article.count_comment IS '评论数量'; | ||
| 67 | + | ||
| 68 | +COMMENT ON COLUMN public.article. "show" IS '评论的展示状态(1显示、2不显示)'; | ||
| 69 | + | ||
| 70 | +COMMENT ON COLUMN public.article.tags IS '标签'; | ||
| 71 | + | ||
| 72 | +COMMENT ON COLUMN public.article.count_read IS '已读数量'; | ||
| 73 | + | ||
| 74 | +-- public.article_and_tag definition | ||
| 75 | +-- Drop table | ||
| 76 | +-- DROP TABLE public.article_and_tag; | ||
| 77 | +CREATE TABLE public.article_and_tag( | ||
| 78 | + id bigserial NOT NULL, | ||
| 79 | + company_id int8 NULL, | ||
| 80 | + created_at int8 NULL, | ||
| 81 | + updated_at int8 NULL, | ||
| 82 | + article_id int8 NULL, | ||
| 83 | + tag_id int8 NULL, | ||
| 84 | + CONSTRAINT article_and_tag_pkey PRIMARY KEY (id) | ||
| 85 | +); | ||
| 86 | + | ||
| 87 | +CREATE INDEX article_and_tag_company_id_idx ON public.article_and_tag USING btree(company_id); | ||
| 88 | + | ||
| 89 | +-- public.article_backup definition | ||
| 90 | +-- Drop table | ||
| 91 | +-- DROP TABLE public.article_backup; | ||
| 92 | +CREATE TABLE public.article_backup( | ||
| 93 | + id bigserial NOT NULL, -- ID | ||
| 94 | + company_id int8 NULL, -- 公司ID | ||
| 95 | + created_at int8 NULL, -- 创建时间 | ||
| 96 | + updated_at int8 NULL, -- 更新时间 | ||
| 97 | + deleted_at int8 NULL, -- 删除时间 | ||
| 98 | + is_del int8 NULL, -- 是否删除 | ||
| 99 | + "version" int8 NULL, -- 版本 | ||
| 100 | + "operator" jsonb NULL, -- 操作人 | ||
| 101 | + title text NULL, -- 标题 | ||
| 102 | + "section" jsonb NULL, -- 分段内容 | ||
| 103 | + images jsonb NULL, -- 图片 | ||
| 104 | + "action" text NULL, -- 操作 | ||
| 105 | + who_read jsonb NULL, -- 谁可以看 | ||
| 106 | + who_review jsonb NULL, -- 评论人 | ||
| 107 | + tags jsonb NULL, -- 标签 | ||
| 108 | + target_user int8 NULL, -- 分发方式 0 分发给所有人 1 分发给指定的人 | ||
| 109 | + article_id int8 NULL, | ||
| 110 | + "location" jsonb NULL, | ||
| 111 | + match_url jsonb NULL DEFAULT '{}' ::jsonb, | ||
| 112 | + videos jsonb NULL DEFAULT '[]' ::jsonb, | ||
| 113 | + CONSTRAINT article_backup_pkey PRIMARY KEY (id) | ||
| 114 | +); | ||
| 115 | + | ||
| 116 | +CREATE INDEX article_backup_company_id_idx ON public.article_backup USING btree(company_id); | ||
| 117 | + | ||
| 118 | +-- Column comments | ||
| 119 | +COMMENT ON COLUMN public.article_backup.id IS 'ID'; | ||
| 120 | + | ||
| 121 | +COMMENT ON COLUMN public.article_backup.company_id IS '公司ID'; | ||
| 122 | + | ||
| 123 | +COMMENT ON COLUMN public.article_backup.created_at IS '创建时间'; | ||
| 124 | + | ||
| 125 | +COMMENT ON COLUMN public.article_backup.updated_at IS '更新时间'; | ||
| 126 | + | ||
| 127 | +COMMENT ON COLUMN public.article_backup.deleted_at IS '删除时间'; | ||
| 128 | + | ||
| 129 | +COMMENT ON COLUMN public.article_backup.is_del IS '是否删除'; | ||
| 130 | + | ||
| 131 | +COMMENT ON COLUMN public.article_backup. "version" IS '版本'; | ||
| 132 | + | ||
| 133 | +COMMENT ON COLUMN public.article_backup. "operator" IS '操作人'; | ||
| 134 | + | ||
| 135 | +COMMENT ON COLUMN public.article_backup.title IS '标题'; | ||
| 136 | + | ||
| 137 | +COMMENT ON COLUMN public.article_backup. "section" IS '分段内容'; | ||
| 138 | + | ||
| 139 | +COMMENT ON COLUMN public.article_backup.images IS '图片'; | ||
| 140 | + | ||
| 141 | +COMMENT ON COLUMN public.article_backup. "action" IS '操作'; | ||
| 142 | + | ||
| 143 | +COMMENT ON COLUMN public.article_backup.who_read IS '谁可以看'; | ||
| 144 | + | ||
| 145 | +COMMENT ON COLUMN public.article_backup.who_review IS '评论人'; | ||
| 146 | + | ||
| 147 | +COMMENT ON COLUMN public.article_backup.tags IS '标签'; | ||
| 148 | + | ||
| 149 | +COMMENT ON COLUMN public.article_backup.target_user IS '分发方式 0 分发给所有人 1 分发给指定的人'; | ||
| 150 | + | ||
| 151 | +-- public.article_comment definition | ||
| 152 | +-- Drop table | ||
| 153 | +-- DROP TABLE public.article_comment; | ||
| 154 | +CREATE TABLE public.article_comment( | ||
| 155 | + id bigserial NOT NULL, -- ID | ||
| 156 | + company_id int8 NULL, -- 公司ID | ||
| 157 | + created_at int8 NULL, -- 创建时间 | ||
| 158 | + updated_at int8 NULL, -- 更新时间 | ||
| 159 | + is_del int8 NULL, -- 是否删除 | ||
| 160 | + deleted_at int8 NULL, -- 删除时间 | ||
| 161 | + "version" int8 NULL, -- 版本 | ||
| 162 | + pid int8 NULL DEFAULT 0, -- 对哪个评论进行回复 | ||
| 163 | + top_id int8 NULL DEFAULT 0, -- 归属于最上级的哪个评论 | ||
| 164 | + article_id int8 NULL DEFAULT 0, -- 文章id | ||
| 165 | + section_id int8 NULL DEFAULT 0, -- 文本段落内容id | ||
| 166 | + section_content text NULL, -- 引用的文章内容文本 | ||
| 167 | + from_user_id int8 NULL DEFAULT 0, -- 谁填写的评论 | ||
| 168 | + from_user jsonb NULL DEFAULT '{}' ::jsonb, -- 谁填写的评论对象 | ||
| 169 | + to_user_id int8 NULL DEFAULT 0, -- 回复谁的评论 | ||
| 170 | + to_user jsonb NULL DEFAULT '{}' ::jsonb, -- 回复谁的评论对象 | ||
| 171 | + "content" text NULL, -- 评论内容 | ||
| 172 | + count_reply int8 NULL DEFAULT 0, -- 回复数量 | ||
| 173 | + count_user_love int8 NULL DEFAULT 0, -- 用户点赞数量 | ||
| 174 | + count_admin_love int8 NULL DEFAULT 0, -- 运营点赞数量 | ||
| 175 | + "show" int8 NULL DEFAULT 1, -- 评论的展示状态(1显示、2不显示) | ||
| 176 | + at_who jsonb NULL DEFAULT '[]' ::jsonb, -- 填写评论时@的人 | ||
| 177 | + match_url jsonb NULL DEFAULT '{}' ::jsonb, -- 评论内容中出现的url. | ||
| 178 | + CONSTRAINT article_comment_pkey PRIMARY KEY (id) | ||
| 179 | +); | ||
| 180 | + | ||
| 181 | +CREATE INDEX article_comment_company_id_idx ON public.article_comment USING btree(company_id); | ||
| 182 | + | ||
| 183 | +-- Column comments | ||
| 184 | +COMMENT ON COLUMN public.article_comment.id IS 'ID'; | ||
| 185 | + | ||
| 186 | +COMMENT ON COLUMN public.article_comment.company_id IS '公司ID'; | ||
| 187 | + | ||
| 188 | +COMMENT ON COLUMN public.article_comment.created_at IS '创建时间'; | ||
| 189 | + | ||
| 190 | +COMMENT ON COLUMN public.article_comment.updated_at IS '更新时间'; | ||
| 191 | + | ||
| 192 | +COMMENT ON COLUMN public.article_comment.is_del IS '是否删除'; | ||
| 193 | + | ||
| 194 | +COMMENT ON COLUMN public.article_comment.deleted_at IS '删除时间'; | ||
| 195 | + | ||
| 196 | +COMMENT ON COLUMN public.article_comment. "version" IS '版本'; | ||
| 197 | + | ||
| 198 | +COMMENT ON COLUMN public.article_comment.pid IS '对哪个评论进行回复'; | ||
| 199 | + | ||
| 200 | +COMMENT ON COLUMN public.article_comment.top_id IS '归属于最上级的哪个评论'; | ||
| 201 | + | ||
| 202 | +COMMENT ON COLUMN public.article_comment.article_id IS '文章id'; | ||
| 203 | + | ||
| 204 | +COMMENT ON COLUMN public.article_comment.section_id IS '文本段落内容id'; | ||
| 205 | + | ||
| 206 | +COMMENT ON COLUMN public.article_comment.section_content IS '引用的文章内容文本'; | ||
| 207 | + | ||
| 208 | +COMMENT ON COLUMN public.article_comment.from_user_id IS '谁填写的评论'; | ||
| 209 | + | ||
| 210 | +COMMENT ON COLUMN public.article_comment.from_user IS '谁填写的评论对象'; | ||
| 211 | + | ||
| 212 | +COMMENT ON COLUMN public.article_comment.to_user_id IS '回复谁的评论'; | ||
| 213 | + | ||
| 214 | +COMMENT ON COLUMN public.article_comment.to_user IS '回复谁的评论对象'; | ||
| 215 | + | ||
| 216 | +COMMENT ON COLUMN public.article_comment. "content" IS '评论内容'; | ||
| 217 | + | ||
| 218 | +COMMENT ON COLUMN public.article_comment.count_reply IS '回复数量'; | ||
| 219 | + | ||
| 220 | +COMMENT ON COLUMN public.article_comment.count_user_love IS '用户点赞数量'; | ||
| 221 | + | ||
| 222 | +COMMENT ON COLUMN public.article_comment.count_admin_love IS '运营点赞数量'; | ||
| 223 | + | ||
| 224 | +COMMENT ON COLUMN public.article_comment. "show" IS '评论的展示状态(1显示、2不显示)'; | ||
| 225 | + | ||
| 226 | +COMMENT ON COLUMN public.article_comment.at_who IS '填写评论时@的人'; | ||
| 227 | + | ||
| 228 | +COMMENT ON COLUMN public.article_comment.match_url IS '评论内容中出现的url.'; | ||
| 229 | + | ||
| 230 | +-- public.article_draft definition | ||
| 231 | +-- Drop table | ||
| 232 | +-- DROP TABLE public.article_draft; | ||
| 233 | +CREATE TABLE public.article_draft( | ||
| 234 | + id bigserial NOT NULL, -- ID | ||
| 235 | + company_id int8 NULL, -- 公司ID | ||
| 236 | + created_at int8 NULL, -- 创建时间 | ||
| 237 | + updated_at int8 NULL, -- 更新时间 | ||
| 238 | + is_del int8 NULL, -- 是否删除 | ||
| 239 | + deleted_at int8 NULL, -- 删除时间 | ||
| 240 | + "version" int8 NULL, -- 版本 | ||
| 241 | + "template" int8 NULL, -- 填写内容时用的样板0、无 1、演绎式 2、归纳式 | ||
| 242 | + "content" jsonb NULL, -- 文章内容 | ||
| 243 | + author_id int8 NULL, -- 发布人 | ||
| 244 | + title text NULL, -- 文章标题 | ||
| 245 | + images jsonb NULL, -- 图片 | ||
| 246 | + who_read jsonb NULL, -- 谁可以看 | ||
| 247 | + who_review jsonb NULL, -- 评论人 | ||
| 248 | + "location" jsonb NULL, -- 坐标 | ||
| 249 | + match_url jsonb NULL DEFAULT '{}' ::jsonb, | ||
| 250 | + CONSTRAINT article_draft_pkey PRIMARY KEY (id) | ||
| 251 | +); | ||
| 252 | + | ||
| 253 | +CREATE INDEX article_draft_company_id_idx ON public.article_draft USING btree(company_id); | ||
| 254 | + | ||
| 255 | +-- Column comments | ||
| 256 | +COMMENT ON COLUMN public.article_draft.id IS 'ID'; | ||
| 257 | + | ||
| 258 | +COMMENT ON COLUMN public.article_draft.company_id IS '公司ID'; | ||
| 259 | + | ||
| 260 | +COMMENT ON COLUMN public.article_draft.created_at IS '创建时间'; | ||
| 261 | + | ||
| 262 | +COMMENT ON COLUMN public.article_draft.updated_at IS '更新时间'; | ||
| 263 | + | ||
| 264 | +COMMENT ON COLUMN public.article_draft.is_del IS '是否删除'; | ||
| 265 | + | ||
| 266 | +COMMENT ON COLUMN public.article_draft.deleted_at IS '删除时间'; | ||
| 267 | + | ||
| 268 | +COMMENT ON COLUMN public.article_draft. "version" IS '版本'; | ||
| 269 | + | ||
| 270 | +COMMENT ON COLUMN public.article_draft. "template" IS '填写内容时用的样板0、无 1、演绎式 2、归纳式'; | ||
| 271 | + | ||
| 272 | +COMMENT ON COLUMN public.article_draft. "content" IS '文章内容'; | ||
| 273 | + | ||
| 274 | +COMMENT ON COLUMN public.article_draft.author_id IS '发布人'; | ||
| 275 | + | ||
| 276 | +COMMENT ON COLUMN public.article_draft.title IS '文章标题'; | ||
| 277 | + | ||
| 278 | +COMMENT ON COLUMN public.article_draft.images IS '图片'; | ||
| 279 | + | ||
| 280 | +COMMENT ON COLUMN public.article_draft.who_read IS '谁可以看'; | ||
| 281 | + | ||
| 282 | +COMMENT ON COLUMN public.article_draft.who_review IS '评论人'; | ||
| 283 | + | ||
| 284 | +COMMENT ON COLUMN public.article_draft. "location" IS '坐标'; | ||
| 285 | + | ||
| 286 | +-- public.article_section definition | ||
| 287 | +-- Drop table | ||
| 288 | +-- DROP TABLE public.article_section; | ||
| 289 | +CREATE TABLE public.article_section( | ||
| 290 | + id bigserial NOT NULL, -- ID | ||
| 291 | + company_id int8 NULL, -- 公司ID | ||
| 292 | + created_at int8 NULL, -- 创建时间 | ||
| 293 | + updated_at int8 NULL, -- 更新时间 | ||
| 294 | + deleted_at int8 NULL, -- 删除时间 | ||
| 295 | + is_del int8 NULL, -- 是否删除 | ||
| 296 | + "version" int8 NULL, -- 版本 | ||
| 297 | + article_id int8 NULL, -- 文章id | ||
| 298 | + "content" text NULL, -- 文本内容 | ||
| 299 | + sort_by int8 NULL, -- 排序 | ||
| 300 | + total_comment int8 NULL, -- 评论的数量 | ||
| 301 | + CONSTRAINT article_section_pkey PRIMARY KEY (id) | ||
| 302 | +); | ||
| 303 | + | ||
| 304 | +CREATE INDEX article_section_article_id_idx ON public.article_section USING btree(article_id); | ||
| 305 | + | ||
| 306 | +CREATE INDEX article_section_company_id_idx ON public.article_section USING btree(company_id); | ||
| 307 | + | ||
| 308 | +-- Column comments | ||
| 309 | +COMMENT ON COLUMN public.article_section.id IS 'ID'; | ||
| 310 | + | ||
| 311 | +COMMENT ON COLUMN public.article_section.company_id IS '公司ID'; | ||
| 312 | + | ||
| 313 | +COMMENT ON COLUMN public.article_section.created_at IS '创建时间'; | ||
| 314 | + | ||
| 315 | +COMMENT ON COLUMN public.article_section.updated_at IS '更新时间'; | ||
| 316 | + | ||
| 317 | +COMMENT ON COLUMN public.article_section.deleted_at IS '删除时间'; | ||
| 318 | + | ||
| 319 | +COMMENT ON COLUMN public.article_section.is_del IS '是否删除'; | ||
| 320 | + | ||
| 321 | +COMMENT ON COLUMN public.article_section. "version" IS '版本'; | ||
| 322 | + | ||
| 323 | +COMMENT ON COLUMN public.article_section.article_id IS '文章id'; | ||
| 324 | + | ||
| 325 | +COMMENT ON COLUMN public.article_section. "content" IS '文本内容'; | ||
| 326 | + | ||
| 327 | +COMMENT ON COLUMN public.article_section.sort_by IS '排序'; | ||
| 328 | + | ||
| 329 | +COMMENT ON COLUMN public.article_section.total_comment IS '评论的数量'; | ||
| 330 | + | ||
| 331 | +-- public.article_tag definition | ||
| 332 | +-- Drop table | ||
| 333 | +-- DROP TABLE public.article_tag; | ||
| 334 | +CREATE TABLE public.article_tag( | ||
| 335 | + id bigserial NOT NULL, -- ID | ||
| 336 | + company_id int8 NULL, -- 公司ID | ||
| 337 | + created_at int8 NULL, -- 创建时间 | ||
| 338 | + updated_at int8 NULL, -- 更新时间 | ||
| 339 | + deleted_at int8 NULL, -- 删除时间 | ||
| 340 | + is_del int8 NULL DEFAULT 0, -- 是否删除 | ||
| 341 | + "version" int8 NULL, -- 版本 | ||
| 342 | + image jsonb NULL, -- 图片 | ||
| 343 | + "name" text NULL, -- 标签名称 | ||
| 344 | + category text NULL, -- 标签分类 | ||
| 345 | + remark text NULL, -- 备注 | ||
| 346 | + sort_by int8 NULL DEFAULT 0, | ||
| 347 | + other text NULL, | ||
| 348 | + CONSTRAINT article_tag_pkey PRIMARY KEY (id) | ||
| 349 | +); | ||
| 350 | + | ||
| 351 | +CREATE INDEX article_tag_company_id_idx ON public.article_tag USING btree(company_id); | ||
| 352 | + | ||
| 353 | +-- Column comments | ||
| 354 | +COMMENT ON COLUMN public.article_tag.id IS 'ID'; | ||
| 355 | + | ||
| 356 | +COMMENT ON COLUMN public.article_tag.company_id IS '公司ID'; | ||
| 357 | + | ||
| 358 | +COMMENT ON COLUMN public.article_tag.created_at IS '创建时间'; | ||
| 359 | + | ||
| 360 | +COMMENT ON COLUMN public.article_tag.updated_at IS '更新时间'; | ||
| 361 | + | ||
| 362 | +COMMENT ON COLUMN public.article_tag.deleted_at IS '删除时间'; | ||
| 363 | + | ||
| 364 | +COMMENT ON COLUMN public.article_tag.is_del IS '是否删除'; | ||
| 365 | + | ||
| 366 | +COMMENT ON COLUMN public.article_tag. "version" IS '版本'; | ||
| 367 | + | ||
| 368 | +COMMENT ON COLUMN public.article_tag.image IS '图片'; | ||
| 369 | + | ||
| 370 | +COMMENT ON COLUMN public.article_tag. "name" IS '标签名称'; | ||
| 371 | + | ||
| 372 | +COMMENT ON COLUMN public.article_tag.category IS '标签分类'; | ||
| 373 | + | ||
| 374 | +COMMENT ON COLUMN public.article_tag.remark IS '备注'; | ||
| 375 | + | ||
| 376 | +-- public.company definition | ||
| 377 | +-- Drop table | ||
| 378 | +-- DROP TABLE public.company; | ||
| 379 | +CREATE TABLE public.company( | ||
| 380 | + id bigserial NOT NULL, -- ID | ||
| 381 | + "name" text NULL, -- 名称 | ||
| 382 | + code text NULL, -- 编码(搜索使用,4位字母数字) | ||
| 383 | + logo text NULL, -- 公司LOGO | ||
| 384 | + created_at int8 NULL, -- 创建时间 | ||
| 385 | + updated_at int8 NULL, -- 更新时间 | ||
| 386 | + deleted_at int8 NULL, -- 删除时间 | ||
| 387 | + "version" int8 NULL, -- 版本 | ||
| 388 | + CONSTRAINT company_pkey PRIMARY KEY (id), | ||
| 389 | + CONSTRAINT idx_company_code UNIQUE (code) | ||
| 390 | +); | ||
| 391 | + | ||
| 392 | +-- Column comments | ||
| 393 | +COMMENT ON COLUMN public.company.id IS 'ID'; | ||
| 394 | + | ||
| 395 | +COMMENT ON COLUMN public.company. "name" IS '名称'; | ||
| 396 | + | ||
| 397 | +COMMENT ON COLUMN public.company.code IS '编码(搜索使用,4位字母数字)'; | ||
| 398 | + | ||
| 399 | +COMMENT ON COLUMN public.company.logo IS '公司LOGO'; | ||
| 400 | + | ||
| 401 | +COMMENT ON COLUMN public.company.created_at IS '创建时间'; | ||
| 402 | + | ||
| 403 | +COMMENT ON COLUMN public.company.updated_at IS '更新时间'; | ||
| 404 | + | ||
| 405 | +COMMENT ON COLUMN public.company.deleted_at IS '删除时间'; | ||
| 406 | + | ||
| 407 | +COMMENT ON COLUMN public.company. "version" IS '版本'; | ||
| 408 | + | ||
| 409 | +-- public.department definition | ||
| 410 | +-- Drop table | ||
| 411 | +-- DROP TABLE public.department; | ||
| 412 | +CREATE TABLE public.department( | ||
| 413 | + id bigserial NOT NULL, | ||
| 414 | + company_id int8 NULL, | ||
| 415 | + parent_id int8 NULL, | ||
| 416 | + "name" text NULL, | ||
| 417 | + created_at int8 NULL, | ||
| 418 | + updated_at int8 NULL, | ||
| 419 | + deleted_at int8 NULL, | ||
| 420 | + "version" int8 NULL, | ||
| 421 | + is_del int8 NULL, | ||
| 422 | + CONSTRAINT department_pkey PRIMARY KEY (id) | ||
| 423 | +); | ||
| 424 | + | ||
| 425 | +-- public.message_business definition | ||
| 426 | +-- Drop table | ||
| 427 | +-- DROP TABLE public.message_business; | ||
| 428 | +CREATE TABLE public.message_business( | ||
| 429 | + id bigserial NOT NULL, | ||
| 430 | + "type" int8 NULL, | ||
| 431 | + opt_type int8 NULL, | ||
| 432 | + company_id int8 NULL, | ||
| 433 | + user_id int8 NULL, | ||
| 434 | + recipient_id int8 NULL, | ||
| 435 | + article_id int8 NULL, | ||
| 436 | + comment_id int8 NULL, | ||
| 437 | + comment_parent_id int8 NULL, | ||
| 438 | + created_at int8 NULL, | ||
| 439 | + updated_at int8 NULL, | ||
| 440 | + deleted_at int8 NULL, | ||
| 441 | + "version" int8 NULL, | ||
| 442 | + is_del int8 NULL, | ||
| 443 | + CONSTRAINT message_business_pkey PRIMARY KEY (id) | ||
| 444 | +); | ||
| 445 | + | ||
| 446 | +-- public.message_system definition | ||
| 447 | +-- Drop table | ||
| 448 | +-- DROP TABLE public.message_system; | ||
| 449 | +CREATE TABLE public.message_system( | ||
| 450 | + id bigserial NOT NULL, | ||
| 451 | + company_id int8 NULL, -- 公司ID | ||
| 452 | + recipient_id int8 NULL, -- 接收者ID | ||
| 453 | + "type" int8 NULL, -- 系统分类(0待定、1业务正常通知、2业务异常通知) | ||
| 454 | + title text NULL, -- 标题 | ||
| 455 | + "content" text NULL, -- 内容 | ||
| 456 | + created_at int8 NULL, -- 创建时间 | ||
| 457 | + updated_at int8 NULL, -- 更新时间 | ||
| 458 | + deleted_at int8 NULL, -- 删除时间 | ||
| 459 | + "version" int8 NULL, -- 版本 | ||
| 460 | + is_del int8 NULL, -- 是否删除 | ||
| 461 | + CONSTRAINT message_system_pkey PRIMARY KEY (id) | ||
| 462 | +); | ||
| 463 | + | ||
| 464 | +-- Column comments | ||
| 465 | +COMMENT ON COLUMN public.message_system.company_id IS '公司ID'; | ||
| 466 | + | ||
| 467 | +COMMENT ON COLUMN public.message_system.recipient_id IS '接收者ID'; | ||
| 468 | + | ||
| 469 | +COMMENT ON COLUMN public.message_system. "type" IS '系统分类(0待定、1业务正常通知、2业务异常通知)'; | ||
| 470 | + | ||
| 471 | +COMMENT ON COLUMN public.message_system.title IS '标题'; | ||
| 472 | + | ||
| 473 | +COMMENT ON COLUMN public.message_system. "content" IS '内容'; | ||
| 474 | + | ||
| 475 | +COMMENT ON COLUMN public.message_system.created_at IS '创建时间'; | ||
| 476 | + | ||
| 477 | +COMMENT ON COLUMN public.message_system.updated_at IS '更新时间'; | ||
| 478 | + | ||
| 479 | +COMMENT ON COLUMN public.message_system.deleted_at IS '删除时间'; | ||
| 480 | + | ||
| 481 | +COMMENT ON COLUMN public.message_system. "version" IS '版本'; | ||
| 482 | + | ||
| 483 | +COMMENT ON COLUMN public.message_system.is_del IS '是否删除'; | ||
| 484 | + | ||
| 485 | +-- public."role" definition | ||
| 486 | +-- Drop table | ||
| 487 | +-- DROP TABLE public."role"; | ||
| 488 | +CREATE TABLE public."role"( | ||
| 489 | + id bigserial NOT NULL, -- ID | ||
| 490 | + "name" text NULL, -- 角色名称 | ||
| 491 | + auths jsonb NULL, -- 角色权限列表 | ||
| 492 | + remark text NULL, -- 备注 | ||
| 493 | + users jsonb NULL, -- 绑定的用户 | ||
| 494 | + created_at int8 NULL, -- 创建时间 | ||
| 495 | + updated_at int8 NULL, -- 更新时间 | ||
| 496 | + deleted_at int8 NULL, -- 删除时间 | ||
| 497 | + "version" int8 NULL, -- 版本 | ||
| 498 | + is_del int8 NULL, -- 是否删除 | ||
| 499 | + company_id int8 NULL, -- 公司ID | ||
| 500 | + CONSTRAINT role_pkey PRIMARY KEY (id) | ||
| 501 | +); | ||
| 502 | + | ||
| 503 | +CREATE INDEX idx_role_company_id ON public.role USING btree(company_id); | ||
| 504 | + | ||
| 505 | +-- Column comments | ||
| 506 | +COMMENT ON COLUMN public."role".id IS 'ID'; | ||
| 507 | + | ||
| 508 | +COMMENT ON COLUMN public."role"."name" IS '角色名称'; | ||
| 509 | + | ||
| 510 | +COMMENT ON COLUMN public."role".auths IS '角色权限列表'; | ||
| 511 | + | ||
| 512 | +COMMENT ON COLUMN public."role".remark IS '备注'; | ||
| 513 | + | ||
| 514 | +COMMENT ON COLUMN public."role".users IS '绑定的用户'; | ||
| 515 | + | ||
| 516 | +COMMENT ON COLUMN public."role".created_at IS '创建时间'; | ||
| 517 | + | ||
| 518 | +COMMENT ON COLUMN public."role".updated_at IS '更新时间'; | ||
| 519 | + | ||
| 520 | +COMMENT ON COLUMN public."role".deleted_at IS '删除时间'; | ||
| 521 | + | ||
| 522 | +COMMENT ON COLUMN public."role"."version" IS '版本'; | ||
| 523 | + | ||
| 524 | +COMMENT ON COLUMN public."role".is_del IS '是否删除'; | ||
| 525 | + | ||
| 526 | +COMMENT ON COLUMN public."role".company_id IS '公司ID'; | ||
| 527 | + | ||
| 528 | +-- public."user" definition | ||
| 529 | +-- Drop table | ||
| 530 | +-- DROP TABLE public."user"; | ||
| 531 | +CREATE TABLE public."user"( | ||
| 532 | + id bigserial NOT NULL, -- 唯一标识 | ||
| 533 | + company_id int8 NULL, -- 公司ID | ||
| 534 | + roles jsonb NULL, -- 角色 | ||
| 535 | + flag int8 NULL, -- 标识 1:管理员 2:普通用户 (有绑定角色是管理员) | ||
| 536 | + "name" text NULL, -- 名称 | ||
| 537 | + avatar text NULL, -- 头像 | ||
| 538 | + phone text NULL, -- 手机号 唯一 | ||
| 539 | + "position" text NULL, -- 职位 | ||
| 540 | + "enable" int8 NULL, -- 启用状态 1:启用 2:禁用 | ||
| 541 | + audit_status int8 NULL, -- 审核状态 0:待审核 1:审核通过 2:拒绝 | ||
| 542 | + follower jsonb NULL, -- 关注我的人 (冗余) | ||
| 543 | + "following" jsonb NULL, -- 我关注的人 (冗余) | ||
| 544 | + created_at int8 NULL, -- 创建时间 | ||
| 545 | + updated_at int8 NULL, -- 更新时间 | ||
| 546 | + deleted_at int8 NULL, -- 删除时间 | ||
| 547 | + "version" int8 NULL, -- 版本 | ||
| 548 | + is_del int8 NULL, -- 是否删除 | ||
| 549 | + departments jsonb NULL, -- 所属部门 | ||
| 550 | + account_from text NULL, -- 账号来源 后台新增、扫码注册 | ||
| 551 | + pin_yin_name text NULL, -- 拼音 | ||
| 552 | + audit_at int8 NULL, | ||
| 553 | + CONSTRAINT user_pkey PRIMARY KEY (id) | ||
| 554 | +); | ||
| 555 | + | ||
| 556 | +CREATE INDEX idx_user_company_id ON public."user" USING btree(company_id); | ||
| 557 | + | ||
| 558 | +CREATE INDEX idx_user_phone ON public."user" USING btree(phone); | ||
| 559 | + | ||
| 560 | +-- Column comments | ||
| 561 | +COMMENT ON COLUMN public."user".id IS '唯一标识'; | ||
| 562 | + | ||
| 563 | +COMMENT ON COLUMN public."user".company_id IS '公司ID'; | ||
| 564 | + | ||
| 565 | +COMMENT ON COLUMN public."user".roles IS '角色'; | ||
| 566 | + | ||
| 567 | +COMMENT ON COLUMN public."user".flag IS '标识 1:管理员 2:普通用户 (有绑定角色是管理员)'; | ||
| 568 | + | ||
| 569 | +COMMENT ON COLUMN public."user"."name" IS '名称'; | ||
| 570 | + | ||
| 571 | +COMMENT ON COLUMN public."user".avatar IS '头像'; | ||
| 572 | + | ||
| 573 | +COMMENT ON COLUMN public."user".phone IS '手机号 唯一'; | ||
| 574 | + | ||
| 575 | +COMMENT ON COLUMN public."user"."position" IS '职位'; | ||
| 576 | + | ||
| 577 | +COMMENT ON COLUMN public."user"."enable" IS '启用状态 1:启用 2:禁用'; | ||
| 578 | + | ||
| 579 | +COMMENT ON COLUMN public."user".audit_status IS '审核状态 0:待审核 1:审核通过 2:拒绝'; | ||
| 580 | + | ||
| 581 | +COMMENT ON COLUMN public."user".follower IS '关注我的人 (冗余)'; | ||
| 582 | + | ||
| 583 | +COMMENT ON COLUMN public."user"."following" IS '我关注的人 (冗余)'; | ||
| 584 | + | ||
| 585 | +COMMENT ON COLUMN public."user".created_at IS '创建时间'; | ||
| 586 | + | ||
| 587 | +COMMENT ON COLUMN public."user".updated_at IS '更新时间'; | ||
| 588 | + | ||
| 589 | +COMMENT ON COLUMN public."user".deleted_at IS '删除时间'; | ||
| 590 | + | ||
| 591 | +COMMENT ON COLUMN public."user"."version" IS '版本'; | ||
| 592 | + | ||
| 593 | +COMMENT ON COLUMN public."user".is_del IS '是否删除'; | ||
| 594 | + | ||
| 595 | +COMMENT ON COLUMN public."user".departments IS '所属部门'; | ||
| 596 | + | ||
| 597 | +COMMENT ON COLUMN public."user".account_from IS '账号来源 后台新增、扫码注册'; | ||
| 598 | + | ||
| 599 | +COMMENT ON COLUMN public."user".pin_yin_name IS '拼音'; | ||
| 600 | + | ||
| 601 | +-- public.user_follow definition | ||
| 602 | +-- Drop table | ||
| 603 | +-- DROP TABLE public.user_follow; | ||
| 604 | +CREATE TABLE public.user_follow( | ||
| 605 | + id bigserial NOT NULL, | ||
| 606 | + created_at int8 NULL, | ||
| 607 | + updated_at int8 NULL, | ||
| 608 | + deleted_at int8 NULL, | ||
| 609 | + "version" int8 NULL, | ||
| 610 | + from_user_id int8 NULL, | ||
| 611 | + to_user_id int8 NULL, | ||
| 612 | + last_read_at int8 NULL, | ||
| 613 | + CONSTRAINT user_follow_pkey PRIMARY KEY (id) | ||
| 614 | +); | ||
| 615 | + | ||
| 616 | +CREATE INDEX idx_user_follow_from_user_id ON public.user_follow USING btree(from_user_id); | ||
| 617 | + | ||
| 618 | +-- public.user_love_flag definition | ||
| 619 | +-- Drop table | ||
| 620 | +-- DROP TABLE public.user_love_flag; | ||
| 621 | +CREATE TABLE public.user_love_flag( | ||
| 622 | + id bigserial NOT NULL, | ||
| 623 | + article_id int8 NULL, -- 点赞文章时,文章id | ||
| 624 | + comment_id int8 NULL, -- 点赞评论时,填评论id | ||
| 625 | + user_id int8 NULL, -- 用户ID,谁点赞 | ||
| 626 | + created_at int8 NULL, -- 创建时间 | ||
| 627 | + updated_at int8 NULL, -- 更新时间 | ||
| 628 | + deleted_at int8 NULL, -- 删除时间 | ||
| 629 | + "version" int8 NULL, -- 版本 | ||
| 630 | + is_del int8 NULL, -- 是否删除 | ||
| 631 | + article_author int8 NULL, -- 文章作者id | ||
| 632 | + comment_author int8 NULL, -- 填写评论的人员id | ||
| 633 | + to_user_id int8 NULL, -- 点赞的接受人 | ||
| 634 | + company_id int8 NULL DEFAULT 0, | ||
| 635 | + CONSTRAINT user_love_flag_pkey PRIMARY KEY (id) | ||
| 636 | +); | ||
| 637 | + | ||
| 638 | +CREATE INDEX user_love_flag_comment_id_idx ON public.user_love_flag USING btree(comment_id); | ||
| 639 | + | ||
| 640 | +CREATE INDEX user_love_flag_user_id_idx ON public.user_love_flag USING btree(user_id); | ||
| 641 | + | ||
| 642 | +-- Column comments | ||
| 643 | +COMMENT ON COLUMN public.user_love_flag.article_id IS '点赞文章时,文章id'; | ||
| 644 | + | ||
| 645 | +COMMENT ON COLUMN public.user_love_flag.comment_id IS '点赞评论时,填评论id'; | ||
| 646 | + | ||
| 647 | +COMMENT ON COLUMN public.user_love_flag.user_id IS '用户ID,谁点赞'; | ||
| 648 | + | ||
| 649 | +COMMENT ON COLUMN public.user_love_flag.created_at IS '创建时间'; | ||
| 650 | + | ||
| 651 | +COMMENT ON COLUMN public.user_love_flag.updated_at IS '更新时间'; | ||
| 652 | + | ||
| 653 | +COMMENT ON COLUMN public.user_love_flag.deleted_at IS '删除时间'; | ||
| 654 | + | ||
| 655 | +COMMENT ON COLUMN public.user_love_flag. "version" IS '版本'; | ||
| 656 | + | ||
| 657 | +COMMENT ON COLUMN public.user_love_flag.is_del IS '是否删除'; | ||
| 658 | + | ||
| 659 | +COMMENT ON COLUMN public.user_love_flag.article_author IS '文章作者id'; | ||
| 660 | + | ||
| 661 | +COMMENT ON COLUMN public.user_love_flag.comment_author IS '填写评论的人员id'; | ||
| 662 | + | ||
| 663 | +COMMENT ON COLUMN public.user_love_flag.to_user_id IS '点赞的接受人'; | ||
| 664 | + | ||
| 665 | +-- public.user_read_article definition | ||
| 666 | +-- Drop table | ||
| 667 | +-- DROP TABLE public.user_read_article; | ||
| 668 | +CREATE TABLE public.user_read_article( | ||
| 669 | + id bigserial NOT NULL, | ||
| 670 | + created_at int8 NULL, | ||
| 671 | + updated_at int8 NULL, | ||
| 672 | + deleted_at int8 NULL, | ||
| 673 | + "version" int8 NULL, | ||
| 674 | + company_id int8 NULL, | ||
| 675 | + user_id int8 NULL, | ||
| 676 | + article_id int8 NULL, | ||
| 677 | + title text NULL, | ||
| 678 | + author jsonb NULL DEFAULT '{}' ::jsonb, | ||
| 679 | + is_del int8 NULL DEFAULT 0, | ||
| 680 | + CONSTRAINT user_read_article_pkey PRIMARY KEY (id) | ||
| 681 | +); | ||
| 682 | + | ||
| 683 | +CREATE INDEX user_read_article_company_id_idx ON public.user_read_article USING btree(company_id); | ||
| 684 | + | ||
| 685 | +CREATE INDEX user_read_article_user_id_idx ON public.user_read_article USING btree(user_id); | ||
| 686 | + | ||
| 687 | +-- public.user_role definition | ||
| 688 | +-- Drop table | ||
| 689 | +-- DROP TABLE public.user_role; | ||
| 690 | +CREATE TABLE public.user_role( | ||
| 691 | + id bigserial NOT NULL, | ||
| 692 | + company_id int8 NULL, | ||
| 693 | + user_id int8 NULL, | ||
| 694 | + role_id int8 NULL, | ||
| 695 | + created_at int8 NULL, | ||
| 696 | + updated_at int8 NULL, | ||
| 697 | + deleted_at int8 NULL, | ||
| 698 | + "version" int8 NULL, | ||
| 699 | + CONSTRAINT user_role_pkey PRIMARY KEY (id) | ||
| 700 | +); | ||
| 701 | + | ||
| 702 | +-- public.user_simples definition | ||
| 703 | +-- Drop table | ||
| 704 | +-- DROP TABLE public.user_simples; | ||
| 705 | +CREATE TABLE public.user_simples( | ||
| 706 | + id bigserial NOT NULL, | ||
| 707 | + "name" text NULL, | ||
| 708 | + avatar text NULL, | ||
| 709 | + "group" text NULL, | ||
| 710 | + "position" text NULL, | ||
| 711 | + CONSTRAINT user_simples_pkey PRIMARY KEY (id) | ||
| 712 | +); | ||
| 713 | + |
-
请 注册 或 登录 后发表评论