正在显示
8 个修改的文件
包含
40 行增加
和
10 行删除
| @@ -301,10 +301,12 @@ type ( | @@ -301,10 +301,12 @@ type ( | ||
| 301 | TagId int64 `json:"tagId"` // 标签id | 301 | TagId int64 `json:"tagId"` // 标签id |
| 302 | } | 302 | } |
| 303 | MiniAllArticleTagResponse{ | 303 | MiniAllArticleTagResponse{ |
| 304 | - TagGroup []string `json:"tagGroup"` | 304 | + TagGroup []ArticleTagGroup `json:"tagGroup"` |
| 305 | + } | ||
| 306 | + ArticleTagGroup { | ||
| 307 | + Group string `json:"group"` | ||
| 305 | Tags []ArticleTagItem `json:"tags"` | 308 | Tags []ArticleTagItem `json:"tags"` |
| 306 | } | 309 | } |
| 307 | - | ||
| 308 | ArticleTagItem { | 310 | ArticleTagItem { |
| 309 | Id int64 `json:"id"` | 311 | Id int64 `json:"id"` |
| 310 | Group string `json:"group"` | 312 | Group string `json:"group"` |
| @@ -7,6 +7,8 @@ import ( | @@ -7,6 +7,8 @@ import ( | ||
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment" |
| 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 MiniArticleCommentAtWhoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | 14 | func MiniArticleCommentAtWhoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { |
| @@ -18,11 +20,10 @@ func MiniArticleCommentAtWhoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc | @@ -18,11 +20,10 @@ func MiniArticleCommentAtWhoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc | ||
| 18 | } | 20 | } |
| 19 | 21 | ||
| 20 | l := comment.NewMiniArticleCommentAtWhoLogic(r.Context(), svcCtx) | 22 | l := comment.NewMiniArticleCommentAtWhoLogic(r.Context(), svcCtx) |
| 23 | + token := contextdata.GetUserTokenFromCtx(r.Context()) | ||
| 24 | + req.CompanyId = token.CompanyId | ||
| 25 | + req.UserId = token.UserId | ||
| 21 | resp, err := l.MiniArticleCommentAtWho(&req) | 26 | resp, err := l.MiniArticleCommentAtWho(&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,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/pkg/xerr" | ||
| 8 | 9 | ||
| 9 | "github.com/zeromicro/go-zero/core/logx" | 10 | "github.com/zeromicro/go-zero/core/logx" |
| 10 | ) | 11 | ) |
| @@ -24,7 +25,21 @@ func NewMiniArticleCommentAtWhoLogic(ctx context.Context, svcCtx *svc.ServiceCon | @@ -24,7 +25,21 @@ func NewMiniArticleCommentAtWhoLogic(ctx context.Context, svcCtx *svc.ServiceCon | ||
| 24 | } | 25 | } |
| 25 | 26 | ||
| 26 | func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniArticleCommentAtWhoRequest) (resp *types.MiniArticleCommentAtWhoResponse, err error) { | 27 | func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniArticleCommentAtWhoRequest) (resp *types.MiniArticleCommentAtWhoResponse, err error) { |
| 27 | - // todo: add your logic here and delete this line | 28 | + var conn = l.svcCtx.DefaultDBConn() |
| 29 | + articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId) | ||
| 30 | + if err != nil { | ||
| 31 | + return nil, xerr.NewErrMsgErr("获取评论人信息失败", err) | ||
| 32 | + } | ||
| 33 | + if articleInfo.CompanyId != req.CompanyId { | ||
| 34 | + resp = &types.MiniArticleCommentAtWhoResponse{} | ||
| 35 | + return resp, nil | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + // userList := []*domain.User{} | ||
| 39 | + // if len(articleInfo.WhoRead) == 0 { | ||
| 40 | + | ||
| 41 | + // return | ||
| 42 | + // } | ||
| 28 | 43 | ||
| 29 | return | 44 | return |
| 30 | } | 45 | } |
| @@ -11,6 +11,7 @@ import ( | @@ -11,6 +11,7 @@ import ( | ||
| 11 | 11 | ||
| 12 | "text/template" | 12 | "text/template" |
| 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 | ||
| @@ -87,11 +88,15 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini | @@ -87,11 +88,15 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini | ||
| 87 | for _, val := range req.AtWho { | 88 | for _, val := range req.AtWho { |
| 88 | uids = append(uids, val.Id) | 89 | uids = append(uids, val.Id) |
| 89 | } | 90 | } |
| 91 | + uids = lo.Uniq(uids) | ||
| 90 | queryOption := domain.NewQueryOptions().WithFindOnly().WithKV("ids", uids) | 92 | queryOption := domain.NewQueryOptions().WithFindOnly().WithKV("ids", uids) |
| 91 | _, atWhoList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption) | 93 | _, atWhoList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption) |
| 92 | if err != nil { | 94 | if err != nil { |
| 93 | return nil, xerr.NewErrMsgErr("检查@的人员失败", err) | 95 | return nil, xerr.NewErrMsgErr("检查@的人员失败", err) |
| 94 | } | 96 | } |
| 97 | + if len(uids) != len(atWhoList) { | ||
| 98 | + return nil, xerr.NewErrMsg("检查@的人员失败") | ||
| 99 | + } | ||
| 95 | } | 100 | } |
| 96 | // 处理文本内容 | 101 | // 处理文本内容 |
| 97 | content := template.HTMLEscapeString(req.Content) | 102 | content := template.HTMLEscapeString(req.Content) |
| @@ -821,7 +821,11 @@ type MiniAllArticleTagRequest struct { | @@ -821,7 +821,11 @@ type MiniAllArticleTagRequest struct { | ||
| 821 | } | 821 | } |
| 822 | 822 | ||
| 823 | type MiniAllArticleTagResponse struct { | 823 | type MiniAllArticleTagResponse struct { |
| 824 | - TagGroup []string `json:"tagGroup"` | 824 | + TagGroup []ArticleTagGroup `json:"tagGroup"` |
| 825 | +} | ||
| 826 | + | ||
| 827 | +type ArticleTagGroup struct { | ||
| 828 | + Group string `json:"group"` | ||
| 825 | Tags []ArticleTagItem `json:"tags"` | 829 | Tags []ArticleTagItem `json:"tags"` |
| 826 | } | 830 | } |
| 827 | 831 |
| @@ -8,6 +8,7 @@ import ( | @@ -8,6 +8,7 @@ import ( | ||
| 8 | "gorm.io/gorm" | 8 | "gorm.io/gorm" |
| 9 | ) | 9 | ) |
| 10 | 10 | ||
| 11 | +// 保存文章和标签的关系,主要用于分组统计用 | ||
| 11 | type ArticleAndTag struct { | 12 | type ArticleAndTag struct { |
| 12 | Id int64 // 唯一标识 | 13 | Id int64 // 唯一标识 |
| 13 | CompanyId int64 `json:"companyId"` | 14 | CompanyId int64 `json:"companyId"` |
| @@ -28,7 +29,7 @@ func (m *ArticleAndTag) BeforeCreate(tx *gorm.DB) (err error) { | @@ -28,7 +29,7 @@ func (m *ArticleAndTag) BeforeCreate(tx *gorm.DB) (err error) { | ||
| 28 | } | 29 | } |
| 29 | 30 | ||
| 30 | func (m *ArticleAndTag) BeforeUpdate(tx *gorm.DB) (err error) { | 31 | func (m *ArticleAndTag) BeforeUpdate(tx *gorm.DB) (err error) { |
| 31 | - // m.UpdatedAt = time.Now().Unix() | 32 | + m.UpdatedAt = time.Now().Unix() |
| 32 | return | 33 | return |
| 33 | } | 34 | } |
| 34 | 35 |
| @@ -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 | + SortBy int64 // 顺序 | ||
| 25 | } | 26 | } |
| 26 | 27 | ||
| 27 | func (m *ArticleTag) TableName() string { | 28 | func (m *ArticleTag) TableName() string { |
| @@ -19,6 +19,7 @@ type ArticleTag struct { | @@ -19,6 +19,7 @@ type ArticleTag struct { | ||
| 19 | Name string `json:"name"` // 标签名称 | 19 | Name string `json:"name"` // 标签名称 |
| 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 | } | 23 | } |
| 23 | type ArticleTagRepository interface { | 24 | type ArticleTagRepository interface { |
| 24 | Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error) | 25 | Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error) |
-
请 注册 或 登录 后发表评论