asset.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package http
  2. import (
  3. api "go-common/app/service/main/ugcpay/api/http"
  4. "go-common/app/service/main/ugcpay/model"
  5. bm "go-common/library/net/http/blademaster"
  6. )
  7. func assetQuery(ctx *bm.Context) {
  8. var (
  9. err error
  10. arg = &api.ArgAssetQuery{}
  11. resp = &api.RespAssetQuery{}
  12. asset *model.Asset
  13. pp map[string]int64
  14. )
  15. if err = ctx.Bind(arg); err != nil {
  16. return
  17. }
  18. if asset, pp, err = srv.AssetQuery(ctx, arg.OID, arg.OType, arg.Currency); err != nil {
  19. ctx.JSON(nil, err)
  20. return
  21. }
  22. resp.Parse(asset, pp)
  23. ctx.JSON(resp, err)
  24. }
  25. func assetRegister(ctx *bm.Context) {
  26. var (
  27. err error
  28. arg = &api.ArgAssetRegister{}
  29. )
  30. if err = ctx.Bind(arg); err != nil {
  31. return
  32. }
  33. ctx.JSON(nil, srv.AssetRegister(ctx, arg.MID, arg.OID, arg.OType, arg.Currency, arg.Price))
  34. }
  35. func assetRelation(ctx *bm.Context) {
  36. var (
  37. err error
  38. arg = &api.ArgAssetRelation{}
  39. resp = &api.RespAssetRelation{}
  40. state string
  41. )
  42. if err = ctx.Bind(arg); err != nil {
  43. return
  44. }
  45. if state, err = srv.AssetRelation(ctx, arg.MID, arg.OID, arg.OType); err != nil {
  46. ctx.JSON(nil, err)
  47. return
  48. }
  49. resp.State = state
  50. ctx.JSON(resp, err)
  51. }
  52. func assetRelationDetail(ctx *bm.Context) {
  53. var (
  54. err error
  55. arg = &api.ArgAssetRelationDetail{}
  56. resp = &api.RespAssetRelationDetail{}
  57. asset *model.Asset
  58. )
  59. if err = ctx.Bind(arg); err != nil {
  60. return
  61. }
  62. if resp.RelationState, err = srv.AssetRelation(ctx, arg.MID, arg.OID, arg.OType); err != nil {
  63. ctx.JSON(nil, err)
  64. return
  65. }
  66. if asset, resp.AssetPlatformPrice, err = srv.AssetQuery(ctx, arg.OID, arg.OType, arg.Currency); err != nil {
  67. ctx.JSON(nil, err)
  68. return
  69. }
  70. resp.AssetPrice = asset.Price
  71. ctx.JSON(resp, err)
  72. }