瀏覽代碼

修复研究员查询

kobe6258 8 月之前
父節點
當前提交
cdcb55be72
共有 2 個文件被更改,包括 18 次插入7 次删除
  1. 7 3
      controllers/analyst.go
  2. 11 4
      models/financial_analyst.go

+ 7 - 3
controllers/analyst.go

@@ -145,23 +145,27 @@ func (this *AnalystController) List() {
 
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
-
+	KeyWord := this.GetString("KeyWord")
 	var startSize int
+	var condition string
 	if pageSize <= 0 {
 		pageSize = utils.PageSize20
 	}
 	if currentIndex <= 0 {
 		currentIndex = 1
 	}
+	if KeyWord != "" {
+		condition += " AND name like '%" + KeyWord + "%'"
+	}
 	startSize = utils.StartIndex(currentIndex, pageSize)
 
-	total, err := models.GetAnalystCount()
+	total, err := models.GetAnalystCount(condition)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
-	list, err := models.GetAnalystList(startSize, pageSize)
+	list, err := models.GetAnalystList(condition, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + err.Error()

+ 11 - 4
models/financial_analyst.go

@@ -54,16 +54,23 @@ func (a *CrmFinancialAnalyst) ToView() *AnalystView {
 		CreatedTime:  a.CreatedTime.Format(time.DateTime),
 	}
 }
-func GetAnalystCount() (count int, err error) {
+func GetAnalystCount(condition string) (count int, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT COUNT(*) AS count FROM crm_financial_analysts`
+	sql := `SELECT COUNT(*) AS count FROM crm_financial_analysts WHERE 1=1 `
+	if condition != "" {
+		sql += condition
+	}
 	err = o.Raw(sql).QueryRow(&count)
 	return
 }
 
-func GetAnalystList(startSize int, pageSize int) (item []*CrmFinancialAnalyst, err error) {
+func GetAnalystList(condition string, startSize int, pageSize int) (item []*CrmFinancialAnalyst, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM crm_financial_analysts  ORDER BY created_time desc LIMIT ?,?`
+	sql := `SELECT * FROM crm_financial_analysts  WHERE 1=1`
+	if condition != "" {
+		sql += condition
+	}
+	sql = sql + ` ORDER BY created_time desc LIMIT ?,?`
 	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&item)
 	return
 }