RtuController.groovy
上传用户:steveyhw
上传日期:2019-05-13
资源大小:307k
文件大小:3k
-
- class RtuController {
-
- def index = { redirect(action:list,params:params) }
- // the delete, save and update actions only accept POST requests
- def allowedMethods = [delete:'POST', save:'POST', update:'POST']
- def list = {
- if(!params.max) params.max = 10
- [ rtuInstanceList: Rtu.list( params ) ]
- }
- def show = {
- def rtuInstance = Rtu.get( params.id )
- if(!rtuInstance) {
- flash.message = "rtuInstance.not.found"
- flash.args = [params.id]
- flash.defaultMessage = "Rtu not found with id ${params.id}"
- redirect(action:list)
- }
- else {
- println 'dd'
- return [ rtuInstance : rtuInstance ] }
- }
- def delete = {
- def rtuInstance = Rtu.get( params.id )
- if(rtuInstance) {
- rtuInstance.delete()
- flash.message = "rtuInstance.deleted"
- flash.args = [params.id]
- flash.defaultMessage = "Rtu ${params.id} deleted"
- redirect(action:list)
- }
- else {
- flash.message = "rtuInstance.not.found"
- flash.args = [params.id]
- flash.defaultMessage = "Rtu not found with id ${params.id}"
- redirect(action:list)
- }
- }
- def edit = {
- def rtuInstance = Rtu.get( params.id )
- if(!rtuInstance) {
- flash.message = "rtuInstance.not.found"
- flash.args = [params.id]
- flash.defaultMessage = "Rtu not found with id ${params.id}"
- redirect(action:list)
- }
- else {
- return [ rtu : rtuInstance ]
- }
- }
- def update = {
- def rtuInstance = Rtu.get( params.id )
- if(rtuInstance) {
- rtuInstance.properties = params
- if(!rtuInstance.hasErrors() && rtuInstance.save()) {
- flash.message = "rtuInstance.updated"
- flash.args = [params.id]
- flash.defaultMessage = "Rtu ${params.id} updated"
- redirect(action:show,id:rtuInstance.id)
- }
- else {
- render(view:'edit',model:[rtuInstance:rtuInstance])
- }
- }
- else {
- flash.message = "rtuInstance.not.found"
- flash.args = [params.id]
- flash.defaultMessage = "Rtu not found with id ${params.id}"
- redirect(action:edit,id:params.id)
- }
- }
- def create = {
- def rtuInstance = new Rtu()
- rtuInstance.properties = params
- return ['rtuInstance':rtuInstance]
- }
- def save = {
- def rtuInstance = new Rtu(params)
- if(!rtuInstance.hasErrors() && rtuInstance.save()) {
- flash.message = "rtuInstance.created"
- flash.args = ["${rtuInstance.id}"]
- flash.defaultMessage = "Rtu ${rtuInstance.id} created"
- redirect(action:show,id:rtuInstance.id)
- }
- else {
- render(view:'create',model:[rtuInstance:rtuInstance])
- }
- }
- }