orderBy新写法

通常,我们处理排序规则的处理方法是在sql 语句中order by create_time desc,

 

但是这时我们需要从控制器中一步步找到该方法,操作多。

 

我们试着将业务逻辑拆分到控制器 中,

 

把排序规则定义在控制器中该如何写呢

xml:

 1 <if test="orderByClause != null" > 2 order by ${orderByClause} 3 </if> 

 

model:

 1     protected boolean distinct;
 2     
 3     protected String orderByClause;
 4     
 5     public void setOrderByClause(String orderByClause) {
 6         this.orderByClause = orderByClause;
 7     }
 8 
 9     public String getOrderByClause() {
10         return orderByClause;
11     }
12 
13     public void setDistinct(boolean distinct) {
14         this.distinct = distinct;
15     }
16 
17     public boolean isDistinct() {
18         return distinct;
19     }

 

控制器中代码,比如设置医院排序规则:

1 GhHospitalExample example = new GhHospitalExample();
2         example.setOrderByClause(" b.area_num, a.SHOW_NO, nvl(a.BOOK_COUNT,0) desc, a.alias_name");
3         return ghHospitalDao.selectByExample(example);

 

转载于:https://www.cnblogs.com/yizhiamumu/p/8854991.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值