作者 tangxvhui
... ... @@ -723,6 +723,24 @@
]
}
},
"v1/mini/show/home_page": {
"get": {
"summary": "小程序首页数据展示",
"operationId": "MiniShowHomePage",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniHomePageRespose"
}
}
},
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/mini/user/apply-join-company": {
"post": {
"summary": "用户申请加入公司",
... ... @@ -1361,6 +1379,34 @@
]
}
},
"v1/system/article_comment/search": {
"post": {
"summary": "管理后台文章评论列表",
"operationId": "SystemArticleCommentSearch",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleCommentSearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleCommentSearchRequest"
}
}
],
"requestBody": {},
"tags": [
"comment"
]
}
},
"v1/system/article_comment/search/me": {
"post": {
"summary": "小程序获取回复@人可选列表",
... ... @@ -1443,6 +1489,24 @@
]
}
},
"v1/system/article_tag/options": {
"get": {
"summary": "后台标签下拉列表",
"operationId": "Options",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagOptionsResponse"
}
}
},
"requestBody": {},
"tags": [
"tags"
]
}
},
"v1/system/article_tag/search": {
"post": {
"summary": "后台搜索标签",
... ... @@ -2308,6 +2372,52 @@
"totalComment"
]
},
"ArticleTagCount": {
"type": "object",
"properties": {
"tagGroup": {
"type": "string",
"description": " 标签分组"
},
"tagId": {
"type": "integer",
"format": "int64",
"description": " 标签id"
},
"tagImage": {
"type": "string",
"description": " 对应的图标"
},
"tagName": {
"type": "string",
"description": " 标签名称"
},
"tagRemark": {
"type": "string",
"description": " 标签备注"
},
"totalArticle": {
"type": "integer",
"format": "int32",
"description": " 总的文章数量"
},
"readArticle": {
"type": "integer",
"format": "int32",
"description": " 已读的标签数量"
}
},
"title": "ArticleTagCount",
"required": [
"tagGroup",
"tagId",
"tagImage",
"tagName",
"tagRemark",
"totalArticle",
"readArticle"
]
},
"ArticleTagGroup": {
"type": "object",
"properties": {
... ... @@ -4033,6 +4143,35 @@
},
"title": "MiniGetArticleCommentResponse"
},
"MiniHomePageRequest": {
"type": "object",
"properties": {
"": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniHomePageRequest"
},
"MiniHomePageRespose": {
"type": "object",
"properties": {
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleTagCount"
}
}
},
"title": "MiniHomePageRespose",
"required": [
"tags"
]
},
"MiniListArticleCommentRequest": {
"type": "object",
"properties": {
... ... @@ -4330,21 +4469,6 @@
"$ref": "#/definitions/UserItem",
"description": " 用户信息"
},
"totalArticle": {
"type": "integer",
"format": "int64",
"description": " 累计信息发布"
},
"totalLoved": {
"type": "integer",
"format": "int64",
"description": " 累计收到的赞"
},
"totalAccepted": {
"type": "integer",
"format": "int64",
"description": " 累计被采纳"
},
"accounts": {
"type": "array",
"items": {
... ... @@ -4363,9 +4487,6 @@
"title": "MiniUserInfoResponse",
"required": [
"user",
"totalArticle",
"totalLoved",
"totalAccepted",
"accounts",
"auths"
]
... ... @@ -4891,6 +5012,87 @@
"value"
]
},
"SystemArticleCommentSearchItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"pid": {
"type": "integer",
"format": "int64"
},
"topId": {
"type": "integer",
"format": "int64"
},
"articleId": {
"type": "integer",
"format": "int64",
"description": " 文章id"
},
"sectionId": {
"type": "integer",
"format": "int64",
"description": " 段落id"
},
"fromUserId": {
"type": "integer",
"format": "int64",
"description": " 填写评论的人"
},
"fromUser": {
"$ref": "#/definitions/CommentAuthor",
"description": " 填写评论的人"
},
"countReply": {
"type": "integer",
"format": "int32",
"description": " 回复数量"
},
"countUserLove": {
"type": "integer",
"format": "int32",
"description": " 用户点赞数量"
},
"countAdminLove": {
"type": "integer",
"format": "int32",
"description": " 运营点赞数量"
},
"createdAt": {
"type": "integer",
"format": "int64",
"description": " 评论时间"
},
"content": {
"type": "string",
"description": " 评论的内容"
},
"show": {
"type": "integer",
"format": "int32",
"description": " 显示状态"
}
},
"title": "SystemArticleCommentSearchItem",
"required": [
"id",
"pid",
"topId",
"articleId",
"sectionId",
"fromUserId",
"fromUser",
"countReply",
"countUserLove",
"countAdminLove",
"createdAt",
"content",
"show"
]
},
"SystemArticleCommentSearchMeRequest": {
"type": "object",
"properties": {
... ... @@ -4945,6 +5147,76 @@
"total"
]
},
"SystemArticleCommentSearchRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
},
"articleId": {
"type": "integer",
"format": "int64",
"description": " 文章ID"
},
"topId": {
"type": "integer",
"format": "int64",
"description": " 文章顶层ID"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": " 用户"
},
"show": {
"type": "integer",
"format": "int32",
"description": " 显示状态"
},
"beginTime": {
"type": "integer",
"format": "int64",
"description": " 开始时间"
},
"endTime": {
"type": "integer",
"format": "int64",
"description": " 结束时间"
}
},
"title": "SystemArticleCommentSearchRequest",
"required": [
"page",
"size",
"articleId",
"topId"
]
},
"SystemArticleCommentSearchResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int64"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/SystemArticleCommentSearchItem"
}
}
},
"title": "SystemArticleCommentSearchResponse",
"required": [
"total",
"list"
]
},
"SystemArticleGetHistoryRequest": {
"type": "object",
"properties": {
... ... @@ -5578,14 +5850,10 @@
},
"description": " 评论人"
},
"location": {
"$ref": "#/definitions/Location",
"description": " 坐标"
},
"targetUser": {
"type": "integer",
"format": "int32",
"description": "分发方式 [0分发给所有人、1分发给指定的人]"
"description": " 分发方式 [0分发给所有人、1分发给指定的人]"
},
"tags": {
"type": "array",
... ... @@ -5594,6 +5862,10 @@
"format": "int64"
},
"description": " 标签"
},
"AccessToken": {
"type": "string",
"description": " 授权token"
}
},
"title": "SystemArticleUpdateRequest",
... ... @@ -5605,9 +5877,9 @@
"images",
"whoRead",
"whoReview",
"location",
"targetUser",
"tags"
"tags",
"x-mmm-accesstoken"
]
},
"SystemArticleUpdateResponse": {
... ... @@ -5643,7 +5915,7 @@
"format": "int32",
"description": "点赞数量"
},
"CountComment": {
"countComment": {
"type": "integer",
"format": "int32",
"description": "评论数量"
... ... @@ -5675,7 +5947,7 @@
"images",
"createdAt",
"countLove",
"CountComment",
"countComment",
"show",
"tags",
"targetUser"
... ... @@ -6368,6 +6640,71 @@
"list"
]
},
"TagOptionValue": {
"type": "object",
"properties": {
"label": {
"type": "string",
"description": " 名称"
},
"value": {
"type": "integer",
"format": "int64",
"description": " 标签ID"
}
},
"title": "TagOptionValue",
"required": [
"label",
"value"
]
},
"TagOptions": {
"type": "object",
"properties": {
"label": {
"type": "string",
"description": " 分组名称"
},
"options": {
"type": "array",
"items": {
"$ref": "#/definitions/TagOptionValue"
}
}
},
"title": "TagOptions",
"required": [
"label",
"options"
]
},
"TagOptionsRequest": {
"type": "object",
"properties": {
"": {
"type": "integer",
"format": "int64",
"description": " 公司ID"
}
},
"title": "TagOptionsRequest"
},
"TagOptionsResponse": {
"type": "object",
"properties": {
"options": {
"type": "array",
"items": {
"$ref": "#/definitions/TagOptions"
}
}
},
"title": "TagOptionsResponse",
"required": [
"options"
]
},
"UserFollowItem": {
"type": "object",
"properties": {
... ...
... ... @@ -32,7 +32,11 @@ service Core {
@doc "后台搜索标签"
@handler SearchTag
post/article_tag/search (TagListRequest) returns (TagListResponse)
post /article_tag/search (TagListRequest) returns (TagListResponse)
@doc "后台标签下拉列表"
@handler Options
get /article_tag/options (TagOptionsRequest) returns (TagOptionsResponse)
}
// 创建标签
... ... @@ -118,3 +122,21 @@ type (
Id int64 `json:"id"`
}
)
//标签下拉列表
type (
TagOptionsRequest {
CompanyId int64 `path:",optional"` // 公司ID
}
TagOptionsResponse {
Options []TagOptions `json:"options"`
}
TagOptions {
Label string `json:"label"` // 分组名称
Options []TagOptionValue `json:"options"`
}
TagOptionValue {
Label string `json:"label"` // 名称
Value int64 `json:"value"` // 标签ID
}
)
\ No newline at end of file
... ...
... ... @@ -388,6 +388,9 @@ type (
Tags []string `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
)
// 管理后台编辑文章
type (
//编辑
SystemArticleUpdateRequest {
Id int64 `json:"id"`
... ... @@ -398,7 +401,6 @@ type (
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
Tags []int64 `json:"tags"` // 标签
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
... ... @@ -415,6 +417,9 @@ type (
Tags []int64 `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
)
// 管理后台编辑历史列表
type (
//历史
SystemArticleHistoryRequest {
ArticleId int64 `json:"articleId"` //文章ID
... ... @@ -434,6 +439,9 @@ type (
Action string `json:"action"` //编辑类型
UpdatedAt int64 `json:"updatedAt"` //编辑时间
}
)
// 管理后台历史记录详情
type (
SystemArticleGetHistoryRequest {
Id int64 `path:"id"` //id
CompanyId int64 `path:",optional"`
... ... @@ -453,6 +461,9 @@ type (
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
Tags []int64 `json:"tags"` // 标签
}
)
// 管理后台文章恢复
type (
SystemArticleRestoreRequest {
Id int64 `json:"id"` //ID
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
... ...
... ... @@ -15,7 +15,6 @@ info(
jwt: MiniAuth
)
service Core {
@doc "小程序填写文章的评论"
@handler MiniCreateArticleComment
post /article_comment (MiniCreateArticleCommentRequest) returns (MiniCreateArticleCommentResponse)
... ... @@ -52,6 +51,11 @@ service Core {
@doc "小程序获取回复@人可选列表"
@handler SystemArticleCommentSearchMe
post /article_comment/search/me (SystemArticleCommentSearchMeRequest) returns (SystemArticleCommentSearchMeResponse)
@doc "管理后台文章评论列表"
@handler SystemArticleCommentSearch
post /article_comment/search (SystemArticleCommentSearchRequest) returns (SystemArticleCommentSearchResponse)
}
//评论的填写人
... ... @@ -204,3 +208,35 @@ type (
Total int64 `json:"total"`
}
)
// 文章里的评论列表
type (
SystemArticleCommentSearchRequest {
Page int `json:"page"`
Size int `json:"size"`
ArticleId int64 `json:"articleId"` // 文章ID
TopId int64 `json:"topId"` // 文章顶层ID
AuthorId int64 `json:"authorId,optional"` // 用户
Show int `json:"show,optional"` // 显示状态
BeginTime int64 `json:"beginTime,optional"` // 开始时间
EndTime int64 `json:"endTime,optional"` // 结束时间
}
SystemArticleCommentSearchResponse {
Total int64 `json:"total"`
List []SystemArticleCommentSearchItem `json:"list"`
}
SystemArticleCommentSearchItem {
Id int64 `json:"id"`
Pid int64 `json:"pid"`
TopId int64 `json:"topId"`
ArtitcleId int64 `json:"articleId"` // 文章id
SectionId int64 `json:"sectionId"` // 段落id
FromUserId int64 `json:"fromUserId"` // 填写评论的人
FromUser CommentAuthor `json:"fromUser"` // 填写评论的人
CountReply int `json:"countReply"` // 回复数量
CountUserLove int `json:"countUserLove"` // 用户点赞数量
CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
CreatedAt int64 `json:"createdAt"` // 评论时间
Content string `json:"content"` // 评论的内容
Show int `json:"show"` // 显示状态
}
)
\ No newline at end of file
... ...
package comment
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"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"
)
func SystemArticleCommentSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleCommentSearchRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := comment.NewSystemArticleCommentSearchLogic(r.Context(), svcCtx)
resp, err := l.SystemArticleCommentSearch(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -64,6 +64,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/article_comment/search/me",
Handler: comment.SystemArticleCommentSearchMeHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_comment/search",
Handler: comment.SystemArticleCommentSearchHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
... ... @@ -114,6 +119,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/article_tag/search",
Handler: tags.SearchTagHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article_tag/options",
Handler: tags.OptionsHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1/system"),
... ...
package tags
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func OptionsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.TagOptionsRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := tags.NewOptionsLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.Options(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -11,6 +11,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"strings"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -51,29 +52,98 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
Height: h,
})
}
//检查文章可被哪些人查看
whoRead := []int64{}
if len(req.WhoRead) > 0 {
whoRead = lo.Uniq(req.WhoRead)
var u *domain.User
for _, val := range whoRead {
u, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, val)
if err != nil {
return nil, xerr.NewErrMsgErr("文章可查看人设置错误", err)
}
if u.CompanyId != article.CompanyId {
return nil, xerr.NewErrMsg("文章可查看人设置错误")
}
}
}
//检查文章可被哪些人评论
whoReview := []int64{}
if len(req.WhoReview) > 0 {
whoReview = lo.Uniq(req.WhoReview)
}
//有指定可查看人的情况
if len(whoRead) > 0 {
if len(whoReview) > 0 {
// 检查 whoRead 是否 完全包含 whoReview
ok := lo.Every(whoRead, whoReview)
if !ok {
return nil, xerr.NewErrMsg("文章可评论人设置错误")
}
}
if len(whoReview) == 0 {
//有指定可查看人 ,但未指定可评论人
return nil, xerr.NewErrMsg("文章可评论人设置错误")
}
}
//没有指定可查看人的情况
if len(whoRead) == 0 {
if len(whoReview) > 0 {
// 未指定可查看人(全员可看),有指定可评论人,
var u *domain.User
for _, val := range whoReview {
u, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, val)
if err != nil {
return nil, xerr.NewErrMsgErr("文章可评论人设置错误", err)
}
if u.CompanyId != article.CompanyId {
return nil, xerr.NewErrMsg("文章可评论人设置错误")
}
}
}
}
//验证tag
if len(req.Tags) > 0 {
req.Tags = lo.Uniq(req.Tags)
for _, value := range req.Tags {
t, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, value)
if err != nil {
return nil, xerr.NewErrMsgErr("文章标签设置错误", err)
}
if t.CompanyId != article.CompanyId {
return nil, xerr.NewErrMsgErr("文章标签设置错误", err)
}
}
}
article.Title = req.Title
article.Version = article.Version + 1
article.Images = images
article.WhoRead = req.WhoRead
article.WhoReview = req.WhoReview
article.WhoRead = whoRead
article.WhoReview = whoReview
article.TargetUser = domain.ArticleTarget(req.TargetUser)
article.Location = domain.Location{
Longitude: req.Location.Longitude,
Latitude: req.Location.Latitude,
Descript: req.Location.Descript,
}
article.Tags = req.Tags
//文章内容
articleSections := []domain.ArticleSection{}
sortBy := 1
lo.ForEach(req.Section, func(item types.ArticleSection, index int) {
articleSections = append(articleSections, domain.ArticleSection{
Id: item.Id,
strList := strings.Split(item.Content, "\n")
for key, value := range strList {
if value == "" {
continue
}
section := domain.ArticleSection{
CompanyId: article.CompanyId,
Version: article.Version,
ArticleId: article.Id,
Content: item.Content,
SortBy: index + 1,
})
Content: value,
SortBy: sortBy,
}
if key == 0 {
section.Id = item.Id
}
articleSections = append(articleSections, section)
sortBy++
}
})
//设置内容概要
if len(req.Section) > 0 {
... ...
package comment
import (
"context"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemArticleCommentSearchLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemArticleCommentSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleCommentSearchLogic {
return &SystemArticleCommentSearchLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemArticleCommentSearchLogic) SystemArticleCommentSearch(req *types.SystemArticleCommentSearchRequest) (resp *types.SystemArticleCommentSearchResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
queryOptions := domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
WithKV("articleId", req.ArticleId).
WithKV("topId", req.TopId).
WithKV("fromUserId", req.AuthorId).
WithKV("beginCreatedAt", req.BeginTime).
WithKV("endCreatedAt", req.EndTime)
total, comments, err := l.svcCtx.ArticleCommentRepository.Find(l.ctx, conn, queryOptions)
if err != nil {
return nil, xerr.NewErrMsgErr("获取文章评论失败", err)
}
resp = &types.SystemArticleCommentSearchResponse{
Total: total,
List: make([]types.SystemArticleCommentSearchItem, 0),
}
lo.ForEach(comments, func(item *domain.ArticleComment, index int) {
resp.List = append(resp.List, types.SystemArticleCommentSearchItem{
Id: item.Id,
Pid: item.Pid,
TopId: item.TopId,
ArtitcleId: item.ArticleId,
SectionId: item.SectionId,
FromUserId: item.FromUserId,
FromUser: types.CommentAuthor{
Id: item.FromUser.Id,
Name: item.FromUser.Name,
Avatar: item.FromUser.Avatar,
Company: item.FromUser.Company,
Position: item.FromUser.Position,
},
CountReply: item.CountReply,
CountUserLove: item.CountUserLove,
CountAdminLove: item.CountAdminLove,
CreatedAt: item.CreatedAt,
Content: item.Content,
Show: int(item.Show),
})
})
return
}
... ...
package tags
import (
"context"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type OptionsLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewOptionsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OptionsLogic {
return &OptionsLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *OptionsLogic) Options(req *types.TagOptionsRequest) (resp *types.TagOptionsResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
queryOption := domain.NewQueryOptions().WithFindOnly()
_, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取标签列表失败", err)
}
var group []string
options := make(map[string][]types.TagOptionValue)
lo.ForEach(tagList, func(tag *domain.ArticleTag, index int) {
if _, ok := options[tag.Category]; !ok {
options[tag.Category] = make([]types.TagOptionValue, 0)
group = append(group, tag.Category)
}
options[tag.Category] = append(options[tag.Category], types.TagOptionValue{
Label: tag.Name,
Value: tag.Id,
})
})
resp = &types.TagOptionsResponse{Options: []types.TagOptions{}}
for _, value := range group {
ops := []types.TagOptionValue{}
if _, ok := options[value]; ok {
ops = options[value]
}
resp.Options = append(resp.Options, types.TagOptions{
Label: value,
Options: ops,
})
}
return
}
... ...
... ... @@ -136,6 +136,38 @@ type SystemArticleCommentSearchMeResponse struct {
Total int64 `json:"total"`
}
type SystemArticleCommentSearchRequest struct {
Page int `json:"page"`
Size int `json:"size"`
ArticleId int64 `json:"articleId"` // 文章ID
TopId int64 `json:"topId"` // 文章顶层ID
AuthorId int64 `json:"authorId,optional"` // 用户
Show int `json:"show,optional"` // 显示状态
BeginTime int64 `json:"beginTime,optional"` // 开始时间
EndTime int64 `json:"endTime,optional"` // 结束时间
}
type SystemArticleCommentSearchResponse struct {
Total int64 `json:"total"`
List []SystemArticleCommentSearchItem `json:"list"`
}
type SystemArticleCommentSearchItem struct {
Id int64 `json:"id"`
Pid int64 `json:"pid"`
TopId int64 `json:"topId"`
ArtitcleId int64 `json:"articleId"` // 文章id
SectionId int64 `json:"sectionId"` // 段落id
FromUserId int64 `json:"fromUserId"` // 填写评论的人
FromUser CommentAuthor `json:"fromUser"` // 填写评论的人
CountReply int `json:"countReply"` // 回复数量
CountUserLove int `json:"countUserLove"` // 用户点赞数量
CountAdminLove int `json:"countAdminLove"` // 运营点赞数量
CreatedAt int64 `json:"createdAt"` // 评论时间
Content string `json:"content"` // 评论的内容
Show int `json:"show"` // 显示状态
}
type MessageSystemRequest struct {
Page int `json:"page"`
Size int `json:"size"`
... ... @@ -274,6 +306,24 @@ type TagDeleteResponse struct {
Id int64 `json:"id"`
}
type TagOptionsRequest struct {
CompanyId int64 `path:",optional"` // 公司ID
}
type TagOptionsResponse struct {
Options []TagOptions `json:"options"`
}
type TagOptions struct {
Label string `json:"label"` // 分组名称
Options []TagOptionValue `json:"options"`
}
type TagOptionValue struct {
Label string `json:"label"` // 名称
Value int64 `json:"value"` // 标签ID
}
type MiniUserLoginRequest struct {
LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login
WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码
... ... @@ -935,7 +985,6 @@ type SystemArticleUpdateRequest struct {
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
Tags []int64 `json:"tags"` // 标签
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
... ...
... ... @@ -96,7 +96,6 @@ func (repository *ArticleSectionRepository) DeleteBy(ctx context.Context, conn t
m = &models.ArticleSection{}
)
queryFunc := func() (interface{}, error) {
tx = tx.Where("id = ?", m.Id)
if v, ok := queryOptions["articleId"]; ok {
tx = tx.Where("article_id = ?", v)
}
... ... @@ -141,7 +140,7 @@ func (repository *ArticleSectionRepository) Find(ctx context.Context, conn trans
total int64
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("id desc")
tx = tx.Model(&ms).Order("sort_by")
if v, ok := queryOptions["articleId"]; ok {
tx = tx.Where("article_id = ?", v)
... ...