Browse Source

修正成果获取

wanglei 4 years ago
parent
commit
28bae7a4fa
2 changed files with 7 additions and 2 deletions
  1. 3 0
      dao/internal/consequent.go
  2. 4 2
      service/result/result.go

+ 3 - 0
dao/internal/consequent.go

@@ -33,6 +33,7 @@ type consequentColumns struct {
 	UpdatedAt   string // 更新时间
 	DeletedAt   string // 删除时间
 	Name        string // 成果名称
+	MediaIds    string // 文件ID
 	Type        string // 成果类型
 	Code        string // 成果编号
 	OwnersId    string // 获得者
@@ -56,6 +57,7 @@ var (
 			UpdatedAt:   "UpdatedAt",
 			DeletedAt:   "DeletedAt",
 			Name:        "Name",
+			MediaIds:    "MediaIds",
 			Type:        "Type",
 			Code:        "Code",
 			OwnersId:    "OwnersId",
@@ -81,6 +83,7 @@ func NewConsequentDao(tenant string) ConsequentDao {
 			UpdatedAt:   "UpdatedAt",
 			DeletedAt:   "DeletedAt",
 			Name:        "Name",
+			MediaIds:    "MediaIds",
 			Type:        "Type",
 			Code:        "Code",
 			OwnersId:    "OwnersId",

+ 4 - 2
service/result/result.go

@@ -2,10 +2,10 @@ package result
 
 import (
 	"context"
+	"encoding/json"
 	"errors"
 	"lims_adapter/dao"
 	"log"
-	"strings"
 
 	"dashoo.cn/common_definition/admin/result_def"
 	"dashoo.cn/common_definition/comm_def"
@@ -133,7 +133,9 @@ func (s Service) GetResultConsequent(req comm_def.IdOnlyReq) (result_def.ResultL
 	var result result_def.ResultList
 	query := s.ConsequentDao.M
 	query.Where("Id = ?", req.Id).Scan(&result)
-	mediaIds := strings.Split(result.MediaIds, ",")
+	mediaIds := []uint{}
+	json.Unmarshal([]byte(result.MediaIds), &mediaIds)
+	log.Println(mediaIds)
 	fields := "Id, FileName as Name, Url"
 	if len(mediaIds) > 0 {
 		s.ConsequentDao.DB.Model("media").Where("Id IN (?)", mediaIds).Fields(fields).Scan(&result.Files)