public class GameNoQueryVO implements Serializable { @ApiModelProperty(value = "游戏ID,必填") private String gameId; @ApiModelProperty(value = "游戏期号,可选", required = false) private String gameNo; @ApiModelProperty(value = "开奖状态,可选", required = false) private String status; @ApiModelProperty(value = "开始日期,格式:yyyy-MM-dd HH:mm:ss, 可选", required = false) private String beginDate; @ApiModelProperty(value = "结束日期,格式:yyyy-MM-dd HH:mm:ss, 可选", required = false) private String endDate; @ApiParam(value = "排序方式,升序:asc,降序:desc", defaultValue = "desc", required = false) private String orderType = "desc"; @ApiParam(value = "页数,默认为 1", defaultValue = "1", required = false) private String pageNum = "1"; @ApiParam(value = "每页显示记录数,默认为10", defaultValue = "10", required = false) private String pageSize = "10"; public GameNoQueryVO() { } } /** * 查询开奖的游戏期号 * * @param vo * @return * @author jqlin */ Page<GameNoModel> queryLotteryGameNo(GameNoQueryVO vo); @Override public Page<GameNoModel> queryLotteryGameNo(GameNoQueryVO vo) { String limitSql = "select * from lot_game_no where 1=1"; String condition = ""; Map<String, Object> params = new HashMap<String, Object>(); if(StringUtils.isNotEmpty(vo.getGameId())){ condition += " and game_id=:gameId"; params.put("gameId", vo.getGameId()); } if(StringUtils.isNotEmpty(vo.getGameNo())){ condition += " and game_no=:gameNo"; params.put("gameNo", vo.getGameNo()); } if(StringUtils.isEmpty(vo.getStatus())){ vo.setStatus(Constants.GameStatus.LOT); } condition += " and status=:status"; params.put("status", vo.getStatus()); if(StringUtils.isNotEmpty(vo.getBeginDate())){ condition += " and lot_time>=:beginDate"; params.put("beginDate", vo.getBeginDate()); } if(StringUtils.isEmpty(vo.getEndDate())){ vo.setEndDate(DateUtil.dateToString(new Date())); } condition += " and lot_time<=:endDate"; params.put("endDate", vo.getEndDate()); limitSql += condition; limitSql += String.format(" order by lot_time %s limit :offset, :pageSize", vo.getOrderType()); String countSql = "select count(*) from lot_game_no where 1=1" + condition; log.info(String.format("查询开奖的游戏期号sql:%s,param:%s", limitSql, params)); log.info(String.format("查询开奖的游戏期号count:%s,param:%s", countSql, params)); long total = selectable.count(countSql, params); return selectable.select(GameNoModel.class, limitSql, params, NumberUtils.toInt(vo.getPageNum(), 1), NumberUtils.toInt(vo.getPageSize(), 10), total); }