开发者

Need ideas in designing Domain classes Grails

I am learning Grails, I am trying to build a small application. And for now I am working on the registration part.

There are 3 different views for registration process 1) As an employee my registration view is different with different fields 2) As an employer registration view would be different where I would be co开发者_如何学运维llecting company details, an authorized representative who can act on behalf of the company. So as a matter of fact I was thinking that company(employer) is not the actor but representative is an actor and hence need a representative domain class. 3) retailer registration view is different.

So I need to define the domain classes and its relationships I am very much new to grails and I need some guidance in designing

I was initially thinking of User domain class and have UserTypes(which defines different types of users ex. representative,retailer and employee) but not sure if that works.

Appreciate if someone could help me in building my domain classes.

Thanks


You definitely want to map out your domain classes before you start working on the views. Is the authorized rep always going to be an employee, or is it a completely different entity?

Think of it in terms of objects, and try to mimic it as much as possible. A company has employees, and can have an authorized representative. Here's a sample mock up:

class Employee {
    String firstName, lastName /* etc... */
}

class Company {
    String name /* etc */

    Representative authorizedRepresentative

    static hasMany = [ employees : Employee ]
}

class Representative {

}

Of course, you may want to have references from the Employees back to its Company. Have a look at the Object Relational Mapping portion of the Grails docs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜