需求:返回对象的id为32位,每次查询的数据固定;displayRedDot 设置参数为0,1间隔显示,时间固定
一、通过for循环实现返回多条对象需求
public List<MessageContainerVO> findAllMessage() {
List<MessageContainerVO> messageVOList = new ArrayList<MessageContainerVO>(); // achieve now time DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设定格式 String formatTime = "2019-03-01 10:12:12"; Date timeDate = dateFormat.parse(formatTime);// Date类型 Timestamp dateTime = new Timestamp(timeDate.getTime()); for (int i = 10; i < 30; i++) { MessageContainerVO messageVO = new MessageContainerVO(); messageVO.setMessageContainerId("0248d87626aa44adab44794de349e4"+i); messageVO.setNewContentTips("最新系统消息" + i); messageVO.setNewMessageTime(dateTime); messageVO.setOrder(1); messageVO.setType(1); messageVO.setPicURL(url); messageVO.setTitle("系统消息:" + i); messageVO.setDisplayRedDot(i%2); messageVOList.add(messageVO); } return messageVOList; } }