作者 tangxvhui

新添加接口

... ... @@ -56,6 +56,17 @@ service Core {
@handler SystemArticleCommentSearch
post /article_comment/search (SystemArticleCommentSearchRequest) returns (SystemArticleCommentSearchResponse)
@doc "管理后台查看所有的评论"
@handler SystemListAticleComment
post /article_comment/list (SystemListCommentRequest)returns (SystemListCommentResponse)
@doc "管理后台评论的详情"
@handler SystemGetAticleComment
get /article_comment/:id (SystemGetCommentRequest)returns (SystemGetCommentResponse)
@doc "管理后台变更评论的显示状态"
@handler SystemEditAticleCommentShow
post /article_comment/edit_show (SystemEditCommentShowRequest)returns (SystemEditCommentShowResponse)
}
//评论的填写人
... ... @@ -239,4 +250,70 @@ type (
Content string `json:"content"` // 评论的内容
Show int `json:"show"` // 显示状态
}
)
// 管理后台 评论管理列表
type (
SystemListCommentRequest {
Page int `json:"page"`
Size int `json:"size"`
CompanyId int64 `json:",optional"` //
TopId int64 `json:"topId"` // 文章顶层ID
FromUser string `json:"fromUser,optional"` // 用户
Show int `json:"show,optional"` // 显示状态
BeginTime int64 `json:"beginTime,optional"` // 填写评论的开始时间
EndTime int64 `json:"endTime,optional"` // 填写评论的结束时间
ArticleTitle string `json:"articleTitle,optional"` //
Content string `json:"content,optional"` //
}
SystemListCommentResponse {
Total int `json:"total"`
List []SystemCommentItem `json:"list"`
}
SystemCommentItem {
Id int64 `json:"id"` //评论id
ArticleTitle string `json:"articleTitle"` //文章标题
FromUserId int64 `json:"fromUserId"` //填写评论的人
FromUser CommentAuthor `json:"fromUser"` //填写评论的人
CreatedAt int64 `json:"createdAt"` //评论的填写时间
Content string `json:"content"` //评论的内容
Show int `json:"show"` //是否展示 [1显示] [2不显示]
CountReply int `json:"countReplay"` //回复数量
CountUserLove int `json:"countUserLove"` //用户点赞数量
CountAdminLove int `json:"countAdminLove"` //运营点赞数量
}
)
// 管理后台获取评论详情
type (
SystemGetCommentRequest {
CompanyId int64 `path:",optional"`
Id int64 `path:"id"`
}
SystemGetCommentResponse {
Id int64 `json:"id"` //评论id
ArticleTitle string `json:"articleTitle"` //文章标题
FromUserId int64 `json:"fromUserId"` //填写评论的人
FromUser CommentAuthor `json:"fromUser"` //填写评论的人
CreatedAt int64 `json:"createdAt"` //评论的填写时间
SectionContent string `json:"sectionContent"` //引用的段落内容
Content string `json:"content"` // 评论的内容
Show int `json:"show"` //是否展示 [1显示] [2不显示]
CountReply int `json:"countReplay"` //回复数量
CountUserLove int `json:"countUserLove"` //用户点赞数量
CountAdminLove int `json:"countAdminLove"` //运营点赞数量
}
)
type (
SystemEditCommentShowRequest {
CompanyId int64 `json:",optional"`
Id []int64 `json:"id"`
Show int `json:"show"`
}
SystemEditCommentShowResponse {
Id []int64 `json:"id"`
}
)
\ No newline at end of file
... ...
package comment
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func SystemEditAticleCommentShowHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemEditCommentShowRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := comment.NewSystemEditAticleCommentShowLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.SystemEditAticleCommentShow(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package comment
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func SystemGetAticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemGetCommentRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := comment.NewSystemGetAticleCommentLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.SystemGetAticleComment(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package comment
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func SystemListAticleCommentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemListCommentRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := comment.NewSystemListAticleCommentLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.SystemListAticleComment(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -69,6 +69,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/article_comment/search",
Handler: comment.SystemArticleCommentSearchHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_comment/list",
Handler: comment.SystemListAticleCommentHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article_comment/:id",
Handler: comment.SystemGetAticleCommentHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_comment/edit_show",
Handler: comment.SystemEditAticleCommentShowHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
... ...
package comment
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemEditAticleCommentShowLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemEditAticleCommentShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemEditAticleCommentShowLogic {
return &SystemEditAticleCommentShowLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemEditAticleCommentShowLogic) SystemEditAticleCommentShow(req *types.SystemEditCommentShowRequest) (resp *types.SystemEditCommentShowResponse, err error) {
resp = &types.SystemEditCommentShowResponse{
Id: []int64{},
}
if req.Show == 1 {
for _, val := range req.Id {
err = l.enableShow(val, req.CompanyId)
if err != nil {
err = xerr.NewErrMsgErr("操作失败", err)
} else {
resp.Id = append(resp.Id, val)
}
}
}
if req.Show == 2 {
for _, val := range req.Id {
err = l.disableShow(val, req.CompanyId)
if err != nil {
err = xerr.NewErrMsgErr("操作失败", err)
} else {
resp.Id = append(resp.Id, val)
}
}
}
return
}
func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyId int64) error {
var conn = l.svcCtx.DefaultDBConn()
commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, commentId)
if err != nil {
return xerr.NewErrMsgErr("删除评论信息失败", err)
}
if commetInfo.CompanyId != commentId {
return xerr.NewErrMsg("没有操作权限")
}
if commetInfo.Show == domain.CommentShowDisable {
return nil
}
commetInfo.Show = domain.CommentShowDisable
// 变更回复数量
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
_, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo)
if err != nil {
return err
}
// 减少上级评论的回复数量
if commetInfo.Pid != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.Pid)
if err != nil {
return err
}
}
// 减少最顶层的评论回复计数
if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commetInfo.TopId)
if err != nil {
return err
}
}
//减少加段落评论计数
if commetInfo.SectionId > 0 {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commetInfo.SectionId)
if err != nil {
return err
}
}
// 减少文章的评论数
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commetInfo.ArticleId)
if err != nil {
return err
}
return nil
}, true)
if err != nil {
return xerr.NewErrMsgErr("删除评论信息失败", err)
}
return nil
}
func (l *SystemEditAticleCommentShowLogic) enableShow(commentId int64, companyId int64) error {
var conn = l.svcCtx.DefaultDBConn()
commetInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, commentId)
if err != nil {
return xerr.NewErrMsgErr("删除评论信息失败", err)
}
if commetInfo.CompanyId != commentId {
return xerr.NewErrMsg("没有操作权限")
}
if commetInfo.Show == domain.CommentShowEnable {
return nil
}
commetInfo.Show = domain.CommentShowEnable
// 变更回复数量
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
_, err = l.svcCtx.ArticleCommentRepository.Update(ctx, c, commetInfo)
if err != nil {
return err
}
// 增加上级评论的回复数量
if commetInfo.Pid != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.Pid)
if err != nil {
return err
}
}
// 增加最顶层的评论回复计数
if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.TopId)
if err != nil {
return err
}
}
//增加加段落评论计数
if commetInfo.SectionId > 0 {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, 1, commetInfo.SectionId)
if err != nil {
return err
}
}
// 增加文章的评论数
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, 1, commetInfo.ArticleId)
if err != nil {
return err
}
return nil
}, true)
if err != nil {
return xerr.NewErrMsgErr("删除评论信息失败", err)
}
return nil
}
... ...
package comment
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemGetAticleCommentLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemGetAticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemGetAticleCommentLogic {
return &SystemGetAticleCommentLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemGetAticleCommentLogic) SystemGetAticleComment(req *types.SystemGetCommentRequest) (resp *types.SystemGetCommentResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
commentInfo, err := l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsgErr("获取评论详情失败", err)
}
if commentInfo.CompanyId != req.CompanyId {
return nil, xerr.NewErrMsg("没有查看权限")
}
resp = &types.SystemGetCommentResponse{
Id: commentInfo.Id,
FromUserId: commentInfo.FromUserId,
FromUser: types.CommentAuthor{
Id: commentInfo.FromUserId,
Name: commentInfo.FromUser.Name,
Avatar: commentInfo.FromUser.Avatar,
Position: commentInfo.FromUser.Position,
Company: commentInfo.FromUser.Company,
},
CreatedAt: commentInfo.CreatedAt,
SectionContent: commentInfo.SectionContent,
Content: commentInfo.Content,
Show: int(commentInfo.Show),
CountReply: commentInfo.CountReply,
CountUserLove: commentInfo.CountUserLove,
CountAdminLove: commentInfo.CountAdminLove,
}
return resp, nil
}
... ...
package comment
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemListAticleCommentLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemListAticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemListAticleCommentLogic {
return &SystemListAticleCommentLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 管理后台评论列表
func (l *SystemListAticleCommentLogic) SystemListAticleComment(req *types.SystemListCommentRequest) (resp *types.SystemListCommentResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
cnt, commentList, err := l.svcCtx.ArticleCommentRepository.CustomSearchBy(l.ctx, conn, req.CompanyId, req.Page, req.Size,
req.ArticleTitle, req.Content, req.FromUser, req.Show,
)
if err != nil {
return nil, xerr.NewErrMsgErr("获取评论详情失败", err)
}
resp = &types.SystemListCommentResponse{
Total: cnt,
List: make([]types.SystemCommentItem, len(commentList)),
}
for i, val := range commentList {
resp.List[i] = types.SystemCommentItem{
Id: val.Id,
ArticleTitle: val.ArticleTitle,
FromUserId: val.FromUserId,
FromUser: types.CommentAuthor{
Id: val.FromUser.Id,
Name: val.FromUser.Name,
Avatar: val.FromUser.Avatar,
Position: val.FromUser.Position,
Company: val.FromUser.Company,
},
CreatedAt: val.CreatedAt,
Content: val.Content,
Show: val.Show,
CountReply: val.CountReply,
CountUserLove: val.CountUserLove,
CountAdminLove: val.CountAdminLove,
}
}
return resp, nil
}
... ...
... ... @@ -168,6 +168,66 @@ type SystemArticleCommentSearchItem struct {
Show int `json:"show"` // 显示状态
}
type SystemListCommentRequest struct {
Page int `json:"page"`
Size int `json:"size"`
CompanyId int64 `json:",optional"` //
TopId int64 `json:"topId"` // 文章顶层ID
FromUser string `json:"fromUser,optional"` // 用户
Show int `json:"show,optional"` // 显示状态
BeginTime int64 `json:"beginTime,optional"` // 填写评论的开始时间
EndTime int64 `json:"endTime,optional"` // 填写评论的结束时间
ArticleTitle string `json:"articleTitle,optional"` //
Content string `json:"content,optional"` //
}
type SystemListCommentResponse struct {
Total int `json:"total"`
List []SystemCommentItem `json:"list"`
}
type SystemCommentItem struct {
Id int64 `json:"id"` //评论id
ArticleTitle string `json:"articleTitle"` //文章标题
FromUserId int64 `json:"fromUserId"` //填写评论的人
FromUser CommentAuthor `json:"fromUser"` //填写评论的人
CreatedAt int64 `json:"createdAt"` //评论的填写时间
Content string `json:"content"` //评论的内容
Show int `json:"show"` //是否展示 [1显示] [2不显示]
CountReply int `json:"countReplay"` //回复数量
CountUserLove int `json:"countUserLove"` //用户点赞数量
CountAdminLove int `json:"countAdminLove"` //运营点赞数量
}
type SystemGetCommentRequest struct {
CompanyId int64 `path:",optional"`
Id int64 `path:"id"`
}
type SystemGetCommentResponse struct {
Id int64 `json:"id"` //评论id
ArticleTitle string `json:"articleTitle"` //文章标题
FromUserId int64 `json:"fromUserId"` //填写评论的人
FromUser CommentAuthor `json:"fromUser"` //填写评论的人
CreatedAt int64 `json:"createdAt"` //评论的填写时间
SectionContent string `json:"sectionContent"` //引用的段落内容
Content string `json:"content"` // 评论的内容
Show int `json:"show"` //是否展示 [1显示] [2不显示]
CountReply int `json:"countReplay"` //回复数量
CountUserLove int `json:"countUserLove"` //用户点赞数量
CountAdminLove int `json:"countAdminLove"` //运营点赞数量
}
type SystemEditCommentShowRequest struct {
CompanyId int64 `json:",optional"`
Id []int64 `json:"id"`
Show int `json:"show"`
}
type SystemEditCommentShowResponse struct {
Id []int64 `json:"id"`
}
type MessageSystemRequest struct {
Page int `json:"page"`
Size int `json:"size"`
... ...
... ... @@ -70,3 +70,16 @@ func (m *ArticleComment) CachePrimaryKeyFunc() string {
}
return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key")
}
type ArticleCommentShow struct {
ArticleTitle string //文章标题
Id int64 //评论id
FromUserId int64 // 评论填写人的id
FromUser domain.UserSimple `gorm:"type:jsonb;serializer:json"`
Content string // 评论内容
CountReply int // 回复数量
CountUserLove int // 用户点赞数量
CountAdminLove int // 运营点赞数量
Show int // 评论的展示状态(0显示、1不显示)
CreatedAt int64 // 评论的创建时间
}
... ...
... ... @@ -325,6 +325,88 @@ func (repository *ArticleCommentRepository) Top5Comment(ctx context.Context, con
}
return dms, nil
}
func (repository *ArticleCommentRepository) CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int,
articleTitle string, contentLike string, fromUserName string, show int) (int, []*domain.ArticleCommentShow, error) {
sqlStr := `select
article.title as article_title ,
article_comment.id ,
article_comment.from_user_id ,
article_comment.from_user,
article_comment."content" ,
article_comment.created_at ,
article_comment.count_reply ,
article_comment.count_user_love ,
article_comment.count_admin_love ,
article_comment."show"
from article_comment
join article on article.id = article_comment.article_id
where 1=1 `
if size <= 0 {
size = 20
}
if page <= 0 {
page = 1
}
where := ""
condition := []interface{}{}
if len(articleTitle) > 0 {
where += ` and article.title like ? `
condition = append(condition, "%"+articleTitle+"%")
}
if len(contentLike) > 0 {
where += ` and article_comment."content" like ? `
condition = append(condition, "%"+contentLike+"%")
}
if len(fromUserName) > 0 {
where += ` and article_comment.from_user ->>'name' like ? `
condition = append(condition, "%"+fromUserName+"%")
}
if show > 0 {
where += ` and article_comment."show" =? `
condition = append(condition, show)
}
countSql := sqlStr + where
var cnt int
db := conn.DB()
result := db.Raw(countSql, condition...).Scan(&cnt)
if result.Error != nil {
return 0, nil, result.Error
}
dataSql := sqlStr + where + ` order by article_comment.id desc limit ? offset ? `
condition = append(condition, size, (page-1)*size)
ms := []models.ArticleCommentShow{}
result = db.Raw(dataSql, condition...).Scan(&ms)
if result.Error != nil {
return 0, nil, result.Error
}
d := []*domain.ArticleCommentShow{}
for _, val := range ms {
d = append(d, &domain.ArticleCommentShow{
ArticleTitle: val.ArticleTitle,
Id: val.Id,
FromUserId: val.FromUserId,
FromUser: val.FromUser,
Content: val.Content,
CountReply: val.CountReply,
CountUserLove: val.CountUserLove,
CountAdminLove: val.CountAdminLove,
Show: val.Show,
CreatedAt: val.CreatedAt,
})
}
return cnt, d, nil
}
func NewArticleCommentRepository(cache *cache.CachedRepository) domain.ArticleCommentRepository {
return &ArticleCommentRepository{CachedRepository: cache}
}
... ...
... ... @@ -312,7 +312,7 @@ func (repository *ArticleRepository) CustomSearchBy(ctx context.Context, conn tr
tx = tx.Where("article_and_tag.tag_id=?", tagId)
} else if len(tagCategory) > 0 {
tx = tx.Joins(`join article_and_tag on article.id = article_and_tag.article_id`)
tx = tx.Where(`article_and_tag.tag_id =any(select article_tag.id from article_tag where category =%s )`, tagCategory)
tx = tx.Where(`article_and_tag.tag_id =any(select article_tag.id from article_tag where category =? )`, tagCategory)
}
if len(titleLike) > 0 {
tx = tx.Where("article.title like ?", "%"+titleLike+"%")
... ...
... ... @@ -50,6 +50,19 @@ func (show CommentShow) Named() string {
return ""
}
type ArticleCommentShow struct {
ArticleTitle string // 文章标题
Id int64 // 评论id
FromUserId int64 // 评论填写人的id
FromUser UserSimple // 评论填写人
Content string // 评论内容
CountReply int // 回复数量
CountUserLove int // 用户点赞数量
CountAdminLove int // 运营点赞数量
Show int // 评论的展示状态(0显示、1不显示)
CreatedAt int64 // 评论的创建时间
}
type ArticleCommentRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error)
Update(ctx context.Context, conn transaction.Conn, dm *ArticleComment) (*ArticleComment, error)
... ... @@ -60,4 +73,7 @@ type ArticleCommentRepository interface {
IncreaseCountUserLove(ctx context.Context, conn transaction.Conn, incr int, commentId int64) error //点赞数量变动
IncreaseCountReply(ctx context.Context, conn transaction.Conn, incr int, commentId int64) error // 评论回复数量变动
Top5Comment(ctx context.Context, conn transaction.Conn, companyId int64, articleId int64) ([]*ArticleComment, error)
// 特定的查询
CustomSearchBy(ctx context.Context, conn transaction.Conn, companyId int64, page int, size int,
articleTitle string, contentLike string, fromUserName string, show int) (int, []*ArticleCommentShow, error)
}
... ...