@Override
public Page<AttendRecordDto> listAttendRecordByPage(AttendRecordDto recordDto) {
PageHelper.startPage(recordDto.getPage(), recordDto.getLimit());
Example example = new Example(TbAttendRecord.class);
Criteria criteria = example.createCriteria();
criteria.andCondition("work_date>="+recordDto.getStartDate());
criteria.andCondition("work_date<="+recordDto.getEndDate());
if(recordDto.getName() != null && !"".equals(recordDto.getName())){
criteria.andCondition("name like '%"+recordDto.getName()+"%'");
}
if(recordDto.getEmpType() != null){
criteria.andCondition("emp_type="+recordDto.getEmpType());
}
if(recordDto.getDeptId() != null){
criteria.andCondition("dept_id="+recordDto.getDeptId());
}
Page<TbAttendRecord> list = (Page<TbAttendRecord>) recordMapper.selectByExample(example);
Page<AttendRecordDto> convertList = BeanUtils.convertPage(list, AttendRecordDto.class);
return convertList;
}
Mybatis自带的selectByExample修改查询条件
猜你喜欢
转载自blog.csdn.net/qq_30264689/article/details/80611537
今日推荐
周排行