作者 tangxvhui

新建接口

... ... @@ -30,9 +30,13 @@ service Core {
@handler MiniSetUserLike
post /article/user_like/set (MiniSetUserLikeRequset) returns (MiniSetUserLikeResponse)
@doc "小程序获取文章的编辑记录"
@handler MiniArticleBackupSearch
post /article_backup/search (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse)
@doc "小程序获取我发布的文章"
@handler MiniArticleSearchMe
post /article/search/me (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse)
post /article/search/me (MiniArticleBackupSearchRequest) returns (MiniArticleBackupSearchResponse)
}
... ...
... ... @@ -125,6 +125,28 @@ type (
}
)
// 小程序端获取文章的编辑记录
type (
MiniArticleBackupSearchRequest {
Page int `json:"page"`
Size int `json:"size"`
ArticleId int `json:"articleId"`
CompanyId int64 `json:",optional"` // 服务端自动获取
}
MiniArticleBackupSearchResponse {
Total int `json:"total"`
List []MiniArticleBackupItem `json:"list"`
}
MiniArticleBackupItem {
Id int `json:"id"`
Content string `json:"content"`
Images []string `json:"images"`
CreatedAt int `json:"createdAt"`
Location Location `json:"location"`
}
)
//管理后台获取文章详情
type (
SystemArticleGetRequest {
... ...
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"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniArticleBackupSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniArticleSearchMeRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewMiniArticleBackupSearchLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.MiniArticleBackupSearch(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -7,6 +7,8 @@ import (
"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"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func SystemGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -18,11 +20,9 @@ func SystemGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := article.NewSystemGetArticleLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.SystemGetArticle(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -7,6 +7,8 @@ import (
"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"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func SystemSearchArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -18,11 +20,10 @@ func SystemSearchArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := article.NewSystemSearchArticleLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.SystemSearchArticle(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -199,6 +199,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
},
{
Method: http.MethodPost,
Path: "/article_backup/search",
Handler: article.MiniArticleBackupSearchHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/search/me",
Handler: article.MiniArticleSearchMeHandler(serverCtx),
},
... ...
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 MiniArticleBackupSearchLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniArticleBackupSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleBackupSearchLogic {
return &MiniArticleBackupSearchLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniArticleBackupSearchLogic) MiniArticleBackupSearch(req *types.MiniArticleSearchMeRequest) (resp *types.MiniArticleSearchMeResponse, err error) {
// todo: add your logic here and delete this line
return
}
... ...
... ... @@ -384,6 +384,26 @@ type MiniSetUserLikeResponse struct {
Count int `json:"count"` //现有的点赞数量
}
type MiniArticleBackupSearchRequest struct {
Page int `json:"page"`
Size int `json:"size"`
ArticleId int `json:"articleId"`
CompanyId int64 `json:",optional"` // 服务端自动获取
}
type MiniArticleBackupSearchResponse struct {
Total int `json:"total"`
List []MiniArticleBackupItem `json:"list"`
}
type MiniArticleBackupItem struct {
Id int `json:"id"`
Content string `json:"content"`
Images []string `json:"images"`
CreatedAt int `json:"createdAt"`
Location Location `json:"location"`
}
type SystemArticleGetRequest struct {
Id int64 `path:"id"` //id
CompanyId int64 `path:",optional"`
... ...