作者 tangxvhui

新增接口

... ... @@ -74,8 +74,8 @@ service Core {
get /article_tag/list/all (MiniAllArticleTagRequest) returns (MiniAllArticleTagResponse)
@doc "小程序首页数据展示"
@handler MinishowHomePage
get /show/home_page (MiniAllArticleTagRequest) returns (MiniAllArticleTagResponse)
@handler MiniShowHomePage
get /show/home_page (MiniHomePageRequest) returns (MiniHomePageRespose)
}
... ...
... ... @@ -281,13 +281,13 @@ type (
}
MiniArticleMarkItem {
Id int64 `json:"id"`
CompanyId int64 `json:"companyId"`
UserId int64 `json:"userId"`
ArticleId int64 `json:"articleId"`
Title string `json:"title"`
Id int64 `json:"id"`
CompanyId int64 `json:"companyId"`
UserId int64 `json:"userId"`
ArticleId int64 `json:"articleId"`
Title string `json:"title"`
Author SimpleUser `json:"author"` // 发布人
UpdatedAt int64 `json:"updatedAt"`
UpdatedAt int64 `json:"updatedAt"`
}
)
... ... @@ -460,4 +460,21 @@ type (
//小程序端 首页数据展示
// 统计各标签下的文章数量,和已被人员阅读的数量
type
\ No newline at end of file
type (
MiniHomePageRequest {
CompanyId int64 `path:",optional"`
UserId int64 `path:",optional"`
}
MiniHomePageRespose {
Tags []ArticleTagCount `json:"tags"`
}
ArticleTagCount {
TagGroup string `json:"tagGroup"` // 标签分组
TagId int64 `json:"tagId"` // 标签id
TagImage string `json:"tagImage"` // 对应的图标
TagName string `json:"tagName"` // 标签名称
TagRemark string `json:"tagRemark"` // 标签备注
TotalArticle int `json:"totalArticle"` // 总的文章数量
ReadArticle int `json:"readArticle"` // 已读的标签数量
}
)
\ No newline at end of file
... ...
package article
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
"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 MiniShowHomePageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniHomePageRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewMiniShowHomePageLogic(r.Context(), svcCtx)
resp, err := l.MiniShowHomePage(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
... ...
... ... @@ -364,6 +364,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/article_tag/list/all",
Handler: article.MiniAllArticleTagHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/show/home_page",
Handler: article.MiniShowHomePageHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
rest.WithPrefix("/v1/mini"),
... ...
package article
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"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniShowHomePageLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniShowHomePageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniShowHomePageLogic {
return &MiniShowHomePageLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest) (resp *types.MiniHomePageRespose, err error) {
// todo: add your logic here and delete this line
return
}
... ...
... ... @@ -993,6 +993,25 @@ type SystemArticleGetHistoryResponse struct {
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
type MiniHomePageRequest struct {
CompanyId int64 `path:",optional"`
UserId int64 `path:",optional"`
}
type MiniHomePageRespose struct {
Tags []ArticleTagCount `json:"tags"`
}
type ArticleTagCount struct {
TagGroup string `json:"tagGroup"` // 标签分组
TagId int64 `json:"tagId"` // 标签id
TagImage string `json:"tagImage"` // 对应的图标
TagName string `json:"tagName"` // 标签名称
TagRemark string `json:"tagRemark"` // 标签备注
TotalArticle int `json:"totalArticle"` // 总的文章数量
ReadArticle int `json:"readArticle"` // 已读的标签数量
}
type RoleGetRequest struct {
Id int64 `path:"id"`
}
... ...