在 Grails 中创建管理部分的最佳方法
嘿,
我想知道在 Grails 应用程序中创建管理(后端)部分的最佳方法是什么?
我想在 Grails 的“controllers”文件夹中创建一个“Admin”文件夹来放置我所有的管理控制器。 但是我是否必须为每个管理控制器手动创建 URL 映射?
我已经使用 generate-all
命令生成了所有前端 GSP,该命令采用域类,但知道如何为我的管理部分生成 CRUD(具有相同的域)班级)。 我完蛋了吗?
非常感谢您的提示!
Hy,
I'm wondering what's the best way to create an Admin (backend) section in a Grails app ?
I want to create an "Admin" folder in the "controllers" folder of Grails to put all my admin controllers. But then will I have to create manually the URL mapping for each Admin controller?
I have already generated all my frontend GSP with the genernate-all
command which takes a Domain Class but know how can I generate my CRUD for my admin section (with the same domain class). Am I screwed ?
Thanks a lot for your tips!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我对此的偏好是有一个单独的管理员应用程序。 将所有域类放入一个插件中,并将该插件安装到管理应用程序和消费者应用程序中。
这样,您就可以根据自己的喜好调整控制器,而不必担心最终用户会碰到它们。 共享服务也可以在域插件中。
您可以将一个名为 BuildConfig.groovy 的特殊文件放入 grails-app/conf 中,您可以在其中指定“本地”插件,例如自动引入类路径的域插件,而无需打包/安装插件。 让它变得超级简单。
My preference for this is to have a separate application for admin. Stick all of your domain classes in a plugin and install that plugin into both the admin application and the consumer appilcation.
That way, you can tweak the controllers to your hearts content and not worry about end users hitting them. Shared services can also be in the domain plugin.
There's a special file that you can put in your grails-app/conf called BuildConfig.groovy where you can specify "local" plugins like the domain plugin that are automatically brought into the classpath without having to package/install the plugin. Makes it super easy.
您可以像任何其他控制器一样创建管理控制器,并使用过滤器来确保仅使用以下方式登录的用户管理员权限可以访问它们。
You could create your admin controllers like any other controller and use a filter to make sure only logged in users with admin privilages can access them.
很晚了,但这里有一种可能有用的方法,至少对于较小的应用程序(我使用的是 Grails 2.0):
在 conf/UrlMappings.groovy 中:
注意 如您所见,我没有以任何方式保证这一点。
Very late to this, but here is one way that might be useful, at least for a smaller application (I'm using Grails 2.0):
In conf/UrlMappings.groovy:
Note As you can see, this i not secured in any way.