-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@ScaffoldContoller and @ScaffoldService support #114
Conversation
As this is a new feature, I think it should probably go into 5.1.x or 6.0.x, not 5.0.x. @codeconsole Do you want this functionality to be available in Grails 6? |
I see there are no tests in this repo. There are some tests in https://github.com/grails/grails-functional-tests that tests scaffolding with the usage of
We could add tests there for using the |
yes, I would like it in 6.2. I agree 5.1.x |
@codeconsole I have created a |
I don't think a new branch is warranted. No breaking features have been introduced. We shouldn't be maintaining point release branches. I don't know why we got rid of master. If there is to be a branch, it should be 5.x |
Introduced support for more concise annotations: @ScaffoldController(value = SecuredGenericController, domain = User)
class UserController {} can now be written as this @ScaffoldController(SecuredGenericController<User>)
class UserController {} |
Introduce It is very powerful if you have common business logic shared across multiple or all services and use a service layer. It works similar to how scaffold controllers work. You have a super class that you define (such are For example, let's create a GenericService that automatically updates Redis and ElasticSearch: class GenericService<T> {
T get(Long id) {
// generic get logic
}
List<T> list(Map args) {
// generic list logic
}
Long count(Map args) {
// generic count logic. (My implementation takes a map so counts can be done based on parameters)
}
void delete(Long id) {
// generic delete logic
}
T save(T domain) {
// generic save logic
}
} Now all I have to do is have define a Service with the annotation and all those methods become implemented. Unlike @ScaffoldService(GenericService<User>)
class UserService {
User save(User user) {
user.modified = new Date()
super.save(user)
}
} |
Adds support for the annotation
@ScaffoldController
which provides an alternative to thestatic scaffold = Domain
approach.It also empowers the developer to use their own base controller instead of being forced to use
RestController
which could be very limiting.RestController
does not encapsulate all necessary business logic and is completely divergent from the Service MVC model that is generated by this plugin. With this annotation, developers can now use an extended RestController to fit their needs, or create an entirely different generic controller that is not related at all to RestController and more closely matches the type of controller that is generated by this plugin.