接口交互比较多, 所以 入参比较多,  有五个参数,是排序 参数, 跟这个五个参数排序,本来想写个对象的, 怕麻烦, 就把 五个参数 变成一个参数, 升序 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 &gt;=#{beginDate}
and a.fds &lt;=#{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了,  随笔记下 ,下次 参考。

mybatis 多参数处理的更多相关文章

  1. mybatis 传递参数的方法总结

    有三种mybatis传递参数的方式: 第一种 mybatis传入参数是有序号的,可以直接用序号取得参数 User selectUser(String name,String area); 可以在xml ...

  2. 【转载】Mybatis多参数查询映射

    转载地址:http://www.07net01.com/zhishi/402787.html 最近在做一个Mybatis的项目,由于是接触不久,虽然看了一下资料,但在实际开发中还是暴 露了很多问题,其 ...

  3. MyBatis传递参数

    MyBatis传递参数 一.使用 map 接口传递参数 在 MyBatis 中允许 map 接口通过键值对传递多个参数,把接口方法定义为 : public List<Role> findR ...

  4. MyBatis传入参数为list、数组、map写法(转载)

    MyBatis传入参数为list.数组.map写法 1.foreach简单介绍: foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有item ...

  5. Mybatis基于代理Dao实现CRUD操作 及 Mybatis的参数深入

    Mybatis基于代理Dao实现CRUD操作 使用要求: 1.持久层接口和持久层接口的映射配置必须在相同的包下 2.持久层映射配置中mapper标签的namespace属性取值必须是持久层接口的全限定 ...

  6. MyBatis的参数,不能传入null

    今天在调试的过程中发现一个bug,把传入的参数写到查询分析器中执行没有问题,但是在程序中执行就报错:org.springframework.jdbc.UncategorizedSQLException ...

  7. MyBatis传入参数为list、数组、map写法

    1.foreach简单介绍: foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有item,index,collection,open,sep ...

  8. mybatis中参数为list集合时使用 mybatis in查询

    mybatis中参数为list集合时使用 mybatis in查询 一.问题描述mybatis sql查询时,若遇到多个条件匹配一个字段,sql 如: select * from user where ...

  9. 【mybatis源码学习】mybatis的参数处理

    一.mybatis的参数处理以及参数取值 1.单个参数 mybatis不做任何处理 取值方式: ​ #{参数名/任意名} <!-- Employee getEmpById(Integer id) ...

  10. Mybatis传入参数类型为Map

    mybatis更新sql语句: <update id="publishT00_notice" parameterType="Map"> update ...

随机推荐

  1. 【HDU4010】【LCT】Query on The Trees

    Problem Description We have met so many problems on the tree, so today we will have a query problem ...

  2. TIFF6 Packbit algorithm

    “Packbits” from ISO 12369 参考TIFF 6.0 Specification,点击TIFF, Version 6.0: @Section 9: PackBits Compres ...

  3. 泛型? extents super

    ?可以接受任何泛型集合,但是不能编辑集合值.所以一般只在方法参数中用 例子: ? extends Number  则类型只能是Number类的子孙类 ? super String  则类型只能是Str ...

  4. CSAPP LAB: Buffer Overflow

    这是CSAPP官网上的著名实验,通过注入汇编代码实现堆栈溢出攻击.实验材料可到我的github仓库 https://github.com/Cheukyin/CSAPP-LAB/ 选择buffer-ov ...

  5. call/apply的第一个参数如果为null。this指向window

    call/apply是用来改变函数的作用域的,第一次参数为this,第二个参数为传输的值,例如 var a ="windowA"; var b = "windowB&qu ...

  6. js字符串倒序

    有的时候我们需要把字符串倒序. 比如“范坚强”的倒序就是“强坚范”. 如何对字符串进行倒序呢?你首先想到的方法就是生成一个栈,从尾到头依次取出字符串中的字符压入栈中,然后把栈连接成字符串. var r ...

  7. easyui_tree 复选框 动态加载树

    controller动态获取单位用户树 #region 下拉树菜单 /// <summary> /// 获取工作人员树菜单 /// </summary> /// <par ...

  8. IOS--UIImageView的使用方法

    IOS--UIImageView的使用方法 //初始化 UIImageView  *imageView=[[UIImageView alloc] initWithFrame:CGRectMake(10 ...

  9. 转:GraphicsMagick介绍及安装

    原文来自于:http://www.cnblogs.com/cocowool/archive/2010/08/16/1800954.html GraphicsMagick 当前稳定版本:1.3.12(发 ...

  10. 转:PHP中实现非阻塞模式

    原文来自于:http://blog.csdn.net/linvo/article/details/5466046 程序非阻塞模式,这里也可以理解成并发.而并发又暂且可以分为网络请求并发 和本地并发 . ...