Ver Fonte

fix(培训考试): 资料查询添加资料类型字段

liuyaqi há 3 anos atrás
pai
commit
47950fffd6

+ 2 - 0
model/learning/learning_material.go

@@ -18,10 +18,12 @@ type LearningMaterialListReq struct {
 	OrderBy *model.OrderBy `json:"orderBy"`
 	SkillId int            `json:"skillId"`
 	Name    string         `json:"name"`
+	Type    int            `json:"type"` // 资料类型 1 资料 2 视频
 }
 
 type LearningMaterialListMyReq struct {
 	SkillId int `json:"skillId" v:"required#请输入技能Id"` // 技能 Id
+	Type    int `json:"type"`                         // 资料类型 1 资料 2 视频
 }
 
 type LearningMaterialListMy struct {

+ 8 - 2
service/learning/material.go

@@ -89,6 +89,9 @@ func (s LearningMaterialService) List(ctx context.Context, req *learning.Learnin
 	if req.SkillId != 0 {
 		dao = dao.Where("SkillId = ?", req.SkillId)
 	}
+	if req.Type != 0 {
+		dao = dao.Where("Type = ?", req.Type)
+	}
 	total, err := dao.Count()
 	if err != nil {
 		return 0, nil, err
@@ -120,8 +123,11 @@ func (s LearningMaterialService) ListMy(ctx context.Context, req *learning.Learn
 	if validErr != nil {
 		return nil, myerrors.NewMsgError(nil, validErr.Current().Error())
 	}
-
-	ent, err := s.Dao.Where("SkillId = ?", req.SkillId).All()
+	dao := s.Dao.Where("SkillId = ?", req.SkillId)
+	if req.Type != 0 {
+		dao = dao.Where("Type = ?", req.Type)
+	}
+	ent, err := dao.All()
 	if err != nil {
 		return nil, err
 	}

+ 8 - 0
swaggerui/swagger.yml

@@ -951,6 +951,9 @@ components:
         name:
           type: string
           description: 按资料名称模糊查询
+        type:
+          type: integer
+          description: 资料类型 1 资料 2 视频
     LearningMaterialListMy:
       type: object
       required:
@@ -959,6 +962,9 @@ components:
         skillId:
           type: integer
           description: 按技能 Id 查询
+        type:
+          type: integer
+          description: 资料类型 1 资料 2 视频
     LearningMaterialPublishRecordList:
         page:
           type: object
@@ -1496,9 +1502,11 @@ components:
           value: id
         skillId: 2
         name: "测试"
+        type: 1
     LearningMaterialListMy:
       value:
         skillId: 2
+        type: 1
     LearningMaterialGet:
       value:
         id: 1