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 ...
随机推荐
- [转]Delphi中,让程序只运行一次的方法
program onlyRunOne; uses Forms,Windows,SysUtils, Dialogs, Unit1 in 'Unit1.pas' {Form1}; {$R *.res} v ...
- Jquery 点击空白处消失
$(document).bind("click", function (e){ if ( $((e.target || e.srcElement)).closest("# ...
- 获取当前页面的url
var url = window.location.href; var b = url.substring(url.lastIndexOf('/')+1, url.length);
- python中的几种集成分类器
from sklearn import ensemble 集成分类器(ensemble): 1.bagging(ensemble.bagging.BaggingClassifier) 对随机选取的子样 ...
- 图的遍历(bfs 和dfs)
BFS的思想: 从一个图的某一个顶点V0出发,首先访问和V0相邻的且未被访问过的顶点V1.V2.……Vn,然后依次访问与V1.V2……Vn相邻且未被访问的顶点.如此继续,找到所要找的顶点或者遍历完整个 ...
- xml 个人练习2
package cn.gdpe.xml; import java.io.File;import java.io.FileInputStream;import java.io.IOException;i ...
- CodeIgniter框架——介绍
CodeIgniter 是一个应用程序框架 CodeIgniter 是一个为用 PHP 编写网络应用程序的人员提供的工具包.它的目标是实现让你比从零开始编写代码更快速地开发项目,为此,CI 提供了一套 ...
- php开发入门教程
LAMP window:WAMP(windows,apache,mysql,php) LAMP是 Linux,Apache,MySQL和PHP的缩写,是我们提供 Web 服务的软件基础. 对于 Lin ...
- 用C++进行函数式编程
http://www.programmer.com.cn/12717/ 文 / John Carmack 译 / 王江平 <Quake>作者Carmack认为追求函数式的程序设计有着实 ...
- BZOJ 3106 棋盘游戏
Description 一个\(n \times n(n \le 2)\)棋盘上有黑白棋子各一枚.游戏者A和B轮流移动棋子,A先走. A的移动规则:只能移动白棋子.可以往上下左右四个方向之一移动一格. ...