Grails 动态属性和模式

发布于 2024-12-04 12:27:13 字数 1192 浏览 0 评论 0原文

我正在尝试开发一个网络应用程序,但我无法想到完整的设计。这个想法如下:

我想创建一个能够创建模式的程序,然后可以使用该程序创建模式的实例。举个例子:我们有家具作为图案,所以我们有一个名称和不同的属性。 因此,管理员创建/删除/编辑模式:假设“椅子”的属性为“颜色”和“尺寸”,“桌子”的属性为“长度”、“颜色”和“尺寸”。

之后,用户可以使用您首先创建的属性添加“桌子”或“椅子”。

我创建了域类:用户、模式、属性、家具 但我坚持了这种关系。我很确定 grails 能够处理此类请求,但我不确定我是否走在正确的轨道上。

编辑:更具体:

我现在对整个结构有了更好的了解: 域类(为了更好地理解,我将跳过用户): 模式 - 属性 - FurnitureProperties - Furniture

我现在知道,我需要“FurnitureProperties”来存储创建的家具的实际价值。我对 hasMany/belongsTo - grails 的定义有点困惑。

Pattern 
hasMany[properties:Property]
belongsTo [furniture:Furniture]

Property
hasMany [furnitureProperties: FurnitureProperties]
belongsTo [pattern:Pattern]

FurnitureProperties
(nothing, just Property and Furniture as fields)

Furniture
hasMany [furnitureProperties: FurnitureProperties]
belongsTo [pattern:Pattern]

我希望我可以创建属于该模式的模式和属性,然后我可以创建新家具,选择模式,查找属性并创建正确的 FurnitureProperties 以用特定值填充它们。会是这样的:

Pattern: Chair and Table
Property: Chair.size, Chair.color / Table.width, Table.color
Furniture:Office-Chair, armchair, kitchen-table
furnitureProperty: all three furnitures with there properties depending on the pattern and the specific value.

I am trying to develop a webapplication, but I can't think of the full design. The idea is the following:

I want to create a program with the possibility to create patterns which then can be used to create instances of the pattern. To make an example: We have funiture as patterns, so we have a name and different properties.
So the admin creates/deletes/edits the patterns: lets say "Chair" with "color" and "size" as properties and "Table" with "length", "color" and "size".

After that, the user could add "Tables" or "Chairs" with the properties you created first.

I have created Domain-Classes: User, Pattern, Property, Funiture
but I stuck with the relationship. I'm pretty sure grails is able to handle such requests but I'm not sure, if I'm on the right track.

Edit: More Specific:

I Have now a better idea of the whole construct:
domain-Classes (I'll skip the users for better understanding):
Pattern - Property - FurnitureProperties - Furniture

I know now, I need the "FurnitureProperties" to store the actual value of a created furniture. I'm a bit confused with the hasMany/belongsTo - Definitions of grails.

Pattern 
hasMany[properties:Property]
belongsTo [furniture:Furniture]

Property
hasMany [furnitureProperties: FurnitureProperties]
belongsTo [pattern:Pattern]

FurnitureProperties
(nothing, just Property and Furniture as fields)

Furniture
hasMany [furnitureProperties: FurnitureProperties]
belongsTo [pattern:Pattern]

I hope I can create patterns and properties which belong to that pattern and after that I can create new furniture, select a pattern, look up the Properties and create correct FurnitureProperties to fill them with specific Values. Would be like this:

Pattern: Chair and Table
Property: Chair.size, Chair.color / Table.width, Table.color
Furniture:Office-Chair, armchair, kitchen-table
furnitureProperty: all three furnitures with there properties depending on the pattern and the specific value.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文