grails executeQuery in
来源:互联网 发布:js 判断对象是否包含 编辑:程序博客网 时间:2024/05/17 05:52
grails的executeQuery跟hql的语法差不多,executeQuery与in一起使用:代码如下【说明 下面的是list的类型是: List<Long>】
String str="select prodId,sum(num),prodPrice from MikuMineBoxProduct where boxId in (:list) group by prodId" def data=MikuMineBoxProduct.executeQuery(str,[list:list])
def getProdOnePeriodData(List<Long> boxIdList,List<Long> prodIdList,String flag){ def data String str="select prodId," if("day".equals(flag)){ str+=" DATE_FORMAT(dateCreated,'%Y-%m-%d')" }else if("month".equals(flag)){ str+=" DATE_FORMAT(dateCreated,'%Y-%m')" } str+=" ,sum(num) from MikuMineBoxProduct where boxId in (:boxIdList) and prodId in (:prodIdList) group by " if("day".equals(flag)){ str+=" DATE_FORMAT(dateCreated,'%Y-%m-%d')" }else if("month".equals(flag)){ str+=" DATE_FORMAT(dateCreated,'%Y-%m')" } data=MikuMineBoxProduct.executeQuery(str,[boxIdList:boxIdList,prodIdList:prodIdList]) return data }
def getAllPeriodTime(String userId,String realId,String begin,String end,int sumflg){ String str="select " if(!sumflg){ str+= "DATE_FORMAT(dateCreated,'%Y-%m-%d')," } str+="IFNULL(sum(price),0)/100," + "IFNULL(sum(case when "+dfSql+" then prepaidFee end),0)/100," + "IFNULL(sum(case when "+dfSql+" then price end),0)/100," + "IFNULL(sum(case when "+onlineSql+" then price end),0)/100," + "IFNULL(sum(case when "+failSql+" then price end),0)/100," + "IFNULL(sum(case when "+wxSql+" then price end),0)/100," + "IFNULL(sum(case when "+alipaySql+" then price end),0)/100," + "count(id)," + "count(case when "+failSql+" then id end)" + " from Trade where "+baseSql+" and dateCreated>='"+begin+"' and dateCreated<'"+end+"' " if (userId){ str+="and wxNo="+userId } else if(realId){ str+="and pUserId="+Long.parseLong(realId) } if(!sumflg){ str+=" group by DATE_FORMAT(dateCreated,'%Y-%m-%d')" } def list=Trade.executeQuery(str) println(list) return list }
0 0
- grails executeQuery in
- executeQuery()
- Grails in Action:完成啦
- 《Spring Boot in Action》【6. Grails】
- grails
- grails
- grails
- Grails
- | Error Error occurred running Grails CLI: Profile [org.grails.profiles:base:3.1 .3] declares and in
- 20130515-Grails In Action-3、建模(01小节)
- 20130515-Grails In Action-3、建模(02小节)
- 20130515-Grails In Action-3、建模(03小节)
- 20130515-Grails In Action-3、建模(04小节)
- 20130515-Grails In Action-3、建模(05小节)
- 20130516-Grails In Action-3、建模(06小节)
- 20130516-Grails In Action-4、让模型工作(01小节)
- 20130516-Grails In Action-4、让模型工作(02小节)
- 20130516-Grails In Action-4、让模型工作(03小节)
- Python函数—基础
- Eclipse常见错误overlaps the location of another project: 'xxx
- #if 预编译对未知宏定义的处理
- org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped [from XX]
- Http协议post请求
- grails executeQuery in
- 内部类详解
- ScrollView嵌套TextView,让TextView可以滚动
- BZOJ 3240 构造矩阵+矩阵快速幂
- Latex使用小结
- Java RSA格式 转换与运算(转)
- linux安装部署git
- 【JAVA】设计模式之命令模式(Command模式)的使用分析
- bootstrap-table分页模板和获取表中的ID