正在显示
21 个修改的文件
包含
162 行增加
和
81 行删除
@@ -306,10 +306,10 @@ type ( | @@ -306,10 +306,10 @@ type ( | ||
306 | CompanyId int64 `json:",optional"` // 公司id | 306 | CompanyId int64 `json:",optional"` // 公司id |
307 | UserId int64 `json:",optional"` // 公司id | 307 | UserId int64 `json:",optional"` // 公司id |
308 | ArticleId int64 `json:"articleId"` // 文章id | 308 | ArticleId int64 `json:"articleId"` // 文章id |
309 | - TagId int64 `json:"tagId"` // 标签id | 309 | + TagId []int64 `json:"tagId"` // 标签id |
310 | } | 310 | } |
311 | MiniArticleSetTagResponse { | 311 | MiniArticleSetTagResponse { |
312 | - Id int64 `json:"id"` | 312 | + Id []int64 `json:"id"` |
313 | } | 313 | } |
314 | ) | 314 | ) |
315 | 315 |
@@ -188,7 +188,8 @@ type( | @@ -188,7 +188,8 @@ type( | ||
188 | Phone string `json:"phone,omitempty"` // 手机号 唯一 | 188 | Phone string `json:"phone,omitempty"` // 手机号 唯一 |
189 | Position string `json:"position,omitempty"` // 职位 | 189 | Position string `json:"position,omitempty"` // 职位 |
190 | Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用 | 190 | Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用 |
191 | - AuditStatus *int `json:"auditStatus,omitempty"` // 审核状态 0:待审核 1:审核通过 2:拒绝 | 191 | + AuditStatus *int `json:"auditStatus,omitempty"` // 审核状态 0:待审核 1:审核通过 2:拒绝 |
192 | + AuditAt int64 `json:"auditAt,omitempty"` // 审核时间 | ||
192 | Follower []int64 `json:"followers,omitempty"` // 关注我的人 (冗余) | 193 | Follower []int64 `json:"followers,omitempty"` // 关注我的人 (冗余) |
193 | Following []int64 `json:"following,omitempty"` // 我关注的人 (冗余) | 194 | Following []int64 `json:"following,omitempty"` // 我关注的人 (冗余) |
194 | Departments []int64 `json:"departments,omitempty"` // 所属部门 | 195 | Departments []int64 `json:"departments,omitempty"` // 所属部门 |
@@ -31,8 +31,7 @@ func (l *MiniArticleBackupSearchLogic) MiniArticleBackupSearch(req *types.MiniAr | @@ -31,8 +31,7 @@ func (l *MiniArticleBackupSearchLogic) MiniArticleBackupSearch(req *types.MiniAr | ||
31 | 31 | ||
32 | queryOption := domain.NewQueryOptions(). | 32 | queryOption := domain.NewQueryOptions(). |
33 | WithOffsetLimit(req.Page, req.Size). | 33 | WithOffsetLimit(req.Page, req.Size). |
34 | - MustWithKV("article_id", req.ArticleId). | ||
35 | - MustWithKV("company_id", req.CompanyId) | 34 | + MustWithKV("articleId", req.ArticleId) |
36 | 35 | ||
37 | cnt, backupList, err := l.svcCtx.ArticleBackupRepository.Find(l.ctx, conn, queryOption) | 36 | cnt, backupList, err := l.svcCtx.ArticleBackupRepository.Find(l.ctx, conn, queryOption) |
38 | if err != nil { | 37 | if err != nil { |
@@ -2,6 +2,7 @@ package article | @@ -2,6 +2,7 @@ package article | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | + | ||
5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message" |
6 | 7 | ||
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
@@ -38,32 +39,37 @@ func (l *MiniArticleSetTagLogic) MiniArticleSetTag(req *types.MiniArticleSetTagR | @@ -38,32 +39,37 @@ func (l *MiniArticleSetTagLogic) MiniArticleSetTag(req *types.MiniArticleSetTagR | ||
38 | if articleInfo.CompanyId != req.CompanyId { | 39 | if articleInfo.CompanyId != req.CompanyId { |
39 | return nil, xerr.NewErrMsg("获取文章信息失败") | 40 | return nil, xerr.NewErrMsg("获取文章信息失败") |
40 | } | 41 | } |
41 | - | ||
42 | - tagInfo, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, req.TagId) | ||
43 | - if err != nil { | ||
44 | - return nil, xerr.NewErrMsgErr("获取标签信息失败", err) | ||
45 | - } | ||
46 | - | ||
47 | - if tagInfo.CompanyId != req.CompanyId { | ||
48 | - return nil, xerr.NewErrMsg("获取标签信息失败") | 42 | + tagIdList := []int64{} |
43 | + // 额外保存一份ArticleAndTag | ||
44 | + var articleAndTagList []domain.ArticleAndTag | ||
45 | + for _, val := range req.TagId { | ||
46 | + tagInfo, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, val) | ||
47 | + if err != nil { | ||
48 | + return nil, xerr.NewErrMsgErr("获取标签信息失败", err) | ||
49 | + } | ||
50 | + if tagInfo.CompanyId != req.CompanyId { | ||
51 | + return nil, xerr.NewErrMsg("获取标签信息失败") | ||
52 | + } | ||
53 | + tagIdList = append(tagIdList, tagInfo.Id) | ||
54 | + articleAndTag := domain.ArticleAndTag{ | ||
55 | + Id: 0, | ||
56 | + CompanyId: articleInfo.CompanyId, | ||
57 | + CreatedAt: 0, | ||
58 | + UpdatedAt: 0, | ||
59 | + ArticleId: articleInfo.Id, | ||
60 | + TagId: tagInfo.Id, | ||
61 | + } | ||
62 | + articleAndTagList = append(articleAndTagList, articleAndTag) | ||
49 | } | 63 | } |
64 | + //更新article中的tags | ||
65 | + articleInfo.Tags = tagIdList | ||
50 | // 查询可能存在的 ArticleAndTag | 66 | // 查询可能存在的 ArticleAndTag |
51 | queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("articleId", articleInfo.Id) | 67 | queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("articleId", articleInfo.Id) |
52 | _, oldTags, err := l.svcCtx.ArticleAndTagRepository.Find(l.ctx, conn, queryOption) | 68 | _, oldTags, err := l.svcCtx.ArticleAndTagRepository.Find(l.ctx, conn, queryOption) |
53 | if err != nil { | 69 | if err != nil { |
54 | return nil, xerr.NewErrMsgErr("检查文章的标签失败", err) | 70 | return nil, xerr.NewErrMsgErr("检查文章的标签失败", err) |
55 | } | 71 | } |
56 | - // 更新article中的tags | ||
57 | - articleInfo.Tags = []int64{tagInfo.Id} | ||
58 | - // 额外保存一份ArticleAndTag | ||
59 | - articleAndTag := domain.ArticleAndTag{ | ||
60 | - Id: 0, | ||
61 | - CompanyId: articleInfo.CompanyId, | ||
62 | - CreatedAt: 0, | ||
63 | - UpdatedAt: 0, | ||
64 | - ArticleId: articleInfo.Id, | ||
65 | - TagId: tagInfo.Id, | ||
66 | - } | 72 | + // |
67 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | 73 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { |
68 | //清理可能存在的 ArticleAndTag | 74 | //清理可能存在的 ArticleAndTag |
69 | for _, v := range oldTags { | 75 | for _, v := range oldTags { |
@@ -77,11 +83,12 @@ func (l *MiniArticleSetTagLogic) MiniArticleSetTag(req *types.MiniArticleSetTagR | @@ -77,11 +83,12 @@ func (l *MiniArticleSetTagLogic) MiniArticleSetTag(req *types.MiniArticleSetTagR | ||
77 | if err != nil { | 83 | if err != nil { |
78 | return err | 84 | return err |
79 | } | 85 | } |
80 | - _, err = l.svcCtx.ArticleAndTagRepository.Insert(ctx, c, &articleAndTag) | ||
81 | - if err != nil { | ||
82 | - return err | 86 | + for i := range articleAndTagList { |
87 | + _, err = l.svcCtx.ArticleAndTagRepository.Insert(ctx, c, &articleAndTagList[i]) | ||
88 | + if err != nil { | ||
89 | + return err | ||
90 | + } | ||
83 | } | 91 | } |
84 | - | ||
85 | // 定性消息通知 | 92 | // 定性消息通知 |
86 | messageLogic := message.NewMiniSystemLogic(ctx, l.svcCtx) | 93 | messageLogic := message.NewMiniSystemLogic(ctx, l.svcCtx) |
87 | err = messageLogic.ArticleDefined(c, articleInfo.CompanyId, articleInfo.AuthorId, articleInfo.Title) | 94 | err = messageLogic.ArticleDefined(c, articleInfo.CompanyId, articleInfo.AuthorId, articleInfo.Title) |
@@ -93,7 +100,10 @@ func (l *MiniArticleSetTagLogic) MiniArticleSetTag(req *types.MiniArticleSetTagR | @@ -93,7 +100,10 @@ func (l *MiniArticleSetTagLogic) MiniArticleSetTag(req *types.MiniArticleSetTagR | ||
93 | }, true) | 100 | }, true) |
94 | 101 | ||
95 | resp = &types.MiniArticleSetTagResponse{ | 102 | resp = &types.MiniArticleSetTagResponse{ |
96 | - Id: articleAndTag.Id, | 103 | + Id: []int64{}, |
104 | + } | ||
105 | + for _, val := range articleAndTagList { | ||
106 | + resp.Id = append(resp.Id, val.Id) | ||
97 | } | 107 | } |
98 | return resp, nil | 108 | return resp, nil |
99 | } | 109 | } |
@@ -201,12 +201,12 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | @@ -201,12 +201,12 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | ||
201 | } | 201 | } |
202 | } | 202 | } |
203 | // 设置保存备份 | 203 | // 设置保存备份 |
204 | - backup := newArticle.MakeBackup(newArticle.Author, sectionList) | ||
205 | - backup.Action = "新增" | ||
206 | - _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, backup) | ||
207 | - if err != nil { | ||
208 | - return xerr.NewErrMsgErr("创建文章内容失败", err) | ||
209 | - } | 204 | + // backup := newArticle.MakeBackup(newArticle.Author, sectionList) |
205 | + // backup.Action = "新增" | ||
206 | + // _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, backup) | ||
207 | + // if err != nil { | ||
208 | + // return xerr.NewErrMsgErr("创建文章内容失败", err) | ||
209 | + // } | ||
210 | return nil | 210 | return nil |
211 | }, true) | 211 | }, true) |
212 | if err != nil { | 212 | if err != nil { |
@@ -38,7 +38,25 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | @@ -38,7 +38,25 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | ||
38 | if articleInfo.CompanyId != req.CompanyId { | 38 | if articleInfo.CompanyId != req.CompanyId { |
39 | return nil, xerr.NewErrMsg("没有查看权限") | 39 | return nil, xerr.NewErrMsg("没有查看权限") |
40 | } | 40 | } |
41 | - //TODO 检查可查看人 | 41 | + |
42 | + if len(articleInfo.WhoRead) > 0 { | ||
43 | + inWhoRead := false | ||
44 | + for _, val := range articleInfo.WhoRead { | ||
45 | + if req.UserId == int(val) { | ||
46 | + inWhoRead = true | ||
47 | + } | ||
48 | + } | ||
49 | + if !inWhoRead { | ||
50 | + // 文章内容不显示 | ||
51 | + resp = &types.MiniArticleGetResponse{ | ||
52 | + Id: articleInfo.Id, | ||
53 | + Title: articleInfo.Title, | ||
54 | + Show: int(domain.ArticleShowDisable), | ||
55 | + } | ||
56 | + return resp, nil | ||
57 | + } | ||
58 | + } | ||
59 | + | ||
42 | if articleInfo.Show == domain.ArticleShowDisable { | 60 | if articleInfo.Show == domain.ArticleShowDisable { |
43 | // 文章内容不显示 | 61 | // 文章内容不显示 |
44 | resp = &types.MiniArticleGetResponse{ | 62 | resp = &types.MiniArticleGetResponse{ |
@@ -81,6 +99,9 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | @@ -81,6 +99,9 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | ||
81 | 99 | ||
82 | follow, _ := l.svcCtx.UserFollowRepository.FindOneUserFollowing(l.ctx, conn, int64(req.UserId), articleInfo.AuthorId) | 100 | follow, _ := l.svcCtx.UserFollowRepository.FindOneUserFollowing(l.ctx, conn, int64(req.UserId), articleInfo.AuthorId) |
83 | 101 | ||
102 | + queryOption = domain.NewQueryOptions().WithFindOnly().WithOffsetLimit(1, 1).WithKV("articleId", articleInfo.Id) | ||
103 | + _, backupList, _ := l.svcCtx.ArticleBackupRepository.Find(l.ctx, conn, queryOption) | ||
104 | + | ||
84 | sortBy := domain.SortArticleSection(sectionList) | 105 | sortBy := domain.SortArticleSection(sectionList) |
85 | sort.Sort(sortBy) | 106 | sort.Sort(sortBy) |
86 | articleSection := []types.ArticleSection{} | 107 | articleSection := []types.ArticleSection{} |
@@ -124,7 +145,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | @@ -124,7 +145,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | ||
124 | Tags: tags, | 145 | Tags: tags, |
125 | MatchUrl: map[string]string{}, | 146 | MatchUrl: map[string]string{}, |
126 | } | 147 | } |
127 | - if articleInfo.CreatedAt != articleInfo.UpdatedAt { | 148 | + if len(backupList) > 0 { |
128 | resp.Edit = 1 | 149 | resp.Edit = 1 |
129 | } | 150 | } |
130 | 151 |
@@ -36,10 +36,30 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl | @@ -36,10 +36,30 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl | ||
36 | if err != nil { | 36 | if err != nil { |
37 | return nil, xerr.NewErrMsgErr("获取编辑历史记录失败", err) | 37 | return nil, xerr.NewErrMsgErr("获取编辑历史记录失败", err) |
38 | } | 38 | } |
39 | + //获取当前用户信息 | ||
40 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
41 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
42 | + if err != nil { | ||
43 | + return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
44 | + } | ||
39 | article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, backup.ArticleId) | 45 | article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, backup.ArticleId) |
40 | if err != nil { | 46 | if err != nil { |
41 | return nil, xerr.NewErrMsgErr("获取文章失败", err) | 47 | return nil, xerr.NewErrMsgErr("获取文章失败", err) |
42 | } | 48 | } |
49 | + _, sectionList, err := l.svcCtx.ArticleSectionRepository.Find(l.ctx, conn, map[string]interface{}{"articleId": article.Id}) | ||
50 | + if err != nil { | ||
51 | + return nil, xerr.NewErrMsgErr("获取文章段落内容失败", err) | ||
52 | + } | ||
53 | + // 备份数据 | ||
54 | + newBackUp := article.MakeBackup(domain.UserSimple{ | ||
55 | + Id: userToken.UserId, | ||
56 | + Name: userMe.User.NickName, | ||
57 | + Avatar: userMe.User.Avatar, | ||
58 | + CompanyId: userToken.CompanyId, | ||
59 | + Company: userMe.CurrentCompany.Name, | ||
60 | + }, sectionList) | ||
61 | + newBackUp.Action = "恢复" | ||
62 | + | ||
43 | article.Version = article.Version + 1 | 63 | article.Version = article.Version + 1 |
44 | article.Images = backup.Images | 64 | article.Images = backup.Images |
45 | article.Title = backup.Title | 65 | article.Title = backup.Title |
@@ -55,12 +75,7 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl | @@ -55,12 +75,7 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl | ||
55 | SortBy: item.SortBy, | 75 | SortBy: item.SortBy, |
56 | }) | 76 | }) |
57 | }) | 77 | }) |
58 | - //获取当前用户信息 | ||
59 | - userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
60 | - userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
61 | - if err != nil { | ||
62 | - return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
63 | - } | 78 | + |
64 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | 79 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { |
65 | //保存文章 | 80 | //保存文章 |
66 | _, err = l.svcCtx.ArticleRepository.Update(ctx, c, article) | 81 | _, err = l.svcCtx.ArticleRepository.Update(ctx, c, article) |
@@ -93,15 +108,7 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl | @@ -93,15 +108,7 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl | ||
93 | return xerr.NewErrMsgErr("保存文章内容失败", err) | 108 | return xerr.NewErrMsgErr("保存文章内容失败", err) |
94 | } | 109 | } |
95 | } | 110 | } |
96 | - //备份数据 | ||
97 | - newBackUp := article.MakeBackup(domain.UserSimple{ | ||
98 | - Id: userToken.UserId, | ||
99 | - Name: userMe.User.NickName, | ||
100 | - Avatar: userMe.User.Avatar, | ||
101 | - CompanyId: userToken.CompanyId, | ||
102 | - Company: userMe.CurrentCompany.Name, | ||
103 | - }, articleSections) | ||
104 | - newBackUp.Action = "恢复" | 111 | + |
105 | _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, newBackUp) | 112 | _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, newBackUp) |
106 | if err != nil { | 113 | if err != nil { |
107 | return xerr.NewErrMsgErr("恢复文章版本失败", err) | 114 | return xerr.NewErrMsgErr("恢复文章版本失败", err) |
@@ -42,11 +42,30 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -42,11 +42,30 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
42 | //TargetUser 设定为分发给所有人,清空 WhoRead | 42 | //TargetUser 设定为分发给所有人,清空 WhoRead |
43 | req.WhoRead = make([]int64, 0) | 43 | req.WhoRead = make([]int64, 0) |
44 | } | 44 | } |
45 | - | 45 | + // 获取当前用户信息 |
46 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
47 | + if err != nil { | ||
48 | + return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
49 | + } | ||
50 | + // 文章数据 | ||
46 | article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.Id) | 51 | article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.Id) |
47 | if err != nil { | 52 | if err != nil { |
48 | return nil, xerr.NewErrMsgErr("帖子不存在", err) | 53 | return nil, xerr.NewErrMsgErr("帖子不存在", err) |
49 | } | 54 | } |
55 | + _, sectionList, err := l.svcCtx.ArticleSectionRepository.Find(l.ctx, conn, map[string]interface{}{"articleId": article.Id}) | ||
56 | + if err != nil { | ||
57 | + return nil, xerr.NewErrMsgErr("获取文章段落内容失败", err) | ||
58 | + } | ||
59 | + //备份数据 | ||
60 | + backup := article.MakeBackup(domain.UserSimple{ | ||
61 | + Id: userToken.UserId, | ||
62 | + Name: userMe.User.NickName, | ||
63 | + Avatar: userMe.User.Avatar, | ||
64 | + CompanyId: userToken.CompanyId, | ||
65 | + Company: userMe.CurrentCompany.Name, | ||
66 | + }, sectionList) | ||
67 | + backup.Action = "编辑" | ||
68 | + | ||
50 | // 获取图片的尺寸大小 | 69 | // 获取图片的尺寸大小 |
51 | images := []domain.Image{} | 70 | images := []domain.Image{} |
52 | for _, val := range req.Images { | 71 | for _, val := range req.Images { |
@@ -166,11 +185,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -166,11 +185,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
166 | } | 185 | } |
167 | article.Summary = req.Section[0].Content[0:stringIndex] | 186 | article.Summary = req.Section[0].Content[0:stringIndex] |
168 | } | 187 | } |
169 | - //获取当前用户信息 | ||
170 | - userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
171 | - if err != nil { | ||
172 | - return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
173 | - } | 188 | + |
174 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | 189 | err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { |
175 | _, err = l.svcCtx.ArticleRepository.Update(l.ctx, c, article) | 190 | _, err = l.svcCtx.ArticleRepository.Update(l.ctx, c, article) |
176 | if err != nil { | 191 | if err != nil { |
@@ -207,15 +222,6 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -207,15 +222,6 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
207 | return xerr.NewErrMsgErr("保存文章内容失败", err) | 222 | return xerr.NewErrMsgErr("保存文章内容失败", err) |
208 | } | 223 | } |
209 | } | 224 | } |
210 | - //备份数据 | ||
211 | - backup := article.MakeBackup(domain.UserSimple{ | ||
212 | - Id: userToken.UserId, | ||
213 | - Name: userMe.User.NickName, | ||
214 | - Avatar: userMe.User.Avatar, | ||
215 | - CompanyId: userToken.CompanyId, | ||
216 | - Company: userMe.CurrentCompany.Name, | ||
217 | - }, articleSections) | ||
218 | - backup.Action = "编辑" | ||
219 | _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, backup) | 225 | _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, backup) |
220 | if err != nil { | 226 | if err != nil { |
221 | return xerr.NewErrMsgErr("保存文章内容失败", err) | 227 | return xerr.NewErrMsgErr("保存文章内容失败", err) |
@@ -47,7 +47,9 @@ func (l *MiniUserAuditListLogic) MiniUserAuditList(req *types.UserSearchRequest) | @@ -47,7 +47,9 @@ func (l *MiniUserAuditListLogic) MiniUserAuditList(req *types.UserSearchRequest) | ||
47 | resp = &types.UserSearchResponse{Total: total, List: make([]*types.UserItem, 0)} | 47 | resp = &types.UserSearchResponse{Total: total, List: make([]*types.UserItem, 0)} |
48 | lo.ForEach(users, func(item *domain.User, index int) { | 48 | lo.ForEach(users, func(item *domain.User, index int) { |
49 | company, _ := domain.LazyLoad(companyMap, l.ctx, conn, item.CompanyId, l.svcCtx.CompanyRepository.FindOne) | 49 | company, _ := domain.LazyLoad(companyMap, l.ctx, conn, item.CompanyId, l.svcCtx.CompanyRepository.FindOne) |
50 | - resp.List = append(resp.List, NewUserItemSimple(item, company)) | 50 | + userAudit := NewUserItemSimple(item, company) |
51 | + userAudit.AuditAt = lo.Ternary(item.AuditAt == 0, item.CreatedAt, item.AuditAt) | ||
52 | + resp.List = append(resp.List, userAudit) | ||
51 | }) | 53 | }) |
52 | 54 | ||
53 | return | 55 | return |
@@ -62,6 +62,7 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs | @@ -62,6 +62,7 @@ func (l *MiniUserDepartmentUsersLogic) MiniUserDepartmentUsers(req *types.MiniUs | ||
62 | Id: user.Id, | 62 | Id: user.Id, |
63 | Name: user.Name, | 63 | Name: user.Name, |
64 | PinYinName: user.PinYinName, | 64 | PinYinName: user.PinYinName, |
65 | + Avatar: user.Avatar, | ||
65 | }) | 66 | }) |
66 | } | 67 | } |
67 | } | 68 | } |
@@ -528,6 +528,7 @@ type UserItem struct { | @@ -528,6 +528,7 @@ type UserItem struct { | ||
528 | Position string `json:"position,omitempty"` // 职位 | 528 | Position string `json:"position,omitempty"` // 职位 |
529 | Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用 | 529 | Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用 |
530 | AuditStatus *int `json:"auditStatus,omitempty"` // 审核状态 0:待审核 1:审核通过 2:拒绝 | 530 | AuditStatus *int `json:"auditStatus,omitempty"` // 审核状态 0:待审核 1:审核通过 2:拒绝 |
531 | + AuditAt int64 `json:"auditAt,omitempty"` // 审核时间 | ||
531 | Follower []int64 `json:"followers,omitempty"` // 关注我的人 (冗余) | 532 | Follower []int64 `json:"followers,omitempty"` // 关注我的人 (冗余) |
532 | Following []int64 `json:"following,omitempty"` // 我关注的人 (冗余) | 533 | Following []int64 `json:"following,omitempty"` // 我关注的人 (冗余) |
533 | Departments []int64 `json:"departments,omitempty"` // 所属部门 | 534 | Departments []int64 `json:"departments,omitempty"` // 所属部门 |
@@ -1062,14 +1063,14 @@ type MiniArticleMarkItem struct { | @@ -1062,14 +1063,14 @@ type MiniArticleMarkItem struct { | ||
1062 | } | 1063 | } |
1063 | 1064 | ||
1064 | type MiniArticleSetTagRequest struct { | 1065 | type MiniArticleSetTagRequest struct { |
1065 | - CompanyId int64 `json:",optional"` // 公司id | ||
1066 | - UserId int64 `json:",optional"` // 公司id | ||
1067 | - ArticleId int64 `json:"articleId"` // 文章id | ||
1068 | - TagId int64 `json:"tagId"` // 标签id | 1066 | + CompanyId int64 `json:",optional"` // 公司id |
1067 | + UserId int64 `json:",optional"` // 公司id | ||
1068 | + ArticleId int64 `json:"articleId"` // 文章id | ||
1069 | + TagId []int64 `json:"tagId"` // 标签id | ||
1069 | } | 1070 | } |
1070 | 1071 | ||
1071 | type MiniArticleSetTagResponse struct { | 1072 | type MiniArticleSetTagResponse struct { |
1072 | - Id int64 `json:"id"` | 1073 | + Id []int64 `json:"id"` |
1073 | } | 1074 | } |
1074 | 1075 | ||
1075 | type MiniAllArticleTagRequest struct { | 1076 | type MiniAllArticleTagRequest struct { |
@@ -21,6 +21,7 @@ type Article struct { | @@ -21,6 +21,7 @@ type Article struct { | ||
21 | Author domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 发布人 | 21 | Author domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 发布人 |
22 | Title string // 文章标题 | 22 | Title string // 文章标题 |
23 | Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片 | 23 | Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片 |
24 | + Videos []domain.Video `gorm:"type:jsonb;serializer:json"` // 视频 | ||
24 | WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看 | 25 | WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看 |
25 | WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人 | 26 | WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人 |
26 | Location domain.Location `gorm:"type:jsonb;serializer:json"` // 坐标 | 27 | Location domain.Location `gorm:"type:jsonb;serializer:json"` // 坐标 |
@@ -15,11 +15,12 @@ type User struct { | @@ -15,11 +15,12 @@ type User struct { | ||
15 | Flag int // 标识 1:管理员 2:普通用户 (有绑定角色是管理员) | 15 | Flag int // 标识 1:管理员 2:普通用户 (有绑定角色是管理员) |
16 | Name string // 名称 | 16 | Name string // 名称 |
17 | PinYinName string | 17 | PinYinName string |
18 | - Avatar string // 头像 | ||
19 | - Phone string // 手机号 唯一 | ||
20 | - Position string // 职位 | ||
21 | - Enable int // 启用状态 1:启用 2:禁用 | ||
22 | - AuditStatus int // 审核状态 0:待审核 1:审核通过 2:拒绝 | 18 | + Avatar string // 头像 |
19 | + Phone string // 手机号 唯一 | ||
20 | + Position string // 职位 | ||
21 | + Enable int // 启用状态 1:启用 2:禁用 | ||
22 | + AuditStatus int // 审核状态 0:待审核 1:审核通过 2:拒绝 | ||
23 | + AuditAt int64 | ||
23 | Follower []int64 `gorm:"type:jsonb;serializer:json"` // 关注我的人 (冗余) | 24 | Follower []int64 `gorm:"type:jsonb;serializer:json"` // 关注我的人 (冗余) |
24 | Following []int64 `gorm:"type:jsonb;serializer:json"` // 我关注的人 (冗余) | 25 | Following []int64 `gorm:"type:jsonb;serializer:json"` // 我关注的人 (冗余) |
25 | Departments []int64 `gorm:"type:jsonb;serializer:json"` // 所属部门 | 26 | Departments []int64 `gorm:"type:jsonb;serializer:json"` // 所属部门 |
@@ -129,6 +129,9 @@ func (repository *ArticleBackupRepository) Find(ctx context.Context, conn transa | @@ -129,6 +129,9 @@ func (repository *ArticleBackupRepository) Find(ctx context.Context, conn transa | ||
129 | if v, ok := queryOptions["articleId"]; ok { | 129 | if v, ok := queryOptions["articleId"]; ok { |
130 | tx = tx.Where("article_id = ?", v) | 130 | tx = tx.Where("article_id = ?", v) |
131 | } | 131 | } |
132 | + if v, ok := queryOptions["companyId"]; ok { | ||
133 | + tx = tx.Where("article_id = ?", v) | ||
134 | + } | ||
132 | if v, ok := queryOptions["operator"]; ok && v.(string) != "" { | 135 | if v, ok := queryOptions["operator"]; ok && v.(string) != "" { |
133 | tx = tx.Where(`operator #>> '{"name"}' like ?`, "%"+v.(string)+"%") | 136 | tx = tx.Where(`operator #>> '{"name"}' like ?`, "%"+v.(string)+"%") |
134 | } | 137 | } |
@@ -120,6 +120,10 @@ func (repository *ArticleDraftRepository) Find(ctx context.Context, conn transac | @@ -120,6 +120,10 @@ func (repository *ArticleDraftRepository) Find(ctx context.Context, conn transac | ||
120 | ) | 120 | ) |
121 | queryFunc := func() (interface{}, error) { | 121 | queryFunc := func() (interface{}, error) { |
122 | tx = tx.Model(&ms).Order("id desc") | 122 | tx = tx.Model(&ms).Order("id desc") |
123 | + if v, ok := queryOptions["authorId"]; ok { | ||
124 | + tx = tx.Where("author_id=?", v) | ||
125 | + } | ||
126 | + | ||
123 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | 127 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { |
124 | return dms, tx.Error | 128 | return dms, tx.Error |
125 | } | 129 | } |
@@ -305,6 +305,7 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (* | @@ -305,6 +305,7 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (* | ||
305 | Tags: from.Tags, | 305 | Tags: from.Tags, |
306 | Summary: from.Summary, | 306 | Summary: from.Summary, |
307 | MatchUrl: from.MatchUrl, | 307 | MatchUrl: from.MatchUrl, |
308 | + Videos: from.Videos, | ||
308 | } | 309 | } |
309 | return to, nil | 310 | return to, nil |
310 | } | 311 | } |
@@ -333,6 +334,7 @@ func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (* | @@ -333,6 +334,7 @@ func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (* | ||
333 | Show: int(from.Show), | 334 | Show: int(from.Show), |
334 | Summary: from.Summary, | 335 | Summary: from.Summary, |
335 | MatchUrl: from.MatchUrl, | 336 | MatchUrl: from.MatchUrl, |
337 | + Videos: from.Videos, | ||
336 | } | 338 | } |
337 | // err := copier.Copy(to, from) | 339 | // err := copier.Copy(to, from) |
338 | return to, nil | 340 | return to, nil |
@@ -122,6 +122,12 @@ func (repository *MessageSystemRepository) Find(ctx context.Context, conn transa | @@ -122,6 +122,12 @@ func (repository *MessageSystemRepository) Find(ctx context.Context, conn transa | ||
122 | queryFunc := func() (interface{}, error) { | 122 | queryFunc := func() (interface{}, error) { |
123 | tx = tx.Model(&ms).Order("id desc") | 123 | tx = tx.Model(&ms).Order("id desc") |
124 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | 124 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { |
125 | + if v, ok := queryOptions["companyId"]; ok { | ||
126 | + tx.Where("company_id = ?", v) | ||
127 | + } | ||
128 | + if v, ok := queryOptions["recipientId"]; ok { | ||
129 | + tx.Where("recipient_id = ?", v) | ||
130 | + } | ||
125 | return dms, tx.Error | 131 | return dms, tx.Error |
126 | } | 132 | } |
127 | return dms, nil | 133 | return dms, nil |
@@ -218,7 +218,7 @@ func (repository *UserRepository) FindDepartmentUsers(ctx context.Context, conn | @@ -218,7 +218,7 @@ func (repository *UserRepository) FindDepartmentUsers(ctx context.Context, conn | ||
218 | ) | 218 | ) |
219 | queryFunc := func() (interface{}, error) { | 219 | queryFunc := func() (interface{}, error) { |
220 | tx = tx.Model(&ms).Order("pin_yin_name asc") | 220 | tx = tx.Model(&ms).Order("pin_yin_name asc") |
221 | - tx.Select("id", "name", "departments", "pin_yin_name") | 221 | + tx.Select("id", "name", "departments", "pin_yin_name", "avatar") |
222 | tx.Where("company_id = ?", companyId) | 222 | tx.Where("company_id = ?", companyId) |
223 | tx.Where("audit_status in (?)", domain.UserAuditStatusPassed) | 223 | tx.Where("audit_status in (?)", domain.UserAuditStatusPassed) |
224 | tx.Where("enable = ?", domain.UserEnable) | 224 | tx.Where("enable = ?", domain.UserEnable) |
@@ -18,6 +18,7 @@ type Article struct { | @@ -18,6 +18,7 @@ type Article struct { | ||
18 | Author UserSimple `json:"author"` // 发布人 | 18 | Author UserSimple `json:"author"` // 发布人 |
19 | Title string `json:"title"` // 文章标题 | 19 | Title string `json:"title"` // 文章标题 |
20 | Images []Image `json:"images"` // 图片 | 20 | Images []Image `json:"images"` // 图片 |
21 | + Videos []Video `json:"videos"` // 视频 | ||
21 | WhoRead []int64 `json:"whoRead"` // 谁可以看 | 22 | WhoRead []int64 `json:"whoRead"` // 谁可以看 |
22 | WhoReview []int64 `json:"whoReview"` // 评论人 | 23 | WhoReview []int64 `json:"whoReview"` // 评论人 |
23 | Location Location `json:"location"` // 坐标 | 24 | Location Location `json:"location"` // 坐标 |
@@ -93,7 +94,11 @@ func (a ArticleShow) Named() string { | @@ -93,7 +94,11 @@ func (a ArticleShow) Named() string { | ||
93 | } | 94 | } |
94 | 95 | ||
95 | // 设置文章的备份数据 | 96 | // 设置文章的备份数据 |
96 | -func (m *Article) MakeBackup(operator UserSimple, section []ArticleSection) *ArticleBackup { | 97 | +func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *ArticleBackup { |
98 | + sectionBackup := make([]ArticleSection, len(section)) | ||
99 | + for i := range section { | ||
100 | + sectionBackup[i] = *section[i] | ||
101 | + } | ||
97 | b := ArticleBackup{ | 102 | b := ArticleBackup{ |
98 | Id: 0, | 103 | Id: 0, |
99 | CompanyId: m.CompanyId, | 104 | CompanyId: m.CompanyId, |
@@ -104,7 +109,7 @@ func (m *Article) MakeBackup(operator UserSimple, section []ArticleSection) *Art | @@ -104,7 +109,7 @@ func (m *Article) MakeBackup(operator UserSimple, section []ArticleSection) *Art | ||
104 | Operator: operator, | 109 | Operator: operator, |
105 | ArticleId: m.Id, | 110 | ArticleId: m.Id, |
106 | Title: m.Title, | 111 | Title: m.Title, |
107 | - Section: section, | 112 | + Section: sectionBackup, |
108 | Images: m.Images, | 113 | Images: m.Images, |
109 | Action: "", | 114 | Action: "", |
110 | TargetUser: m.TargetUser, | 115 | TargetUser: m.TargetUser, |
@@ -7,6 +7,14 @@ type Image struct { | @@ -7,6 +7,14 @@ type Image struct { | ||
7 | Height int `json:"height"` // 图片高度 | 7 | Height int `json:"height"` // 图片高度 |
8 | } | 8 | } |
9 | 9 | ||
10 | +// 视频信息 | ||
11 | +type Video struct { | ||
12 | + Url string `json:"url"` //视频文件的地址 | ||
13 | + Cover string `json:"cover"` //封面 | ||
14 | + Width int `json:"width"` //封面图片宽 | ||
15 | + Height int `json:"height"` //封面图片长 | ||
16 | +} | ||
17 | + | ||
10 | // 坐标位置 | 18 | // 坐标位置 |
11 | type Location struct { | 19 | type Location struct { |
12 | Longitude float64 `json:"longitude"` //经度 | 20 | Longitude float64 `json:"longitude"` //经度 |
@@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
6 | "github.com/samber/lo" | 6 | "github.com/samber/lo" |
7 | "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" |
8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool" |
9 | + "time" | ||
9 | ) | 10 | ) |
10 | 11 | ||
11 | type User struct { | 12 | type User struct { |
@@ -21,6 +22,7 @@ type User struct { | @@ -21,6 +22,7 @@ type User struct { | ||
21 | Position string `json:"position,omitempty"` // 职位 | 22 | Position string `json:"position,omitempty"` // 职位 |
22 | Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用 | 23 | Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用 |
23 | AuditStatus int `json:"auditStatus,omitempty"` // 审核状态 0:待审核 1:审核通过 2:拒绝 | 24 | AuditStatus int `json:"auditStatus,omitempty"` // 审核状态 0:待审核 1:审核通过 2:拒绝 |
25 | + AuditAt int64 `json:"auditAt,omitempty"` // 审核时间 | ||
24 | Follower []int64 `json:"followers,omitempty"` // 关注我的人 (冗余) | 26 | Follower []int64 `json:"followers,omitempty"` // 关注我的人 (冗余) |
25 | Following []int64 `json:"following,omitempty"` // 我关注的人 (冗余) | 27 | Following []int64 `json:"following,omitempty"` // 我关注的人 (冗余) |
26 | Departments []int64 `json:"departments,omitempty"` // 所属部门 | 28 | Departments []int64 `json:"departments,omitempty"` // 所属部门 |
@@ -88,6 +90,7 @@ func (m *User) Audit(status int) error { | @@ -88,6 +90,7 @@ func (m *User) Audit(status int) error { | ||
88 | return fmt.Errorf("用户不是在待审核状态") | 90 | return fmt.Errorf("用户不是在待审核状态") |
89 | } | 91 | } |
90 | m.AuditStatus = status | 92 | m.AuditStatus = status |
93 | + m.AuditAt = time.Now().Unix() | ||
91 | return nil | 94 | return nil |
92 | } | 95 | } |
93 | 96 |
-
请 注册 或 登录 后发表评论