Search in sources :

Example 56 with Condition

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;
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PageInfo(com.github.pagehelper.PageInfo) User(com.cas.sim.tis.entity.User) Criteria(tk.mybatis.mapper.entity.Example.Criteria)

Example 57 with Condition

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;
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PageInfo(com.github.pagehelper.PageInfo) User(com.cas.sim.tis.entity.User) Criteria(tk.mybatis.mapper.entity.Example.Criteria)

Example 58 with Condition

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());
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) User(com.cas.sim.tis.entity.User) Criteria(tk.mybatis.mapper.entity.Example.Criteria) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 59 with Condition

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);
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) Resource(javax.annotation.Resource) Criteria(tk.mybatis.mapper.entity.Example.Criteria) PageInfo(com.github.pagehelper.PageInfo) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 60 with Condition

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);
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) PanoramicDailyInventorySummary(com.monitor.model.dailyinventorysummary.PanoramicDailyInventorySummary) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Condition (tk.mybatis.mapper.entity.Condition)69 Criteria (tk.mybatis.mapper.entity.Example.Criteria)25 Transactional (org.springframework.transaction.annotation.Transactional)21 PostMapping (org.springframework.web.bind.annotation.PostMapping)21 MachineOrder (com.eservice.api.model.machine_order.MachineOrder)15 Machine (com.eservice.api.model.machine.Machine)13 TaskRecord (com.eservice.api.model.task_record.TaskRecord)10 Date (java.util.Date)10 PageInfo (com.github.pagehelper.PageInfo)9 ArrayList (java.util.ArrayList)9 ProcessRecord (com.eservice.api.model.process_record.ProcessRecord)8 ServerToClientMsg (com.eservice.api.service.mqtt.ServerToClientMsg)7 Contract (com.eservice.api.model.contract.Contract)6 ContractSign (com.eservice.api.model.contract_sign.ContractSign)6 Task (com.eservice.api.model.task.Task)6 PanoramicRealTimeConsumptionGather (com.monitor.model.realtimeconsumptiongather.PanoramicRealTimeConsumptionGather)6 OrderSign (com.eservice.api.model.order_sign.OrderSign)5 User (com.cas.sim.tis.entity.User)4 User (com.eservice.api.model.user.User)4 AbnormalRecord (com.eservice.api.model.abnormal_record.AbnormalRecord)3