| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- package handler
- import (
- "context"
- "lims_adapter/model"
- "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 LearningSkill struct{}
- func (c *LearningSkill) List(ctx context.Context, req *model.EmptyArgs, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningSkill.List request %v ", &req)
- s, err := learningSrv.NewLearningSkillService(ctx)
- if err != nil {
- return err
- }
- ent, err := s.List(ctx)
- _, err, code, msg := myerrors.CheckError(err)
- if err != nil {
- return err
- }
- if ent == nil {
- ent = []*learning.LearningSkill{}
- }
- rsp.Code = code
- rsp.Msg = msg
- rsp.Data = ent
- return nil
- }
- func (c *LearningSkill) Get(ctx context.Context, req *learning.LearningSkillGetReq, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningSkill.Get request %v ", &req)
- s, err := learningSrv.NewLearningSkillService(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 *LearningSkill) Add(ctx context.Context, req *learning.LearningSkillAddReq, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningSkill.Add request %v ", &req)
- s, err := learningSrv.NewLearningSkillService(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 *LearningSkill) Update(ctx context.Context, req *learning.LearningSkillUpdateReq, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningSkill.Add request %v ", &req)
- s, err := learningSrv.NewLearningSkillService(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 *LearningSkill) Delete(ctx context.Context, req *learning.LearningSkillDeleteReq, rsp *comm_def.CommonMsg) error {
- g.Log().Infof("LearningSkill.Add request %v ", &req)
- s, err := learningSrv.NewLearningSkillService(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
- }
|