// 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 // @Success 200 {object} v1.JtContentInfoResponse // @Failure 500 {object} base.HTTPError // @Router /api/v1/jt/desc [get] func (c *Controller) JtDescInfo(ctx *gin.Context) { // 解析参数 req := ¶m_v1.JtContentInfoRequest{} parseParamTask := func() error { err := util.ShouldBind(ctx, nil, nil, nil, 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.JtContentInfoResponse{} rpcReq := &apis.JtContentListRequest{ ContentType: consts.OperationModuleDesc, PageSize: 10, Page: 1, } 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 len(rpcRsp.List) == 0 { ctx.JSON(http.StatusOK, resp) return nil } resp.Data.FirstPics = rpcRsp.List[0].FirstPics resp.Data.Title = rpcRsp.List[0].Title resp.Data.Content = rpcRsp.List[0].Content resp.Data.CreatedAt = rpcRsp.List[0].CreatedAt resp.Data.Id = rpcRsp.List[0].Id resp.Data.PublishStatus = rpcRsp.List[0].PublishStatus ctx.JSON(http.StatusOK, resp) return nil } // 执行任务 httptasker.Exec(ctx, parseParamTask, handleServiceTask) }