recommend.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package http
  2. import (
  3. "context"
  4. "net/http"
  5. "strconv"
  6. "go-common/app/admin/main/mcn/model"
  7. "go-common/library/net/http/blademaster"
  8. )
  9. func recommendAdd(c *blademaster.Context) {
  10. httpPostJSONCookie(
  11. new(model.RecommendUpReq),
  12. func(cont context.Context, arg interface{}) (res interface{}, err error) {
  13. var uids, name *http.Cookie
  14. args := arg.(*model.RecommendUpReq)
  15. if name, err = c.Request.Cookie("username"); err == nil {
  16. args.UserName = name.Value
  17. }
  18. if uids, err = c.Request.Cookie("uid"); err == nil {
  19. if args.UID, err = strconv.ParseInt(uids.Value, 10, 64); err != nil {
  20. return
  21. }
  22. }
  23. return nil, srv.RecommendAdd(cont, arg.(*model.RecommendUpReq))
  24. },
  25. "recommendAdd")(c)
  26. }
  27. func recommendOP(c *blademaster.Context) {
  28. httpPostJSONCookie(
  29. new(model.RecommendStateOpReq),
  30. func(cont context.Context, arg interface{}) (res interface{}, err error) {
  31. var uids, name *http.Cookie
  32. args := arg.(*model.RecommendStateOpReq)
  33. if name, err = c.Request.Cookie("username"); err == nil {
  34. args.UserName = name.Value
  35. }
  36. if uids, err = c.Request.Cookie("uid"); err == nil {
  37. if args.UID, err = strconv.ParseInt(uids.Value, 10, 64); err != nil {
  38. return
  39. }
  40. }
  41. return nil, srv.RecommendOP(cont, arg.(*model.RecommendStateOpReq))
  42. },
  43. "recommendOP")(c)
  44. }
  45. func recommendList(c *blademaster.Context) {
  46. httpGetWriterByExport(
  47. new(model.MCNUPRecommendReq),
  48. func(cont context.Context, arg interface{}) (res interface{}, err error) {
  49. return srv.RecommendList(cont, arg.(*model.MCNUPRecommendReq))
  50. },
  51. "recommendList")(c)
  52. }