|
@@ -695,7 +695,7 @@ func (this *MaterialController) List() {
|
|
|
pageSize, _ := this.GetInt("PageSize")
|
|
|
currentIndex, _ := this.GetInt("CurrentIndex")
|
|
|
keyword := this.GetString("Keyword")
|
|
|
-
|
|
|
+ keyword = strings.Trim(keyword, " ")
|
|
|
var total int
|
|
|
page := paging.GetPaging(currentIndex, pageSize, total)
|
|
|
|
|
@@ -754,11 +754,31 @@ func (this *MaterialController) List() {
|
|
|
}
|
|
|
|
|
|
if keyword != "" {
|
|
|
+ // 将关键词按照空格拆分,并处理查询
|
|
|
+ keywordList := strings.Split(keyword, " ")
|
|
|
switch this.Lang {
|
|
|
case utils.LANG_EN:
|
|
|
- condition += ` AND ( material_name_en LIKE '%` + keyword + `%' )`
|
|
|
+ if len(keywordList) == 1 {
|
|
|
+ condition += ` AND ( material_name_en LIKE '%` + keyword + `%' )`
|
|
|
+ } else {
|
|
|
+ condition += ` AND (`
|
|
|
+ for _, key := range keywordList {
|
|
|
+ condition += ` material_name_en LIKE '%` + key + `%' AND`
|
|
|
+ }
|
|
|
+ condition = strings.TrimSuffix(condition, "AND")
|
|
|
+ condition += ` )`
|
|
|
+ }
|
|
|
default:
|
|
|
- condition += ` AND ( material_name LIKE '%` + keyword + `%' )`
|
|
|
+ if len(keywordList) == 1 {
|
|
|
+ condition += ` AND ( material_name LIKE '%` + keyword + `%' )`
|
|
|
+ } else {
|
|
|
+ condition += ` AND (`
|
|
|
+ for _, key := range keywordList {
|
|
|
+ condition += ` material_name LIKE '%` + key + `%' AND`
|
|
|
+ }
|
|
|
+ condition = strings.TrimSuffix(condition, "AND")
|
|
|
+ condition += ` )`
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|