server_teacher.go 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package service
  2. import (
  3. "bet24.com/log"
  4. "bet24.com/servers/coreservice/client"
  5. "bet24.com/servers/coreservice/teacher"
  6. "context"
  7. "encoding/json"
  8. "github.com/pkg/errors"
  9. )
  10. // 注册
  11. func (s *Server) TeacherRegister(ctx context.Context, args *client.Request, reply *client.Reply) error {
  12. var req client.Request_base
  13. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  14. log.Debug("Server.TeacherRegister unmarshal fail %v", err)
  15. return errors.New("unmarshal error")
  16. }
  17. info := teacher.Register(req.UserId)
  18. d, _ := json.Marshal(info)
  19. reply.Resp.RetCode = 1
  20. reply.Resp.Data = string(d)
  21. return nil
  22. }
  23. // 师父信息
  24. func (s *Server) TeacherInfo(ctx context.Context, args *client.Request, reply *client.Reply) error {
  25. var req client.Request_base
  26. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  27. log.Debug("Server.TeacherInfo unmarshal fail %v", err)
  28. return errors.New("unmarshal error")
  29. }
  30. info := teacher.Info(req.UserId)
  31. d, _ := json.Marshal(info)
  32. reply.Resp.RetCode = 1
  33. reply.Resp.Data = string(d)
  34. return nil
  35. }
  36. // 绑定
  37. func (s *Server) BindTeacher(ctx context.Context, args *client.Request, reply *client.Reply) error {
  38. var req client.Teacher_req
  39. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  40. log.Debug("Server.BindTeacher unmarshal fail %v", err)
  41. return errors.New("unmarshal error")
  42. }
  43. var respData struct {
  44. RetCode int
  45. Items interface{}
  46. }
  47. respData.RetCode, respData.Items = teacher.Bind(req.UserId, req.TeacherId, req.IsSendMail)
  48. d, _ := json.Marshal(respData)
  49. reply.Resp.RetCode = 1
  50. reply.Resp.Data = string(d)
  51. return nil
  52. }
  53. // 徒弟列表
  54. func (s *Server) Students(ctx context.Context, args *client.Request, reply *client.Reply) error {
  55. var req client.Teacher_req
  56. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  57. log.Debug("Server.Students unmarshal fail %v", err)
  58. return errors.New("unmarshal error")
  59. }
  60. list := teacher.Students(req.TeacherId)
  61. d, _ := json.Marshal(list)
  62. reply.Resp.RetCode = 1
  63. reply.Resp.Data = string(d)
  64. return nil
  65. }
  66. // 收益列表
  67. func (s *Server) TeacherProfitList(ctx context.Context, args *client.Request, reply *client.Reply) error {
  68. var req client.TeacherProfit_req
  69. if err := json.Unmarshal([]byte(args.Data), &req); err != nil {
  70. log.Debug("Server.TeacherProfitList unmarshal fail %v", err)
  71. return errors.New("unmarshal error")
  72. }
  73. var respData struct {
  74. RecordCount int
  75. List interface{}
  76. }
  77. respData.RecordCount, respData.List = teacher.ProfitList(req.UserId, req.Days, req.PageIndex, req.PageSize)
  78. d, _ := json.Marshal(respData)
  79. reply.Resp.RetCode = 1
  80. reply.Resp.Data = string(d)
  81. return nil
  82. }