testpaper.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. package learning
  2. import (
  3. "context"
  4. "lims_adapter/model"
  5. "lims_adapter/model/learning"
  6. learningSrv "lims_adapter/service/learning"
  7. "dashoo.cn/common_definition/comm_def"
  8. "dashoo.cn/micro_libary/myerrors"
  9. "github.com/gogf/gf/frame/g"
  10. )
  11. type LearningTestpaper struct{}
  12. func (c *LearningTestpaper) List(ctx context.Context, req *learning.LearningTestpaperListReq, rsp *comm_def.CommonMsg) error {
  13. g.Log().Infof("LearningTestpaper.List request %#v ", *req)
  14. s, err := learningSrv.NewLearningTestpaperService(ctx)
  15. if err != nil {
  16. return err
  17. }
  18. total, ent, err := s.List(ctx, req)
  19. _, err, code, msg := myerrors.CheckError(err)
  20. if err != nil {
  21. return err
  22. }
  23. if ent == nil {
  24. ent = []*learning.LearningTestpaper{}
  25. }
  26. rsp.Code = code
  27. rsp.Msg = msg
  28. rsp.Data = map[string]interface{}{
  29. "total": total,
  30. "list": ent,
  31. }
  32. return nil
  33. }
  34. func (c *LearningTestpaper) ListMy(ctx context.Context, req *model.EmptyArgs, rsp *comm_def.CommonMsg) error {
  35. g.Log().Infof("LearningTestpaper.ListMy request %#v ", *req)
  36. s, err := learningSrv.NewLearningTestpaperService(ctx)
  37. if err != nil {
  38. return err
  39. }
  40. ent, err := s.ListMy(ctx)
  41. _, err, code, msg := myerrors.CheckError(err)
  42. if err != nil {
  43. return err
  44. }
  45. if ent == nil {
  46. ent = []*learning.LearningTestpaperMy{}
  47. }
  48. rsp.Code = code
  49. rsp.Msg = msg
  50. rsp.Data = ent
  51. return nil
  52. }
  53. func (c *LearningTestpaper) Get(ctx context.Context, req *learning.LearningTestpaperGetReq, rsp *comm_def.CommonMsg) error {
  54. g.Log().Infof("LearningTestpaper.Get request %#v ", *req)
  55. s, err := learningSrv.NewLearningTestpaperService(ctx)
  56. if err != nil {
  57. return err
  58. }
  59. ent, err := s.Get(ctx, req)
  60. _, err, code, msg := myerrors.CheckError(err)
  61. if err != nil {
  62. return err
  63. }
  64. rsp.Code = code
  65. rsp.Msg = msg
  66. rsp.Data = ent
  67. return nil
  68. }
  69. func (c *LearningTestpaper) Add(ctx context.Context, req *learning.LearningTestpaperAddReq, rsp *comm_def.CommonMsg) error {
  70. g.Log().Infof("LearningTestpaper.Add request %#v ", *req)
  71. s, err := learningSrv.NewLearningTestpaperService(ctx)
  72. if err != nil {
  73. return err
  74. }
  75. id, err := s.Add(ctx, req)
  76. _, err, code, msg := myerrors.CheckError(err)
  77. if err != nil {
  78. return err
  79. }
  80. rsp.Code = code
  81. rsp.Msg = msg
  82. rsp.Data = id
  83. return nil
  84. }
  85. func (c *LearningTestpaper) Update(ctx context.Context, req *learning.LearningTestpaperUpdateReq, rsp *comm_def.CommonMsg) error {
  86. g.Log().Infof("LearningTestpaper.Update request %#v ", *req)
  87. s, err := learningSrv.NewLearningTestpaperService(ctx)
  88. if err != nil {
  89. return err
  90. }
  91. err = s.Update(ctx, req)
  92. _, err, code, msg := myerrors.CheckError(err)
  93. if err != nil {
  94. return err
  95. }
  96. rsp.Code = code
  97. rsp.Msg = msg
  98. return nil
  99. }
  100. func (c *LearningTestpaper) Delete(ctx context.Context, req *learning.LearningTestpaperDeleteReq, rsp *comm_def.CommonMsg) error {
  101. g.Log().Infof("LearningTestpaper.Delete request %#v ", *req)
  102. s, err := learningSrv.NewLearningTestpaperService(ctx)
  103. if err != nil {
  104. return err
  105. }
  106. err = s.Delete(ctx, req.Id)
  107. _, err, code, msg := myerrors.CheckError(err)
  108. if err != nil {
  109. return err
  110. }
  111. rsp.Code = code
  112. rsp.Msg = msg
  113. return nil
  114. }