2023-04-01 16:43:13 +08:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
|
|
|
"data_minio/global"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Dataset struct {
|
|
|
|
DatasetId int64 `xorm:"not null pk autoincr INT(11)" json:"datasetId"`
|
|
|
|
DatasetName string `xorm:"varchar(200) not null" json:"datasetName"`
|
|
|
|
DatasetDesc string `xorm:"varchar(200)" json:"datasetDesc"`
|
|
|
|
StoreName string `xorm:"varchar(200)" json:"storeName"`
|
|
|
|
CategoryId int `xorm:"not null SMALLINT default 1" json:"categoryId"` //业务分类, 1:道路 2:桥梁 3:隧道 4:边坡
|
|
|
|
ProjectId int64 `xorm:"INT(11) not null default 0 index" json:"projectId"`
|
|
|
|
OwnerId int64 `xorm:"INT(11) not null default 0 index" json:"ownerId"`
|
|
|
|
Creator int64 `xorm:"INT(11) not null default 0 index" json:"creator"`
|
|
|
|
Status int `xorm:"SMALLINT not null default 1" json:"status"`
|
|
|
|
CreateAt int64 `xorm:"created" json:"createAt"`
|
|
|
|
UpdateAt int64 `xorm:"updated" json:"updateAt"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetDatasetById(id int64) (data *Dataset, err error) {
|
|
|
|
data = new(Dataset)
|
|
|
|
b, err := global.DB.ID(id).Get(data)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if !b {
|
|
|
|
return nil, fmt.Errorf("未能找到对应的数据集")
|
|
|
|
}
|
|
|
|
return data, nil
|
|
|
|
}
|
2023-04-02 23:35:12 +08:00
|
|
|
|
|
|
|
func GetDatasetScene(categoryId int) string {
|
|
|
|
switch categoryId {
|
|
|
|
case 1:
|
|
|
|
return "road"
|
|
|
|
case 2:
|
|
|
|
return "bridge"
|
|
|
|
case 3:
|
|
|
|
return "tunnel"
|
|
|
|
case 4:
|
|
|
|
return "sideSlope"
|
|
|
|
default:
|
|
|
|
return "other"
|
|
|
|
}
|
|
|
|
}
|
2023-06-17 09:37:49 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|