|
|
@@ -113,6 +113,34 @@ func (s LearningMaterialService) List(ctx context.Context, req *learning.Learnin
|
|
|
return total, ent, err
|
|
|
}
|
|
|
|
|
|
+func (s LearningMaterialService) ListMy(ctx context.Context, req *learning.LearningMaterialListMyReq) ([]*learning.LearningMaterialListMy, error) {
|
|
|
+ validErr := gvalid.CheckStruct(ctx, req, nil)
|
|
|
+ if validErr != nil {
|
|
|
+ return nil, myerrors.NewMsgError(nil, validErr.Current().Error())
|
|
|
+ }
|
|
|
+
|
|
|
+ ent, err := s.Dao.Where("SkillId = ?", req.SkillId).All()
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ list := []*learning.LearningMaterialListMy{}
|
|
|
+ for _, m := range ent {
|
|
|
+ lr, err := s.LearningRecordDao.Where("MaterialId = ?", m.Id).One()
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ learnt := true
|
|
|
+ if lr == nil {
|
|
|
+ learnt = false
|
|
|
+ }
|
|
|
+ list = append(list, &learning.LearningMaterialListMy{
|
|
|
+ LearningMaterial: *m,
|
|
|
+ Learnt: learnt,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return list, nil
|
|
|
+}
|
|
|
+
|
|
|
func (s LearningMaterialService) Add(ctx context.Context, req *learning.LearningMaterialAddReq) (int, error) {
|
|
|
validErr := gvalid.CheckStruct(ctx, req, nil)
|
|
|
if validErr != nil {
|