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中ShellExecute的妙用
Delphi中ShellExecute的妙用 ShellExecute的功能是运行一个外部程序(或者是打开一个已注册的文件.打开一个目录.打印一个文件等等),并对外部程序有一定的控制. ...
- Cocos2dx开发(2)——Win8.1下Cocod2dx 3.2环境搭建
正式开始搭建cocos2dx环境,回到熟悉的VS 1.Python安装配置 这一步很简单,下载Python2.7.3,笔者直接用软件助手直接下载安装,最后配置环境变量 如下成功 2.cocos2dx ...
- iOS 视频播放横屏,隐藏状态栏
MPMoviePlayerViewController *moviePlayerViewController = [[MPMoviePlayerViewController alloc] init]; ...
- js中的潜伏者之Arguments对象
argument 说明: 在JavaScript中,arguments是对象的一个特殊属性.arguments对象就像数组,但是它却不是数组.可以理解为他是潜伏者,通俗的说,就是你传的参数不一定按照参 ...
- ICE学习第三步-----Slice语言
ICE:Slice语言(一)-编译 Introduce简介 Slice(Specification language for ice)是分离对象和对象的实现的基础的抽象机制.Slice在客户端和服务器 ...
- 数据库,inner join,left join right join 的区别
假设有两个表: 学生和课程 student: class: id student id class studentId 1 ...
- Bootstrap_网格系统
首先添加CSS样式: [class *= col-]{ background-color: #eee; border: 1px solid #ccc; } [class *= col-] [class ...
- img超出div width时, jQuery动态改变图片显示大小
参考: 1. http://blog.csdn.net/roman_yu/article/details/6641911 2. http://www.cnblogs.com/zyzlywq/archi ...
- jQuery API中文文档
jQuery API中文文档 http://www.css88.com/jqapi-1.9/category/events/event-handler-attachment/ jQuery UI AP ...
- linux下搭建svn服务器
安装步骤如下: 1.yum install subversion 2.输入rpm -ql subversion查看安装位置,如下图: 我们知道svn在bin目录下生成了几个二进制文件. 输入 ...