正在显示
10 个修改的文件
包含
58 行增加
和
6 行删除
| @@ -131,7 +131,8 @@ type ( | @@ -131,7 +131,8 @@ type ( | ||
| 131 | type ( | 131 | type ( |
| 132 | MiniGetArticleCommentRequest { | 132 | MiniGetArticleCommentRequest { |
| 133 | CommentId int64 `path:"commentId"` | 133 | CommentId int64 `path:"commentId"` |
| 134 | - CompanyId int64 `json:",optional"` | 134 | + CompanyId int64 `path:",optional"` |
| 135 | + UserId int64 `path:",optional"` | ||
| 135 | } | 136 | } |
| 136 | MiniGetArticleCommentResponse { | 137 | MiniGetArticleCommentResponse { |
| 137 | ArticleCommentAndReply | 138 | ArticleCommentAndReply |
| @@ -26,6 +26,7 @@ func NewMiniArticleMarkUserReadLogic(ctx context.Context, svcCtx *svc.ServiceCon | @@ -26,6 +26,7 @@ func NewMiniArticleMarkUserReadLogic(ctx context.Context, svcCtx *svc.ServiceCon | ||
| 26 | } | 26 | } |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | +// 记录人员浏览的文章 | ||
| 29 | func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniArticleMarkUserReadRequest) (resp *types.MiniArticleMarkUserReadResponse, err error) { | 30 | func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniArticleMarkUserReadRequest) (resp *types.MiniArticleMarkUserReadResponse, err error) { |
| 30 | var conn = l.svcCtx.DefaultDBConn() | 31 | var conn = l.svcCtx.DefaultDBConn() |
| 31 | 32 |
| @@ -28,6 +28,7 @@ func NewMiniCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) | @@ -28,6 +28,7 @@ func NewMiniCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) | ||
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | +// 创建新文章 | ||
| 31 | func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateRequest) (resp *types.MiniArticleCreateResponse, err error) { | 32 | func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateRequest) (resp *types.MiniArticleCreateResponse, err error) { |
| 32 | var conn = l.svcCtx.DefaultDBConn() | 33 | var conn = l.svcCtx.DefaultDBConn() |
| 33 | // 检查发布人 | 34 | // 检查发布人 |
| @@ -26,6 +26,7 @@ func NewMiniGetArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mi | @@ -26,6 +26,7 @@ func NewMiniGetArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mi | ||
| 26 | } | 26 | } |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | +// 小程序端展示文章内容 | ||
| 29 | func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (resp *types.MiniArticleGetResponse, err error) { | 30 | func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (resp *types.MiniArticleGetResponse, err error) { |
| 30 | // 获取文章内容 | 31 | // 获取文章内容 |
| 31 | var conn = l.svcCtx.DefaultDBConn() | 32 | var conn = l.svcCtx.DefaultDBConn() |
| @@ -91,7 +92,6 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | @@ -91,7 +92,6 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | ||
| 91 | Id: articleInfo.Author.Id, | 92 | Id: articleInfo.Author.Id, |
| 92 | Name: articleInfo.Author.Name, | 93 | Name: articleInfo.Author.Name, |
| 93 | Avatar: articleInfo.Author.Avatar, | 94 | Avatar: articleInfo.Author.Avatar, |
| 94 | - // Group: articleInfo.Author.Group, | ||
| 95 | Position: articleInfo.Author.Position, | 95 | Position: articleInfo.Author.Position, |
| 96 | Company: articleInfo.Author.Company, | 96 | Company: articleInfo.Author.Company, |
| 97 | }, | 97 | }, |
| @@ -49,7 +49,7 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini | @@ -49,7 +49,7 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini | ||
| 49 | return nil, xerr.NewErrMsg("没有评论权限") | 49 | return nil, xerr.NewErrMsg("没有评论权限") |
| 50 | } | 50 | } |
| 51 | //查看评论权限, | 51 | //查看评论权限, |
| 52 | - //临时注释 | 52 | + //TODO 临时注释 |
| 53 | // if len(articleInfo.WhoReview) > 0 { | 53 | // if len(articleInfo.WhoReview) > 0 { |
| 54 | // ok := lo.IndexOf(articleInfo.WhoReview, req.FromUserId) | 54 | // ok := lo.IndexOf(articleInfo.WhoReview, req.FromUserId) |
| 55 | // if ok < 0 { | 55 | // if ok < 0 { |
| @@ -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 | ) |
| @@ -23,8 +25,24 @@ func NewMiniDeleteArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCo | @@ -23,8 +25,24 @@ func NewMiniDeleteArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCo | ||
| 23 | } | 25 | } |
| 24 | } | 26 | } |
| 25 | 27 | ||
| 28 | +// 小程序端人人员删除评论 | ||
| 26 | func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.MiniDeleteArticleCommentRequest) (resp *types.MiniDeleteArticleCommentResponse, err error) { | 29 | func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.MiniDeleteArticleCommentRequest) (resp *types.MiniDeleteArticleCommentResponse, err error) { |
| 27 | - // todo: add your logic here and delete this line | 30 | + var conn = l.svcCtx.DefaultDBConn() |
| 31 | + commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.CommentId) | ||
| 32 | + if err != nil { | ||
| 33 | + return nil, xerr.NewErrMsgErr("删除评论信息失败", err) | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + if commetInfo.FromUserId != req.UserId { | ||
| 37 | + return nil, xerr.NewErrMsg("没有操作权限") | ||
| 38 | + } | ||
| 28 | 39 | ||
| 29 | - return | 40 | + commetInfo.Show = domain.CommentShowDisable |
| 41 | + | ||
| 42 | + _, err = l.svcCtx.ArticleCommentRepository.Update(l.ctx, conn, commetInfo) | ||
| 43 | + if err != nil { | ||
| 44 | + return nil, xerr.NewErrMsgErr("删除评论信息失败", err) | ||
| 45 | + } | ||
| 46 | + resp = &types.MiniDeleteArticleCommentResponse{Id: commetInfo.Id} | ||
| 47 | + return resp, nil | ||
| 30 | } | 48 | } |
| @@ -25,6 +25,7 @@ func NewMiniGetArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceConte | @@ -25,6 +25,7 @@ func NewMiniGetArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceConte | ||
| 25 | } | 25 | } |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | +// 获取单条评论详情 | ||
| 28 | func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArticleCommentRequest) (resp *types.MiniGetArticleCommentResponse, err error) { | 29 | func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArticleCommentRequest) (resp *types.MiniGetArticleCommentResponse, err error) { |
| 29 | var conn = l.svcCtx.DefaultDBConn() | 30 | var conn = l.svcCtx.DefaultDBConn() |
| 30 | //获取主评论 | 31 | //获取主评论 |
| @@ -42,7 +43,18 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt | @@ -42,7 +43,18 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt | ||
| 42 | if err != nil { | 43 | if err != nil { |
| 43 | return nil, xerr.NewErrMsgErr("获取评论信息失败", err) | 44 | return nil, xerr.NewErrMsgErr("获取评论信息失败", err) |
| 44 | } | 45 | } |
| 46 | + queryOption = domain.NewQueryOptions().WithFindOnly(). | ||
| 47 | + MustWithKV("articleId", commentInfo.ArticleId). | ||
| 48 | + MustWithKV("userId", req.UserId) | ||
| 45 | //TODO 获取我点赞的评论 | 49 | //TODO 获取我点赞的评论 |
| 50 | + _, userFlagList, err := l.svcCtx.UserLoveFlagRepository.Find(l.ctx, conn, queryOption) | ||
| 51 | + if err != nil { | ||
| 52 | + return nil, xerr.NewErrMsgErr("获取评论信息失败", err) | ||
| 53 | + } | ||
| 54 | + flagMap := map[int64]struct{}{} | ||
| 55 | + for _, val := range userFlagList { | ||
| 56 | + flagMap[val.CommentId] = struct{}{} | ||
| 57 | + } | ||
| 46 | 58 | ||
| 47 | //混合数据 | 59 | //混合数据 |
| 48 | commentResp := types.ArticleCommentItem{ | 60 | commentResp := types.ArticleCommentItem{ |
| @@ -73,6 +85,10 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt | @@ -73,6 +85,10 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt | ||
| 73 | CountAdminLove: commentInfo.CountAdminLove, | 85 | CountAdminLove: commentInfo.CountAdminLove, |
| 74 | AtWho: []types.CommentAuthor{}, | 86 | AtWho: []types.CommentAuthor{}, |
| 75 | CreatedAt: commentInfo.CreatedAt, | 87 | CreatedAt: commentInfo.CreatedAt, |
| 88 | + MeLoveFlag: 0, | ||
| 89 | + } | ||
| 90 | + if _, ok := flagMap[commentInfo.Id]; ok { | ||
| 91 | + commentResp.MeLoveFlag = 1 | ||
| 76 | } | 92 | } |
| 77 | for _, val := range commentInfo.AtWho { | 93 | for _, val := range commentInfo.AtWho { |
| 78 | commentResp.AtWho = append(commentResp.AtWho, types.CommentAuthor{ | 94 | commentResp.AtWho = append(commentResp.AtWho, types.CommentAuthor{ |
| @@ -115,6 +131,9 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt | @@ -115,6 +131,9 @@ func (l *MiniGetArticleCommentLogic) MiniGetArticleComment(req *types.MiniGetArt | ||
| 115 | CreatedAt: val.CreatedAt, | 131 | CreatedAt: val.CreatedAt, |
| 116 | MeLoveFlag: 0, | 132 | MeLoveFlag: 0, |
| 117 | } | 133 | } |
| 134 | + if _, ok := flagMap[val.Id]; ok { | ||
| 135 | + reply.MeLoveFlag = 1 | ||
| 136 | + } | ||
| 118 | for _, val2 := range val.AtWho { | 137 | for _, val2 := range val.AtWho { |
| 119 | reply.AtWho = append(reply.AtWho, types.CommentAuthor{ | 138 | reply.AtWho = append(reply.AtWho, types.CommentAuthor{ |
| 120 | Id: val2.Id, | 139 | Id: val2.Id, |
| @@ -83,7 +83,8 @@ type ArticleCommentItem struct { | @@ -83,7 +83,8 @@ type ArticleCommentItem struct { | ||
| 83 | 83 | ||
| 84 | type MiniGetArticleCommentRequest struct { | 84 | type MiniGetArticleCommentRequest struct { |
| 85 | CommentId int64 `path:"commentId"` | 85 | CommentId int64 `path:"commentId"` |
| 86 | - CompanyId int64 `json:",optional"` | 86 | + CompanyId int64 `path:",optional"` |
| 87 | + UserId int64 `path:",optional"` | ||
| 87 | } | 88 | } |
| 88 | 89 | ||
| 89 | type MiniGetArticleCommentResponse struct { | 90 | type MiniGetArticleCommentResponse struct { |
| @@ -9,6 +9,7 @@ import ( | @@ -9,6 +9,7 @@ import ( | ||
| 9 | "gorm.io/plugin/soft_delete" | 9 | "gorm.io/plugin/soft_delete" |
| 10 | ) | 10 | ) |
| 11 | 11 | ||
| 12 | +// 文章的所有标签 | ||
| 12 | type ArticleTag struct { | 13 | type ArticleTag struct { |
| 13 | Id int64 `gorm:"primaryKey"` // 唯一标识 | 14 | Id int64 `gorm:"primaryKey"` // 唯一标识 |
| 14 | CompanyId int64 | 15 | CompanyId int64 |
| @@ -40,6 +40,16 @@ const ( | @@ -40,6 +40,16 @@ const ( | ||
| 40 | CommentShowDisable CommentShow = 1 | 40 | CommentShowDisable CommentShow = 1 |
| 41 | ) | 41 | ) |
| 42 | 42 | ||
| 43 | +func (show CommentShow) Named() string { | ||
| 44 | + switch show { | ||
| 45 | + case CommentShowEnable: | ||
| 46 | + return "显示" | ||
| 47 | + case CommentShowDisable: | ||
| 48 | + return "隐藏" | ||
| 49 | + } | ||
| 50 | + return "" | ||
| 51 | +} | ||
| 52 | + | ||
| 43 | type ArticleCommentRepository interface { | 53 | type ArticleCommentRepository interface { |
| 44 | Insert(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error) | 54 | Insert(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error) |
| 45 | Update(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error) | 55 | Update(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error) |
-
请 注册 或 登录 后发表评论