Merge branch 'master' of 10.10.14.250:huanghai/dsMin

master
huanghai 5 years ago
commit 7cdf5e76d8

@ -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
}
}

@ -166,17 +166,21 @@ func RemoveDatasource(id string) (bool, string, error) {
func ReadESDoc(datasourceCode string, orgIDs []string, page int, begin string, conditions map[string]interface{}, sort map[string]interface{}) (bool, string, []map[string]interface{}) {
result, message, esdata := ES7Util.SearchDocPage(datasourceCode, orgIDs, page, begin, conditions, sort)
var query = "AND datasource_code='" + datasourceCode + "'"
res, _, data, _ := DatasourceDAO.GetDatasourceRow(query)
var datasourceName interface{}
if res == true {
datasourceName = data["datasource_name"]
}
var esDatas []map[string]interface{}
var esData map[string]interface{}
//esDatas := make(map[string]map[string]interface{})
//esData := make(map[string]interface{})
for _, value := range esdata {
//esDatas = append(esDatas, value.DataContent)
j, _ := json.Marshal(value)
json.Unmarshal(j, &esData)
//fmt.Println(esData)
esData = make(map[string]interface{})
esData["datasource_name"] = datasourceName
esDatas = append(esDatas, esData)
}

Loading…
Cancel
Save