wechat.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package http
  2. import (
  3. "go-common/app/admin/ep/saga/model"
  4. bm "go-common/library/net/http/blademaster"
  5. "go-common/library/net/http/blademaster/binding"
  6. )
  7. //queryContactLogs queryContactLogs
  8. func queryContactLogs(c *bm.Context) {
  9. v := &model.QueryContactLogRequest{}
  10. if err := c.Bind(v); err != nil {
  11. return
  12. }
  13. if err := v.Verify(); err != nil {
  14. c.JSON(nil, err)
  15. return
  16. }
  17. c.JSON(srv.QueryContactLogs(c, v))
  18. }
  19. //queryContactLogs queryContactLogs
  20. func queryRedisdata(c *bm.Context) {
  21. v := &model.QueryContactLogRequest{}
  22. if err := c.Bind(v); err != nil {
  23. return
  24. }
  25. if err := v.Verify(); err != nil {
  26. c.JSON(nil, err)
  27. return
  28. }
  29. c.JSON(srv.QueryContactLogs(c, v))
  30. }
  31. // SyncContacts sync the wechat contacts 更新企业微信列表(用户信息和saga信息)
  32. func queryContacts(ctx *bm.Context) {
  33. var (
  34. req = &model.EmptyReq{}
  35. v = &model.Pagination{}
  36. err error
  37. )
  38. if err = ctx.Bind(req); err != nil {
  39. ctx.JSON(nil, err)
  40. return
  41. }
  42. if err = ctx.Bind(v); err != nil {
  43. return
  44. }
  45. ctx.JSON(srv.QueryContacts(ctx, v))
  46. }
  47. func createWechat(ctx *bm.Context) {
  48. var (
  49. username string
  50. err error
  51. )
  52. req := &model.CreateChatReq{}
  53. if err = ctx.BindWith(req, binding.JSON); err != nil {
  54. ctx.JSON(nil, err)
  55. return
  56. }
  57. if username, err = getUsername(ctx); err != nil {
  58. ctx.JSON(nil, err)
  59. return
  60. }
  61. ctx.JSON(srv.CreateWechat(ctx, req, username))
  62. }
  63. func queryWechatCreateLog(ctx *bm.Context) {
  64. var (
  65. req = &model.Pagination{}
  66. err error
  67. user string
  68. )
  69. if err = ctx.Bind(req); err != nil {
  70. return
  71. }
  72. if err = req.Verify(); err != nil {
  73. ctx.JSON(nil, err)
  74. return
  75. }
  76. if user, err = getUsername(ctx); err != nil {
  77. ctx.JSON(nil, err)
  78. return
  79. }
  80. ctx.JSON(srv.QueryWechatCreateLog(ctx, req, user))
  81. }
  82. func getWechat(ctx *bm.Context) {
  83. ctx.JSON(srv.WechatParams(ctx, ctx.Request.Form.Get("chatid")))
  84. }
  85. func sendGroupWechat(ctx *bm.Context) {
  86. req := &model.SendChatReq{}
  87. if err := ctx.BindWith(req, binding.JSON); err != nil {
  88. ctx.JSON(nil, err)
  89. return
  90. }
  91. ctx.JSON(srv.SendGroupWechat(ctx, req))
  92. }
  93. func sendWechat(ctx *bm.Context) {
  94. req := &model.SendMessageReq{}
  95. if err := ctx.BindWith(req, binding.JSON); err != nil {
  96. ctx.JSON(nil, err)
  97. return
  98. }
  99. ctx.JSON(srv.SendWechat(ctx, req))
  100. }
  101. func updateWechat(ctx *bm.Context) {
  102. req := &model.UpdateChatReq{}
  103. if err := ctx.BindWith(req, binding.JSON); err != nil {
  104. ctx.JSON(nil, err)
  105. return
  106. }
  107. ctx.JSON(srv.UpdateWechat(ctx, req))
  108. }
  109. func syncWechatContacts(ctx *bm.Context) {
  110. ctx.JSON(srv.SyncWechatContacts(ctx))
  111. }