【文章內(nèi)容簡介】
構(gòu)后的 ACL模型,解決系統(tǒng)用戶權(quán)限繼承角色權(quán)限,以及權(quán)限排斥的問題。 權(quán)限管理實現(xiàn)授權(quán)登陸用戶能夠添加模塊信息、刪除模塊信息 ,添加角色、刪除角色、給角色授權(quán),給用戶分配帳號、刪除帳號、修改帳號信息,給用戶分配角色、給特權(quán)用戶授權(quán)、查看用戶信息,普通登陸用戶能夠查看模塊信息、角色信息 、修改用戶密碼。 本系統(tǒng)采用了分層開發(fā),但是對三層架構(gòu)做了修改,將持久層合并在業(yè)務(wù)邏輯層中,系統(tǒng)分為呈現(xiàn)層、業(yè)務(wù)邏輯層。 呈現(xiàn)層使用 jsp 和 jstl[15]表示。 系統(tǒng) 層次 如圖 42 所示 : 領(lǐng)域模型業(yè)務(wù)邏輯層呈現(xiàn)層 圖 42 數(shù)據(jù)庫結(jié)構(gòu)的設(shè)計 系統(tǒng)開發(fā)中先根據(jù)系統(tǒng)需求建立領(lǐng)域模型,根據(jù)領(lǐng)域模型構(gòu)造出實例對象,最后采用 O/R映射工具 Hibernate,從對象模型導(dǎo)出 關(guān) 系模型。領(lǐng)域模型如 圖 43所示: M od u l e 模塊 1*+ pa r en t+ ch i l dr enO r ga n i z at i on 機構(gòu) 1*+ pa r en t+ ch i l dr enR o l e 角色 A C L 訪問控制列表 *1*1U se r sR ol es 用戶角色 *1A p pr ov eI n f o 審批信息 D ocu m en t 公文 *1W or kf l ow 流程 *1A d dr essL i st 通信錄 N o t e 便簽 In f or m at i o n 公共信息 E m pl oy ee 員工 *1+ or gU se r 用戶 * 111*1*1 ap pr ov er*1 cr ea t or1*1* 圖 43 系統(tǒng)模型圖 數(shù)據(jù)庫表的生成 根據(jù)領(lǐng)域模型創(chuàng)建實體類,創(chuàng)建出實體類之間的關(guān)聯(lián)關(guān)系。通過工具 xdoclet 生成實體類的映射文件和 hibernate 配置文件。利用 hibernate 的工具類倒出數(shù)據(jù)庫表,系統(tǒng)的表結(jié)構(gòu)如下所示: 表 41 t_anization(機構(gòu)表) Field Type Null Key Default Extra 描述 id int(11) NO PRI NULL auto_increment 機構(gòu) id serialNumber varchar(255) YES NULL 機構(gòu)編號 Name varchar(255) YES NULL 機構(gòu)名稱 description varchar(255) YES NULL 描述 parentId int(11) YES MUL NULL 父機構(gòu) ID 表 42 t_employee (員工表) Field Type Null Key Default Extra 描述 id int(11) NO PRI NULL auto_increment 員工 id empName varchar(255) YES NULL 員工姓名 gender varchar(255) YES NULL 性別 age int(11) YES NULL 年齡 telephone varchar(255) YES NULL 電話 address varchar(255) YES NULL 地址 varchar(255) YES NULL duty varchar(255) YES NULL 職務(wù) Id int(11) YES MUL NULL 機構(gòu) ID remark varchar(255) YES NULL 備注 表 43 t_note (便簽表) Field Type Null Key Default Extra 描述 id int(11) NO PRI NULL auto_increment 便簽 id title varchar(255) YES NULL 便簽標(biāo)題 content varchar(255) YES NULL 便簽內(nèi)容 createTime datetime YES NULL 便簽日期 createorId int(11) YES MUL NULL 創(chuàng)建者 ID 表 44 t_addressList (通信錄表) Field Type Null Key Default Extra 描述 id int(11) NO PRI NULL auto_increment 通訊錄 id name varchar(255) YES NULL 名字 mobilePhone varchar(255) YES NULL 手機電話 homePhone varchar(255) YES NULL 家庭電話 officePhone varchar(255) YES NULL 辦公室電話 varchar(255) YES NULL MSN varchar(255) YES NULL MSN Code varchar(255) YES NULL 郵編 address varchar(255) YES NULL 地址 remark varchar(255) YES NULL 備注 creatorId int(11) YES MUL NULL 創(chuàng)建者 ID 表 45 t_user (用戶表) Field Type Null Key Default Extra 描述 id int(11) NO PRI NULL auto_increment 用戶 id username varchar(255) YES NULL 用戶名 password varchar(255) YES NULL 密碼 createTime datetime YES NULL 創(chuàng)建時間 expireTime datetime YES NULL 失效時間 emp int(11) YES UNI NULL 員工 ID 表 46 t_role (角色表) Field Type Null Key Default Extra 描述 id int(11) NO PRI NULL auto_increment 角色 id roleName varchar(255) YES NULL 角色名 表 47 t_users_roles (用戶角色第三方表) Field Type Null Key Default Extra 描述 id int(11) NO PRI NULL auto_increment id userId int(11) YES MUL NULL 用戶 ID roleId int(11) YES MUL NULL 角色 ID orderNo int(11) YES NULL 角色級別,該字段用于解決權(quán)限沖突問題 表 48 t_acl ( acl列表) Field Type Null Key Default Extra 描述 id int(11) NO PRI NULL auto_increment id principalType varchar(255) YES NULL 主體類型( Role、User) principalId int(11) YES NULL 主體 id moduleId int(11) YES NULL 模塊 id aclState int(11) YES NULL 訪問控制狀態(tài) aclTriState int(11) YES NULL 是否繼承,該字段用于解決權(quán)限繼承問題 表 49 t_module (模塊表) Field Type Null Key Default Extra 描述 id int(11) NO PRI NULL auto_increment 模塊 id moduleName varchar(255) YES NULL 模塊名稱 url varchar(255) YES NULL 模塊的 url orderNo int(11) YES NULL 排序號碼 serialNumber varchar(255) YES NULL 模塊編號 parentId int(11) YES MUL NULL 父模塊 ID 表 410 t_workflow (流程表) Field Type Null Key Default Extra 描述 id int(11) NO PRI NULL auto_increment 流程 id workflowName varchar(255) YES NULL 流程名稱 processDef longblob YES NULL 流程定義 processImage longblob YES NULL 流程圖片 表 411 t_document (公文表) Field Type Null Key Default Extra 描述 id int(11) NO PRI NULL auto_increment 公文 id title varchar(255) YES NULL 公文標(biāo)題 content longblob YES NULL 公文內(nèi)容 annex longblob YES NULL 公文附件 description varchar(255) YES NULL 公文描述 createTime datetime YES NULL 創(chuàng)建時間 processInstanceId bigint(20) YES NULL 流程實例 ID status varchar(255) YES NULL 公文狀態(tài) createorId int(11) YES MUL NULL 創(chuàng)建者 ID 表 412 t_approveinfo (審批信息表) Field Type Null Key Default Extra 描述 id int(11) NO PRI NULL auto_increment 審批信息 id approveTime datetime YES NULL 審批時間 ment varchar(255) YES NULL 審批內(nèi)容 documentId int(11) YES MUL NULL 公文 ID approverId int(11) YES MUL NULL 審批者 ID 表 413 t_information (信息表) Field Type Null Key Default Extra 描述 id int(11) NO PRI NULL auto_increment 信息 id title varchar(255) YES NULL 信息標(biāo)題 cotent varchar(255) YES NULL 信息內(nèi)容 annex longblob YES NULL 信息附件 createTime datetime YES NULL 信息發(fā)布時間 數(shù)據(jù)庫的操作 Hibernate是現(xiàn)在非常流行的持久化框架,使用 Hibernate進(jìn)行持久化數(shù)據(jù)是一個非常好的選擇。在 Hibernate中 Session負(fù)責(zé)完成對象的持久化操作, Session在 Hibernate中相當(dāng)于 JDBC Connection中的 Connection。創(chuàng)建 Session的步驟: 1) 根據(jù)傳入的 Hibernate 配置文件 或者 創(chuàng)建 Configuration類的實例 : Configuration config = new Configuration().configure(); 2) 根據(jù) Configuration 類實例創(chuàng)建 Session 的工廠 SessionFactory 的實例SessionFactory sessionFactory = (); 3) 創(chuàng)建 Session的實例 : Session session = (); 上述數(shù)據(jù)庫操作要頻繁地創(chuàng)建 SessionFatory 實例,管理 session 的打開和關(guān)閉,但是創(chuàng)建 SessionFactory 非常耗費系統(tǒng)資源,這種操作不應(yīng)該是首選方法。在 Spring 中封裝了一個實現(xiàn) Hibernate相關(guān)接口的的基類 HibernateDaoSupport,在這個類中提供了數(shù)據(jù)訪問模板 HibernateTemplate進(jìn)行持久化操作。外部類只要繼承基類 HibernateDaoSupport,并利用Spring 的依賴注入特性向其注入 SessionFactory 就能使用 Spring 的 HibernateTemplate。使用 Spring 的 HibernateTemplate 進(jìn)行持久化操作,就能避免了 SessionFactory 的頻繁創(chuàng)建以及避免了對 Sess