jt_desc.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package v1
  4. import (
  5. "git.getensh.com/common/gopkgs/logger"
  6. "git.getensh.com/common/gopkgs/tasker/httptasker"
  7. "git.getensh.com/common/gopkgs/util"
  8. "github.com/gin-gonic/gin"
  9. "go.uber.org/zap"
  10. "net/http"
  11. "xingjia-official-gateway/apis"
  12. "xingjia-official-gateway/consts"
  13. "xingjia-official-gateway/errors"
  14. "xingjia-official-gateway/impl/v1/jt"
  15. param_v1 "xingjia-official-gateway/param/v1"
  16. )
  17. //
  18. // @Summary 集团简介信息
  19. // @Description 集团简介信息
  20. // @Tags 集团简介
  21. // @Accept json
  22. // @Produce json
  23. // @Success 200 {object} v1.JtContentInfoResponse
  24. // @Failure 500 {object} base.HTTPError
  25. // @Router /api/v1/jt/desc [get]
  26. func (c *Controller) JtDescInfo(ctx *gin.Context) {
  27. // 解析参数
  28. req := &param_v1.JtContentInfoRequest{}
  29. parseParamTask := func() error {
  30. err := util.ShouldBind(ctx, nil, nil, nil, nil)
  31. if err != nil {
  32. logger.Error("func",
  33. zap.String("call", "util.ShouldBind"),
  34. zap.String("error", err.Error()))
  35. return errors.ParamsError
  36. }
  37. return nil
  38. }
  39. // 业务处理
  40. handleServiceTask := func() error {
  41. // 响应数据
  42. resp := param_v1.JtContentInfoResponse{}
  43. rpcReq := &apis.JtContentListRequest{
  44. ContentType: consts.OperationModuleDesc,
  45. PageSize: 10,
  46. Page: 1,
  47. }
  48. rpcRsp, err := jt.JtContentList(ctx, rpcReq)
  49. if err != nil {
  50. s, _ := json.MarshalToString(req)
  51. logger.Error("func",
  52. zap.String("call", "jt.JtContentList"),
  53. zap.String("params", s),
  54. zap.String("error", err.Error()))
  55. return errors.ErrorTransForm(err)
  56. }
  57. if len(rpcRsp.List) == 0 {
  58. ctx.JSON(http.StatusOK, resp)
  59. return nil
  60. }
  61. resp.Data.FirstPics = rpcRsp.List[0].FirstPics
  62. resp.Data.Title = rpcRsp.List[0].Title
  63. resp.Data.Content = rpcRsp.List[0].Content
  64. resp.Data.CreatedAt = rpcRsp.List[0].CreatedAt
  65. resp.Data.Id = rpcRsp.List[0].Id
  66. resp.Data.PublishStatus = rpcRsp.List[0].PublishStatus
  67. ctx.JSON(http.StatusOK, resp)
  68. return nil
  69. }
  70. // 执行任务
  71. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  72. }