10、groovy grails List 集合 排序方法1
程序员文章站
2022-03-24 13:36:36
...
class Contract implements Comparable<Contract>{ int id //合同id UserInformation userInfo //用户扩展表 double bond = 0.0 //保证金 UserLevel userLevel //用户级别 Date signDate //签订日期 Date beginDate //合同开始时间 Date endDate //合同结束时间 String openAccount //开户行 String accountName //开户名 String accountNumber //开户账号 String attachment //合同附件 int status = 1 //状态 1.执行中 2.已过期 3.未开始 Date createDate //入库时间 static constraints = { userInfo blank:true,nullable: true; bond blank:true,nullable: true; userLevel blank:true,nullable: true; signDate blank:true,nullable: true; openAccount blank:true,nullable: true; accountNumber blank:true,nullable: true; status blank:true,nullable: true; beginDate blank:true,nullable: true; endDate blank:true,nullable: true; attachment blank: true,nullable: true; createDate blank:true,nullable: true; accountName blank:true,nullable: true; } static mapping = { version false } //签订日期排序 @Override int compareTo(Contract contract) { if (contract?.signDate==null){ contract?.signDate = new Date(0) } if (!this.signDate) { this.signDate = new Date(0); } return contract?.signDate?.compareTo(signDate); } } class ContractController { def index() { def contractGroup = Contract.list(); Collections.sort(contractGroup); render(view: "index",mapping:"adminurl",model:[contractGroup:contractGroup]); } }
上一篇: PHP 闭包函数
下一篇: Grails3 Eclipse开发环境