| 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 LearningQuestion struct{}
- func (c *LearningQuestion) List(ctx context.Context, req *learning.LearningQuestionListReq, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningQuestion.List request %v ", &req)
- s, err := learningSrv.NewLearningQuestionService(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.LearningQuestionGetRsp{}
- }
- rsp.Code = code
- rsp.Msg = msg
- rsp.Data = map[string]interface{}{
- "total": total,
- "list": ent,
- }
- return nil
- }
- func (c *LearningQuestion) Get(ctx context.Context, req *learning.LearningQuestionGetReq, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningQuestion.Get request %v ", &req)
- s, err := learningSrv.NewLearningQuestionService(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 *LearningQuestion) Add(ctx context.Context, req *learning.LearningQuestionAddReq, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningQuestion.Add request %v ", &req)
- s, err := learningSrv.NewLearningQuestionService(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 *LearningQuestion) Update(ctx context.Context, req *learning.LearningQuestionUpdateReq, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningQuestion.Add request %v ", &req)
- s, err := learningSrv.NewLearningQuestionService(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 *LearningQuestion) Delete(ctx context.Context, req *learning.LearningQuestionDeleteReq, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningQuestion.Add request %v ", &req)
- s, err := learningSrv.NewLearningQuestionService(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
- }
|