|
@@ -1,13 +1,15 @@
|
|
|
package selectbusiness
|
|
package selectbusiness
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
- "strconv"
|
|
|
|
|
-
|
|
|
|
|
. "dashoo.cn/backend/api/mydb"
|
|
. "dashoo.cn/backend/api/mydb"
|
|
|
"dashoo.cn/utils"
|
|
"dashoo.cn/utils"
|
|
|
"github.com/go-xorm/xorm"
|
|
"github.com/go-xorm/xorm"
|
|
|
|
|
+ "strconv"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+type TotalResult struct {
|
|
|
|
|
+ Total int64 `xorm:"INT(11) 'total'"`
|
|
|
|
|
+}
|
|
|
type SelectService struct {
|
|
type SelectService struct {
|
|
|
MyServiceBase
|
|
MyServiceBase
|
|
|
}
|
|
}
|
|
@@ -19,10 +21,9 @@ func GetSelectService(xormEngine *xorm.Engine) *SelectService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (s *SelectService) GetMyPagingEntitiesWithOrderBytbl(supplierTableName, supplierCertTableName, OilInfoChangeName, OilSupplierCert2FileName string, pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where,having string) (total int64) {
|
|
func (s *SelectService) GetMyPagingEntitiesWithOrderBytbl(supplierTableName, supplierCertTableName, OilInfoChangeName, OilSupplierCert2FileName string, pageIndex, itemsPerPage int64, orderby string, asc bool, entitiesPtr interface{}, where,having string) (total int64) {
|
|
|
- var resultsSlice []map[string][]byte
|
|
|
|
|
|
|
|
|
|
//获取总记录数
|
|
//获取总记录数
|
|
|
- sqlCount := `select count(*) from (`
|
|
|
|
|
|
|
+ /*sqlCount := `select count(*) from (`
|
|
|
sqlCount += `select a.Id,a.SupplierName,b.AccessCardNo,max(c.OldSupplierName) OldSupplierName,b.SupplierTypeCode,`
|
|
sqlCount += `select a.Id,a.SupplierName,b.AccessCardNo,max(c.OldSupplierName) OldSupplierName,b.SupplierTypeCode,`
|
|
|
sqlCount += `a.LegalPerson,a.RegCapital,a.Mobile,b.AuditDate,b.ApplyTime,b.InFlag,a.ContactName,a.CommercialNo, `
|
|
sqlCount += `a.LegalPerson,a.RegCapital,a.Mobile,b.AuditDate,b.ApplyTime,b.InFlag,a.ContactName,a.CommercialNo, `
|
|
|
sqlCount += `a.DepositBank,a.HseTraining,a.CompanyType,a.SetupTime,a.Address,a.Province,a.City,a.Street, `
|
|
sqlCount += `a.DepositBank,a.HseTraining,a.CompanyType,a.SetupTime,a.Address,a.Province,a.City,a.Street, `
|
|
@@ -33,10 +34,10 @@ func (s *SelectService) GetMyPagingEntitiesWithOrderBytbl(supplierTableName, sup
|
|
|
sqlCount += `left join ` + OilInfoChangeName + ` c on c.SupplierId = a.Id `
|
|
sqlCount += `left join ` + OilInfoChangeName + ` c on c.SupplierId = a.Id `
|
|
|
sqlCount += `left join ` + OilSupplierCert2FileName + ` d on d.SupplierId = b.Id `
|
|
sqlCount += `left join ` + OilSupplierCert2FileName + ` d on d.SupplierId = b.Id `
|
|
|
sqlCount += `where ` + where
|
|
sqlCount += `where ` + where
|
|
|
- sqlCount += `group by a.Id,b.Id `+having+`) f`
|
|
|
|
|
|
|
+ sqlCount += `group by a.Id,b.Id `+having+`) f`*/
|
|
|
|
|
|
|
|
var sql string
|
|
var sql string
|
|
|
- sql = `select a.Id,a.SupplierName,b.AccessCardNo,max(c.OldSupplierName) OldSupplierName,b.SupplierTypeCode,`
|
|
|
|
|
|
|
+ sql = `select SQL_CALC_FOUND_ROWS a.Id,a.SupplierName,b.AccessCardNo,max(c.OldSupplierName) OldSupplierName,b.SupplierTypeCode,`
|
|
|
sql += `a.LegalPerson,a.RegCapital,a.Mobile,b.AuditDate,b.ApplyTime,b.InFlag,a.ContactName,a.CommercialNo, `
|
|
sql += `a.LegalPerson,a.RegCapital,a.Mobile,b.AuditDate,b.ApplyTime,b.InFlag,a.ContactName,a.CommercialNo, `
|
|
|
sql += `a.DepositBank,a.HseTraining,a.CompanyType,a.SetupTime,a.Address,a.Province,a.City,a.Street, `
|
|
sql += `a.DepositBank,a.HseTraining,a.CompanyType,a.SetupTime,a.Address,a.Province,a.City,a.Street, `
|
|
|
sql += `a.LinkAddress,a.LinkProvince,a.LinkCity,a.LinkStreet,a.BusinessScope, `
|
|
sql += `a.LinkAddress,a.LinkProvince,a.LinkCity,a.LinkStreet,a.BusinessScope, `
|
|
@@ -54,17 +55,17 @@ func (s *SelectService) GetMyPagingEntitiesWithOrderBytbl(supplierTableName, sup
|
|
|
sql += ` order by ` + orderby + ` DESC `
|
|
sql += ` order by ` + orderby + ` DESC `
|
|
|
}
|
|
}
|
|
|
sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
|
|
sql += ` limit ` + utils.ToStr((pageIndex-1)*itemsPerPage) + "," + utils.ToStr(itemsPerPage)
|
|
|
- s.DBE.SQL(sql).Find(entitiesPtr)
|
|
|
|
|
|
|
|
|
|
- resultsSlice, _ = s.DBE.Query(sqlCount)
|
|
|
|
|
|
|
|
|
|
- if len(resultsSlice) > 0 {
|
|
|
|
|
- results := resultsSlice[0]
|
|
|
|
|
- for _, value := range results {
|
|
|
|
|
- total, _ = strconv.ParseInt(string(value), 10, 64)
|
|
|
|
|
- break
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ sqlCount := "SELECT FOUND_ROWS() as total"
|
|
|
|
|
+
|
|
|
|
|
+ var totalResult TotalResult
|
|
|
|
|
+ session := s.DBE.NewSession()
|
|
|
|
|
+ session.Begin()
|
|
|
|
|
+ session.SQL(sql).Find(entitiesPtr)
|
|
|
|
|
+ session.SQL(sqlCount).Get(&totalResult)
|
|
|
|
|
+ session.Commit()
|
|
|
|
|
+ total = totalResult.Total
|
|
|
|
|
|
|
|
return total
|
|
return total
|
|
|
}
|
|
}
|