1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- // 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/vision [get]
- func (c *Controller) JtVisionInfo(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.OperationModuleVision,
- }
- 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)
- }
|