From 764b09f4dde5aab39ea263bdfa1d2f85a5bfc45d Mon Sep 17 00:00:00 2001 From: wangjian Date: Sat, 17 Jun 2023 09:37:49 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E6=94=B9minio=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E6=96=87=E4=BB=B6=E5=90=8D=EF=BC=8C=E9=87=87=E7=94=A8?= =?UTF-8?q?uuid=E6=96=B9=E5=BC=8F=E8=BF=9B=E8=A1=8C=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/dataset.go | 20 ++++++++++++++++++++ model/file.go | 2 +- mq/index.go | 9 ++++++++- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/model/dataset.go b/model/dataset.go index 053eff1..9152829 100644 --- a/model/dataset.go +++ b/model/dataset.go @@ -45,3 +45,23 @@ func GetDatasetScene(categoryId int) string { return "other" } } + +func GetDatasetByName(name string, dataType int) (data *Dataset, err error) { + data = new(Dataset) + b, err := global.DB.Where("dataset_name = ?", name). + And("category_id=?", dataType).Get(data) + if err != nil { + return nil, err + } + if !b { + item := new(Dataset) + item.DatasetName = name + item.CategoryId = dataType + _, err = global.DB.Insert(item) + if err != nil { + return nil, err + } + return item, err + } + return data, nil +} diff --git a/model/file.go b/model/file.go index c6034bc..f99888f 100644 --- a/model/file.go +++ b/model/file.go @@ -5,7 +5,7 @@ type FileManager struct { FileName string `xorm:"VARCHAR(200)" json:"fileName"` //文件名 AccessUrl string `xorm:"VARCHAR(400)" json:"url"` //访问路径 Scene string `xorm:"VARCHAR(40)" json:"scene"` //应用场景,0 : 其他, 1: 道路; 2: 桥梁; 3:隧道; 4: 边坡 - DataType int `xorm:"TINYINT index default 0" json:"dataType"` //数据类型,1:数据集;2:病害库;3:应用;0:其他 + DataType int `xorm:"TINYINT index default 0" json:"dataType"` //数据类型,0 : 其他, 1: 道路; 2: 桥梁; 3:隧道; 4: 边坡 DatasetId int64 `xorm:"INT(11) index default 0" json:"datasetId"` //数据集 FileSize int64 `xorm:"BIGINT" json:"fileSize"` //文件大小 FileMd5 string `xorm:"VARCHAR(64)" json:"fileMd5"` //文件MD5 diff --git a/mq/index.go b/mq/index.go index fef7070..0f587a3 100644 --- a/mq/index.go +++ b/mq/index.go @@ -109,7 +109,14 @@ func handler(data []byte) (frame.Tag, []byte) { case DatasetRequest: payload := req.Payload.(map[string]interface{}) if int64(payload["fileSize"].(float64)) > 0 { - dt, err := model.GetDatasetById(int64(payload["datasetId"].(float64))) + var dt *model.Dataset + if dtId, ok := payload["datasetId"].(float64); ok { + dt, err = model.GetDatasetById(int64(dtId)) + } else { + if dtName, ok := payload["datasetName"].(string); ok { + dt, err = model.GetDatasetByName(dtName, int(payload["dataType"].(float64))) + } + } global.Must(err) var fileContent []byte if payload["isCompress"].(bool) {