// Copyright 2019 github.com. All rights reserved. // Use of this source code is governed by github.com. package v1 import ( "git.getensh.com/common/gopkgs/logger" "git.getensh.com/common/gopkgs/tasker/httptasker" "git.getensh.com/common/gopkgs/util" "github.com/gin-gonic/gin" "go.uber.org/zap" "net/http" "xingjia-official-gateway/apis" "xingjia-official-gateway/consts" "xingjia-official-gateway/errors" "xingjia-official-gateway/impl/v1/jt" param_v1 "xingjia-official-gateway/param/v1" ) // // @Summary 兴嘉要闻列表 // @Description 兴嘉要闻列表 // @Tags 兴嘉要闻 // @Accept json // @Produce json // @Param page query int false " " // @Param page_size query int false " " // @Success 200 {object} v1.JtContentListResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/jt/news [get] func (c *Controller) JtNewsList(ctx *gin.Context) { // 解析参数 req := ¶m_v1.JtContentListRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, nil, nil, &req.JtContentListQuery, nil) if err != nil { logger.Error("func", zap.String("call", "util.ShouldBind"), zap.String("error", err.Error())) return errors.ParamsError } return nil } // 业务处理 handleServiceTask := func() error { // 响应数据 resp := param_v1.JtContentListResponse{} rpcReq := &apis.JtContentListRequest{ ContentType: consts.OperationModuleNews, PageSize: req.PageSize, Page: req.Page, } rpcRsp, err := jt.JtContentList(ctx, rpcReq) if err != nil { s, _ := json.MarshalToString(req) logger.Error("func", zap.String("call", "jt.JtContentList"), zap.String("params", s), zap.String("error", err.Error())) return errors.ErrorTransForm(err) } if rpcRsp.List == nil { rpcRsp.List = make([]*apis.JtContentItem, 0) } resp.Data = *rpcRsp ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) }