vip.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/admin/main/vip/model"
  5. "go-common/library/ecode"
  6. bm "go-common/library/net/http/blademaster"
  7. )
  8. func drawback(c *bm.Context) {
  9. var (
  10. mid int64
  11. params = c.Request.Form
  12. err error
  13. remark = params.Get("remark")
  14. username string
  15. days int
  16. )
  17. if nameInter, ok := c.Get("username"); ok {
  18. username = nameInter.(string)
  19. }
  20. midStr := params.Get("mid")
  21. if mid, err = strconv.ParseInt(midStr, 10, 64); err != nil {
  22. c.JSON(nil, ecode.RequestErr)
  23. return
  24. }
  25. daysStr := params.Get("days")
  26. if days, err = strconv.Atoi(daysStr); err != nil {
  27. c.JSON(nil, ecode.RequestErr)
  28. return
  29. }
  30. if err = vipSvc.Drawback(c, days, mid, username, remark); err != nil {
  31. c.JSON(nil, err)
  32. return
  33. }
  34. c.JSON(nil, nil)
  35. }
  36. func historyList(c *bm.Context) {
  37. var (
  38. err error
  39. count int
  40. res []*model.VipChangeHistory
  41. req = new(model.UserChangeHistoryReq)
  42. )
  43. if err = c.Bind(req); err != nil {
  44. return
  45. }
  46. if res, count, err = vipSvc.HistoryPage(c, req); err != nil {
  47. c.JSON(nil, err)
  48. return
  49. }
  50. page := &model.PageInfo{Count: count, Item: res}
  51. c.JSON(page, nil)
  52. }
  53. func vipInfo(c *bm.Context) {
  54. arg := new(struct {
  55. Mid int64 `form:"mid"`
  56. })
  57. if err := c.Bind(arg); err != nil {
  58. return
  59. }
  60. c.JSON(vipSvc.VipInfo(c, arg.Mid))
  61. }