-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1: create controller for all domain
- Loading branch information
1 parent
00edd71
commit acaa1f6
Showing
22 changed files
with
1,488 additions
and
0 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
grails-app/controllers/com/lftechnology/findMe/RoomController.groovy
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package com.lftechnology.findMe | ||
|
||
|
||
import static org.springframework.http.HttpStatus.* | ||
import grails.transaction.Transactional | ||
|
||
@Transactional(readOnly = true) | ||
class RoomController { | ||
|
||
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"] | ||
|
||
def index(Integer max) { | ||
params.max = Math.min(max ?: 10, 100) | ||
respond Room.list(params), model: [roomInstanceCount: Room.count()] | ||
} | ||
|
||
def show(Room roomInstance) { | ||
respond roomInstance | ||
} | ||
|
||
def create() { | ||
respond new Room(params) | ||
} | ||
|
||
@Transactional | ||
def save(Room roomInstance) { | ||
if (roomInstance == null) { | ||
notFound() | ||
return | ||
} | ||
|
||
if (roomInstance.hasErrors()) { | ||
respond roomInstance.errors, view: 'create' | ||
return | ||
} | ||
|
||
roomInstance.save flush: true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.created.message', args: [message(code: 'room.label', default: 'Room'), roomInstance.id]) | ||
redirect roomInstance | ||
} | ||
'*' { respond roomInstance, [status: CREATED] } | ||
} | ||
} | ||
|
||
def edit(Room roomInstance) { | ||
respond roomInstance | ||
} | ||
|
||
@Transactional | ||
def update(Room roomInstance) { | ||
if (roomInstance == null) { | ||
notFound() | ||
return | ||
} | ||
|
||
if (roomInstance.hasErrors()) { | ||
respond roomInstance.errors, view: 'edit' | ||
return | ||
} | ||
|
||
roomInstance.save flush: true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.updated.message', args: [message(code: 'Room.label', default: 'Room'), roomInstance.id]) | ||
redirect roomInstance | ||
} | ||
'*' { respond roomInstance, [status: OK] } | ||
} | ||
} | ||
|
||
@Transactional | ||
def delete(Room roomInstance) { | ||
|
||
if (roomInstance == null) { | ||
notFound() | ||
return | ||
} | ||
|
||
roomInstance.delete flush: true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.deleted.message', args: [message(code: 'Room.label', default: 'Room'), roomInstance.id]) | ||
redirect action: "index", method: "GET" | ||
} | ||
'*' { render status: NO_CONTENT } | ||
} | ||
} | ||
|
||
protected void notFound() { | ||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.not.found.message', args: [message(code: 'room.label', default: 'Room'), params.id]) | ||
redirect action: "index", method: "GET" | ||
} | ||
'*' { render status: NOT_FOUND } | ||
} | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
grails-app/controllers/com/lftechnology/findMe/ScheduleController.groovy
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package com.lftechnology.findMe | ||
|
||
|
||
import static org.springframework.http.HttpStatus.* | ||
import grails.transaction.Transactional | ||
|
||
@Transactional(readOnly = true) | ||
class ScheduleController { | ||
|
||
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"] | ||
|
||
def index(Integer max) { | ||
params.max = Math.min(max ?: 10, 100) | ||
respond Schedule.list(params), model: [scheduleInstanceCount: Schedule.count()] | ||
} | ||
|
||
def show(Schedule scheduleInstance) { | ||
respond scheduleInstance | ||
} | ||
|
||
def create() { | ||
respond new Schedule(params) | ||
} | ||
|
||
@Transactional | ||
def save(Schedule scheduleInstance) { | ||
if (scheduleInstance == null) { | ||
notFound() | ||
return | ||
} | ||
|
||
if (scheduleInstance.hasErrors()) { | ||
respond scheduleInstance.errors, view: 'create' | ||
return | ||
} | ||
|
||
scheduleInstance.save flush: true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.created.message', args: [message(code: 'schedule.label', default: 'Schedule'), scheduleInstance.id]) | ||
redirect scheduleInstance | ||
} | ||
'*' { respond scheduleInstance, [status: CREATED] } | ||
} | ||
} | ||
|
||
def edit(Schedule scheduleInstance) { | ||
respond scheduleInstance | ||
} | ||
|
||
@Transactional | ||
def update(Schedule scheduleInstance) { | ||
if (scheduleInstance == null) { | ||
notFound() | ||
return | ||
} | ||
|
||
if (scheduleInstance.hasErrors()) { | ||
respond scheduleInstance.errors, view: 'edit' | ||
return | ||
} | ||
|
||
scheduleInstance.save flush: true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.updated.message', args: [message(code: 'Schedule.label', default: 'Schedule'), scheduleInstance.id]) | ||
redirect scheduleInstance | ||
} | ||
'*' { respond scheduleInstance, [status: OK] } | ||
} | ||
} | ||
|
||
@Transactional | ||
def delete(Schedule scheduleInstance) { | ||
|
||
if (scheduleInstance == null) { | ||
notFound() | ||
return | ||
} | ||
|
||
scheduleInstance.delete flush: true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.deleted.message', args: [message(code: 'Schedule.label', default: 'Schedule'), scheduleInstance.id]) | ||
redirect action: "index", method: "GET" | ||
} | ||
'*' { render status: NO_CONTENT } | ||
} | ||
} | ||
|
||
protected void notFound() { | ||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.not.found.message', args: [message(code: 'schedule.label', default: 'Schedule'), params.id]) | ||
redirect action: "index", method: "GET" | ||
} | ||
'*' { render status: NOT_FOUND } | ||
} | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
grails-app/controllers/com/lftechnology/findMe/UserController.groovy
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package com.lftechnology.findMe | ||
|
||
|
||
import static org.springframework.http.HttpStatus.* | ||
import grails.transaction.Transactional | ||
|
||
@Transactional(readOnly = true) | ||
class UserController { | ||
|
||
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"] | ||
|
||
def index(Integer max) { | ||
params.max = Math.min(max ?: 10, 100) | ||
respond User.list(params), model: [userInstanceCount: User.count()] | ||
} | ||
|
||
def show(User userInstance) { | ||
respond userInstance | ||
} | ||
|
||
def create() { | ||
respond new User(params) | ||
} | ||
|
||
@Transactional | ||
def save(User userInstance) { | ||
if (userInstance == null) { | ||
notFound() | ||
return | ||
} | ||
|
||
if (userInstance.hasErrors()) { | ||
respond userInstance.errors, view: 'create' | ||
return | ||
} | ||
|
||
userInstance.save flush: true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.created.message', args: [message(code: 'user.label', default: 'User'), userInstance.id]) | ||
redirect userInstance | ||
} | ||
'*' { respond userInstance, [status: CREATED] } | ||
} | ||
} | ||
|
||
def edit(User userInstance) { | ||
respond userInstance | ||
} | ||
|
||
@Transactional | ||
def update(User userInstance) { | ||
if (userInstance == null) { | ||
notFound() | ||
return | ||
} | ||
|
||
if (userInstance.hasErrors()) { | ||
respond userInstance.errors, view: 'edit' | ||
return | ||
} | ||
|
||
userInstance.save flush: true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.updated.message', args: [message(code: 'User.label', default: 'User'), userInstance.id]) | ||
redirect userInstance | ||
} | ||
'*' { respond userInstance, [status: OK] } | ||
} | ||
} | ||
|
||
@Transactional | ||
def delete(User userInstance) { | ||
|
||
if (userInstance == null) { | ||
notFound() | ||
return | ||
} | ||
|
||
userInstance.delete flush: true | ||
|
||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.deleted.message', args: [message(code: 'User.label', default: 'User'), userInstance.id]) | ||
redirect action: "index", method: "GET" | ||
} | ||
'*' { render status: NO_CONTENT } | ||
} | ||
} | ||
|
||
protected void notFound() { | ||
request.withFormat { | ||
form multipartForm { | ||
flash.message = message(code: 'default.not.found.message', args: [message(code: 'user.label', default: 'User'), params.id]) | ||
redirect action: "index", method: "GET" | ||
} | ||
'*' { render status: NOT_FOUND } | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<%@ page import="com.lftechnology.findMe.Room" %> | ||
|
||
|
||
|
||
<div class="fieldcontain ${hasErrors(bean: roomInstance, field: 'name', 'error')} required"> | ||
<label for="name"> | ||
<g:message code="room.name.label" default="Name"/> | ||
<span class="required-indicator">*</span> | ||
</label> | ||
<g:textField name="name" required="" value="${roomInstance?.name}"/> | ||
|
||
</div> | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="layout" content="main"> | ||
<g:set var="entityName" value="${message(code: 'room.label', default: 'Room')}"/> | ||
<title><g:message code="default.create.label" args="[entityName]"/></title> | ||
</head> | ||
|
||
<body> | ||
<a href="#create-room" class="skip" tabindex="-1"><g:message code="default.link.skip.label" | ||
default="Skip to content…"/></a> | ||
|
||
<div class="nav" role="navigation"> | ||
<ul> | ||
<li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li> | ||
<li><g:link class="list" action="index"><g:message code="default.list.label" args="[entityName]"/></g:link></li> | ||
</ul> | ||
</div> | ||
|
||
<div id="create-room" class="content scaffold-create" role="main"> | ||
<h1><g:message code="default.create.label" args="[entityName]"/></h1> | ||
<g:if test="${flash.message}"> | ||
<div class="message" role="status">${flash.message}</div> | ||
</g:if> | ||
<g:hasErrors bean="${roomInstance}"> | ||
<ul class="errors" role="alert"> | ||
<g:eachError bean="${roomInstance}" var="error"> | ||
<li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message | ||
error="${error}"/></li> | ||
</g:eachError> | ||
</ul> | ||
</g:hasErrors> | ||
<g:form url="[resource: roomInstance, action: 'save']"> | ||
<fieldset class="form"> | ||
<g:render template="form"/> | ||
</fieldset> | ||
<fieldset class="buttons"> | ||
<g:submitButton name="create" class="save" | ||
value="${message(code: 'default.button.create.label', default: 'Create')}"/> | ||
</fieldset> | ||
</g:form> | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.