|
|
|
@ -2,17 +2,33 @@ package DatasourceDAO
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"dsSupport/MyModel/MySwagger"
|
|
|
|
|
"dsSupport/Utils/CacheUtil"
|
|
|
|
|
"dsSupport/Utils/DbUtil"
|
|
|
|
|
"dsSupport/Utils/ErrorConst"
|
|
|
|
|
"dsSupport/Utils/LogUtil"
|
|
|
|
|
"dsSupport/models"
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
//数据库
|
|
|
|
|
var db = DbUtil.Engine
|
|
|
|
|
|
|
|
|
|
func GetDatasourceRow(query string) (bool, string, map[string]interface{}, error) {
|
|
|
|
|
sql := "SELECT * FROM t_dataex_datasource WHERE 1 = 1 " + query
|
|
|
|
|
|
|
|
|
|
var datasource models.TDataexDatasource
|
|
|
|
|
has, _ := DbUtil.Engine.SQL(sql).Get(&datasource)
|
|
|
|
|
if has == true {
|
|
|
|
|
m := make(map[string]interface{})
|
|
|
|
|
j, _ := json.Marshal(datasource)
|
|
|
|
|
json.Unmarshal(j, &m)
|
|
|
|
|
|
|
|
|
|
return true, "数据获取成功", m, nil
|
|
|
|
|
} else {
|
|
|
|
|
return false, "数据获取失败,数据源不存在", nil, nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetDatasourceResults(query MySwagger.DatasourceQuery) (bool, string, int, []map[string]interface{}, error) {
|
|
|
|
|
sql := "SELECT * FROM t_dataex_datasource WHERE 1 = 1" + query.Conditions + " ORDER BY create_time DESC, change_time DESC"
|
|
|
|
|
//接收传入参数
|
|
|
|
@ -80,15 +96,14 @@ func IsDatasourceExistsById(id string) bool {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetDatasourceIdByCode(code string) (bool, string, interface{}, error) {
|
|
|
|
|
sql := "SELECT id FROM t_dataex_datasource WHERE datasource_code='" + code + "'"
|
|
|
|
|
fmt.Println("sql = ", sql)
|
|
|
|
|
|
|
|
|
|
//通过SQL获取带缓存的数据
|
|
|
|
|
list, count, _ := CacheUtil.Page(sql, 1, 0)
|
|
|
|
|
sql := "SELECT id FROM t_dataex_datasource WHERE datasource_code=?"
|
|
|
|
|
|
|
|
|
|
if count > 0 {
|
|
|
|
|
return true, "数据获取成功", list[0]["id"], nil
|
|
|
|
|
var id int
|
|
|
|
|
has, _ := DbUtil.Engine.SQL(sql, code).Get(&id)
|
|
|
|
|
fmt.Println(id)
|
|
|
|
|
if has == true {
|
|
|
|
|
return true, "数据获取成功", id, nil
|
|
|
|
|
} else {
|
|
|
|
|
return false, "数据获取失败,systemID对应的数据源类型不存在", nil, nil
|
|
|
|
|
return false, "数据获取失败,数据源不存在", nil, nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|