victoryhoo的gravatar头像
victoryhoo 2013-03-28 10:05:38

spring+springsecurity+hibernate+struts2 权限代码数据库

spring+security+hibernate+struts2权限代码数据库

lib包下载地址:http://pan.baidu.com/s/1c1C0j0c

源码实现的功能很简单,仅仅演示了下spring security的语法而已。

项目截图

spring+springsecurity+hibernate+struts2 权限代码数据库运行截图

spring+springsecurity+hibernate+struts2 权限代码数据库

spring+springsecurity+hibernate+struts2 权限代码数据库

数据库截图

spring+springsecurity+hibernate+struts2 权限代码数据库

数据库脚本

/*
Navicat MySQL Data Transfer

Source Server         : MyConnection
Source Server Version : 50144
Source Host           : localhost:3306
Source Database       : testsecurity2

Target Server Type    : MYSQL
Target Server Version : 50144
File Encoding         : 65001

Date: 2012-06-21 16:45:55
*/

SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `bookinfo`
-- ----------------------------
DROP TABLE IF EXISTS `bookinfo`;
CREATE TABLE `bookinfo` (
  `bookId` int(11) NOT NULL AUTO_INCREMENT,
  `bookName` varchar(50) DEFAULT NULL,
  `bookAuthor` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`bookId`)
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of bookinfo
-- ----------------------------
INSERT INTO bookinfo VALUES ('29', 'as', 'as');
INSERT INTO bookinfo VALUES ('30', '2', '2');
INSERT INTO bookinfo VALUES ('31', '2', '2');
INSERT INTO bookinfo VALUES ('32', '2', '2');
INSERT INTO bookinfo VALUES ('33', '2', '2');
INSERT INTO bookinfo VALUES ('34', '2', '2');

-- ----------------------------
-- Table structure for `resource`
-- ----------------------------
DROP TABLE IF EXISTS `resource`;
CREATE TABLE `resource` (
  `resourceId` int(11) NOT NULL AUTO_INCREMENT,
  `resourceName` varchar(50) NOT NULL,
  `resourceURL` varchar(50) DEFAULT NULL,
  `parentId` int(11) NOT NULL,
  `desc` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`resourceId`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of resource
-- ----------------------------
INSERT INTO resource VALUES ('1', '用户列表', '/security/userList.action', '6', '查询所有用户');
INSERT INTO resource VALUES ('2', '增加用户', '/security/userAdd.action', '7', '增加用户');
INSERT INTO resource VALUES ('3', '删除用户', '/security/userDelete.action', '7', '删除用户');
INSERT INTO resource VALUES ('4', '修改用户', '/security/userEdit.action', '7', '修改用户');
INSERT INTO resource VALUES ('5', 'ID查询用户', '/security/userFindById.action', '6', '查询用户详情');
INSERT INTO resource VALUES ('6', '查询功能', null, '9', '双击打开');
INSERT INTO resource VALUES ('7', '操作功能', null, '9', '双击打开');
INSERT INTO resource VALUES ('8', '其他功能', null, '9', '双击打开');
INSERT INTO resource VALUES ('9', '权限系统', null, '0', null);
INSERT INTO resource VALUES ('10', '权限分配', '/security/role_resource.action', '7', '分配权限');

-- ----------------------------
-- Table structure for `role`
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(20) DEFAULT NULL,
  `desc` varchar(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of role
-- ----------------------------
INSERT INTO role VALUES ('1', 'ROLE_ADMIN', '管理员角色');
INSERT INTO role VALUES ('2', 'ROLE_XIAOADMIN', '小角色');
INSERT INTO role VALUES ('3', 'ROLE_EVERYBODY', '普通用户角色');

-- ----------------------------
-- Table structure for `role_resource`
-- ----------------------------
DROP TABLE IF EXISTS `role_resource`;
CREATE TABLE `role_resource` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `role_id` int(11) NOT NULL,
  `resource_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `role_id` (`role_id`),
  KEY `resource_id` (`resource_id`),
  CONSTRAINT `role_resource_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`),
  CONSTRAINT `role_resource_ibfk_2` FOREIGN KEY (`resource_id`) REFERENCES `resource` (`resourceId`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of role_resource
-- ----------------------------
INSERT INTO role_resource VALUES ('1', '1', '1');
INSERT INTO role_resource VALUES ('2', '1', '2');
INSERT INTO role_resource VALUES ('3', '1', '3');
INSERT INTO role_resource VALUES ('4', '1', '4');
INSERT INTO role_resource VALUES ('5', '1', '5');
INSERT INTO role_resource VALUES ('6', '2', '1');
INSERT INTO role_resource VALUES ('7', '2', '5');
INSERT INTO role_resource VALUES ('8', '1', '10');

-- ----------------------------
-- Table structure for `user`
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(20) NOT NULL,
  `password` varchar(20) NOT NULL,
  `status` int(1) NOT NULL,
  `desc` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO user VALUES ('1', 'admin', 'admin', '1', '管理员');
INSERT INTO user VALUES ('2', 'zhangsan', 'zhangsan', '1', '小角色');
INSERT INTO user VALUES ('3', 'jiangyou', 'jiangyou', '1', '普通用户');

-- ----------------------------
-- Table structure for `user_role`
-- ----------------------------
DROP TABLE IF EXISTS `user_role`;
CREATE TABLE `user_role` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `role_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `role_id` (`role_id`),
  CONSTRAINT `user_role_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`),
  CONSTRAINT `user_role_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- ----------------------------
-- Records of user_role
-- ----------------------------
INSERT INTO user_role VALUES ('1', '1', '1');
INSERT INTO user_role VALUES ('2', '1', '2');
INSERT INTO user_role VALUES ('3', '2', '2');
INSERT INTO user_role VALUES ('4', '1', '3');
INSERT INTO user_role VALUES ('5', '2', '3');
INSERT INTO user_role VALUES ('6', '3', '3');

 


最代码官方编辑于2017-3-30 12:41:46

打赏

文件名:TestSecurity7.zip,文件大小:18526K 下载
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友