2011-03-12 66 views
0

嗨: 我正在使用任務發佈系統。尋找建模模式

在系統中,也有一些部門,例如:開發/銷售/產品等

屬於不同部門的一些任務。

而最重要的型號:用戶

使用這個系統的人只是不同部門和老闆(最大的老闆)的老闆)。

這些人都在管理頁面工作,普通老闆只能發佈和看到他/她部門的任務。他/她可以添加/刪除/修改任務(其中修改意味着他可以設置狀態的任務:完成/完成/不開始),他/她的所有操作都應該由最大的老闆驗證。

最大的老闆可以看到/添加/刪除/修改所有的任務,從所有的部門,也是他/她可以添加刪除用戶(普通老闆),設置用戶在未經許可的哪個部門的(任務用戶可以看到)。

=================== 以下是我自己設計的:

Department 
    String name;//name of this department 

    List<Task> listAllTasks();// list all tasks belong to this department 

Task 
    String name; 
    String desc;//description of this task 
    Date startTime;//when this task will start 
    Date endTime; 
    int status; //is this task done? doing? not starting? 
    String executorName; //the name of the person who will responsible for this task(here the person does not need to be common boss,just a name). 
    Department depart;//which department does this task belong to ? 

Boss 
    String loginName; 
    String realName; 
    String password; 
    Department depart;//which department does this boss belong to ? 

以上是我所有的想法,我不知道到繼續做權威設計。

例如,最大的老闆當然不屬於任何部門,但他擁有最大的權力。

任何人都可以幫我一個忙嗎?

順便說一句,我將使用hibernate作爲DAO和struts2作爲網頁控制器。

回答

1

將您的Boss類更改爲Person,然後添加@ManyToOnePerson superior(假設每個員工只有一個上述優勢)。

@ManyToManyList<Person> superiorList=new ArrayList<Person>()如果每個員工有多個上級,

如果某人是噓聲(組織樹中的最高權威人士),superiorsuperiorList將爲空。

對於角色

創建角色類

Role 
@OneToMany List<Task> taskList = new ArrayList<Task>(); 
role_code 

在Person類使許多以一個角色,如果一個人能分配到只有一個角色

@ManyToOne Role role 

@ManyToMany List<Role> roleList 

if a per兒子可以分配很多角色。

+0

如何控制用戶的權限?例如,當一個普通的老闆登錄時,我必須列出他有權限的所有任務,該怎麼辦? – hguser 2011-03-12 06:02:46

+0

感謝您的關注。你可以使用XML配置文件嗎?我從來沒有使用和「討厭」annoation .. :( – hguser 2011-03-12 08:18:22

+0

)我真的很抱歉,編寫hibernate xml映射現在已經超出了我的專業領域。如果你不需要任何兼容性問題來解決,我真的建議使用JPA-Hibernate的實現和註解,它更加簡單和容易。 – zawhtut 2011-03-13 06:08:59