sobot.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package http
  2. import (
  3. "encoding/json"
  4. "go-common/app/service/main/workflow/model/account"
  5. "go-common/app/service/main/workflow/model/sobot"
  6. bm "go-common/library/net/http/blademaster"
  7. "go-common/library/net/http/blademaster/binding"
  8. )
  9. func sobotFetchUser(c *bm.Context) {
  10. data := []byte(`
  11. {
  12. "mid": 1,
  13. "uname": "biliuser",
  14. "tel": "132****1234",
  15. "email": "biliuser@qq.com",
  16. "status": 0,
  17. "formal": 0,
  18. "moral": 70,
  19. "level": 3,
  20. "exp": "4000",
  21. "coin": 300.12,
  22. "bcoin": 10.12,
  23. "medal": "青铜殿堂",
  24. "up": {
  25. "relation": {
  26. "following": 1,
  27. "whisper": 1,
  28. "black": 0,
  29. "follower": 1
  30. },
  31. "archive": 5,
  32. "identify": 1,
  33. "office": "bilibili认证",
  34. "shell": 10.12,
  35. "bank_card": "6227123412341234123"
  36. },
  37. "extra": {
  38. "arc_pubed": 312,
  39. "arc_not_pubed": 34,
  40. "arc_is_pubing": 175
  41. }
  42. }
  43. `)
  44. user := &account.User{}
  45. user.Extra = make(map[string]interface{})
  46. if err := json.Unmarshal(data, user); err != nil {
  47. c.JSON(nil, err)
  48. return
  49. }
  50. c.JSON(user, nil)
  51. }
  52. func sobotInfoTicket(c *bm.Context) {
  53. tp := new(struct {
  54. TicketID int32 `form:"ticket_id" validate:"required"`
  55. })
  56. if err := c.Bind(tp); err != nil {
  57. return
  58. }
  59. c.JSON(wkfSvc.SobotTicketInfo(c, tp.TicketID))
  60. }
  61. func sobotAddTicket(c *bm.Context) {
  62. tp := new(sobot.TicketParam)
  63. if err := c.BindWith(tp, binding.FormPost); err != nil {
  64. return
  65. }
  66. c.JSON(nil, wkfSvc.SobotTicketAdd(c, tp))
  67. }
  68. func sobotModifyTicket(c *bm.Context) {
  69. tp := new(sobot.TicketParam)
  70. if err := c.BindWith(tp, binding.FormPost); err != nil {
  71. return
  72. }
  73. c.JSON(nil, wkfSvc.SobotTicketModify(c, tp))
  74. }
  75. func sobotAddReply(c *bm.Context) {
  76. rp := new(sobot.ReplyParam)
  77. if err := c.BindWith(rp, binding.FormPost); err != nil {
  78. return
  79. }
  80. c.JSON(nil, wkfSvc.SobotReplyAdd(c, rp))
  81. }
  82. // func sobotCallback(c *bm.Context) {
  83. // req := c.Request
  84. // bs, err := ioutil.ReadAll(req.Body)
  85. // if err != nil {
  86. // log.Error("ioutil.ReadAll() error(%v)", err)
  87. // c.JSON(nil, ecode.RequestErr)
  88. // return
  89. // }
  90. // req.Body.Close()
  91. // var jsbody map[string]interface{}
  92. // if err := json.Unmarshal(bs, &jsbody); err != nil {
  93. // c.JSON(nil, ecode.RequestErr)
  94. // return
  95. // }
  96. // log.Info("sobotCallback(%s)", string(bs))
  97. // c.JSON(jsbody, nil)
  98. // }