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) ListMy(ctx context.Context, req *learning.LearningMaterialListMyReq, rsp *comm_def.CommonMsg) error { g.Log().Infof("LearningMaterial.ListMy request %#v ", *req) s, err := learningSrv.NewLearningMaterialService(ctx) if err != nil { return err } ent, err := s.ListMy(ctx, req) _, err, code, msg := myerrors.CheckError(err) if err != nil { return err } if ent == nil { ent = []*learning.LearningMaterialListMy{} } rsp.Code = code rsp.Msg = msg rsp.Data = 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 }