接口交互比较多, 所以 入参比较多, 有五个参数,是排序 参数, 跟这个五个参数排序,本来想写个对象的, 怕麻烦, 就把 五个参数 变成一个参数, 升序 1 ,降序2 ,比如 11221 ,第三第四个降序。
mybatis 处理麻烦, 本来是想用charAt 的;
mybatis sql:
<if test=" order.chartAt[0]=='1' "> 结果总是报错, 用了 数字取余 完成了。
select b.* from(
SELECT
a.parent_category_name as first,
a.category_name as second,
a.fds as time,
sum(a.bid_rtnum) AS flow,
sum(a.pv) AS pv,
sum(a.click) / sum(a.pv) AS ctr,
sum(a.cost) / 100 / sum(a.pv) AS cpm,
sum(a.cost) / 100 / 1000 / sum(a.click) AS cpc
FROM
rpt_app_category a
where 1=1
and (a.parent_category_name like CONCAT('%','${search}','%' ) or a.category_name like CONCAT('%','${search}','%' ))
and a.fds >=#{beginDate}
and a.fds <=#{endDate}
GROUP BY
<if test="flag==1">
a.parent_category_id
</if>
<if test="flag==2">
a.category_id
</if>
) b
ORDER BY
b.time DESC
<choose>
<when test="order/10000%1000%100%10==1">
, b.flow DESC
</when>
<otherwise>
, b.flow ASC
</otherwise>
</choose>
<choose>
<when test="order/1000%100%10==1">
, b.pv DESC
</when>
<otherwise>
, b.pv ASC
</otherwise>
</choose>
<choose>
<when test="order/100%10==1">
, b.ctr DESC
</when>
<otherwise>
, b.ctr ASC
</otherwise>
</choose>
<choose>
<when test="order%100/10==1">
, b.cpm DESC
</when>
<otherwise>
,b.cpm ASC
</otherwise>
</choose>
<choose>
<when test="order%100%10==1">
, b.cpc DESC
</when>
<otherwise>
,b.cpc ASC
</otherwise>
</choose>
LIMIT #{page},10
这样就OK了, 随笔记下 ,下次 参考。