Skip to content

Commit

Permalink
修改实体,添加建表脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
angilin committed Mar 21, 2014
1 parent 1866e0e commit 6eabd57
Show file tree
Hide file tree
Showing 20 changed files with 571 additions and 141 deletions.
2 changes: 1 addition & 1 deletion .myhibernatedata
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
#Thu Mar 20 17:37:38 CST 2014
#Fri Mar 21 10:08:58 CST 2014
genBasicCompId=false
sessionFactoryName=factory.HibernateSessionFactory
profile=
Expand Down
2 changes: 1 addition & 1 deletion WebRoot/WEB-INF/classes/com/rbac/entity/SysAccount.hbm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<comment>盐</comment>
</column>
</property>
<property name="isDeleted" type="java.lang.Short">
<property name="isDeleted" type="java.lang.Integer">
<column name="IS_DELETED" not-null="true">
<comment>删除标识位</comment>
</column>
Expand Down
5 changes: 2 additions & 3 deletions WebRoot/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>登录页面</title>
</head>
<body>
登录用户名:<c:out value="${sessionScope['user'].username}"></c:out>
用户登录名:<c:out value="${sessionScope['user'].username}"></c:out>
<br/>
登录用户真实姓名:<c:out value="${sessionScope['user'].realname}"></c:out>
用户显示名:<c:out value="${sessionScope['user'].realname}"></c:out>
</body>
</html>

Expand Down
161 changes: 161 additions & 0 deletions rbac.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
-- --------------------------------------------------------
-- 主机: 127.0.0.1
-- 服务器版本: 5.0.41-community-nt - MySQL Community Edition (GPL)
-- 服务器操作系统: Win32
-- HeidiSQL 版本: 8.0.0.4396
-- --------------------------------------------------------

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;

-- 导出 表 rbac.sys_account 结构
CREATE TABLE IF NOT EXISTS `sys_account` (
`ID` bigint(20) NOT NULL auto_increment COMMENT '主键',
`USERNAME` varchar(20) NOT NULL COMMENT '用户登录名',
`PASSWORD` varchar(100) NOT NULL COMMENT '密码',
`REALNAME` varchar(20) default NULL COMMENT '用户显示名',
`SALT` varchar(100) NOT NULL COMMENT '',
`IS_DELETED` int(11) NOT NULL default '0' COMMENT '删除标识位',
`CREATOR_ID` bigint(20) default NULL COMMENT '创建者id',
`CREATE_TIME` timestamp NULL default NULL COMMENT '创建时间',
`MODIFIER_ID` bigint(20) default NULL COMMENT '修改者id',
`MODIFY_TIME` timestamp NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '修改日期',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户表';

-- 正在导出表 rbac.sys_account 的数据:~1 rows (大约)
/*!40000 ALTER TABLE `sys_account` DISABLE KEYS */;
INSERT INTO `sys_account` (`ID`, `USERNAME`, `PASSWORD`, `REALNAME`, `SALT`, `IS_DELETED`, `CREATOR_ID`, `CREATE_TIME`, `MODIFIER_ID`, `MODIFY_TIME`) VALUES
(1, 'admin', 'bb84f339b1cfb72a933809dd1a55edb4deb326fd78975554', '系统管理员', '3fc91ab38271c27ed4531999670716fb2a3c7e59d02293de', 0, NULL, NULL, NULL, '2014-03-20 16:59:51');
/*!40000 ALTER TABLE `sys_account` ENABLE KEYS */;


-- 导出 表 rbac.sys_account_role 结构
CREATE TABLE IF NOT EXISTS `sys_account_role` (
`ID` bigint(20) NOT NULL auto_increment COMMENT '主键',
`ACCOUNT_ID` bigint(20) default NULL COMMENT '用户id',
`ROLE_ID` bigint(20) default NULL COMMENT '角色id',
`IS_DELETED` int(11) NOT NULL default '0' COMMENT '删除标识位',
`CREATOR_ID` bigint(20) default NULL COMMENT '创建者id',
`CREATE_TIME` timestamp NULL default NULL COMMENT '创建时间',
`MODIFIER_ID` bigint(20) default NULL COMMENT '修改者id',
`MODIFY_TIME` timestamp NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '修改日期',
PRIMARY KEY (`ID`),
KEY `FK_sys_account_role_sys_account` (`ACCOUNT_ID`),
KEY `FK_sys_account_role_sys_role` (`ROLE_ID`),
CONSTRAINT `FK_sys_account_role_sys_account` FOREIGN KEY (`ACCOUNT_ID`) REFERENCES `sys_account` (`ID`),
CONSTRAINT `FK_sys_account_role_sys_role` FOREIGN KEY (`ROLE_ID`) REFERENCES `sys_role` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='账号角色表';

-- 正在导出表 rbac.sys_account_role 的数据:~0 rows (大约)
/*!40000 ALTER TABLE `sys_account_role` DISABLE KEYS */;
/*!40000 ALTER TABLE `sys_account_role` ENABLE KEYS */;


-- 导出 表 rbac.sys_action 结构
CREATE TABLE IF NOT EXISTS `sys_action` (
`ID` bigint(20) NOT NULL auto_increment,
`NAME` varchar(20) default NULL COMMENT '权限名称',
`URL` varchar(50) default NULL COMMENT '权限url',
`NEED_CHECK` int(11) default '1' COMMENT '是否需要验证',
`IS_DELETED` int(11) NOT NULL default '0' COMMENT '删除标识位',
`CREATOR_ID` bigint(20) default NULL COMMENT '创建者id',
`CREATE_TIME` timestamp NULL default NULL COMMENT '创建时间',
`MODIFIER_ID` bigint(20) default NULL COMMENT '修改者id',
`MODIFY_TIME` timestamp NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '修改日期',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='权限表';

-- 正在导出表 rbac.sys_action 的数据:~0 rows (大约)
/*!40000 ALTER TABLE `sys_action` DISABLE KEYS */;
/*!40000 ALTER TABLE `sys_action` ENABLE KEYS */;


-- 导出 表 rbac.sys_menu 结构
CREATE TABLE IF NOT EXISTS `sys_menu` (
`ID` bigint(20) NOT NULL auto_increment,
`NAME` varchar(20) default NULL COMMENT '菜单显示名',
`URL` varchar(50) default NULL COMMENT '菜单的url路径',
`PARENT_ID` bigint(20) default NULL COMMENT '父菜单id',
`NEED_CHECK` int(11) NOT NULL default '1' COMMENT '是否需要权限才能访问',
`IS_SHOW` int(11) NOT NULL default '1' COMMENT '是否显示该菜单',
`IS_DELETED` int(11) NOT NULL default '0' COMMENT '删除标识位',
`CREATOR_ID` bigint(20) default NULL COMMENT '创建者id',
`CREATE_TIME` timestamp NULL default NULL COMMENT '创建时间',
`MODIFIER_ID` bigint(20) default NULL COMMENT '修改者id',
`MODIFY_TIME` timestamp NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '修改日期',
PRIMARY KEY (`ID`),
KEY `FK_sys_menu_sys_menu` (`PARENT_ID`),
CONSTRAINT `FK_sys_menu_sys_menu` FOREIGN KEY (`PARENT_ID`) REFERENCES `sys_menu` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='菜单表';

-- 正在导出表 rbac.sys_menu 的数据:~0 rows (大约)
/*!40000 ALTER TABLE `sys_menu` DISABLE KEYS */;
/*!40000 ALTER TABLE `sys_menu` ENABLE KEYS */;


-- 导出 表 rbac.sys_menu_action 结构
CREATE TABLE IF NOT EXISTS `sys_menu_action` (
`ID` bigint(20) NOT NULL auto_increment,
`ACTION_ID` bigint(20) default NULL COMMENT '权限id',
`MENU_ID` bigint(20) default NULL COMMENT '菜单id',
`IS_DELETED` int(11) NOT NULL default '0' COMMENT '删除标识位',
`CREATOR_ID` bigint(20) default NULL COMMENT '创建者id',
`CREATE_TIME` timestamp NULL default NULL COMMENT '创建时间',
`MODIFIER_ID` bigint(20) default NULL COMMENT '修改者id',
`MODIFY_TIME` timestamp NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '修改日期',
PRIMARY KEY (`ID`),
KEY `FK_sys_action_relate_sys_action` (`ACTION_ID`),
KEY `FK_sys_action_relate_sys_menu` (`MENU_ID`),
CONSTRAINT `FK_sys_action_relate_sys_action` FOREIGN KEY (`ACTION_ID`) REFERENCES `sys_action` (`ID`),
CONSTRAINT `FK_sys_action_relate_sys_menu` FOREIGN KEY (`MENU_ID`) REFERENCES `sys_menu` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='菜单权限表';

-- 正在导出表 rbac.sys_menu_action 的数据:~0 rows (大约)
/*!40000 ALTER TABLE `sys_menu_action` DISABLE KEYS */;
/*!40000 ALTER TABLE `sys_menu_action` ENABLE KEYS */;


-- 导出 表 rbac.sys_role 结构
CREATE TABLE IF NOT EXISTS `sys_role` (
`ID` bigint(20) NOT NULL auto_increment COMMENT '主键',
`ROLE_NAME` varchar(50) default NULL COMMENT '角色名',
`ROLE_DESC` varchar(200) default NULL COMMENT '角色描述',
`IS_DELETED` int(11) NOT NULL default '0' COMMENT '删除标识位',
`CREATOR_ID` bigint(20) default NULL COMMENT '创建者id',
`CREATE_TIME` timestamp NULL default NULL COMMENT '创建时间',
`MODIFIER_ID` bigint(20) default NULL COMMENT '修改者id',
`MODIFY_TIME` timestamp NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '修改日期',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='角色表';

-- 正在导出表 rbac.sys_role 的数据:~0 rows (大约)
/*!40000 ALTER TABLE `sys_role` DISABLE KEYS */;
/*!40000 ALTER TABLE `sys_role` ENABLE KEYS */;


-- 导出 表 rbac.sys_role_menu 结构
CREATE TABLE IF NOT EXISTS `sys_role_menu` (
`ID` bigint(20) NOT NULL auto_increment,
`ROLE_ID` bigint(20) default NULL COMMENT '角色id',
`MENU_ID` bigint(20) default NULL COMMENT '菜单id',
`IS_DELETED` int(11) NOT NULL default '0' COMMENT '删除标识位',
`CREATOR_ID` bigint(20) default NULL COMMENT '创建者id',
`CREATE_TIME` timestamp NULL default NULL COMMENT '创建时间',
`MODIFIER_ID` bigint(20) default NULL COMMENT '修改者id',
`MODIFY_TIME` timestamp NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP COMMENT '修改日期',
PRIMARY KEY (`ID`),
KEY `FK_sys_role_action_sys_role` (`ROLE_ID`),
KEY `FK_sys_role_action_sys_menu` (`MENU_ID`),
CONSTRAINT `FK_sys_role_action_sys_menu` FOREIGN KEY (`MENU_ID`) REFERENCES `sys_menu` (`ID`),
CONSTRAINT `FK_sys_role_action_sys_role` FOREIGN KEY (`ROLE_ID`) REFERENCES `sys_role` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='角色菜单表';

-- 正在导出表 rbac.sys_role_menu 的数据:~0 rows (大约)
/*!40000 ALTER TABLE `sys_role_menu` DISABLE KEYS */;
/*!40000 ALTER TABLE `sys_role_menu` ENABLE KEYS */;
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
3 changes: 0 additions & 3 deletions src/com/rbac/common/SscConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@
public class SscConstant {

public static final String USER = "com_user";

public static final Short isDeleted = new Short("1");
public static final Short isNotDeleted = new Short("0");
}
3 changes: 1 addition & 2 deletions src/com/rbac/dao/LoginDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
import org.springframework.stereotype.Component;

import com.rbac.common.BaseDaoSupport;
import com.rbac.common.SscConstant;
import com.rbac.entity.SysAccount;

@Component("loginDao")
public class LoginDao extends BaseDaoSupport {

public SysAccount getSysAccountByUsername(String username) {
List list = super.getSession().createCriteria(SysAccount.class).add(
Restrictions.eq("isDeleted", SscConstant.isNotDeleted)).add(
Restrictions.eq("isDeleted", 0)).add(
Restrictions.eq("username", username)).list();
if (list.size() > 0) {
return (SysAccount) list.get(0);
Expand Down
2 changes: 1 addition & 1 deletion src/com/rbac/entity/SysAccount.hbm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<comment>盐</comment>
</column>
</property>
<property name="isDeleted" type="java.lang.Short">
<property name="isDeleted" type="java.lang.Integer">
<column name="IS_DELETED" not-null="true">
<comment>删除标识位</comment>
</column>
Expand Down
10 changes: 5 additions & 5 deletions src/com/rbac/entity/SysAccount.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class SysAccount implements java.io.Serializable {

private String salt;

private Short isDeleted;
private Integer isDeleted;

private Long creatorId;

Expand All @@ -42,7 +42,7 @@ public SysAccount() {

/** minimal constructor */
public SysAccount(String username, String password, String salt,
Short isDeleted) {
Integer isDeleted) {
this.username = username;
this.password = password;
this.salt = salt;
Expand All @@ -51,7 +51,7 @@ public SysAccount(String username, String password, String salt,

/** full constructor */
public SysAccount(String username, String password, String realname,
String salt, Short isDeleted, Long creatorId, Date createTime,
String salt, Integer isDeleted, Long creatorId, Date createTime,
Long modifierId, Date modifyTime, Set sysAccountRoles) {
this.username = username;
this.password = password;
Expand Down Expand Up @@ -107,11 +107,11 @@ public void setSalt(String salt) {
this.salt = salt;
}

public Short getIsDeleted() {
public Integer getIsDeleted() {
return this.isDeleted;
}

public void setIsDeleted(Short isDeleted) {
public void setIsDeleted(Integer isDeleted) {
this.isDeleted = isDeleted;
}

Expand Down
2 changes: 1 addition & 1 deletion src/com/rbac/entity/SysAccountRole.hbm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<comment>角色id</comment>
</column>
</many-to-one>
<property name="isDeleted" type="java.lang.Short">
<property name="isDeleted" type="java.lang.Integer">
<column name="IS_DELETED" not-null="true">
<comment>删除标识位</comment>
</column>
Expand Down
12 changes: 6 additions & 6 deletions src/com/rbac/entity/SysAccountRole.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class SysAccountRole implements java.io.Serializable {

private SysRole sysRole;

private Short isDeleted;
private Integer isDeleted;

private Long creatorId;

Expand All @@ -33,14 +33,14 @@ public SysAccountRole() {
}

/** minimal constructor */
public SysAccountRole(Short isDeleted) {
public SysAccountRole(Integer isDeleted) {
this.isDeleted = isDeleted;
}

/** full constructor */
public SysAccountRole(SysAccount sysAccount, SysRole sysRole,
Short isDeleted, Long creatorId, Date createTime, Long modifierId,
Date modifyTime) {
Integer isDeleted, Long creatorId, Date createTime,
Long modifierId, Date modifyTime) {
this.sysAccount = sysAccount;
this.sysRole = sysRole;
this.isDeleted = isDeleted;
Expand Down Expand Up @@ -76,11 +76,11 @@ public void setSysRole(SysRole sysRole) {
this.sysRole = sysRole;
}

public Short getIsDeleted() {
public Integer getIsDeleted() {
return this.isDeleted;
}

public void setIsDeleted(Short isDeleted) {
public void setIsDeleted(Integer isDeleted) {
this.isDeleted = isDeleted;
}

Expand Down
35 changes: 17 additions & 18 deletions src/com/rbac/entity/SysAction.hbm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@
<generator class="native" />
</id>
<property name="name" type="java.lang.String">
<column name="NAME" length="20" />
<column name="NAME" length="20">
<comment>权限名称</comment>
</column>
</property>
<property name="url" type="java.lang.String">
<column name="URL" length="50" />
<column name="URL" length="50">
<comment>权限url</comment>
</column>
</property>
<property name="isDeleted" type="java.lang.Short">
<property name="needCheck" type="java.lang.Integer">
<column name="NEED_CHECK">
<comment>是否需要验证</comment>
</column>
</property>
<property name="isDeleted" type="java.lang.Integer">
<column name="IS_DELETED" not-null="true">
<comment>删除标识位</comment>
</column>
Expand All @@ -41,23 +50,13 @@
<comment>修改日期</comment>
</column>
</property>
<set name="sysRoleActions" inverse="true">
<key>
<column name="ACTION_ID" />
</key>
<one-to-many class="com.rbac.entity.SysRoleAction" />
</set>
<set name="sysActionRelatesForActionId" inverse="true">
<key>
<column name="ACTION_ID" />
</key>
<one-to-many class="com.rbac.entity.SysActionRelate" />
</set>
<set name="sysActionRelatesForRelateActionId" inverse="true">
<set name="sysMenuActions" inverse="true">
<key>
<column name="RELATE_ACTION_ID" />
<column name="ACTION_ID">
<comment>权限id</comment>
</column>
</key>
<one-to-many class="com.rbac.entity.SysActionRelate" />
<one-to-many class="com.rbac.entity.SysMenuAction" />
</set>
</class>
</hibernate-mapping>
Loading

0 comments on commit 6eabd57

Please sign in to comment.