admin
2021-04-12 5129d2c63fbef70c6ee45ba5ec12654937e05231
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
package com.yeshi.buwan.dao.vip;
 
import com.yeshi.buwan.dao.base.BaseDao;
import com.yeshi.buwan.domain.vip.OrderType;
import com.yeshi.buwan.domain.vip.OrderRecord;
import org.springframework.stereotype.Repository;
 
import java.util.List;
 
@Repository
public class OrderRecordDao extends BaseDao<OrderRecord> {
 
 
    private String getHql(DaoQuery daoQuery) {
 
        String hql = "from OrderRecord r where 1=1";
 
        if (daoQuery.state != null) {
            hql += " and r.state=" + daoQuery.state;
        }
 
        if (daoQuery.uid != null) {
            hql += " and r.uid=" + daoQuery.uid;
        }
 
        if (daoQuery.orderType != null) {
            hql += " and r.orderType=" + daoQuery.orderType;
        }
 
        hql += " order by r.createTime desc";
        return hql;
    }
 
 
    public List<OrderRecord> list(DaoQuery daoQuery) {
        return super.list(getHql(daoQuery), daoQuery.start, daoQuery.count, null);
    }
 
 
    public long count(DaoQuery daoQuery) {
        return super.getCount(getHql(daoQuery), null);
    }
 
    public static class DaoQuery {
        public Integer state;
        public OrderType orderType;
        public String uid;
        public int start;
        public int count;
    }
 
}