jt_df.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. // @Param page query int false " "
  24. // @Param page_size query int false " "
  25. // @Success 200 {object} v1.JtContentListResponse
  26. // @Failure 500 {object} base.HTTPError
  27. // @Router /api/v1/jt/df [get]
  28. func (c *Controller) JtDfList(ctx *gin.Context) {
  29. // 解析参数
  30. req := &param_v1.JtContentListRequest{}
  31. parseParamTask := func() error {
  32. err := util.ShouldBind(ctx, nil, nil, &req.JtContentListQuery, nil)
  33. if err != nil {
  34. logger.Error("func",
  35. zap.String("call", "util.ShouldBind"),
  36. zap.String("error", err.Error()))
  37. return errors.ParamsError
  38. }
  39. return nil
  40. }
  41. // 业务处理
  42. handleServiceTask := func() error {
  43. // 响应数据
  44. resp := param_v1.JtContentListResponse{}
  45. rpcReq := &apis.JtContentListRequest{
  46. ContentType: consts.OperationModuleDangfeng,
  47. PageSize: req.PageSize,
  48. Page: req.Page,
  49. }
  50. rpcRsp, err := jt.JtContentList(ctx, rpcReq)
  51. if err != nil {
  52. s, _ := json.MarshalToString(req)
  53. logger.Error("func",
  54. zap.String("call", "jt.JtContentList"),
  55. zap.String("params", s),
  56. zap.String("error", err.Error()))
  57. return errors.ErrorTransForm(err)
  58. }
  59. if rpcRsp.List == nil {
  60. rpcRsp.List = make([]*apis.JtContentItem, 0)
  61. }
  62. resp.Data = *rpcRsp
  63. ctx.JSON(http.StatusOK, resp)
  64. return nil
  65. }
  66. // 执行任务
  67. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  68. }