CkindController.groovy
上传用户:steveyhw
上传日期:2019-05-13
资源大小:307k
文件大小:3k
-
- class CkindController {
-
- 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
- [ ckindList: Ckind.list( params ) ]
- }
- def show = {
- def ckind = Ckind.get( params.id )
- if(!ckind) {
- flash.message = "ckind.not.found"
- flash.args = [params.id]
- flash.defaultMessage = "Ckind not found with id ${params.id}"
- redirect(action:list)
- }
- else { return [ ckind : ckind ] }
- }
- def delete = {
- def ckind = Ckind.get( params.id )
- if(ckind) {
- ckind.delete()
- flash.message = "ckind.deleted"
- flash.args = [params.id]
- flash.defaultMessage = "Ckind ${params.id} deleted"
- redirect(action:list)
- }
- else {
- flash.message = "ckind.not.found"
- flash.args = [params.id]
- flash.defaultMessage = "Ckind not found with id ${params.id}"
- redirect(action:list)
- }
- }
- def edit = {
- def ckind = Ckind.get( params.id )
- if(!ckind) {
- flash.message = "ckind.not.found"
- flash.args = [params.id]
- flash.defaultMessage = "Ckind not found with id ${params.id}"
- redirect(action:list)
- }
- else {
- return [ ckind : ckind ]
- }
- }
- def update = {
- def ckind = Ckind.get( params.id )
- if(ckind) {
- ckind.properties = params
- if(!ckind.hasErrors() && ckind.save()) {
- flash.message = "ckind.updated"
- flash.args = [params.id]
- flash.defaultMessage = "Ckind ${params.id} updated"
- redirect(action:show,id:ckind.id)
- }
- else {
- render(view:'edit',model:[ckind:ckind])
- }
- }
- else {
- flash.message = "ckind.not.found"
- flash.args = [params.id]
- flash.defaultMessage = "Ckind not found with id ${params.id}"
- redirect(action:edit,id:params.id)
- }
- }
- def create = {
- def ckind = new Ckind()
- ckind.properties = params
- return ['ckind':ckind]
- }
- def save = {
- def ckind = new Ckind(params)
- if(!ckind.hasErrors() && ckind.save()) {
- flash.message = "ckind.created"
- flash.args = ["${ckind.id}"]
- flash.defaultMessage = "Ckind ${ckind.id} created"
- redirect(action:show,id:ckind.id)
- }
- else {
- render(view:'create',model:[ckind:ckind])
- }
- }
- }