use of tk.mybatis.mapper.entity.Condition in project TeachingInSimulation by ScOrPiOzzy.
the class UserServiceImpl method findTeachers.
@Override
public PageInfo<User> findTeachers(int pageIndex, int pageSize) {
Condition condition = new Condition(User.class);
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("role", RoleConst.TEACHER);
criteria.andEqualTo("del", 0);
condition.orderBy("createDate").desc();
PageHelper.startPage(pageIndex, pageSize);
List<User> result = findByCondition(condition);
PageInfo<User> page = new PageInfo<>(result);
LOG.info("成功查找到{}条资源,当前页码{},每页{}条资源,共{}页", result.size(), pageIndex, pageSize, page.getPages());
return page;
}
use of tk.mybatis.mapper.entity.Condition in project TeachingInSimulation by ScOrPiOzzy.
the class UserServiceImpl method findStudents.
@Override
public PageInfo<User> findStudents(int pageIndex, int pageSize, int classId) {
Condition condition = new Condition(User.class);
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("role", RoleConst.STUDENT);
criteria.andEqualTo("classId", classId);
criteria.andEqualTo("del", 0);
condition.orderBy("createDate").desc();
PageHelper.startPage(pageIndex, pageSize);
List<User> result = findByCondition(condition);
PageInfo<User> page = new PageInfo<>(result);
LOG.info("成功查找到{}条资源,当前页码{},每页{}条资源,共{}页", result.size(), pageIndex, pageSize, page.getPages());
return page;
}
use of tk.mybatis.mapper.entity.Condition in project TeachingInSimulation by ScOrPiOzzy.
the class DBTest method testAdminLogin.
@Test
public void testAdminLogin() throws Exception {
Condition condition = new Condition(User.class);
Criteria criteria = condition.createCriteria();
criteria.andEqualTo("code", "admin");
criteria.andEqualTo("password", "123456");
List<User> users = userMapper.selectByCondition(condition);
Assert.assertEquals(1, users.size());
}
use of tk.mybatis.mapper.entity.Condition in project TeachingInSimulation by ScOrPiOzzy.
the class PageHelpTest method testPage.
@Test
public void testPage() throws Exception {
Condition condition = new Condition(com.cas.sim.tis.entity.Resource.class);
Criteria criteria = condition.createCriteria();
// 条件1、查找用户指定的几种资源类型
criteria.andIn("type", new ArrayList<>(Arrays.asList(1, 4)));
// 条件2、只能查找管理员或自己上传的资源。
// 属于自己的资源
// criteria.andEqualTo("creatorId", 2);
// 或者是公开的资源
criteria.orEqualTo("share", true);
PageHelper.startPage(0, 2);
List<com.cas.sim.tis.entity.Resource> resources = resourceService.findByCondition(condition);
PageInfo<com.cas.sim.tis.entity.Resource> page = new PageInfo<com.cas.sim.tis.entity.Resource>(resources);
System.out.println(page.getTotal());
Assert.assertEquals(4, resources.size());
resources.stream().forEach(System.out::println);
}
use of tk.mybatis.mapper.entity.Condition in project new-cloud by xie-summer.
the class PanoramicDailyInventorySummaryServiceImpl method queryByDateAndCode.
@Override
@Transactional(propagation = Propagation.NOT_SUPPORTED, rollbackFor = Exception.class)
public PanoramicDailyInventorySummary queryByDateAndCode(String code, String date) {
Condition condition = new Condition(PanoramicDailyInventorySummary.class, false);
condition.createCriteria().andCondition(" code ='" + code + "' and f_id=2 and delete_flag=1 and utime >= '" + DateUtil.parseTimestamp(date, "yyyy-MM-dd") + "' and utime < '" + DateUtil.parseTimestamp(DateUtil.getSpecifiedDayBefor(date, -1), "yyyy-MM-dd") + "'");
condition.setOrderByClause(" utime desc ");
List<PanoramicDailyInventorySummary> recordList = dailyInventorySummaryMapper.selectByCondition(condition);
return (null == recordList || recordList.size() == 0) ? null : recordList.get(0);
}
Aggregations