作者 tangxvhui

Merge branch 'dev' into test

... ... @@ -417,6 +417,7 @@ type (
Tags []int64 `json:"tags,optional"` //标签
Page int `json:"page"` //页码
Size int `json:"size"` //每页行数
OrderMode string `json:"orderMode"` //排序方式
}
SystemArticleSearchResponse {
... ...
... ... @@ -39,6 +39,9 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest)
if err != nil {
return nil, xerr.NewErrMsgErr("获取文章汇总数量失败", err)
}
//TODO 拆分统计
countDataMap := map[int64]*domain.CountArticleTagRead{}
for _, val := range countData {
countDataMap[val.TagId] = val
... ...
... ... @@ -2,6 +2,7 @@ package article
import (
"context"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -33,7 +34,9 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS
WithKV("authorId", req.Author).
WithKV("tags", req.Tags).
WithKV("beginCreatedAt", req.BeginTime).
WithKV("endCreatedAt", req.EndTime)
WithKV("endCreatedAt", req.EndTime).
WithKV("orderMode", req.OrderMode)
total, articles, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, req.CompanyId, queryOptions)
if err != nil {
return nil, xerr.NewErrMsgErr("搜索帖子异常", err)
... ...
... ... @@ -1248,6 +1248,7 @@ type SystemArticleSearchRequest struct {
Tags []int64 `json:"tags,optional"` //标签
Page int `json:"page"` //页码
Size int `json:"size"` //每页行数
OrderMode string `json:"orderMode"` //排序方式
}
type SystemArticleSearchResponse struct {
... ...
... ... @@ -121,7 +121,22 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.
total int64
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("id desc").Where("company_id=?", companyId)
tx = tx.Model(&ms).Where("company_id=?", companyId)
if v, ok := queryOptions["orderMode"]; ok {
mode := v.(string)
switch mode {
case "CountComment ASC":
tx = tx.Order("count_comment asc")
case "CountComment DESC":
tx = tx.Order("count_comment desc")
case "CountLove ASC":
tx = tx.Order("count_love asc")
case "CountLove DESC":
tx = tx.Order("count_love desc")
default:
tx = tx.Order("id desc")
}
}
if v, ok := queryOptions["ids"]; ok {
tx = tx.Where("id in (?)", v)
}
... ...
... ... @@ -3,14 +3,15 @@ package database
import (
"context"
"fmt"
"log"
"os"
"time"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/driver/mysql"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"log"
"os"
"time"
)
func OpenGormDB(source string) *gorm.DB {
... ... @@ -44,6 +45,7 @@ func OpenGormPGDB(source string, logMode string) *gorm.DB {
if err != nil {
panic(err)
}
return db
}
... ...