service 层
public List<HoseOrderVo> getHoseNameAndId() {
Sql sql = Sqls.queryRecord("select t1.houseid,t1.title,o.begintime,o.endtime FROM house AS t1 left join orderinfo AS o on t1.houseid=o.houseid");
dao().execute(sql);
return sql.getList(HoseOrderVo.class);
}
controller
public void getHouseStatue(String yearMonth){
List<HoseOrderVo> list=houseService.getHoseNameAndId();
System.out.println(list);
}
vo层
public class HoseOrderVo implements Serializable {
private String houseid;
private String title;
List<BEtime> time;
public List<BEtime> getTime() {
return time;
}
public void setTime(List<BEtime> time) {
this.time = time;
}
public String getHouseid() {
return houseid;
}
public void setHouseid(String houseid) {
this.houseid = houseid;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
class BEtime {
private String begintime;
private String endtime;
public String getBegintime() {
return begintime;
}
public void setBegintime(String begintime) {
this.begintime = begintime;
}
public String getEndtime() {
return endtime;
}
public void setEndtime(String endtime) {
this.endtime = endtime;
}
}
运行结果
[{
"houseid" :"7b235124b2fe4c9aa7f9f9b051c5acfe",
"title" :"1",
"begintime" :"1456366485",
"endtime" :"1456366485"
}, {
"houseid" :"7b235124b2fe4c9aa7f9f9b051c5acfe",
"title" :"1",
"begintime" :"1456366485",
"endtime" :"1456366485"
}, {
"houseid" :"7b235124b2fe4c9aa7f9f9b051c5acfe",
"title" :"1",
"begintime" :"1456366485",
"endtime" :"1456366485"
}, {
"houseid" :"7b235124b2fe4c9aa7f9f9b051c5acfe",
"title" :"1",
"begintime" :"1456366485",
"endtime" :"1456366485"
}, {
"houseid" :"0e1e3ed9cdba4e729520e5235d83d3ed",
"title" :"test",
"begintime" :"1458144000",
"endtime" :"1458489600"
}, {
"houseid" :"a000a8273c124d499ac4b3866a251594",
"title" :"图片",
"begintime" :"1456848000",
"endtime" :"1456934400"
}, {
原生sql 不会把结果自动装进 list 吗?