SourceIpList, err := g.Model(appListTableName).Fields("Address").Where("AppName=?", queryAppName).Array()
accessData := g.Model(`Appaccess ac`).
LeftJoin(`hz_app_list ha`, `ac.dst_ip=ha.Address`).
Fields(`ha.AppName,ac.proto,ac.dst_port,ac.count,ac.accesstype,ac.dst_ip`).
WhereIn(`ac.src_ip`, SourceIpList).
Where("ac.accesstype=?", "hzinner").
Distinct()
res, _ := g.Model("? aa", accessData).
Fields(`aa.AppName,aa.proto,aa.dst_port,SUM(count) as count,aa.accesstype`).
Group(`AppName,proto,dst_port,accesstype`).
All()
GoFrame CLI Tool v1.17.0, https://goframe.org
GoFrame Version: v1.16.6 in current go.mod
CLI Installed At: D:\Go\bin\gf.exe
CLI Built Detail:
Go Version: go1.16.3
GF Version: v1.16.4
Git Commit: 971ed46f0b9d4dfebd1907cd3ed851cf9e1a5503
Build Time: 2021-08-10 10:22:59
github.com/gogf/gf v1.16.6
2021-12-23 09:56:33.649 [ERRO] [ 19 ms] [default] SHOW FULL COLUMNS FROM
Error: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'' at line 1
Stack:
1. gfast/app/migrationtool/service.AppCallOtherInner
D:/project/src/app/migrationtool/service/app_call.go:42
2. gfast/app/migrationtool/api.AppCallOtherInner
D:/project/src/app/migrationtool/api/call.go:29
3. gfast/middleware.Auth
D:/project/src/middleware/auth.go:72
4. gfast/middleware.Ctx
D:/project/src/middleware/auth.go:46
5. gfast/app/system/api.(*auth).authAfterFunc
D:/project/src/app/system/api/auth.go:126
6. github.com/goflyfox/gtoken/gtoken.(*GfToken).authMiddleware
D:/project/src/pkg/mod/github.com/tiger1103/gtoken@v1.4.8/gtoken/gtoken.go:331
7. gfast/middleware.CORS
D:/project/src/middleware/cors.go:15
2021-12-23 09:56:33.685 [ERRO] [ 0 ms] [default] SHOW FULL COLUMNS FROM
Error: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'' at line 1
Stack:
1. gfast/app/migrationtool/service.AppCallOtherInner
D:/project/src/app/migrationtool/service/app_call.go:44
2. gfast/app/api.AppCallOtherInner
D:/project/src/app/migrationtool/api/call.go:29
3. gfast/middleware.Auth
D:/project/src/middleware/auth.go:72
4. gfast/middleware.Ctx
D:/project/src/middleware/auth.go:46
5. gfast/app/system/api.(*auth).authAfterFunc
D:/project/src/app/system/api/auth.go:126
6. github.com/goflyfox/gtoken/gtoken.(*GfToken).authMiddleware
D:/project/src/pkg/mod/github.com/tiger1103/gtoken@v1.4.8/gtoken/gtoken.go:331
7. gfast/middleware.CORS
D:/project/src/middleware/cors.go:15
2021-12-23 09:56:33.764 [ERRO] [ 32 ms] [default] SHOW FULL COLUMNS FROM
Error: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'' at line 1
Stack:
1. gfast/app/migrationtool/service.AppCallOtherInner
D:/project/src/app/migrationtool/service/app_call.go:44
2. gfast/app/migrationtool/api.AppCallOtherInner
D:/project/src/app/migrationtool/api/call.go:29
3. gfast/middleware.Auth
D:/project/src/middleware/auth.go:72
4. gfast/middleware.Ctx
D:/project/src/middleware/auth.go:46
5. gfast/app/system/api.(*auth).authAfterFunc
D:/project/src/app/system/api/auth.go:126
6. github.com/goflyfox/gtoken/gtoken.(*GfToken).authMiddleware
D:/project/src/pkg/mod/github.com/tiger1103/gtoken@v1.4.8/gtoken/gtoken.go:331
7. gfast/middleware.CORS
D:/project/src/middleware/cors.go:15
// 实际可执行到子查询这一步
2021-12-23 09:56:33.848 [DEBU] [ 35 ms] [default] SELECT aa.AppName,aa.proto,aa.dst_port,SUM(count) as count,aa.accesstype FROM (SELECT DISTINCT ha.AppName,ac.proto,ac.dst_port,ac.count,ac.accesstype,ac.dst_ip FROM `Appaccess` ac LEFT JOIN `hz_app_list` ha ON (ac.dst_ip=ha.Address) WHERE (ac.src_ip IN ('1.1.1.1','2.2.2.2')) AND (ac.accesstype='hzinner')) aa GROUP BY `AppName`,`proto`,`dst_port`,`accesstype`