mini_get_article_handler.go
1.0 KB
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 MiniGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniArticleGetRequest
if err := httpx.Parse(r, &req); err != nil {
result.HttpResult(r, w, nil, err)
return
}
l := article.NewMiniGetArticleLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
req.UserId = int(token.UserId)
resp, err := l.MiniGetArticle(&req)
result.HttpResult(r, w, resp, err)
}
}