nutz对最复杂SQL的处理 自定义SQL 实体类 返回 添加字段 如何获取到值呢
Keywords 实体类 表没有字段ranking 关联表 d有 我在 Keywords 添加 private Long ranking; 返回实体类 没有得到对应的值 该怎么办呢
@Override
public TableDataInfo tableList(Integer pageNumber, Integer pageSize, String keywords, Date startTime,Date endTime) {
String sqlstr = "select distinct k.*, d.ranking " +
"from jp_keywords k " +
"left join jp_keywords_details as d on k.id = d.key_id " +
"where 1=1 ";
if(Strings.isNotBlank(keywords)) {
sqlstr += "and k.keywords like @keywords ";
}
if (Lang.isNotEmpty(startTime)) {
sqlstr += "and d.create_time >=@startTime ";
}
if (Lang.isNotEmpty(endTime)) {
sqlstr += "and d.create_time <=@endTime ";
}
sqlstr += " order by CAST(d.ranking AS SIGNED) ";
Pager pager=this.dao().createPager(pageNumber, pageSize);
Sql sql = Sqls.create(sqlstr);
sql.setPager(pager);
sql.params().set("keywords", "%" + keywords + "%");
sql.params().set("startTime", startTime);
sql.params().set("endTime", endTime);
sql.setCallback(Sqls.callback.entities());
Entity<Keywords> entity = dao().getEntity(Keywords.class);
sql.setEntity(entity);
dao().execute(sql);
return new TableDataInfo(sql.getList(Keywords.class), pager.getPageCount());
}