cy
2022-06-23 b83c40548208609d0d6826be13d742c28a784806
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package cn.ksource.core.fulltext;
 
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
 
import org.apache.commons.lang.StringUtils;
 
import cn.ksource.core.util.ConvertUtil;
import cn.ksource.core.util.JsonUtil;
 
/**
 * 全文检索查询条件实体
 */
public class FullText_QueryEntity {
 
    
    private String keywords;
    
    private int pagesize;
    
    private int pageindex;
    
    private Map<String,String[]> filter = new HashMap();
    
    
    public Map addFilter(String key,String[] values){
        this.filter.put(key, values);
        return this.filter;
    }
    
    
    public String toJson(){
        Map query = new HashMap();
        query.put("keywords", this.getKeywords());
        query.put("pagesize", this.getPagesize());
        query.put("pageindex",this.getPageindex());
        query.put("filter", this.filter);
        return JsonUtil.map2Json(query);
    }
    
    
    
    public FullText_QueryEntity parseJson(String json){
        FullText_QueryEntity entity = new FullText_QueryEntity();
        Map map = JsonUtil.json2SimpleMap(json);
        entity.setKeywords(ConvertUtil.obj2Str(map.get("keywords")));
        entity.setPageindex(ConvertUtil.obj2Int(map.get("pageindex")));
        entity.setPagesize(ConvertUtil.obj2Int(map.get("pagesize")));
        Map myFilter = (Map)map.get("filter");
        for (Iterator iterator = myFilter.keySet().iterator(); iterator.hasNext();) {
            String key = (String) iterator.next();
            if (myFilter.get(key) != null) {
                String[] values =  (String[])myFilter.get(key);
                entity.addFilter(key, values);
            }
        }
        
        return entity;
    }
    
    
 
    public String getKeywords() {
        return keywords;
    }
 
    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }
 
    public int getPagesize() {
        return pagesize;
    }
 
    public void setPagesize(int pagesize) {
        this.pagesize = pagesize;
    }
 
    public int getPageindex() {
        return pageindex;
    }
 
    public void setPageindex(int pageindex) {
        this.pageindex = pageindex;
    }
 
    public Map getFilter() {
        return filter;
    }
 
    public void setFilter(Map filter) {
        this.filter = filter;
    }
    
    
    
    
    
    
}