作者 庄敏学
正在显示 30 个修改的文件 包含 1242 行增加94 行删除
@@ -544,6 +544,7 @@ type ( @@ -544,6 +544,7 @@ type (
544 MiniSearchArticleItem{ 544 MiniSearchArticleItem{
545 ArticleId int64 `json:"articleId"` 545 ArticleId int64 `json:"articleId"`
546 Title string `json:"title"` 546 Title string `json:"title"`
  547 + AuthorId int64 `json:"authorId"`
547 Author string `json:"author"` // 发布人 548 Author string `json:"author"` // 发布人
548 Avatar string `json:"avatar"`// 发布人的头像 549 Avatar string `json:"avatar"`// 发布人的头像
549 Images []string `json:"images"` 550 Images []string `json:"images"`
@@ -106,6 +106,7 @@ type ( @@ -106,6 +106,7 @@ type (
106 106
107 CommentAtWho { 107 CommentAtWho {
108 Id int64 `json:"id"` 108 Id int64 `json:"id"`
  109 + Avatar string `json:"avatar,optional"` // 人员头像URL
109 Name string `json:"name,optional"` 110 Name string `json:"name,optional"`
110 FirstLetter string `json:"firstLetter,optional"` 111 FirstLetter string `json:"firstLetter,optional"`
111 } 112 }
@@ -365,6 +366,7 @@ type ( @@ -365,6 +366,7 @@ type (
365 CompanyId int64 `json:",optional"` 366 CompanyId int64 `json:",optional"`
366 Id int64 `json:"id"` 367 Id int64 `json:"id"`
367 Show int `json:"show"` //[1 显示评论] [2: 隐藏评论] 368 Show int `json:"show"` //[1 显示评论] [2: 隐藏评论]
  369 + Content string `json:"content,optional"`
368 CountAdminLove int `json:"countAdminLove,optional"` 370 CountAdminLove int `json:"countAdminLove,optional"`
369 } 371 }
370 372
@@ -55,6 +55,9 @@ service Core { @@ -55,6 +55,9 @@ service Core {
55 @doc "用户快讯" 55 @doc "用户快讯"
56 @handler miniUserNews 56 @handler miniUserNews
57 post /mini/user/news (MiniUserNewsRequest)returns(MiniUserNewsResposne) 57 post /mini/user/news (MiniUserNewsRequest)returns(MiniUserNewsResposne)
  58 + @doc "我关注人发布的信息"
  59 + @handler miniUserMyFollowingNews
  60 + post /mini/user/my_following_news (MiniUserNewsRequest)returns(MiniUserNewsResposne)
58 @doc "关注我的人" 61 @doc "关注我的人"
59 @handler miniUserFollower 62 @handler miniUserFollower
60 post /mini/user/follower (MiniUserFollowedSearchRequest)returns(MiniUserFollowedSearchResponse) 63 post /mini/user/follower (MiniUserFollowedSearchRequest)returns(MiniUserFollowedSearchResponse)
@@ -9,12 +9,13 @@ Timeout: 30000 @@ -9,12 +9,13 @@ 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
16 TimeFormat: 2006-01-02 15:04:05 16 TimeFormat: 2006-01-02 15:04:05
17 - #Rotation: size 17 + Rotation: size
  18 + MaxContentLength: 10240
18 19
19 SystemAuth: 20 SystemAuth:
20 AccessSecret: digital-platform 21 AccessSecret: digital-platform
@@ -276,6 +276,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -276,6 +276,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
276 }, 276 },
277 { 277 {
278 Method: http.MethodPost, 278 Method: http.MethodPost,
  279 + Path: "/mini/user/my_following_news",
  280 + Handler: user.MiniUserMyFollowingNewsHandler(serverCtx),
  281 + },
  282 + {
  283 + Method: http.MethodPost,
279 Path: "/mini/user/follower", 284 Path: "/mini/user/follower",
280 Handler: user.MiniUserFollowerHandler(serverCtx), 285 Handler: user.MiniUserFollowerHandler(serverCtx),
281 }, 286 },
  1 +package user
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
  5 + "net/http"
  6 +
  7 + "github.com/zeromicro/go-zero/rest/httpx"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/user"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  11 +)
  12 +
  13 +func MiniUserMyFollowingNewsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  14 + return func(w http.ResponseWriter, r *http.Request) {
  15 + var req types.MiniUserNewsRequest
  16 + if err := httpx.Parse(r, &req); err != nil {
  17 + httpx.ErrorCtx(r.Context(), w, err)
  18 + return
  19 + }
  20 +
  21 + l := user.NewMiniUserMyFollowingNewsLogic(r.Context(), svcCtx)
  22 + resp, err := l.MiniUserMyFollowingNews(&req)
  23 + result.HttpResult(r, w, resp, err)
  24 + }
  25 +}
@@ -3,8 +3,10 @@ package article @@ -3,8 +3,10 @@ package article
3 import ( 3 import (
4 "context" 4 "context"
5 5
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
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 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" 8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
8 10
9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 11 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
10 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" 12 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
@@ -16,6 +18,7 @@ type MiniArticleMarkListLogic struct { @@ -16,6 +18,7 @@ type MiniArticleMarkListLogic struct {
16 logx.Logger 18 logx.Logger
17 ctx context.Context 19 ctx context.Context
18 svcCtx *svc.ServiceContext 20 svcCtx *svc.ServiceContext
  21 + userCache map[int64]*domain.User
19 } 22 }
20 23
21 func NewMiniArticleMarkListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleMarkListLogic { 24 func NewMiniArticleMarkListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleMarkListLogic {
@@ -23,6 +26,7 @@ func NewMiniArticleMarkListLogic(ctx context.Context, svcCtx *svc.ServiceContext @@ -23,6 +26,7 @@ func NewMiniArticleMarkListLogic(ctx context.Context, svcCtx *svc.ServiceContext
23 Logger: logx.WithContext(ctx), 26 Logger: logx.WithContext(ctx),
24 ctx: ctx, 27 ctx: ctx,
25 svcCtx: svcCtx, 28 svcCtx: svcCtx,
  29 + userCache: make(map[int64]*domain.User, 0),
26 } 30 }
27 } 31 }
28 32
@@ -36,10 +40,16 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar @@ -36,10 +40,16 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar
36 if err != nil { 40 if err != nil {
37 return nil, err 41 return nil, err
38 } 42 }
  43 + companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, l.svcCtx.DefaultDBConn(), userToken.CompanyId)
  44 + if err != nil {
  45 + return nil, xerr.NewErrMsgErr("获取文章信息失败", err)
  46 + }
39 resp = &types.MiniArticleMarkListResponse{} 47 resp = &types.MiniArticleMarkListResponse{}
40 resp.Total = total 48 resp.Total = total
41 resp.List = make([]types.MiniArticleMarkItem, 0) 49 resp.List = make([]types.MiniArticleMarkItem, 0)
  50 + var author domain.User
42 for _, item := range list { 51 for _, item := range list {
  52 + author = l.getAuthor(l.svcCtx.DefaultDBConn(), item.Author.Id)
43 to := types.MiniArticleMarkItem{ 53 to := types.MiniArticleMarkItem{
44 Id: item.Id, 54 Id: item.Id,
45 CompanyId: item.CompanyId, 55 CompanyId: item.CompanyId,
@@ -48,10 +58,10 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar @@ -48,10 +58,10 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar
48 Author: types.SimpleUser{ 58 Author: types.SimpleUser{
49 Id: item.Author.Id, 59 Id: item.Author.Id,
50 CompanyId: item.Author.CompanyId, 60 CompanyId: item.Author.CompanyId,
51 - CompanyName: item.Author.Company,  
52 - Name: item.Author.Name,  
53 - Avatar: item.Author.Avatar,  
54 - Position: item.Author.Position, 61 + CompanyName: companyInfo.Name,
  62 + Name: author.Name,
  63 + Avatar: author.Avatar,
  64 + Position: author.Position,
55 }, 65 },
56 UpdatedAt: item.UpdatedAt, 66 UpdatedAt: item.UpdatedAt,
57 } 67 }
@@ -59,3 +69,15 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar @@ -59,3 +69,15 @@ func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMar
59 } 69 }
60 return resp, nil 70 return resp, nil
61 } 71 }
  72 +
  73 +func (l *MiniArticleMarkListLogic) getAuthor(conn transaction.Conn, userid int64) domain.User {
  74 + if u, ok := l.userCache[userid]; ok {
  75 + return *u
  76 + }
  77 + toUser, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, userid)
  78 + if err == nil {
  79 + l.userCache[toUser.Id] = toUser
  80 + return *toUser
  81 + }
  82 + return domain.User{}
  83 +}
@@ -11,6 +11,7 @@ import ( @@ -11,6 +11,7 @@ import (
11 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" 11 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
12 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" 12 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
13 13
  14 + "github.com/samber/lo"
14 "github.com/zeromicro/go-zero/core/logx" 15 "github.com/zeromicro/go-zero/core/logx"
15 ) 16 )
16 17
@@ -61,6 +62,7 @@ func (l *MiniArticleSetTagLogic) MiniArticleSetTag(req *types.MiniArticleSetTagR @@ -61,6 +62,7 @@ func (l *MiniArticleSetTagLogic) MiniArticleSetTag(req *types.MiniArticleSetTagR
61 } 62 }
62 articleAndTagList = append(articleAndTagList, articleAndTag) 63 articleAndTagList = append(articleAndTagList, articleAndTag)
63 } 64 }
  65 + tagIdList = lo.Union(tagIdList)
64 //更新article中的tags 66 //更新article中的tags
65 articleInfo.Tags = tagIdList 67 articleInfo.Tags = tagIdList
66 // 查询可能存在的 ArticleAndTag 68 // 查询可能存在的 ArticleAndTag
@@ -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,7 +41,8 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( @@ -41,7 +41,8 @@ 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 + // 检查文章的可查看人
  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
47 for _, val := range articleInfo.WhoRead { 48 for _, val := range articleInfo.WhoRead {
@@ -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), 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("没有查看权限")
58 } 62 }
59 - return resp, nil  
60 } 63 }
61 } 64 }
62 -  
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().
@@ -80,7 +83,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( @@ -80,7 +83,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
80 } 83 }
81 84
82 //获取作者信息 85 //获取作者信息
83 - author, _ := l.svcCtx.UserRepository.FindOne(l.ctx, conn, int64(req.UserId)) 86 + author, _ := l.svcCtx.UserRepository.FindOne(l.ctx, conn, int64(articleInfo.AuthorId))
84 87
85 var meLoveFlag int 88 var meLoveFlag int
86 if req.UserId > 0 { 89 if req.UserId > 0 {
@@ -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
@@ -15,6 +16,7 @@ type MiniSearchArticlePageLogic struct { @@ -15,6 +16,7 @@ type MiniSearchArticlePageLogic struct {
15 logx.Logger 16 logx.Logger
16 ctx context.Context 17 ctx context.Context
17 svcCtx *svc.ServiceContext 18 svcCtx *svc.ServiceContext
  19 + userCache map[int64]*domain.User
18 } 20 }
19 21
20 func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniSearchArticlePageLogic { 22 func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniSearchArticlePageLogic {
@@ -22,6 +24,7 @@ func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceConte @@ -22,6 +24,7 @@ func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceConte
22 Logger: logx.WithContext(ctx), 24 Logger: logx.WithContext(ctx),
23 ctx: ctx, 25 ctx: ctx,
24 svcCtx: svcCtx, 26 svcCtx: svcCtx,
  27 + userCache: make(map[int64]*domain.User),
25 } 28 }
26 } 29 }
27 30
@@ -63,11 +66,13 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch @@ -63,11 +66,13 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch
63 } 66 }
64 67
65 for i, val := range articleList { 68 for i, val := range articleList {
  69 + author := l.getAuthor(conn, val.AuthorId)
66 item := types.MiniSearchArticleItem{ 70 item := types.MiniSearchArticleItem{
67 ArticleId: val.Id, 71 ArticleId: val.Id,
68 Title: val.Title, 72 Title: val.Title,
69 - Author: val.Author.Name,  
70 - Avatar: val.Author.Avatar, 73 + AuthorId: val.AuthorId,
  74 + Author: author.Name,
  75 + Avatar: author.Avatar,
71 Images: []string{}, 76 Images: []string{},
72 CreatedAt: val.CreatedAt, 77 CreatedAt: val.CreatedAt,
73 MeReadFlag: 0, 78 MeReadFlag: 0,
@@ -84,3 +89,15 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch @@ -84,3 +89,15 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch
84 89
85 return resp, nil 90 return resp, nil
86 } 91 }
  92 +
  93 +func (l *MiniSearchArticlePageLogic) getAuthor(conn transaction.Conn, userid int64) domain.User {
  94 + if u, ok := l.userCache[userid]; ok {
  95 + return *u
  96 + }
  97 + toUser, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, userid)
  98 + if err == nil {
  99 + l.userCache[toUser.Id] = toUser
  100 + return *toUser
  101 + }
  102 + return domain.User{}
  103 +}
@@ -102,7 +102,7 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeArticle(req *types.MiniSetUserLi @@ -102,7 +102,7 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeArticle(req *types.MiniSetUserLi
102 102
103 // 删除点赞文章消息 103 // 删除点赞文章消息
104 var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx) 104 var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
105 - err = messageLogic.UnLikeArticle(c, articleInfo.Id) 105 + err = messageLogic.UnLikeArticle(c, articleInfo.Id, articleInfo.AuthorId)
106 if err != nil { 106 if err != nil {
107 return err 107 return err
108 } 108 }
@@ -183,7 +183,7 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeComment(req *types.MiniSetUserLi @@ -183,7 +183,7 @@ func (l *MiniSetUserLikeLogic) cancelSetUserLikeComment(req *types.MiniSetUserLi
183 183
184 // 删除点赞评论消息 184 // 删除点赞评论消息
185 var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx) 185 var messageLogic = message.NewMiniBusinessLogic(l.ctx, l.svcCtx)
186 - err = messageLogic.UnLikeComment(c, commentInfo.ArticleId, commentInfo.Id) 186 + err = messageLogic.UnLikeComment(c, commentInfo.ArticleId, commentInfo.Id, commentInfo.FromUserId)
187 if err != nil { 187 if err != nil {
188 return err 188 return err
189 } 189 }
@@ -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"
@@ -85,6 +86,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU @@ -85,6 +86,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
85 if err != nil { 86 if err != nil {
86 return nil, err 87 return nil, err
87 } 88 }
  89 +
88 //检查文章可被哪些人查看 90 //检查文章可被哪些人查看
89 whoRead, err := l.validateAndGetWhoRead(req, article) 91 whoRead, err := l.validateAndGetWhoRead(req, article)
90 if err != nil { 92 if err != nil {
@@ -115,19 +117,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU @@ -115,19 +117,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
115 //文章内容 117 //文章内容
116 articleSections := l.getSections(req, article) 118 articleSections := l.getSections(req, article)
117 //设置内容概要 119 //设置内容概要
118 - if len(req.Section) > 0 {  
119 - // 截取内容 50个字  
120 - runeNumber := 0 //字数  
121 - stringIndex := 0 //字符串长度  
122 - for i := range req.Section[0].Content {  
123 - if runeNumber > 50 {  
124 - break  
125 - }  
126 - runeNumber += 1  
127 - stringIndex = i  
128 - }  
129 - article.Summary = req.Section[0].Content[0:stringIndex]  
130 - } 120 + article.SetSummary(articleSections)
131 121
132 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 {
133 _, err = l.svcCtx.ArticleRepository.Update(l.ctx, c, article) 123 _, err = l.svcCtx.ArticleRepository.Update(l.ctx, c, article)
@@ -198,8 +188,8 @@ func (l *SystemUpdateArticleLogic) validateTextLimit(req *types.SystemArticleUpd @@ -198,8 +188,8 @@ func (l *SystemUpdateArticleLogic) validateTextLimit(req *types.SystemArticleUpd
198 num := utf8.RuneCountInString(req.Section[i].Content) 188 num := utf8.RuneCountInString(req.Section[i].Content)
199 wordNum += num 189 wordNum += num
200 } 190 }
201 - if wordNum >= 1000 {  
202 - return xerr.NewErrMsg("最多只能输入1000字") 191 + if wordNum > 1000 {
  192 + return xerr.NewErrMsg("内容最多只能输入1000字")
203 } 193 }
204 return nil 194 return nil
205 } 195 }
@@ -40,7 +40,7 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr @@ -40,7 +40,7 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr
40 } 40 }
41 41
42 var userList []*domain.User 42 var userList []*domain.User
43 - if len(articleInfo.WhoRead) == 0 { 43 + if articleInfo.TargetUser == domain.ArticleTargetAll {
44 //获取所有人 44 //获取所有人
45 queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("companyId", articleInfo.CompanyId) 45 queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("companyId", articleInfo.CompanyId)
46 _, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption) 46 _, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
@@ -49,6 +49,7 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr @@ -49,6 +49,7 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr
49 return resp, nil 49 return resp, nil
50 } 50 }
51 } else { 51 } else {
  52 + if len(articleInfo.WhoRead) > 0 {
52 queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("ids", articleInfo.WhoRead) 53 queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("ids", articleInfo.WhoRead)
53 _, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption) 54 _, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
54 if err != nil { 55 if err != nil {
@@ -56,13 +57,13 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr @@ -56,13 +57,13 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr
56 return resp, nil 57 return resp, nil
57 } 58 }
58 } 59 }
59 - 60 + }
60 uList := make([]types.CommentAtWho, len(userList)) 61 uList := make([]types.CommentAtWho, len(userList))
61 -  
62 for i := range userList { 62 for i := range userList {
63 uList[i] = types.CommentAtWho{ 63 uList[i] = types.CommentAtWho{
64 Id: userList[i].Id, 64 Id: userList[i].Id,
65 Name: userList[i].Name, 65 Name: userList[i].Name,
  66 + Avatar: userList[i].Avatar,
66 FirstLetter: "", 67 FirstLetter: "",
67 } 68 }
68 for _, val := range userList[i].PinYinName { 69 for _, val := range userList[i].PinYinName {
@@ -96,8 +96,10 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini @@ -96,8 +96,10 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
96 if err != nil { 96 if err != nil {
97 return nil, xerr.NewErrMsgErr("检查@的人员失败", err) 97 return nil, xerr.NewErrMsgErr("检查@的人员失败", err)
98 } 98 }
99 - if len(atWhoIds) != len(atWhoList) {  
100 - return nil, xerr.NewErrMsg("检查@的人员失败") 99 + for _, val := range atWhoList {
  100 + if val.CompanyId != req.CompanyId {
  101 + return nil, xerr.NewErrMsgErr("检查@的人员失败", err)
  102 + }
101 } 103 }
102 } 104 }
103 // 处理文本内容 105 // 处理文本内容
@@ -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
@@ -15,6 +16,7 @@ type MiniTop5ArticleCommentLogic struct { @@ -15,6 +16,7 @@ type MiniTop5ArticleCommentLogic struct {
15 logx.Logger 16 logx.Logger
16 ctx context.Context 17 ctx context.Context
17 svcCtx *svc.ServiceContext 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 {
@@ -22,6 +24,7 @@ func NewMiniTop5ArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCont @@ -22,6 +24,7 @@ func NewMiniTop5ArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCont
22 Logger: logx.WithContext(ctx), 24 Logger: logx.WithContext(ctx),
23 ctx: ctx, 25 ctx: ctx,
24 svcCtx: svcCtx, 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,
@@ -36,7 +36,32 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System @@ -36,7 +36,32 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System
36 if commetInfo.CompanyId != req.CompanyId { 36 if commetInfo.CompanyId != req.CompanyId {
37 return nil, xerr.NewErrMsg("没有操作权限") 37 return nil, xerr.NewErrMsg("没有操作权限")
38 } 38 }
  39 + {
  40 + //检查运营点赞的值
  41 + //查找对应的文章
  42 + articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, commetInfo.ArticleId)
  43 + if err != nil {
  44 + return nil, xerr.NewErrMsgErr("没有找到对应的文章", err)
  45 + }
  46 + var maxCount int
  47 + //获取文章可以被多少人查看
  48 + if articleInfo.TargetUser == domain.ArticleTargetLimit {
  49 + maxCount = commetInfo.MaxCountAdminLove(len(articleInfo.WhoRead))
  50 + } else {
  51 + //统计全员人数
  52 + queryOption := domain.NewQueryOptions().WithCountOnly().MustWithKV("companyId", req.CompanyId)
  53 + cnt, _, err := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
  54 + if err != nil {
  55 + return nil, xerr.NewErrMsgErr("获取人员数据失败", err)
  56 + }
  57 + maxCount = commetInfo.MaxCountAdminLove(int(cnt))
  58 + }
  59 + if maxCount < req.CountAdminLove {
  60 + return nil, xerr.NewErrMsg("运营点数设置错误")
  61 + }
  62 + }
39 commetInfo.CountAdminLove = req.CountAdminLove 63 commetInfo.CountAdminLove = req.CountAdminLove
  64 + commetInfo.Content = req.Content
40 var increaseCount int 65 var increaseCount int
41 switch req.Show { 66 switch req.Show {
42 case 1: 67 case 1:
@@ -52,7 +77,7 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System @@ -52,7 +77,7 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System
52 increaseCount = -1 77 increaseCount = -1
53 } 78 }
54 } 79 }
55 - commetInfo.Show = domain.CommentShowEnable 80 +
56 // 变更回复数量 81 // 变更回复数量
57 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 {
58 _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo) 83 _, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo)
@@ -47,6 +47,35 @@ func (l *SystemEditAticleCommentLoveLogic) SystemEditAticleCommentLove(req *type @@ -47,6 +47,35 @@ func (l *SystemEditAticleCommentLoveLogic) SystemEditAticleCommentLove(req *type
47 if err != nil { 47 if err != nil {
48 return nil, xerr.NewErrMsgErr("编辑评论信息失败", err) 48 return nil, xerr.NewErrMsgErr("编辑评论信息失败", err)
49 } 49 }
  50 +
  51 + for _, commetInfo := range commetList {
  52 + //检查运营点赞的值
  53 + //查找对应的文章
  54 + articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, commetInfo.ArticleId)
  55 + if err != nil {
  56 + return nil, xerr.NewErrMsgErr("没有找到对应的文章", err)
  57 + }
  58 + var maxCount int
  59 + //获取文章可以被多少人查看
  60 + if articleInfo.TargetUser == domain.ArticleTargetLimit {
  61 + maxCount = commetInfo.MaxCountAdminLove(len(articleInfo.WhoRead))
  62 + } else {
  63 + //统计全员人数
  64 + queryOption := domain.NewQueryOptions().WithCountOnly().MustWithKV("companyId", req.CompanyId)
  65 + cnt, _, err := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
  66 + if err != nil {
  67 + return nil, xerr.NewErrMsgErr("获取人员数据失败", err)
  68 + }
  69 + maxCount = commetInfo.MaxCountAdminLove(int(cnt))
  70 + }
  71 +
  72 + if paramCountData, ok := paramMap[commetInfo.Id]; ok {
  73 + if maxCount < paramCountData {
  74 + return nil, xerr.NewErrMsg("运营点数设置错误")
  75 + }
  76 + }
  77 + }
  78 + // 更新运营点赞数
50 resp = &types.SystemEditCommentLoveResponse{} 79 resp = &types.SystemEditCommentLoveResponse{}
51 for _, val := range commetList { 80 for _, val := range commetList {
52 if val.CompanyId != req.CompanyId { 81 if val.CompanyId != req.CompanyId {
@@ -248,13 +248,13 @@ func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64, @@ -248,13 +248,13 @@ func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64,
248 } 248 }
249 249
250 // UnLikeArticle 取消点赞文章 250 // UnLikeArticle 取消点赞文章
251 -func (l *MiniBusinessLogic) UnLikeArticle(conn transaction.Conn, articleId int64) (err error) {  
252 - return l.deleteMessage(conn, domain.OptTypeArticle, articleId, 0) 251 +func (l *MiniBusinessLogic) UnLikeArticle(conn transaction.Conn, articleId int64, recipientId int64) (err error) {
  252 + return l.deleteMessage(conn, domain.OptTypeArticle, articleId, 0, recipientId)
253 } 253 }
254 254
255 // UnLikeComment 取消点赞评论 255 // UnLikeComment 取消点赞评论
256 -func (l *MiniBusinessLogic) UnLikeComment(conn transaction.Conn, articleId int64, commentId int64) (err error) {  
257 - return l.deleteMessage(conn, domain.OptTypeComment, articleId, commentId) 256 +func (l *MiniBusinessLogic) UnLikeComment(conn transaction.Conn, articleId int64, commentId int64, recipientId int64) (err error) {
  257 + return l.deleteMessage(conn, domain.OptTypeComment, articleId, commentId, recipientId)
258 } 258 }
259 259
260 func (l *MiniBusinessLogic) createMessage( 260 func (l *MiniBusinessLogic) createMessage(
@@ -287,14 +287,14 @@ func (l *MiniBusinessLogic) createMessage( @@ -287,14 +287,14 @@ func (l *MiniBusinessLogic) createMessage(
287 return nil 287 return nil
288 } 288 }
289 289
290 -func (l *MiniBusinessLogic) deleteMessage(conn transaction.Conn, optType domain.MsgBusinessOpt, articleId int64, commentId int64) (err error) { 290 +func (l *MiniBusinessLogic) deleteMessage(conn transaction.Conn, optType domain.MsgBusinessOpt, articleId int64, commentId int64, recipientId int64) (err error) {
291 var userToken = contextdata.GetUserTokenFromCtx(l.ctx) 291 var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
292 292
293 queryOption := domain.NewQueryOptions().WithFindOnly().WithOffsetLimit(1, 1). 293 queryOption := domain.NewQueryOptions().WithFindOnly().WithOffsetLimit(1, 1).
294 MustWithKV("type", domain.MsgTypeLike). 294 MustWithKV("type", domain.MsgTypeLike).
295 MustWithKV("optType", optType). 295 MustWithKV("optType", optType).
296 MustWithKV("companyId", userToken.CompanyId). 296 MustWithKV("companyId", userToken.CompanyId).
297 - MustWithKV("recipientId", userToken.UserId). 297 + MustWithKV("recipientId", recipientId).
298 MustWithKV("articleId", articleId). 298 MustWithKV("articleId", articleId).
299 MustWithKV("commentId", commentId) 299 MustWithKV("commentId", commentId)
300 300
  1 +package user
  2 +
  3 +import (
  4 + "context"
  5 + "github.com/samber/lo"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  9 +
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  12 +
  13 + "github.com/zeromicro/go-zero/core/logx"
  14 +)
  15 +
  16 +type MiniUserMyFollowingNewsLogic struct {
  17 + logx.Logger
  18 + ctx context.Context
  19 + svcCtx *svc.ServiceContext
  20 +}
  21 +
  22 +func NewMiniUserMyFollowingNewsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUserMyFollowingNewsLogic {
  23 + return &MiniUserMyFollowingNewsLogic{
  24 + Logger: logx.WithContext(ctx),
  25 + ctx: ctx,
  26 + svcCtx: svcCtx,
  27 + }
  28 +}
  29 +
  30 +func (l *MiniUserMyFollowingNewsLogic) MiniUserMyFollowingNews(req *types.MiniUserNewsRequest) (resp *types.MiniUserNewsResposne, err error) {
  31 + var (
  32 + conn = l.svcCtx.DefaultDBConn()
  33 + user *domain.User
  34 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  35 + articles []*domain.Article
  36 + readArticles = make([]*domain.UserReadArticle, 0)
  37 + userMap = make(map[int64]*domain.User)
  38 + )
  39 + if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil {
  40 + return nil, xerr.NewErrMsgErr("用户不存在", err)
  41 + }
  42 + var (
  43 + users = user.Following
  44 + )
  45 + if req.AuthorId > 0 {
  46 + users = []int64{req.AuthorId}
  47 + }
  48 + if _, articles, err = l.svcCtx.ArticleRepository.FindAuthorsLatestArticle(l.ctx, conn, user.CompanyId, users, user.Id, req.LastArticleId, req.Size); err != nil {
  49 + return nil, xerr.NewErrMsgErr("获取快讯异常", err)
  50 + }
  51 + resp = &types.MiniUserNewsResposne{
  52 + List: make([]types.UserNewsItem, 0),
  53 + }
  54 + articleIds := domain.Values(articles, func(item *domain.Article) int64 {
  55 + return item.Id
  56 + })
  57 + if len(articleIds) > 0 {
  58 + resp.LastArticleId = articleIds[len(articleIds)-1]
  59 + _, readArticles, _ = l.svcCtx.UserReadArticleRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().WithFindOnly().WithKV("articleIds", articleIds))
  60 + }
  61 + readArticlesMap := lo.KeyBy(readArticles, func(item *domain.UserReadArticle) int64 {
  62 + return item.ArticleId
  63 + })
  64 + lo.ForEach(articles, func(item *domain.Article, index int) {
  65 + newsItem := types.UserNewsItem{
  66 + NewsId: item.Id,
  67 + Type: "article",
  68 + Title: item.Title,
  69 + Summary: item.Summary,
  70 + Time: item.CreatedAt,
  71 + Images: make([]string, 0),
  72 + ReadFlag: false,
  73 + }
  74 + if author, _ := domain.LazyLoad(userMap, l.ctx, conn, item.AuthorId, l.svcCtx.UserRepository.FindOne); author != nil {
  75 + newsItem.Author = types.UserItem{
  76 + Id: author.Id,
  77 + Name: author.Name,
  78 + Avatar: lo.ToPtr(author.Avatar),
  79 + }
  80 + }
  81 + for _, img := range item.Images {
  82 + newsItem.Images = append(newsItem.Images, img.Url)
  83 + }
  84 + if _, ok := readArticlesMap[item.Id]; ok {
  85 + newsItem.ReadFlag = true
  86 + }
  87 + resp.List = append(resp.List, newsItem)
  88 + })
  89 + return
  90 +}
@@ -39,15 +39,7 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp * @@ -39,15 +39,7 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp *
39 if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil { 39 if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil {
40 return nil, xerr.NewErrMsgErr("用户不存在", err) 40 return nil, xerr.NewErrMsgErr("用户不存在", err)
41 } 41 }
42 - var (  
43 - users = user.Following  
44 - )  
45 - if req.AuthorId > 0 {  
46 - users = []int64{req.AuthorId}  
47 - } else {  
48 - users = append(users, user.Id)  
49 - }  
50 - if _, articles, err = l.svcCtx.ArticleRepository.FindAuthorsLatestArticle(l.ctx, conn, user.CompanyId, users, user.Id, req.LastArticleId, req.Size); err != nil { 42 + if _, articles, err = l.svcCtx.ArticleRepository.FindLatestAccessibleArticle(l.ctx, conn, user.CompanyId, user.Id, req.LastArticleId, req.Size); err != nil {
51 return nil, xerr.NewErrMsgErr("获取快讯异常", err) 43 return nil, xerr.NewErrMsgErr("获取快讯异常", err)
52 } 44 }
53 resp = &types.MiniUserNewsResposne{ 45 resp = &types.MiniUserNewsResposne{
@@ -58,7 +50,7 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp * @@ -58,7 +50,7 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp *
58 }) 50 })
59 if len(articleIds) > 0 { 51 if len(articleIds) > 0 {
60 resp.LastArticleId = articleIds[len(articleIds)-1] 52 resp.LastArticleId = articleIds[len(articleIds)-1]
61 - _, readArticles, _ = l.svcCtx.UserReadArticleRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().WithKV("articleIds", articleIds)) 53 + _, readArticles, _ = l.svcCtx.UserReadArticleRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().WithFindOnly().WithKV("articleIds", articleIds))
62 } 54 }
63 readArticlesMap := lo.KeyBy(readArticles, func(item *domain.UserReadArticle) int64 { 55 readArticlesMap := lo.KeyBy(readArticles, func(item *domain.UserReadArticle) int64 {
64 return item.ArticleId 56 return item.ArticleId
@@ -34,6 +34,7 @@ type MiniCreateArticleCommentRequest struct { @@ -34,6 +34,7 @@ type MiniCreateArticleCommentRequest struct {
34 34
35 type CommentAtWho struct { 35 type CommentAtWho struct {
36 Id int64 `json:"id"` 36 Id int64 `json:"id"`
  37 + Avatar string `json:"avatar,optional"` // 人员头像URL
37 Name string `json:"name,optional"` 38 Name string `json:"name,optional"`
38 FirstLetter string `json:"firstLetter,optional"` 39 FirstLetter string `json:"firstLetter,optional"`
39 } 40 }
@@ -268,6 +269,7 @@ type SystemEditCommentRequest struct { @@ -268,6 +269,7 @@ type SystemEditCommentRequest struct {
268 CompanyId int64 `json:",optional"` 269 CompanyId int64 `json:",optional"`
269 Id int64 `json:"id"` 270 Id int64 `json:"id"`
270 Show int `json:"show"` //[1 显示评论] [2: 隐藏评论] 271 Show int `json:"show"` //[1 显示评论] [2: 隐藏评论]
  272 + Content string `json:"content,optional"`
271 CountAdminLove int `json:"countAdminLove,optional"` 273 CountAdminLove int `json:"countAdminLove,optional"`
272 } 274 }
273 275
@@ -1315,6 +1317,7 @@ type MiniSearchArticleResponse struct { @@ -1315,6 +1317,7 @@ type MiniSearchArticleResponse struct {
1315 type MiniSearchArticleItem struct { 1317 type MiniSearchArticleItem struct {
1316 ArticleId int64 `json:"articleId"` 1318 ArticleId int64 `json:"articleId"`
1317 Title string `json:"title"` 1319 Title string `json:"title"`
  1320 + AuthorId int64 `json:"authorId"`
1318 Author string `json:"author"` // 发布人 1321 Author string `json:"author"` // 发布人
1319 Avatar string `json:"avatar"` // 发布人的头像 1322 Avatar string `json:"avatar"` // 发布人的头像
1320 Images []string `json:"images"` 1323 Images []string `json:"images"`
@@ -164,6 +164,47 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. @@ -164,6 +164,47 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.
164 return total, dms, nil 164 return total, dms, nil
165 } 165 }
166 166
  167 +// FindLatestAccessibleArticle 最新可访问的文章
  168 +func (repository *ArticleRepository) FindLatestAccessibleArticle(ctx context.Context, conn transaction.Conn,
  169 + companyId int64, whoRead int64, lastId int64, limit int) (int64, []*domain.Article, error) {
  170 + var (
  171 + tx = conn.DB()
  172 + ms []*models.Article
  173 + dms = make([]*domain.Article, 0)
  174 + total int64
  175 + )
  176 + queryFunc := func() (interface{}, error) {
  177 + tx = tx.Model(&ms).
  178 + Where("company_id=?", companyId).
  179 + Where(fmt.Sprintf("author_id = %d or target_user=0 or who_read @>'[%d]'", whoRead, whoRead)).
  180 + Where("show = 1")
  181 + if lastId > 0 {
  182 + tx.Where("id < ?", lastId)
  183 + }
  184 + tx.Order("id desc")
  185 + if limit > 0 {
  186 + tx.Limit(limit)
  187 + }
  188 + if total, tx = transaction.PaginationAndCount(ctx, tx, domain.NewQueryOptions().WithFindOnly(), &ms); tx.Error != nil {
  189 + return dms, tx.Error
  190 + }
  191 + return dms, nil
  192 + }
  193 +
  194 + if _, err := repository.Query(queryFunc); err != nil {
  195 + return 0, nil, err
  196 + }
  197 +
  198 + for _, item := range ms {
  199 + if dm, err := repository.ModelToDomainModel(item); err != nil {
  200 + return 0, dms, err
  201 + } else {
  202 + dms = append(dms, dm)
  203 + }
  204 + }
  205 + return total, dms, nil
  206 +}
  207 +
167 // FindAuthorsLatestArticle 作者最新的文章 208 // FindAuthorsLatestArticle 作者最新的文章
168 func (repository *ArticleRepository) FindAuthorsLatestArticle(ctx context.Context, conn transaction.Conn, 209 func (repository *ArticleRepository) FindAuthorsLatestArticle(ctx context.Context, conn transaction.Conn,
169 companyId int64, authors []int64, whoRead int64, lastId int64, limit int) (int64, []*domain.Article, error) { 210 companyId int64, authors []int64, whoRead int64, lastId int64, limit int) (int64, []*domain.Article, error) {
@@ -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 )
@@ -43,6 +44,7 @@ type ArticleRepository interface { @@ -43,6 +44,7 @@ type ArticleRepository interface {
43 FindAuthorsLatestFirstArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, limit int) (int64, []*Article, error) 44 FindAuthorsLatestFirstArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, limit int) (int64, []*Article, error)
44 FindAuthorsLatestFirstUnreadArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, limit int) (int64, []*Article, error) 45 FindAuthorsLatestFirstUnreadArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, limit int) (int64, []*Article, error)
45 FindAuthorsLatestArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, lastId int64, limit int) (int64, []*Article, error) 46 FindAuthorsLatestArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, lastId int64, limit int) (int64, []*Article, error)
  47 + FindLatestAccessibleArticle(ctx context.Context, conn transaction.Conn, companyId int64, whoRead int64, lastId int64, limit int) (int64, []*Article, error)
46 IncreaseCountLove(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //点赞数量变动 48 IncreaseCountLove(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //点赞数量变动
47 IncreaseCountComment(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //评论数量变动 49 IncreaseCountComment(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //评论数量变动
48 IncreaseCountRead(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //浏览数量变动 50 IncreaseCountRead(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //浏览数量变动
@@ -118,6 +120,7 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar @@ -118,6 +120,7 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar
118 WhoReview: m.WhoReview, 120 WhoReview: m.WhoReview,
119 Tags: m.Tags, 121 Tags: m.Tags,
120 MatchUrl: map[string]string{}, 122 MatchUrl: map[string]string{},
  123 + Location: m.Location,
121 } 124 }
122 copy(b.Videos, m.Videos) 125 copy(b.Videos, m.Videos)
123 copy(b.Images, m.Images) 126 copy(b.Images, m.Images)
@@ -126,3 +129,30 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar @@ -126,3 +129,30 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar
126 } 129 }
127 return &b 130 return &b
128 } 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
@@ -81,3 +81,14 @@ type ArticleCommentRepository interface { @@ -81,3 +81,14 @@ type ArticleCommentRepository interface {
81 CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int, 81 CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int,
82 topId int64, articleTitle string, contentLike string, fromUserId int64, show int, createdAtRange [2]int64) (int, []*ArticleCommentShow, error) 82 topId int64, articleTitle string, contentLike string, fromUserId int64, show int, createdAtRange [2]int64) (int, []*ArticleCommentShow, error)
83 } 83 }
  84 +
  85 +// 运营点数 填写的最大值
  86 +func (m *ArticleComment) MaxCountAdminLove(articleWhoRead int) int {
  87 + // 帖子的可见人数/3向上取整
  88 + x := articleWhoRead / 3 // 取商
  89 + y := articleWhoRead % 3 // 取余
  90 + if y > 0 {
  91 + x = x + 1
  92 + }
  93 + return x
  94 +}
  1 +#!/bin/bash
  2 +export PATH=/root/local/bin:$PATH
  3 +kubectl -n mmm-suplus-test get pods | grep -q sumifcc-discuss
  4 +if [ "$?" == "1" ];then
  5 + kubectl create -f /tmp/test/sumifcc-discuss/sumifcc-discuss.yaml --record
  6 + kubectl -n mmm-suplus-test get svc | grep -q sumifcc-discuss
  7 + if [ "$?" == "0" ];then
  8 + echo "sumifcc-discuss service install success!"
  9 + else
  10 + echo "sumifcc-discuss service install fail!"
  11 + fi
  12 + kubectl -n mmm-suplus-test get pods | grep -q sumifcc-discuss
  13 + if [ "$?" == "0" ];then
  14 + echo "sumifcc-discuss deployment install success!"
  15 + else
  16 + echo "sumifcc-discuss deployment install fail!"
  17 + fi
  18 +else
  19 + kubectl delete -f /tmp/test/sumifcc-discuss/sumifcc-discuss.yaml
  20 + kubectl -n mmm-suplus-test get svc | grep -q sumifcc-discuss
  21 + while [ "$?" == "0" ]
  22 + do
  23 + kubectl -n mmm-suplus-test get svc | grep -q sumifcc-discuss
  24 + done
  25 + kubectl -n mmm-suplus-test get pods | grep -q sumifcc-discuss
  26 + while [ "$?" == "0" ]
  27 + do
  28 + kubectl -n mmm-suplus-test get pods | grep -q sumifcc-discuss
  29 + done
  30 + kubectl create -f /tmp/test/sumifcc-discuss/sumifcc-discuss.yaml --record
  31 + kubectl -n mmm-suplus-test get svc | grep -q sumifcc-discuss
  32 + if [ "$?" == "0" ];then
  33 + echo "sumifcc-discuss service update success!"
  34 + else
  35 + echo "sumifcc-discuss service update fail!"
  36 + fi
  37 + kubectl -n mmm-suplus-test get pods | grep -q sumifcc-discuss
  38 + if [ "$?" == "0" ];then
  39 + echo "sumifcc-discuss deployment update success!"
  40 + else
  41 + echo "sumifcc-discuss deployment update fail!"
  42 + fi
  43 +fi
  1 +apiVersion: v1
  2 +kind: Service
  3 +metadata:
  4 + name: sumifcc-discuss
  5 + namespace: mmm-suplus-test
  6 + labels:
  7 + k8s-app: sumifcc-discuss
  8 +spec:
  9 + ports:
  10 + - name: "http"
  11 + port: 80
  12 + targetPort: 8081
  13 + - name: "https"
  14 + port: 443
  15 + targetPort: 443
  16 + selector:
  17 + k8s-app: sumifcc-discuss
  18 +---
  19 +apiVersion: extensions/v1beta1
  20 +kind: Deployment
  21 +metadata:
  22 + name: sumifcc-discuss
  23 + namespace: mmm-suplus-test
  24 + labels:
  25 + k8s-app: sumifcc-discuss
  26 +spec:
  27 + replicas: 1
  28 + template:
  29 + metadata:
  30 + labels:
  31 + k8s-app: sumifcc-discuss
  32 + spec:
  33 + affinity:
  34 + nodeAffinity:
  35 + preferredDuringSchedulingIgnoredDuringExecution:
  36 + - preference: {}
  37 + weight: 100
  38 + requiredDuringSchedulingIgnoredDuringExecution:
  39 + nodeSelectorTerms:
  40 + - matchExpressions:
  41 + - key: kubernetes.io/hostname
  42 + operator: In
  43 + values:
  44 + - cn-hangzhou.i-bp1djh1xn7taumbue1ze
  45 +
  46 + containers:
  47 + - name: sumifcc-discuss
  48 + image: 192.168.0.243:5000/mmm/sumifcc-discuss:dev
  49 + imagePullPolicy: Always
  50 + ports:
  51 + - containerPort: 8081
  52 + - containerPort: 443
  53 + volumeMounts:
  54 + - mountPath: /opt/logs
  55 + name: accesslogs
  56 + env:
  57 + - name: LOG_LEVEL
  58 + value: "debug"
  59 + - name: LOG_FILE
  60 + value: "true"
  61 + - name: REDIS_HOST
  62 + valueFrom:
  63 + configMapKeyRef:
  64 + name: suplus-config
  65 + key: redis.ip
  66 + - name: REDIS_PORT
  67 + valueFrom:
  68 + configMapKeyRef:
  69 + name: suplus-config
  70 + key: redis.port
  71 + volumes:
  72 + - name: accesslogs
  73 + emptyDir: {}
  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 +