skill.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 LearningSkill struct{}
  12. func (c *LearningSkill) List(ctx context.Context, req *model.EmptyArgs, rsp *comm_def.CommonMsg) error {
  13. g.Log().Infof("LearningSkill.List request %#v ", *req)
  14. s, err := learningSrv.NewLearningSkillService(ctx)
  15. if err != nil {
  16. return err
  17. }
  18. ent, err := s.List(ctx)
  19. _, err, code, msg := myerrors.CheckError(err)
  20. if err != nil {
  21. return err
  22. }
  23. if ent == nil {
  24. ent = []*learning.LearningSkill{}
  25. }
  26. rsp.Code = code
  27. rsp.Msg = msg
  28. rsp.Data = ent
  29. return nil
  30. }
  31. func (c *LearningSkill) ListMy(ctx context.Context, req *model.EmptyArgs, rsp *comm_def.CommonMsg) error {
  32. g.Log().Infof("LearningSkill.ListMy request %#v ", *req)
  33. s, err := learningSrv.NewLearningSkillService(ctx)
  34. if err != nil {
  35. return err
  36. }
  37. ent, err := s.ListMy(ctx)
  38. _, err, code, msg := myerrors.CheckError(err)
  39. if err != nil {
  40. return err
  41. }
  42. if ent == nil {
  43. ent = []*learning.LearningSkillMy{}
  44. }
  45. rsp.Code = code
  46. rsp.Msg = msg
  47. rsp.Data = ent
  48. return nil
  49. }
  50. func (c *LearningSkill) Get(ctx context.Context, req *learning.LearningSkillGetReq, rsp *comm_def.CommonMsg) error {
  51. g.Log().Infof("LearningSkill.Get request %#v ", *req)
  52. s, err := learningSrv.NewLearningSkillService(ctx)
  53. if err != nil {
  54. return err
  55. }
  56. ent, err := s.Get(ctx, req)
  57. _, err, code, msg := myerrors.CheckError(err)
  58. if err != nil {
  59. return err
  60. }
  61. rsp.Code = code
  62. rsp.Msg = msg
  63. rsp.Data = ent
  64. return nil
  65. }
  66. func (c *LearningSkill) Add(ctx context.Context, req *learning.LearningSkillAddReq, rsp *comm_def.CommonMsg) error {
  67. g.Log().Infof("LearningSkill.Add request %#v ", *req)
  68. s, err := learningSrv.NewLearningSkillService(ctx)
  69. if err != nil {
  70. return err
  71. }
  72. id, err := s.Add(ctx, req)
  73. _, err, code, msg := myerrors.CheckError(err)
  74. if err != nil {
  75. return err
  76. }
  77. rsp.Code = code
  78. rsp.Msg = msg
  79. rsp.Data = id
  80. return nil
  81. }
  82. func (c *LearningSkill) Update(ctx context.Context, req *learning.LearningSkillUpdateReq, rsp *comm_def.CommonMsg) error {
  83. g.Log().Infof("LearningSkill.Update request %#v ", *req)
  84. s, err := learningSrv.NewLearningSkillService(ctx)
  85. if err != nil {
  86. return err
  87. }
  88. err = s.Update(ctx, req)
  89. _, err, code, msg := myerrors.CheckError(err)
  90. if err != nil {
  91. return err
  92. }
  93. rsp.Code = code
  94. rsp.Msg = msg
  95. return nil
  96. }
  97. func (c *LearningSkill) Delete(ctx context.Context, req *learning.LearningSkillDeleteReq, rsp *comm_def.CommonMsg) error {
  98. g.Log().Infof("LearningSkill.Delete request %#v ", *req)
  99. s, err := learningSrv.NewLearningSkillService(ctx)
  100. if err != nil {
  101. return err
  102. }
  103. err = s.Delete(ctx, req.Id)
  104. _, err, code, msg := myerrors.CheckError(err)
  105. if err != nil {
  106. return err
  107. }
  108. rsp.Code = code
  109. rsp.Msg = msg
  110. return nil
  111. }