|
@@ -12,25 +12,26 @@ import (
|
|
|
type SqlService struct {
|
|
|
}
|
|
|
|
|
|
-func (l SqlService) SqlManage(in *types.SqlManageReq) *[]map[string]interface{} {
|
|
|
+func (l SqlService) SqlManage(in *types.SqlManageReq) (*[]map[string]interface{}, int64) {
|
|
|
sqlData := MC.BaseMysql.FindOne("sql_manage", map[string]interface{}{
|
|
|
"id": common.Int64All(in.Id),
|
|
|
}, "", "")
|
|
|
if sqlData == nil || len(*sqlData) == 0 {
|
|
|
- return &[]map[string]interface{}{}
|
|
|
+ return &[]map[string]interface{}{}, 0
|
|
|
}
|
|
|
dbType := (*sqlData)["db_type"]
|
|
|
rs := &[]map[string]interface{}{}
|
|
|
+ count := int64(0)
|
|
|
switch dbType {
|
|
|
case "es":
|
|
|
- rs = elastic.Get(common.InterfaceToStr((*sqlData)["db_name"]), common.InterfaceToStr((*sqlData)["db_name"]), Sqlformat(common.InterfaceToStr((*sqlData)["content"]), *in))
|
|
|
+ count, rs = elastic.GetWithCount(common.InterfaceToStr((*sqlData)["db_name"]), common.InterfaceToStr((*sqlData)["db_name"]), "", Sqlformat(common.InterfaceToStr((*sqlData)["content"]), *in))
|
|
|
}
|
|
|
|
|
|
for k, v := range *rs {
|
|
|
(*rs)[k]["id"] = encrypt.EncodeArticleId2ByCheck(common.InterfaceToStr(v["id"]))
|
|
|
delete((*rs)[k], "_id")
|
|
|
}
|
|
|
- return rs
|
|
|
+ return rs, count
|
|
|
}
|
|
|
func Sqlformat(sqlStr string, sqlData types.SqlManageReq) string {
|
|
|
data := []interface{}{}
|