参数对象定义
参数对象使用
// @summary 展示文章首页
// @tags 前台-文章
// @produce html
// @param cate query int false "栏目ID"
// @param size query int false "分页数量"
// @param sort query string false "排序方式"
// @router /article [GET]
// @success 200 {string} html "页面HTML"
func (a *articleApi) Index(r *ghttp.Request) {
data *define.ContentServiceGetListReq
)
if err := r.Parse(&data); err != nil {
service.View.Render500(r, model.View{
Error: err.Error(),
})
}
data.Type = model.ContentTypeArticle
if getListRes, err := service.Content.GetList(r.Context(), data); err != nil {
service.View.Render500(r, model.View{
} else {
service.View.Render(r, model.View{
ContentType: data.Type,
Data: getListRes,
Title: service.View.GetTitle(r.Context(), &define.ViewServiceGetTitleReq{
ContentType: data.Type,
CategoryId: data.CategoryId,
}),
})
}
}