需要排序的字段已经根据bootstrap table官网设置table th data-sortable=true,可是desc和asc数据没什么变化。
请求也正常发出去了,http://localhost:8080/game_center_contro/gift/getGift?sort=id&order=desc&limit=10&offset=0 数据也返回了。
原来请求没问题,是后台处理时的问题。后台将sort,order加上了字符串。
@SQL("select a.id,a.name,a.appId,a.expireDate,a.num,a.shortDesc,a.detailDesc,a.number,b.appName from game_center_gift a LEFT JOIN game_center_app_info b on a.appId=b.appId #if(:1!=null){ where b.appName like '%##(:1)%'} #if(:2!=null) { order by :2 :3 } limit :5 offset :4")
public List<Gift> getGift(String name,String sort, String order, int pageIndex, int pageSize);
##框架sql解析结果
SELECT
a.id,
a. NAME,
a.appId,
a.expireDate,
a.num,
a.shortDesc,
a.detailDesc,
a.number,
b.appName
FROM
game_center_gift a
LEFT JOIN game_center_app_info b ON a.appId = b.appId order by 'id' 'desc' limit 10 offset 0
##可以得到正确数据的sql
SELECT
a.id,
a. NAME,
a.appId,
a.expireDate,
a.num,
a.shortDesc,
a.detailDesc,
a.number,
b.appName
FROM
game_center_gift a
LEFT JOIN game_center_app_info b ON a.appId = b.appId order by id desc limit 10 offset 0
修改后的sql
@SQL(“select a.id,a.name,a.appId,a.expireDate,a.num,a.shortDesc,a.detailDesc,a.number,b.appName from game_center_gift a LEFT JOIN game_center_app_info b on a.appId=b.appId #if(:1!=null){ where b.appName like ‘%##(:1)%’} #if(:2!=null) { order by ##(:2) ##(:3) } limit :5 offset :4”)
public List getGift(String name,String sort, String order, int pageIndex, int pageSize);
结论:多个引号害死人!