|
@@ -70,7 +70,7 @@ var (
|
|
|
}
|
|
|
)
|
|
|
|
|
|
-//Check 校验查询参数是否合法
|
|
|
+// Check 校验查询参数是否合法
|
|
|
func (es *EnterpriseSearch) Check() (*EnterpriseSearch, error) {
|
|
|
if es.PageSize == 0 { //默认十条
|
|
|
es.PageSize = 10
|
|
@@ -118,7 +118,7 @@ func (es *EnterpriseSearch) Check() (*EnterpriseSearch, error) {
|
|
|
return es, nil
|
|
|
}
|
|
|
|
|
|
-//判断是否是空查询
|
|
|
+// 判断是否是空查询
|
|
|
func (es *EnterpriseSearch) isEmptySearch() bool {
|
|
|
if es.Match == "" &&
|
|
|
es.EntArea == "" &&
|
|
@@ -135,9 +135,9 @@ func (es *EnterpriseSearch) isEmptySearch() bool {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
-//GetQuerySql 获取检索语句
|
|
|
-//return company_name、company_status、legal_person、capital、company_address、id、company_shortname
|
|
|
-//返回字段 企业名称、企业状态、法人、注册资本、地址、企业id、企业简称
|
|
|
+// GetQuerySql 获取检索语句
|
|
|
+// return company_name、company_status、legal_person、capital、company_address、id、company_shortname
|
|
|
+// 返回字段 企业名称、企业状态、法人、注册资本、地址、企业id、企业简称
|
|
|
func (es *EnterpriseSearch) GetQuerySql() (string, string) {
|
|
|
musts := make([]string, 0, 0)
|
|
|
//仅展示公司类型小于等于22的 company_type_int 22
|
|
@@ -251,7 +251,7 @@ func (es *EnterpriseSearch) GetQuerySql() (string, string) {
|
|
|
return fmt.Sprintf(entQueryCount, strings.Join(musts, ","), ""), fmt.Sprintf(entQuery, strings.Join(musts, ","), "")
|
|
|
}
|
|
|
|
|
|
-//DoQuery 根据EnterpriseSearch参数进行企业相关查询
|
|
|
+// DoQuery 根据EnterpriseSearch参数进行企业相关查询
|
|
|
func (es *EnterpriseSearch) DoQuery() (list *[]map[string]interface{}, total int64, err error) {
|
|
|
if es.isEmptySearch() { //是否是空查询,返回默认企业
|
|
|
list = GetEntIndexShow()
|
|
@@ -262,13 +262,17 @@ func (es *EnterpriseSearch) DoQuery() (list *[]map[string]interface{}, total int
|
|
|
start, limit := es.PageNum*es.PageSize, es.PageSize
|
|
|
total = -1
|
|
|
|
|
|
- if !es.IsVip {
|
|
|
- start, limit = 0, freeSearchNum
|
|
|
- } else if start == 0 {
|
|
|
- total = elastic.Count(index, itype, countSql)
|
|
|
- if total == 0 {
|
|
|
- return
|
|
|
- }
|
|
|
+ /*if !es.IsVip {
|
|
|
+ start, limit = 0, freeSearchNum
|
|
|
+ } else if start == 0 {
|
|
|
+ total = elastic.Count(index, itype, countSql)
|
|
|
+ if total == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ total = elastic.Count(index, itype, countSql)
|
|
|
+ if total == 0 {
|
|
|
+ return
|
|
|
}
|
|
|
sql = sql[:len(sql)-1] + fmt.Sprintf(`,"from":%d,"size":%d}`, start, limit)
|
|
|
list = elastic.Get(index, itype, sql)
|
|
@@ -281,7 +285,7 @@ func (es *EnterpriseSearch) DoQuery() (list *[]map[string]interface{}, total int
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-////格式化字段,加密id
|
|
|
+// //格式化字段,加密id
|
|
|
func formatData(list *[]map[string]interface{}) *[]map[string]interface{} {
|
|
|
if list != nil {
|
|
|
for index, _ := range *list {
|
|
@@ -303,7 +307,7 @@ func formatData(list *[]map[string]interface{}) *[]map[string]interface{} {
|
|
|
return list
|
|
|
}
|
|
|
|
|
|
-//暂不处理前端处理
|
|
|
+// 暂不处理前端处理
|
|
|
func getCompanyShortName(entName string) string {
|
|
|
if entName == "" {
|
|
|
return ""
|
|
@@ -330,7 +334,7 @@ func GetEntIndexShow() (list *[]map[string]interface{}) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//formatEstablishTime 格式化成立时间
|
|
|
+// formatEstablishTime 格式化成立时间
|
|
|
// Year range
|
|
|
// [start]y-[end]y
|
|
|
// Timestamp range
|