Search in sources :

Example 1 with QDict

use of com.github.liuweijw.business.admin.domain.QDict 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 QDict

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

the class DictServiceImpl method delById.

@Override
@Transactional
@CacheEvict(allEntries = true)
public boolean delById(Integer id) {
    if (null == id || id <= 0)
        return Boolean.FALSE;
    QDict qDict = QDict.dict;
    long num = // 0 正常 1删除
    this.queryFactory.update(qDict).set(qDict.statu, 1).where(qDict.id.eq(id.intValue())).execute();
    return num > 0;
}
Also used : QDict(com.github.liuweijw.business.admin.domain.QDict) CacheEvict(org.springframework.cache.annotation.CacheEvict) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with QDict

use of com.github.liuweijw.business.admin.domain.QDict 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

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