use of tk.mybatis.mapper.entity.Example.Criteria in project TeachingInSimulation by ScOrPiOzzy.
the class ResourceServiceImpl method findResourcesByCreator.
@Override
public PageInfo<Resource> findResourcesByCreator(int pagination, int pageSize, List<Integer> resourceTypes, String keyword, String orderByClause, Integer creator) {
// 获取当前登陆者身份信息
Condition condition = new Condition(Resource.class);
// 条件1、查找用户指定的几种资源类型
if (resourceTypes.size() == 0) {
return new PageInfo<Resource>(new ArrayList<Resource>());
} else {
Criteria criteria = condition.createCriteria();
criteria.andIn("type", resourceTypes);
}
// 条件2、关键字搜索
if (keyword != null && !"".equals(keyword)) {
Criteria criteria = condition.createCriteria();
List<String> words = StringUtil.split(keyword, ' ');
for (String word : words) {
criteria.orLike("keyword", "%" + word + "%");
}
condition.and(criteria);
}
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("creator", creator);
condition.and(criteria);
// 开始分页查询
PageHelper.startPage(pagination, pageSize, orderByClause);
List<Resource> result = findByCondition(condition);
PageInfo<Resource> page = new PageInfo<Resource>(result);
// 查到的总记录数
// 解释一下:这个page.getTotal(),是所有符合条件的记录数。
// result.size():是当前页中的数据量 <= pageSize
LOG.info("成功查找到{}条资源,当前页码{},每页{}条资源,共{}页", result.size(), pagination, pageSize, page.getPages());
return page;
}
use of tk.mybatis.mapper.entity.Example.Criteria in project TeachingInSimulation by ScOrPiOzzy.
the class CatalogServiceImpl method findCatalogsByParentId.
@Override
public List<Catalog> findCatalogsByParentId(Integer rid) {
Condition condition = new Condition(Catalog.class);
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("rid", rid);
criteria.andEqualTo("del", 0);
CatalogMapper catalogMapper = (CatalogMapper) mapper;
catalogMapper.selectByCondition(condition);
List<Catalog> catalogs = null;
try {
catalogs = catalogMapper.selectByCondition(condition);
LOG.debug("查询到子节点数量:{}", catalogs.size());
} catch (Exception e) {
LOG.error("查询ID{}下子节点失败!", rid);
catalogs = Collections.emptyList();
}
return catalogs;
}
use of tk.mybatis.mapper.entity.Example.Criteria in project TeachingInSimulation by ScOrPiOzzy.
the class ClassServiceImpl method findClassesByTeacher.
@Override
public List<Class> findClassesByTeacher(int teacherId) {
Condition condition = new Condition(Class.class);
condition.orderBy("createDate").desc();
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("teacherId", teacherId);
criteria.andEqualTo("del", 0);
return findByCondition(condition);
}
use of tk.mybatis.mapper.entity.Example.Criteria in project TeachingInSimulation by ScOrPiOzzy.
the class ElecCompServiceImpl method findElecCompByModel.
@Override
public ElecComp findElecCompByModel(String model) {
ElecCompMapper dao = (ElecCompMapper) mapper;
Condition condition = new Condition(ElecComp.class);
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("model", model);
List<ElecComp> compList = dao.selectByCondition(condition);
if (compList.size() == 0) {
return null;
} else if (compList.size() > 1) {
throw new TooManyResultsException();
}
return compList.get(0);
}
use of tk.mybatis.mapper.entity.Example.Criteria in project TeachingInSimulation by ScOrPiOzzy.
the class QuestionServiceImpl method countQuestionByLibrary.
@Override
public int countQuestionByLibrary(int rid) {
Condition condition = new Condition(Question.class);
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("relateId", rid);
return getTotalBy(condition);
}
Aggregations