赞
踩
一前一直没使用过groovy语言,但是在新的公司需要用到这个语言;不过还好,groovy是基于java之上的语言;学起来不是很吃力;
会一直更新新这篇文章。。。。。
刚开始的时候看到一个符号“<<”
List<Byte> types = Lists.newArrayList()
if (type == 3) {
types << (1 as byte)
types << (2 as byte)
} else {
types << (byte) type
}
一开始很不理解,这不是按位运算符吗;啥意思啊我天;然后自己试了试:
class SymbolDemo { static void main(String[] args) { def i = methdod01(2) println(i) } static def methdod01(Integer a){ Integer type = 3 List<Integer> list = Lists.newArrayList(); list << 1 list << 2 list << 3 if (a == 2){ list << a }else { list << 5 } } }
看到这些代码应该就很明确了。这相当于list.add
需求是这样的一张图片;就是说需要从数据库中查书数据来,然后根据bug status(状态分组);
List<BugStatusFindVo> bugStatusFindVos = Lists.newArrayList()
List<Bug> bugs = bugService.findBugList(status, systemId, timeType, startTime, endTime)
bugs.each {
Bug bug ->
bugStatusFindVos.each {
BugStatusFindVo statusFindVo ->
if (bug.status == statusFindVo.status){
statusFindVo.bugs << bug
}
}
}
bugStatusFindVos.each {
it.bugNum = it.bugs.size()
}
BugStatusFindVo :实体类是这样的:
class BugStatusFindVo implements Serializable{
private static final long serialVersionUID = 8401342664443969084L
Long bugNum
Byte status
String statusName
List<Bug> bugs = Lists.newArrayList()
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。