6
0

learning.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package handler
  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) Get(ctx context.Context, req *learning.LearningSkillGetReq, rsp *comm_def.CommonMsg) error {
  32. g.Log().Infof("LearningSkill.Get request %v ", &req)
  33. s, err := learningSrv.NewLearningSkillService(ctx)
  34. if err != nil {
  35. return err
  36. }
  37. ent, err := s.Get(ctx, req)
  38. _, err, code, msg := myerrors.CheckError(err)
  39. if err != nil {
  40. return err
  41. }
  42. rsp.Code = code
  43. rsp.Msg = msg
  44. rsp.Data = ent
  45. return nil
  46. }
  47. func (c *LearningSkill) Add(ctx context.Context, req *learning.LearningSkillAddReq, rsp *comm_def.CommonMsg) error {
  48. g.Log().Infof("LearningSkill.Add request %v ", &req)
  49. s, err := learningSrv.NewLearningSkillService(ctx)
  50. if err != nil {
  51. return err
  52. }
  53. id, err := s.Add(ctx, req)
  54. _, err, code, msg := myerrors.CheckError(err)
  55. if err != nil {
  56. return err
  57. }
  58. rsp.Code = code
  59. rsp.Msg = msg
  60. rsp.Data = id
  61. return nil
  62. }
  63. func (c *LearningSkill) Update(ctx context.Context, req *learning.LearningSkillUpdateReq, rsp *comm_def.CommonMsg) error {
  64. g.Log().Infof("LearningSkill.Add request %v ", &req)
  65. s, err := learningSrv.NewLearningSkillService(ctx)
  66. if err != nil {
  67. return err
  68. }
  69. err = s.Update(ctx, req)
  70. _, err, code, msg := myerrors.CheckError(err)
  71. if err != nil {
  72. return err
  73. }
  74. rsp.Code = code
  75. rsp.Msg = msg
  76. return nil
  77. }
  78. func (c *LearningSkill) Delete(ctx context.Context, req *learning.LearningSkillDeleteReq, rsp *comm_def.CommonMsg) error {
  79. g.Log().Infof("LearningSkill.Add request %v ", &req)
  80. s, err := learningSrv.NewLearningSkillService(ctx)
  81. if err != nil {
  82. return err
  83. }
  84. err = s.Delete(ctx, req.Id)
  85. _, err, code, msg := myerrors.CheckError(err)
  86. if err != nil {
  87. return err
  88. }
  89. rsp.Code = code
  90. rsp.Msg = msg
  91. return nil
  92. }