business.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package http
  2. import (
  3. bm "go-common/library/net/http/blademaster"
  4. )
  5. func listBusiness(c *bm.Context) {
  6. v := new(struct {
  7. State int32 `form:"state"`
  8. })
  9. err := c.Bind(v)
  10. if err != nil {
  11. return
  12. }
  13. res, err := rpSvc.ListBusiness(c, v.State)
  14. c.JSON(res, err)
  15. }
  16. func getBusiness(c *bm.Context) {
  17. v := new(struct {
  18. Type int32 `form:"type"`
  19. })
  20. err := c.Bind(v)
  21. if err != nil {
  22. return
  23. }
  24. res, err := rpSvc.GetBusiness(c, v.Type)
  25. c.JSON(res, err)
  26. }
  27. func addBusiness(c *bm.Context) {
  28. v := new(struct {
  29. Type int32 `form:"type" validate:"required"`
  30. Name string `form:"name" validate:"required"`
  31. Appkey string `form:"app_key" validate:"required"`
  32. Remark string `form:"remark" validate:"required"`
  33. Alias string `form:"alias" validate:"required"`
  34. })
  35. var err error
  36. err = c.Bind(v)
  37. if err != nil {
  38. return
  39. }
  40. _, err = rpSvc.AddBusiness(c, v.Type, v.Name, v.Appkey, v.Remark, v.Alias)
  41. c.JSON(nil, err)
  42. }
  43. func upBusiness(c *bm.Context) {
  44. v := new(struct {
  45. Type int32 `form:"type" validate:"required"`
  46. Name string `form:"name" validate:"required"`
  47. Appkey string `form:"app_key" validate:"required"`
  48. Remark string `form:"remark" validate:"required"`
  49. Alias string `form:"alias" validate:"required"`
  50. })
  51. var err error
  52. err = c.Bind(v)
  53. if err != nil {
  54. return
  55. }
  56. _, err = rpSvc.UpBusiness(c, v.Name, v.Appkey, v.Remark, v.Alias, v.Type)
  57. c.JSON(nil, err)
  58. }
  59. func upBusiState(c *bm.Context) {
  60. v := new(struct {
  61. State int32 `form:"state"`
  62. Type int32 `form:"type" validate:"required"`
  63. })
  64. var err error
  65. err = c.Bind(v)
  66. if err != nil {
  67. return
  68. }
  69. _, err = rpSvc.UpBusinessState(c, v.State, v.Type)
  70. c.JSON(nil, err)
  71. }