| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- package learning
- import (
- "context"
- "lims_adapter/model/learning"
- learningSrv "lims_adapter/service/learning"
- "dashoo.cn/common_definition/comm_def"
- "dashoo.cn/micro_libary/myerrors"
- "github.com/gogf/gf/frame/g"
- )
- type LearningMaterial struct{}
- func (c *LearningMaterial) List(ctx context.Context, req *learning.LearningMaterialListReq, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningMaterial.List request %#v ", *req)
- s, err := learningSrv.NewLearningMaterialService(ctx)
- if err != nil {
- return err
- }
- total, ent, err := s.List(ctx, req)
- _, err, code, msg := myerrors.CheckError(err)
- if err != nil {
- return err
- }
- if ent == nil {
- ent = []*learning.LearningMaterial{}
- }
- rsp.Code = code
- rsp.Msg = msg
- rsp.Data = map[string]interface{}{
- "total": total,
- "list": ent,
- }
- return nil
- }
- func (c *LearningMaterial) Get(ctx context.Context, req *learning.LearningMaterialGetReq, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningMaterial.Get request %#v ", *req)
- s, err := learningSrv.NewLearningMaterialService(ctx)
- if err != nil {
- return err
- }
- ent, err := s.Get(ctx, req)
- _, err, code, msg := myerrors.CheckError(err)
- if err != nil {
- return err
- }
- rsp.Code = code
- rsp.Msg = msg
- rsp.Data = ent
- return nil
- }
- func (c *LearningMaterial) Add(ctx context.Context, req *learning.LearningMaterialAddReq, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningMaterial.Add request %#v ", *req)
- s, err := learningSrv.NewLearningMaterialService(ctx)
- if err != nil {
- return err
- }
- id, err := s.Add(ctx, req)
- _, err, code, msg := myerrors.CheckError(err)
- if err != nil {
- return err
- }
- rsp.Code = code
- rsp.Msg = msg
- rsp.Data = id
- return nil
- }
- func (c *LearningMaterial) Update(ctx context.Context, req *learning.LearningMaterialUpdateReq, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningMaterial.Update request %#v ", *req)
- s, err := learningSrv.NewLearningMaterialService(ctx)
- if err != nil {
- return err
- }
- err = s.Update(ctx, req)
- _, err, code, msg := myerrors.CheckError(err)
- if err != nil {
- return err
- }
- rsp.Code = code
- rsp.Msg = msg
- return nil
- }
- func (c *LearningMaterial) Delete(ctx context.Context, req *learning.LearningMaterialDeleteReq, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningMaterial.Delete request %#v ", *req)
- s, err := learningSrv.NewLearningMaterialService(ctx)
- if err != nil {
- return err
- }
- err = s.Delete(ctx, req.Id)
- _, err, code, msg := myerrors.CheckError(err)
- if err != nil {
- return err
- }
- rsp.Code = code
- rsp.Msg = msg
- return nil
- }
|