jt_contact.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/errors"
  13. "xingjia-official-gateway/impl/v1/contact"
  14. param_v1 "xingjia-official-gateway/param/v1"
  15. )
  16. //
  17. // @Summary 联系我们信息
  18. // @Description 联系我们信息
  19. // @Tags 联系我们
  20. // @Accept json
  21. // @Produce json
  22. // @Success 200 {object} v1.ContactInfoResponse
  23. // @Failure 500 {object} base.HTTPError
  24. // @Router /api/v1/jt/contact [get]
  25. func (c *Controller) JtContactInfo(ctx *gin.Context) {
  26. // 解析参数
  27. req := &param_v1.ContactInfoRequest{}
  28. parseParamTask := func() error {
  29. err := util.ShouldBind(ctx, nil, nil, nil, nil)
  30. if err != nil {
  31. logger.Error("func",
  32. zap.String("call", "util.ShouldBind"),
  33. zap.String("error", err.Error()))
  34. return errors.ParamsError
  35. }
  36. return nil
  37. }
  38. // 业务处理
  39. handleServiceTask := func() error {
  40. // 响应数据
  41. resp := param_v1.ContactInfoResponse{}
  42. rpcReq := &apis.ContactInfoRequest{}
  43. rpcRsp, err := contact.ContactInfo(ctx, rpcReq)
  44. if err != nil {
  45. s, _ := json.MarshalToString(req)
  46. logger.Error("func",
  47. zap.String("call", "ContactInfo"),
  48. zap.String("params", s),
  49. zap.String("error", err.Error()))
  50. return errors.ErrorTransForm(err)
  51. }
  52. resp.Data = *rpcRsp
  53. ctx.JSON(http.StatusOK, resp)
  54. return nil
  55. }
  56. // 执行任务
  57. httptasker.Exec(ctx, parseParamTask, handleServiceTask)
  58. }