Created
August 27, 2018 18:09
-
-
Save urbansky/049133d18ff48ef266ad1789656c7440 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------------------ | |
// Controller classes | |
// ------------------------ | |
package de.beispiel.api | |
import de.beispiel.SuperController | |
import de.beispiel.exception.DomainObjectNotFoundException | |
class CrmProjectController extends SuperController { | |
CrmProjectService crmProjectService | |
def index(String product) { | |
[projects: CrmProject.findAllByProduct(product)] | |
} | |
def show(String product, long projectId) { | |
CrmProject project = CrmProject.get(projectId) | |
if (project?.product != product) throw new DomainObjectNotFoundException("CrmProject not found") | |
[project: project] | |
} | |
def create(String product) { | |
[:] | |
} | |
def save(String product) { | |
CrmProject project = crmProjectService.create(product, params) | |
redirect action: "show", params: [product: product, projectId: project.id] | |
} | |
def edit(String product, long projectId) { | |
CrmProject project = CrmProject.get(projectId) | |
if (project?.product != product) throw new DomainObjectNotFoundException("CrmProject not found") | |
[project: project] | |
} | |
def update(String product, long projectId) { | |
CrmProject project = CrmProject.get(projectId) | |
if (project?.product != product) throw new DomainObjectNotFoundException("CrmProject not found") | |
crmProjectService.update(project, params) | |
redirect action: "show", params: [product: product, projectId: project.id] | |
} | |
def delete(String product, long projectId) { | |
CrmProject project = CrmProject.get(projectId) | |
if (project?.product != product) throw new DomainObjectNotFoundException("CrmProject not found") | |
crmProjectService.delete(project) | |
redirect action: "index", params: [product: product] | |
} | |
} | |
// ------------------------ | |
// URL mapping | |
// ------------------------ | |
"/crm/project/$product" (controller: "crmProject") | |
"/crm/project/$product/create" (controller: "crmProject", action: "create") | |
"/crm/project/$product/save" (controller: "crmProject", action: "save") | |
"/crm/project/$product/edit" (controller: "crmProject", action: "edit") | |
"/crm/project/$product/update" (controller: "crmProject", action: "update") | |
"/crm/project/$product/$projectId/show" (controller: "crmProject", action: "show") | |
"/crm/project/$product/$projectId/delete" (controller: "crmProject", action: "delete") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment