6
0

material.go 3.0 KB

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