fix
Helius
2021-08-05 8bbb027dc36b3f3c7f2d505fc75180261fb4d640
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
package com.xzx.gc.model;
 
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xzx.gc.annotation.Query;
import com.xzx.gc.util.PageQuery;
 
import java.lang.reflect.Field;
 
/**
 * 子类继承此类获得翻页功能
 * @author lijiazhi
 */
public class PageParam {
     Integer page = null;
     Integer limit = null;
 
    public Integer getPage() {
        return page;
    }
 
    public void setPage(Integer page) {
        this.page = page;
    }
 
    @JsonIgnore
    public PageQuery getPageQuery() {
        Field[] fs =this.getClass().getDeclaredFields();
        for(Field f:fs){
            Query query = f.getAnnotation(Query.class);
            if(query==null){
                continue ;
            }
            if (query.fuzzy()) {
                try {
                    if ( f.getType() == String.class) {
                        f.setAccessible(true);
                        Object o = f.get(this);
                        if (o != null && !o.toString().isEmpty()) {
                            f.set(this,"%"+o.toString()+"%");
                        }
                    }
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
        PageQuery query = new PageQuery();
        query.setParas(this);
        if (page != null) {
            query.setPageNumber(page);
            query.setPageSize(limit);
        }
        return query;
    }
 
    public Integer getLimit() {
        return limit;
    }
 
    public void setLimit(Integer limit) {
        this.limit = limit;
    }
 
 
}