fund.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package controller
  2. import (
  3. "context"
  4. "github.com/gogf/gf/v2/errors/gcode"
  5. "github.com/gogf/gf/v2/errors/gerror"
  6. "gof_ppw_api/api"
  7. "gof_ppw_api/internal/service"
  8. )
  9. var Fund = &FundController{}
  10. type FundController struct {
  11. Controller
  12. }
  13. // List 基金列表
  14. func (p *FundController) List(ctx context.Context, req *api.FundListReq) (res *api.CommonRes, err error) {
  15. data, count, err := service.Fund.List(ctx, req)
  16. res = &api.CommonRes{
  17. Data: api.PagerRes{
  18. Data: data,
  19. Pager: p.getPager(count, req.Page, req.PageSize),
  20. },
  21. }
  22. return
  23. }
  24. // Detail 基金详情
  25. func (p *FundController) Detail(ctx context.Context, req *api.FundDetailReq) (res *api.CommonRes, err error) {
  26. data, err := service.Fund.Detail(ctx, req.FundId)
  27. res = &api.CommonRes{
  28. Data: data,
  29. }
  30. return
  31. }
  32. // Test 自定义错误测试
  33. func (p *FundController) Test(ctx context.Context, req *api.FundTestReq) (res *api.CommonRes, err error) {
  34. // g.RequestFromCtx(ctx).Response.WriteJson(data)
  35. // 自定义错误代码、错误信息返回
  36. return nil, gerror.NewCode(gcode.New(400, "", nil), "我来报错了-_-")
  37. }