mybatis 多参数处理
接口交互比较多, 所以 入参比较多, 有五个参数,是排序 参数, 跟这个五个参数排序,本来想写个对象的, 怕麻烦, 就把 五个参数 变成一个参数, 升序 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了, 随笔记下 ,下次 参考。
mybatis 多参数处理的更多相关文章
- mybatis 传递参数的方法总结
有三种mybatis传递参数的方式: 第一种 mybatis传入参数是有序号的,可以直接用序号取得参数 User selectUser(String name,String area); 可以在xml ...
- 【转载】Mybatis多参数查询映射
转载地址:http://www.07net01.com/zhishi/402787.html 最近在做一个Mybatis的项目,由于是接触不久,虽然看了一下资料,但在实际开发中还是暴 露了很多问题,其 ...
- MyBatis传递参数
MyBatis传递参数 一.使用 map 接口传递参数 在 MyBatis 中允许 map 接口通过键值对传递多个参数,把接口方法定义为 : public List<Role> findR ...
- MyBatis传入参数为list、数组、map写法(转载)
MyBatis传入参数为list.数组.map写法 1.foreach简单介绍: foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有item ...
- Mybatis基于代理Dao实现CRUD操作 及 Mybatis的参数深入
Mybatis基于代理Dao实现CRUD操作 使用要求: 1.持久层接口和持久层接口的映射配置必须在相同的包下 2.持久层映射配置中mapper标签的namespace属性取值必须是持久层接口的全限定 ...
- MyBatis的参数,不能传入null
今天在调试的过程中发现一个bug,把传入的参数写到查询分析器中执行没有问题,但是在程序中执行就报错:org.springframework.jdbc.UncategorizedSQLException ...
- MyBatis传入参数为list、数组、map写法
1.foreach简单介绍: foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有item,index,collection,open,sep ...
- mybatis中参数为list集合时使用 mybatis in查询
mybatis中参数为list集合时使用 mybatis in查询 一.问题描述mybatis sql查询时,若遇到多个条件匹配一个字段,sql 如: select * from user where ...
- 【mybatis源码学习】mybatis的参数处理
一.mybatis的参数处理以及参数取值 1.单个参数 mybatis不做任何处理 取值方式: #{参数名/任意名} <!-- Employee getEmpById(Integer id) ...
- Mybatis传入参数类型为Map
mybatis更新sql语句: <update id="publishT00_notice" parameterType="Map"> update ...
随机推荐
- mysql基础操作整理(一)
显示当前数据库 mysql> select database(); +------------+ | database() | +------------+ | test | +-------- ...
- MVC 文本转换成html显示
最近在学习ASP.NET MVC,项目中需要将后台传输的HTML文本在前台页面显示:@Html.Raw(HttpUtility.HtmlDecode(ViewBag.DisplayText)).记下来 ...
- InvalidArgument=Value of '1' is not valid for 'index'
用ListView实现点击ListView的项删除该项的效果,调用ItemSelectionChanged事件. 代码如下: private void listView1_ItemSelectionC ...
- 反射给对象赋值遇到的问题——类型转换[转http://blog.csdn.net/xiaohan2826/article/details/8536074]
发布时间:2012-10-25 10:49浏览次数:225 给一个对象属性赋值可以通过PropertyInfo.SetValue()方式进行赋值,但要注意值的类型要与属性保持一致. 创建对象实例的 ...
- js 中的流程控制-条件语句
条件语句: if(exp)执行一句代码 <script> var x = 1 ; if(x == 1 ) //当if判断语句结果是true 或者 false 当判断结果等于true的时候, ...
- 最大乘积(Maximum Product,UVA 11059)
Problem D - Maximum Product Time Limit: 1 second Given a sequence of integers S = {S1, S2, ..., Sn}, ...
- 去除后台ckeditor的style="...."的样式
.cnt_text .text img {/*width :auto !important;*/height :auto !important; max-width:660px;} 高度自适应,高度让 ...
- 项目任务管理(TaskMgr)技术篇
判定是否为枚举型:type.IsEnum 应用原型:如果是枚举返回字符型,如果是其他类型直接返回: object value = pro1.FieldType.IsEnum ? pro1.GetVal ...
- ural1057Amount of Degrees
Description Create a code to determine the amount of integers, lying in the set [ X; Y] and being a ...
- iscc2016-好长的字符串
Vm0wd2QyVkhVWGhVYmxKV1YwZDRXRmxVUm5kVlJscHpXa2M1VjFKdGVGWlZNbmhQWVd4YWMxZHViRmROYWxaeVdWZDRZV014WkhG ...