正在显示
13 个修改的文件
包含
110 行增加
和
29 行删除
@@ -107,6 +107,7 @@ type ( | @@ -107,6 +107,7 @@ type ( | ||
107 | UserId int64 `json:"userId"` // 人员id | 107 | UserId int64 `json:"userId"` // 人员id |
108 | Name string `json:"name"` // 人员名称 | 108 | Name string `json:"name"` // 人员名称 |
109 | Avatar string `json:"avatar"` // 人员头像 | 109 | Avatar string `json:"avatar"` // 人员头像 |
110 | + Position string `json:"position"` // 职位 | ||
110 | CreatedAt int64 `json:"createdAt"` // 点赞记录的时间 | 111 | CreatedAt int64 `json:"createdAt"` // 点赞记录的时间 |
111 | } | 112 | } |
112 | ) | 113 | ) |
@@ -297,8 +298,6 @@ type ( | @@ -297,8 +298,6 @@ type ( | ||
297 | MiniAllArticleTagRequest{ | 298 | MiniAllArticleTagRequest{ |
298 | CompanyId int64 `json:",optional"` // 公司id | 299 | CompanyId int64 `json:",optional"` // 公司id |
299 | UserId int64 `json:",optional"` // 公司id | 300 | UserId int64 `json:",optional"` // 公司id |
300 | - ArticleId int64 `json:"articleId"` // 文章id | ||
301 | - TagId int64 `json:"tagId"` // 标签id | ||
302 | } | 301 | } |
303 | MiniAllArticleTagResponse{ | 302 | MiniAllArticleTagResponse{ |
304 | TagGroup []ArticleTagGroup `json:"tagGroup"` | 303 | TagGroup []ArticleTagGroup `json:"tagGroup"` |
@@ -311,6 +310,7 @@ type ( | @@ -311,6 +310,7 @@ type ( | ||
311 | Id int64 `json:"id"` | 310 | Id int64 `json:"id"` |
312 | Group string `json:"group"` | 311 | Group string `json:"group"` |
313 | Name string `json:"name"` | 312 | Name string `json:"name"` |
313 | + Image string `json:"image"` | ||
314 | } | 314 | } |
315 | ) | 315 | ) |
316 | 316 |
@@ -80,6 +80,7 @@ type ( | @@ -80,6 +80,7 @@ type ( | ||
80 | CommentAtWho { | 80 | CommentAtWho { |
81 | Id int64 `json:"id"` | 81 | Id int64 `json:"id"` |
82 | Name string `json:"name,optional"` | 82 | Name string `json:"name,optional"` |
83 | + FirstLetter string `json:"firstLetter,optional"` | ||
83 | } | 84 | } |
84 | MiniCreateArticleCommentResponse { | 85 | MiniCreateArticleCommentResponse { |
85 | Id int64 `json:"id"` | 86 | Id int64 `json:"id"` |
@@ -7,6 +7,8 @@ import ( | @@ -7,6 +7,8 @@ import ( | ||
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" |
8 | "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" |
9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
10 | ) | 12 | ) |
11 | 13 | ||
12 | func MiniAllArticleTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | 14 | func MiniAllArticleTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { |
@@ -18,11 +20,10 @@ func MiniAllArticleTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -18,11 +20,10 @@ func MiniAllArticleTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
18 | } | 20 | } |
19 | 21 | ||
20 | l := article.NewMiniAllArticleTagLogic(r.Context(), svcCtx) | 22 | l := article.NewMiniAllArticleTagLogic(r.Context(), svcCtx) |
23 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
24 | + req.CompanyId = token.CompanyId | ||
25 | + req.UserId = token.UserId | ||
21 | resp, err := l.MiniAllArticleTag(&req) | 26 | resp, err := l.MiniAllArticleTag(&req) |
22 | - if err != nil { | ||
23 | - httpx.ErrorCtx(r.Context(), w, err) | ||
24 | - } else { | ||
25 | - httpx.OkJsonCtx(r.Context(), w, resp) | ||
26 | - } | 27 | + result.HttpResult(r, w, resp, err) |
27 | } | 28 | } |
28 | } | 29 | } |
@@ -5,6 +5,8 @@ import ( | @@ -5,6 +5,8 @@ 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/domain" | ||
9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
8 | 10 | ||
9 | "github.com/zeromicro/go-zero/core/logx" | 11 | "github.com/zeromicro/go-zero/core/logx" |
10 | ) | 12 | ) |
@@ -24,7 +26,44 @@ func NewMiniAllArticleTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) | @@ -24,7 +26,44 @@ func NewMiniAllArticleTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) | ||
24 | } | 26 | } |
25 | 27 | ||
26 | func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagRequest) (resp *types.MiniAllArticleTagResponse, err error) { | 28 | func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagRequest) (resp *types.MiniAllArticleTagResponse, err error) { |
27 | - // todo: add your logic here and delete this line | ||
28 | - | ||
29 | - return | 29 | + var conn = l.svcCtx.DefaultDBConn() |
30 | + queryOption := domain.NewQueryOptions().WithFindOnly() | ||
31 | + _, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOption) | ||
32 | + if err != nil { | ||
33 | + return nil, xerr.NewErrMsgErr("获取标签列表失败", err) | ||
34 | + } | ||
35 | + // 合并输出数据 | ||
36 | + var group []string | ||
37 | + tagMap := map[string][]types.ArticleTagItem{} | ||
38 | + for _, val := range tagList { | ||
39 | + if m, ok := tagMap[val.Group]; ok { | ||
40 | + m = append(m, types.ArticleTagItem{ | ||
41 | + Id: val.Id, | ||
42 | + Group: val.Group, | ||
43 | + Name: val.Name, | ||
44 | + Image: val.Image.Url, | ||
45 | + }) | ||
46 | + tagMap[val.Group] = m | ||
47 | + } else { | ||
48 | + group = append(group, val.Group) | ||
49 | + tagMap[val.Group] = []types.ArticleTagItem{ | ||
50 | + { | ||
51 | + Id: val.Id, | ||
52 | + Group: val.Group, | ||
53 | + Name: val.Name, | ||
54 | + Image: val.Image.Url, | ||
55 | + }, | ||
56 | + } | ||
57 | + } | ||
58 | + } | ||
59 | + resp = &types.MiniAllArticleTagResponse{ | ||
60 | + TagGroup: make([]types.ArticleTagGroup, 0), | ||
61 | + } | ||
62 | + for i := range group { | ||
63 | + resp.TagGroup = append(resp.TagGroup, types.ArticleTagGroup{ | ||
64 | + Group: group[i], | ||
65 | + Tags: tagMap[group[i]], | ||
66 | + }) | ||
67 | + } | ||
68 | + return resp, nil | ||
30 | } | 69 | } |
@@ -71,6 +71,7 @@ func (l *MiniUserLikeArticleLogic) MiniUserLikeArticle(req *types.MiniUserLikeAr | @@ -71,6 +71,7 @@ func (l *MiniUserLikeArticleLogic) MiniUserLikeArticle(req *types.MiniUserLikeAr | ||
71 | if u, ok := userMap[val.UserId]; ok { | 71 | if u, ok := userMap[val.UserId]; ok { |
72 | item.Name = u.Name | 72 | item.Name = u.Name |
73 | item.Avatar = u.Avatar | 73 | item.Avatar = u.Avatar |
74 | + item.Position = u.Position | ||
74 | } | 75 | } |
75 | resp.List[i] = item | 76 | resp.List[i] = item |
76 | } | 77 | } |
@@ -2,9 +2,12 @@ package comment | @@ -2,9 +2,12 @@ package comment | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | + "sort" | ||
6 | + "strings" | ||
5 | 7 | ||
6 | "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" |
7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" |
10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
9 | 12 | ||
10 | "github.com/zeromicro/go-zero/core/logx" | 13 | "github.com/zeromicro/go-zero/core/logx" |
@@ -24,6 +27,7 @@ func NewMiniArticleCommentAtWhoLogic(ctx context.Context, svcCtx *svc.ServiceCon | @@ -24,6 +27,7 @@ func NewMiniArticleCommentAtWhoLogic(ctx context.Context, svcCtx *svc.ServiceCon | ||
24 | } | 27 | } |
25 | } | 28 | } |
26 | 29 | ||
30 | +// MiniArticleCommentAtWho 填写评估时@谁 的可选择者列表 | ||
27 | func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniArticleCommentAtWhoRequest) (resp *types.MiniArticleCommentAtWhoResponse, err error) { | 31 | func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniArticleCommentAtWhoRequest) (resp *types.MiniArticleCommentAtWhoResponse, err error) { |
28 | var conn = l.svcCtx.DefaultDBConn() | 32 | var conn = l.svcCtx.DefaultDBConn() |
29 | articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId) | 33 | articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId) |
@@ -35,11 +39,42 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr | @@ -35,11 +39,42 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr | ||
35 | return resp, nil | 39 | return resp, nil |
36 | } | 40 | } |
37 | 41 | ||
38 | - // userList := []*domain.User{} | ||
39 | - // if len(articleInfo.WhoRead) == 0 { | 42 | + var userList []*domain.User |
43 | + if len(articleInfo.WhoRead) == 0 { | ||
44 | + //获取所有人 | ||
45 | + queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("companyId", articleInfo.CompanyId) | ||
46 | + _, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption) | ||
47 | + if err != nil { | ||
48 | + resp = &types.MiniArticleCommentAtWhoResponse{} | ||
49 | + return resp, nil | ||
50 | + } | ||
51 | + } else { | ||
52 | + queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("ids", articleInfo.WhoRead) | ||
53 | + _, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption) | ||
54 | + if err != nil { | ||
55 | + resp = &types.MiniArticleCommentAtWhoResponse{} | ||
56 | + return resp, nil | ||
57 | + } | ||
58 | + } | ||
40 | 59 | ||
41 | - // return | ||
42 | - // } | 60 | + uList := make([]types.CommentAtWho, len(userList)) |
43 | 61 | ||
44 | - return | 62 | + for i := range userList { |
63 | + uList[i] = types.CommentAtWho{ | ||
64 | + Id: userList[i].Id, | ||
65 | + Name: userList[i].Name, | ||
66 | + FirstLetter: "", | ||
67 | + } | ||
68 | + for _, val := range userList[i].PinYinName { | ||
69 | + uList[i].FirstLetter = strings.ToUpper(string(val)) | ||
70 | + break | ||
71 | + } | ||
72 | + } | ||
73 | + sort.Slice(uList, func(i, j int) bool { | ||
74 | + return uList[i].FirstLetter < uList[j].FirstLetter | ||
75 | + }) | ||
76 | + resp = &types.MiniArticleCommentAtWhoResponse{ | ||
77 | + List: uList, | ||
78 | + } | ||
79 | + return resp, nil | ||
45 | } | 80 | } |
@@ -52,12 +52,12 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini | @@ -52,12 +52,12 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini | ||
52 | return nil, xerr.NewErrMsg("没有评论权限") | 52 | return nil, xerr.NewErrMsg("没有评论权限") |
53 | } | 53 | } |
54 | //查看评论权限, | 54 | //查看评论权限, |
55 | - // if len(articleInfo.WhoReview) > 0 { | ||
56 | - // ok := lo.IndexOf(articleInfo.WhoReview, req.FromUserId) | ||
57 | - // if ok < 0 { | ||
58 | - // return nil, xerr.NewErrMsg("没有评论权限") | ||
59 | - // } | ||
60 | - // } | 55 | + if len(articleInfo.WhoReview) > 0 { |
56 | + ok := lo.IndexOf(articleInfo.WhoReview, req.FromUserId) | ||
57 | + if ok < 0 { | ||
58 | + return nil, xerr.NewErrMsg("没有评论权限") | ||
59 | + } | ||
60 | + } | ||
61 | // 对段落进行评论 | 61 | // 对段落进行评论 |
62 | var selctionInfo *domain.ArticleSection | 62 | var selctionInfo *domain.ArticleSection |
63 | if req.SectionId > 0 { | 63 | if req.SectionId > 0 { |
@@ -29,6 +29,7 @@ type MiniCreateArticleCommentRequest struct { | @@ -29,6 +29,7 @@ type MiniCreateArticleCommentRequest struct { | ||
29 | type CommentAtWho struct { | 29 | type CommentAtWho struct { |
30 | Id int64 `json:"id"` | 30 | Id int64 `json:"id"` |
31 | Name string `json:"name,optional"` | 31 | Name string `json:"name,optional"` |
32 | + FirstLetter string `json:"firstLetter,optional"` | ||
32 | } | 33 | } |
33 | 34 | ||
34 | type MiniCreateArticleCommentResponse struct { | 35 | type MiniCreateArticleCommentResponse struct { |
@@ -656,6 +657,7 @@ type WhichUserLikeArticle struct { | @@ -656,6 +657,7 @@ type WhichUserLikeArticle struct { | ||
656 | UserId int64 `json:"userId"` // 人员id | 657 | UserId int64 `json:"userId"` // 人员id |
657 | Name string `json:"name"` // 人员名称 | 658 | Name string `json:"name"` // 人员名称 |
658 | Avatar string `json:"avatar"` // 人员头像 | 659 | Avatar string `json:"avatar"` // 人员头像 |
660 | + Position string `json:"position"` // 职位 | ||
659 | CreatedAt int64 `json:"createdAt"` // 点赞记录的时间 | 661 | CreatedAt int64 `json:"createdAt"` // 点赞记录的时间 |
660 | } | 662 | } |
661 | 663 | ||
@@ -818,8 +820,6 @@ type MiniArticleSetTagResponse struct { | @@ -818,8 +820,6 @@ type MiniArticleSetTagResponse struct { | ||
818 | type MiniAllArticleTagRequest struct { | 820 | type MiniAllArticleTagRequest struct { |
819 | CompanyId int64 `json:",optional"` // 公司id | 821 | CompanyId int64 `json:",optional"` // 公司id |
820 | UserId int64 `json:",optional"` // 公司id | 822 | UserId int64 `json:",optional"` // 公司id |
821 | - ArticleId int64 `json:"articleId"` // 文章id | ||
822 | - TagId int64 `json:"tagId"` // 标签id | ||
823 | } | 823 | } |
824 | 824 | ||
825 | type MiniAllArticleTagResponse struct { | 825 | type MiniAllArticleTagResponse struct { |
@@ -835,6 +835,7 @@ type ArticleTagItem struct { | @@ -835,6 +835,7 @@ type ArticleTagItem struct { | ||
835 | Id int64 `json:"id"` | 835 | Id int64 `json:"id"` |
836 | Group string `json:"group"` | 836 | Group string `json:"group"` |
837 | Name string `json:"name"` | 837 | Name string `json:"name"` |
838 | + Image string `json:"image"` | ||
838 | } | 839 | } |
839 | 840 | ||
840 | type SystemArticleGetRequest struct { | 841 | type SystemArticleGetRequest struct { |
@@ -22,6 +22,7 @@ func Migrate(db *gorm.DB) { | @@ -22,6 +22,7 @@ func Migrate(db *gorm.DB) { | ||
22 | &models.MessageSystem{}, | 22 | &models.MessageSystem{}, |
23 | &models.MessageBusiness{}, | 23 | &models.MessageBusiness{}, |
24 | &models.Department{}, | 24 | &models.Department{}, |
25 | + &models.ArticleAndTag{}, | ||
25 | } | 26 | } |
26 | 27 | ||
27 | db.AutoMigrate(modelsList...) | 28 | db.AutoMigrate(modelsList...) |
@@ -10,12 +10,12 @@ import ( | @@ -10,12 +10,12 @@ import ( | ||
10 | 10 | ||
11 | // 保存文章和标签的关系,主要用于分组统计用 | 11 | // 保存文章和标签的关系,主要用于分组统计用 |
12 | type ArticleAndTag struct { | 12 | type ArticleAndTag struct { |
13 | - Id int64 // 唯一标识 | ||
14 | - CompanyId int64 `json:"companyId"` | ||
15 | - CreatedAt int64 `json:"createdAt,omitempty"` | ||
16 | - UpdatedAt int64 `json:"updatedAt,omitempty"` | ||
17 | - ArticleId int64 `json:"articleId"` | ||
18 | - TagId int64 `json:"tagId"` | 13 | + Id int64 `gorm:"primaryKey"` // 唯一标识 |
14 | + CompanyId int64 | ||
15 | + CreatedAt int64 | ||
16 | + UpdatedAt int64 | ||
17 | + ArticleId int64 | ||
18 | + TagId int64 | ||
19 | } | 19 | } |
20 | 20 | ||
21 | func (m *ArticleAndTag) TableName() string { | 21 | func (m *ArticleAndTag) TableName() string { |
@@ -22,6 +22,7 @@ type ArticleTag struct { | @@ -22,6 +22,7 @@ type ArticleTag struct { | ||
22 | Name string // 标签名称 | 22 | Name string // 标签名称 |
23 | Group string // 标签分类 | 23 | Group string // 标签分类 |
24 | Remark string // 备注 | 24 | Remark string // 备注 |
25 | + Other string // 其他内容 | ||
25 | SortBy int64 // 顺序 | 26 | SortBy int64 // 顺序 |
26 | } | 27 | } |
27 | 28 |
@@ -20,6 +20,7 @@ type ArticleTag struct { | @@ -20,6 +20,7 @@ type ArticleTag struct { | ||
20 | Group string `json:"group"` // 标签分类 | 20 | Group string `json:"group"` // 标签分类 |
21 | Remark string `json:"remark"` // 备注 | 21 | Remark string `json:"remark"` // 备注 |
22 | SortBy int64 `json:"sortBy"` // 顺序 | 22 | SortBy int64 `json:"sortBy"` // 顺序 |
23 | + Other string `json:"other"` // | ||
23 | } | 24 | } |
24 | type ArticleTagRepository interface { | 25 | type ArticleTagRepository interface { |
25 | Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error) | 26 | Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error) |
-
请 注册 或 登录 后发表评论