package learning import ( "context" "fmt" "lims_adapter/model/learning" learningSrv "lims_adapter/service/learning" "dashoo.cn/common_definition/comm_def" "dashoo.cn/micro_libary/micro_srv" "dashoo.cn/micro_libary/myerrors" "github.com/gogf/gf/frame/g" ) type LearningLearningRecord struct{} func (c *LearningLearningRecord) List(ctx context.Context, req *learning.LearningLearningRecordListReq, rsp *comm_def.CommonMsg) error { g.Log().Infof("LearningLearningRecord.List request %#v ", *req) s, err := learningSrv.NewLearningLearningRecordService(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.LearningLearningRecordGetRsp{} } rsp.Code = code rsp.Msg = msg rsp.Data = map[string]interface{}{ "total": total, "list": ent, } return nil } func (c *LearningLearningRecord) ListMy(ctx context.Context, req *learning.LearningLearningRecordListReq, rsp *comm_def.CommonMsg) error { g.Log().Infof("LearningLearningRecord.ListMy request %#v ", *req) s, err := learningSrv.NewLearningLearningRecordService(ctx) if err != nil { return err } userInfo, err := micro_srv.GetUserInfo(ctx) if err != nil { return fmt.Errorf("获取用户信息异常:%s", err.Error()) } req.UserId = int(userInfo.Id) total, ent, err := s.List(ctx, req) _, err, code, msg := myerrors.CheckError(err) if err != nil { return err } if ent == nil { ent = []*learning.LearningLearningRecordGetRsp{} } rsp.Code = code rsp.Msg = msg rsp.Data = map[string]interface{}{ "total": total, "list": ent, } return nil } func (c *LearningLearningRecord) AddToMy(ctx context.Context, req *learning.LearningLearningRecordAddReq, rsp *comm_def.CommonMsg) error { g.Log().Infof("LearningLearningRecord.AddToMy request %#v ", *req) s, err := learningSrv.NewLearningLearningRecordService(ctx) if err != nil { return err } userInfo, err := micro_srv.GetUserInfo(ctx) if err != nil { return fmt.Errorf("获取用户信息异常:%s", err.Error()) } req.UserId = int(userInfo.Id) 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 }