From 25d5ba52ac9145a1667a5ff2b58df118bbad5a67 Mon Sep 17 00:00:00 2001 From: wangshuai Date: Tue, 1 Sep 2020 10:37:55 +0800 Subject: [PATCH] 'commit' --- Logs/dsSupport.log | 4 ++++ dsSupport/MyModel/DataAccess/DataaccessDAO/DataaccessDAO.go | 4 ++-- dsSupport/Utils/CacheUtil/DaoCache.go | 5 +---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Logs/dsSupport.log b/Logs/dsSupport.log index d671c71a..42557812 100644 --- a/Logs/dsSupport.log +++ b/Logs/dsSupport.log @@ -26,3 +26,7 @@ [Error]2020/09/01 09:10:09 SqlQueryError sql: expected 16 destination arguments in Scan, not 1 [Error]2020/09/01 09:13:36 SqlQueryError sql: expected 16 destination arguments in Scan, not 1 [Error]2020/09/01 09:13:36 SqlQueryError sql: expected 16 destination arguments in Scan, not 1 +[Error]2020/09/01 10:08:28 SqlQueryError sql: expected 16 destination arguments in Scan, not 1 +[Error]2020/09/01 10:08:28 SqlQueryError sql: expected 16 destination arguments in Scan, not 1 +[Error]2020/09/01 10:11:52 SqlQueryError sql: expected 16 destination arguments in Scan, not 1 +[Error]2020/09/01 10:11:52 SqlQueryError sql: expected 16 destination arguments in Scan, not 1 diff --git a/dsSupport/MyModel/DataAccess/DataaccessDAO/DataaccessDAO.go b/dsSupport/MyModel/DataAccess/DataaccessDAO/DataaccessDAO.go index 0955c1a6..8bc4c224 100644 --- a/dsSupport/MyModel/DataAccess/DataaccessDAO/DataaccessDAO.go +++ b/dsSupport/MyModel/DataAccess/DataaccessDAO/DataaccessDAO.go @@ -14,8 +14,8 @@ import ( var db = DbUtil.Engine func GetDataaccessResults(query MySwagger.DataaccessQuery) (bool, string, int32, []map[string]interface{}, error) { - //sql := "SELECT id FROM t_dataex_dataaccess WHERE 1 = 1" + query.Conditions - sql := "SELECT ls.id source_systemid, ls.system_name source_systemname, ls1.system_name consume_systemname, da.* FROM t_dataex_dataaccess da LEFT JOIN t_dataex_datasource ds ON da.datasource_id = ds.id LEFT JOIN t_dataex_linksystem ls ON ls.id = ds.system_id LEFT JOIN t_dataex_linksystem ls1 ON ls1.id = da.consume_systemid" + query.Conditions + sql := "SELECT id FROM t_dataex_dataaccess WHERE 1 = 1" + query.Conditions + //sql := "SELECT ls.id source_systemid, ls.system_name source_systemname, ls1.system_name consume_systemname, da.* FROM t_dataex_dataaccess da LEFT JOIN t_dataex_datasource ds ON da.datasource_id = ds.id LEFT JOIN t_dataex_linksystem ls ON ls.id = ds.system_id LEFT JOIN t_dataex_linksystem ls1 ON ls1.id = da.consume_systemid" + query.Conditions fmt.Println("sql=", sql) //通过SQL获取带缓存的数据 diff --git a/dsSupport/Utils/CacheUtil/DaoCache.go b/dsSupport/Utils/CacheUtil/DaoCache.go index cfc7c5b4..73b93032 100644 --- a/dsSupport/Utils/CacheUtil/DaoCache.go +++ b/dsSupport/Utils/CacheUtil/DaoCache.go @@ -143,15 +143,12 @@ func batchReadRedis(ids []string, prefix string) ([]map[string]interface{}, []st */ func count(baseSql string, pkField string, args []interface{}) (int32, error) { //替换掉分页代码,获取数据量总数 - //reg := regexp.MustCompile(`SELECT ` + pkField + ` `) countSql := strings.Replace(baseSql, "SELECT "+pkField+" ", "SELECT count(*) as count ", -1) - //countSql := reg.ReplaceAllString(baseSql, "SELECT count(*) as count ") - fmt.Println("countSql==", countSql) + var count int32 //去掉最后的limit+offset args = args[0 : len(args)-2] _, err := DbUtil.Engine.SQL(countSql, args...).Get(&count) - fmt.Println("err==", err) if err != nil { LogUtil.Error(ErrorConst.SqlQueryError, err.Error()) return 0, err