Search in sources :

Example 1 with Dict

use of com.github.liuweijw.business.admin.domain.Dict in project fw-cloud-framework by liuweijw.

the class DictServiceImpl method getDictList.

@Override
@Cacheable(key = "'dict_' + #type", unless = "#result eq null")
public List<Dict> getDictList(String type) {
    List<Dict> dictList = new ArrayList<Dict>();
    if (StringHelper.isBlank(type))
        return dictList;
    QDict qDict = QDict.dict;
    return this.queryFactory.selectFrom(qDict).where(qDict.type.eq(type.trim())).fetch();
}
Also used : QDict(com.github.liuweijw.business.admin.domain.QDict) QDict(com.github.liuweijw.business.admin.domain.QDict) Dict(com.github.liuweijw.business.admin.domain.Dict) ArrayList(java.util.ArrayList) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 2 with Dict

use of com.github.liuweijw.business.admin.domain.Dict in project fw-cloud-framework by liuweijw.

the class DictServiceImpl method findAll.

@Override
@Cacheable(key = "'page_dict_' + #p0.currentPage + '_' + #p0.pageSize + '_' + #p1.type + '_' + #p1.label")
public PageBean<Dict> findAll(PageParams pageParams, Dict dict) {
    QDict qDict = QDict.dict;
    // 用户名查询条件
    Predicate qLabelPredicate = null;
    Predicate qTypePredicate = null;
    if (null != dict) {
        if (StringHelper.isNotBlank(dict.getLabel())) {
            qLabelPredicate = qDict.label.like("%" + dict.getLabel().trim() + "%");
        }
        if (StringHelper.isNotBlank(dict.getType())) {
            qTypePredicate = qDict.type.like("%" + dict.getType().trim() + "%");
        }
    }
    Predicate predicate = qDict.id.goe(0).and(qTypePredicate).and(qLabelPredicate);
    Sort sort = new Sort(new Sort.Order(Sort.Direction.DESC, "id"));
    PageRequest pageRequest = PageUtils.of(pageParams, sort);
    Page<Dict> pageList = dictRepository.findAll(predicate, pageRequest);
    return PageUtils.of(pageList);
}
Also used : QDict(com.github.liuweijw.business.admin.domain.QDict) PageRequest(org.springframework.data.domain.PageRequest) QDict(com.github.liuweijw.business.admin.domain.QDict) Dict(com.github.liuweijw.business.admin.domain.Dict) Sort(org.springframework.data.domain.Sort) Predicate(com.querydsl.core.types.Predicate) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

Dict (com.github.liuweijw.business.admin.domain.Dict)2 QDict (com.github.liuweijw.business.admin.domain.QDict)2 Cacheable (org.springframework.cache.annotation.Cacheable)2 Predicate (com.querydsl.core.types.Predicate)1 ArrayList (java.util.ArrayList)1 PageRequest (org.springframework.data.domain.PageRequest)1 Sort (org.springframework.data.domain.Sort)1