浏览代码

feature:培训考试资料详情添加学习记录

liuyaqi 3 年之前
父节点
当前提交
b78b0030f0
共有 3 个文件被更改,包括 15 次插入10 次删除
  1. 2 1
      model/learning/learning_material.go
  2. 1 1
      model/learning/learning_skill.go
  3. 12 8
      service/learning/material.go

+ 2 - 1
model/learning/learning_material.go

@@ -27,7 +27,8 @@ type LearningMaterialGetReq struct {
 
 type LearningMaterialGetRsp struct {
 	LearningMaterial
-	File []*LearningMaterialFile `json:"file"`
+	File           []*LearningMaterialFile   `json:"file"`
+	LearningRecord []*LearningLearningRecord `json:"learningRecord"`
 }
 
 type LearningMaterialAddReqFile struct {

+ 1 - 1
model/learning/learning_skill.go

@@ -30,7 +30,7 @@ type LearningSkillGetRsp struct {
 }
 
 type LearningSkillUpdateReq struct {
-	Id           int    `json:"id" v:"required#请输入技能Id"` // 技能名称
+	Id           int    `json:"id" v:"required#请输入技能Id"` // 技能 Id
 	Name         string `json:"name"`                    // 技能名称
 	InstrumentId *[]int `json:"instrumentId"`            // 绑定设备 Id
 }

+ 12 - 8
service/learning/material.go

@@ -14,10 +14,11 @@ import (
 )
 
 type LearningMaterialService struct {
-	Dao      *dao.LearningMaterialDao
-	FileDao  *dao.LearningMaterialFileDao
-	Tenant   string
-	userInfo request.UserInfo
+	Dao               *dao.LearningMaterialDao
+	FileDao           *dao.LearningMaterialFileDao
+	LearningRecordDao *dao.LearningLearningRecordDao
+	Tenant            string
+	userInfo          request.UserInfo
 }
 
 func NewLearningMaterialService(ctx context.Context) (*LearningMaterialService, error) {
@@ -31,10 +32,11 @@ func NewLearningMaterialService(ctx context.Context) (*LearningMaterialService,
 		return nil, fmt.Errorf("获取用户信息异常:%s", err.Error())
 	}
 	return &LearningMaterialService{
-		Dao:      dao.NewLearningMaterialDao(tenant),
-		FileDao:  dao.NewLearningMaterialFileDao(tenant),
-		Tenant:   tenant,
-		userInfo: userInfo,
+		Dao:               dao.NewLearningMaterialDao(tenant),
+		FileDao:           dao.NewLearningMaterialFileDao(tenant),
+		LearningRecordDao: dao.NewLearningLearningRecordDao(tenant),
+		Tenant:            tenant,
+		userInfo:          userInfo,
 	}, nil
 }
 
@@ -59,10 +61,12 @@ func (s LearningMaterialService) Get(ctx context.Context, req *learning.Learning
 	if err != nil {
 		return nil, err
 	}
+	record, err := s.LearningRecordDao.Where("MaterialId = ?", m.Id).All()
 
 	return &learning.LearningMaterialGetRsp{
 		LearningMaterial: *m,
 		File:             file,
+		LearningRecord:   record,
 	}, nil
 }