Skip to content

Commit c86c898

Browse files
committed
init project
0 parents  commit c86c898

23 files changed

+2026
-0
lines changed

.gitignore

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (https://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
public/
39+
.idea/
40+
41+
# Typescript v1 declaration files
42+
typings/
43+
44+
# Optional npm cache directory
45+
.npm
46+
47+
# Optional eslint cache
48+
.eslintcache
49+
50+
# Optional REPL history
51+
.node_repl_history
52+
53+
# Output of 'npm pack'
54+
*.tgz
55+
56+
# Yarn Integrity file
57+
.yarn-integrity
58+
59+
# dotenv environment variables file
60+
.env

conf/db.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"dev": {
3+
"host":"localhost",
4+
"driver": "mysql",
5+
"user": "root",
6+
"database": "vue_dm_db",
7+
"password": "123456"
8+
},
9+
10+
"production": {
11+
"driver": "mysql",
12+
"user": "root",
13+
"database": "vueDM_db"
14+
}
15+
}

conf/vue_dm_db.sql

+190
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
/*
2+
Navicat MySQL Data Transfer
3+
4+
Source Server : localhost
5+
Source Server Version : 50717
6+
Source Host : localhost:3306
7+
Source Database : vue_dm_db
8+
9+
Target Server Type : MYSQL
10+
Target Server Version : 50717
11+
File Encoding : 65001
12+
13+
Date: 2017-09-08 16:14:58
14+
*/
15+
16+
SET FOREIGN_KEY_CHECKS=0;
17+
18+
-- ----------------------------
19+
-- Table structure for t_admin
20+
-- ----------------------------
21+
DROP TABLE IF EXISTS `t_admin`;
22+
CREATE TABLE `t_admin` (
23+
`tid` int(11) NOT NULL AUTO_INCREMENT,
24+
`username` varchar(40) DEFAULT NULL,
25+
`password` varchar(50) DEFAULT NULL,
26+
`role_id` int(11) DEFAULT NULL,
27+
`is_use` tinyint(4) DEFAULT NULL,
28+
`realname` varchar(40) DEFAULT NULL,
29+
PRIMARY KEY (`tid`)
30+
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
31+
32+
-- ----------------------------
33+
-- Records of t_admin
34+
-- ----------------------------
35+
INSERT INTO `t_admin` VALUES ('2', 'user2', 'd033e22ae348aeb5660fc2140aec35850c4da997', '13', '1', 'user2');
36+
INSERT INTO `t_admin` VALUES ('5', 'admin', 'd033e22ae348aeb5660fc2140aec35850c4da997', '18', '1', 'admin');
37+
38+
-- ----------------------------
39+
-- Table structure for t_resource
40+
-- ----------------------------
41+
DROP TABLE IF EXISTS `t_resource`;
42+
CREATE TABLE `t_resource` (
43+
`tid` int(11) NOT NULL AUTO_INCREMENT,
44+
`resource_name` varchar(20) DEFAULT NULL,
45+
`resource_description` varchar(40) DEFAULT NULL,
46+
`permission_url` varchar(60) DEFAULT NULL,
47+
`disabled` tinyint(1) DEFAULT NULL,
48+
PRIMARY KEY (`tid`)
49+
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;
50+
51+
-- ----------------------------
52+
-- Records of t_resource
53+
-- ----------------------------
54+
INSERT INTO `t_resource` VALUES ('1', '查看角色', '查看所有的角色列表', 'admin/system/role/create/*', '1');
55+
INSERT INTO `t_resource` VALUES ('2', '添加角色', '添加一个新的角色', 'admin/system/role/add/*', '1');
56+
INSERT INTO `t_resource` VALUES ('3', '编辑角色', '编辑已有角色的权限列表', 'admin/system/role/edit/*', '1');
57+
INSERT INTO `t_resource` VALUES ('4', '删除角色', '删除一个已有的角色', 'admin/system/role/del/*', '1');
58+
INSERT INTO `t_resource` VALUES ('5', '查看用户', '查看所有的用户列表', 'admin/system/user/create/*', '1');
59+
INSERT INTO `t_resource` VALUES ('6', '添加用户', '添加一个新的用户', 'admin/system/user/add/*', '1');
60+
INSERT INTO `t_resource` VALUES ('7', '启用用户', '启用一个已有用户', 'admin/system/user/enabled/*', '1');
61+
INSERT INTO `t_resource` VALUES ('8', '禁用用户', '禁用一个已有用户', 'admin/system/user/disabled/*', '1');
62+
INSERT INTO `t_resource` VALUES ('9', '删除用户', '删除一个已有用户', 'admin/system/user/del/*', '1');
63+
INSERT INTO `t_resource` VALUES ('10', '编辑用户', '修改一个已有用户的所属角色', 'admin/system/user/edit/*', '1');
64+
INSERT INTO `t_resource` VALUES ('11', '表格权限', null, 'admin/data/table/*', '0');
65+
66+
-- ----------------------------
67+
-- Table structure for t_role
68+
-- ----------------------------
69+
DROP TABLE IF EXISTS `t_role`;
70+
CREATE TABLE `t_role` (
71+
`tid` int(11) NOT NULL AUTO_INCREMENT,
72+
`nick_name` varchar(20) DEFAULT NULL,
73+
`description` varchar(255) DEFAULT NULL,
74+
PRIMARY KEY (`tid`)
75+
) ENGINE=InnoDB AUTO_INCREMENT=20 DEFAULT CHARSET=utf8;
76+
77+
-- ----------------------------
78+
-- Records of t_role
79+
-- ----------------------------
80+
INSERT INTO `t_role` VALUES ('13', '普通用户', '普通权限');
81+
INSERT INTO `t_role` VALUES ('16', '潮神', 'dota');
82+
INSERT INTO `t_role` VALUES ('18', '超级管理员', '系统的最高级别角色');
83+
INSERT INTO `t_role` VALUES ('19', 'GAI', '没有描述');
84+
85+
-- ----------------------------
86+
-- Table structure for t_role_resource
87+
-- ----------------------------
88+
DROP TABLE IF EXISTS `t_role_resource`;
89+
CREATE TABLE `t_role_resource` (
90+
`tid` int(11) NOT NULL AUTO_INCREMENT,
91+
`role_id` int(11) DEFAULT NULL,
92+
`resource_id` int(11) DEFAULT NULL,
93+
PRIMARY KEY (`tid`)
94+
) ENGINE=InnoDB AUTO_INCREMENT=61 DEFAULT CHARSET=utf8;
95+
96+
-- ----------------------------
97+
-- Records of t_role_resource
98+
-- ----------------------------
99+
INSERT INTO `t_role_resource` VALUES ('47', '18', '1');
100+
INSERT INTO `t_role_resource` VALUES ('48', '18', '2');
101+
INSERT INTO `t_role_resource` VALUES ('49', '18', '3');
102+
INSERT INTO `t_role_resource` VALUES ('50', '18', '4');
103+
INSERT INTO `t_role_resource` VALUES ('51', '18', '5');
104+
INSERT INTO `t_role_resource` VALUES ('52', '18', '6');
105+
INSERT INTO `t_role_resource` VALUES ('53', '18', '7');
106+
INSERT INTO `t_role_resource` VALUES ('54', '18', '8');
107+
INSERT INTO `t_role_resource` VALUES ('55', '18', '9');
108+
INSERT INTO `t_role_resource` VALUES ('56', '18', '10');
109+
INSERT INTO `t_role_resource` VALUES ('57', '18', '11');
110+
INSERT INTO `t_role_resource` VALUES ('60', '13', '11');
111+
112+
-- ----------------------------
113+
-- Table structure for t_select
114+
-- ----------------------------
115+
DROP TABLE IF EXISTS `t_select`;
116+
CREATE TABLE `t_select` (
117+
`tid` int(11) NOT NULL AUTO_INCREMENT,
118+
`select_key` varchar(100) DEFAULT NULL,
119+
`select_value` varchar(100) DEFAULT NULL,
120+
PRIMARY KEY (`tid`)
121+
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
122+
123+
-- ----------------------------
124+
-- Records of t_select
125+
-- ----------------------------
126+
INSERT INTO `t_select` VALUES ('1', '测试表格_选择列', '苹果');
127+
INSERT INTO `t_select` VALUES ('2', '测试表格_选择列', '香蕉');
128+
INSERT INTO `t_select` VALUES ('3', '测试表格_选择列', '');
129+
130+
-- ----------------------------
131+
-- Table structure for t_table
132+
-- ----------------------------
133+
DROP TABLE IF EXISTS `t_table`;
134+
CREATE TABLE `t_table` (
135+
`tid` int(11) NOT NULL AUTO_INCREMENT,
136+
`parent_code` int(11) DEFAULT NULL,
137+
`name` varchar(64) DEFAULT NULL,
138+
PRIMARY KEY (`tid`)
139+
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8;
140+
141+
-- ----------------------------
142+
-- Records of t_table
143+
-- ----------------------------
144+
INSERT INTO `t_table` VALUES ('1', '0', '安检部');
145+
INSERT INTO `t_table` VALUES ('2', '1', '测试表格');
146+
INSERT INTO `t_table` VALUES ('3', '1', '测试表格二');
147+
INSERT INTO `t_table` VALUES ('4', '1', '测试表格三');
148+
INSERT INTO `t_table` VALUES ('5', '0', '护卫部');
149+
INSERT INTO `t_table` VALUES ('6', '5', '测试表格四');
150+
INSERT INTO `t_table` VALUES ('7', '5', '测试表格五');
151+
INSERT INTO `t_table` VALUES ('8', '0', '其他部');
152+
INSERT INTO `t_table` VALUES ('9', '8', '其他一部');
153+
INSERT INTO `t_table` VALUES ('10', '8', '其他二部');
154+
INSERT INTO `t_table` VALUES ('11', '9', '内容测试');
155+
INSERT INTO `t_table` VALUES ('12', '11', '测试表格六');
156+
INSERT INTO `t_table` VALUES ('13', '10', '测试表格七');
157+
158+
-- ----------------------------
159+
-- Table structure for 测试表格
160+
-- ----------------------------
161+
DROP TABLE IF EXISTS `测试表格`;
162+
CREATE TABLE `测试表格` (
163+
`tid` int(11) NOT NULL AUTO_INCREMENT,
164+
`text_文本列` varchar(255) DEFAULT NULL,
165+
`number_数字列` int(11) DEFAULT NULL,
166+
`date_时间列` datetime DEFAULT NULL,
167+
`select_选择列` varchar(255) DEFAULT NULL,
168+
`img_图片列` text,
169+
PRIMARY KEY (`tid`)
170+
) ENGINE=InnoDB AUTO_INCREMENT=218 DEFAULT CHARSET=utf8;
171+
172+
-- ----------------------------
173+
-- Records of 测试表格
174+
-- ----------------------------
175+
INSERT INTO `测试表格` VALUES ('114', '文本123', '123', '2017-08-15 10:58:37', '香蕉', 'upload/20170831/14618c8196de4a9480e1a928e44a3cd8.jpg');
176+
INSERT INTO `测试表格` VALUES ('115', '文本1324', '12', '2017-08-15 10:58:37', '香蕉', 'upload/20170831/2012feb6c45643c48a31313920bcca9a.jpg');
177+
INSERT INTO `测试表格` VALUES ('117', '文本12', '12', '2017-08-15 10:58:37', '香蕉', 'upload/20170901/f5063dd1523a4d85864f792a0f56d94a.jpg');
178+
INSERT INTO `测试表格` VALUES ('118', '文本1', '12', '2017-08-15 10:58:37', '苹果', 'upload/20170901/4b21f0c35251473e9f143f3a78fcc5f5.jpg');
179+
INSERT INTO `测试表格` VALUES ('119', '文本1', '12', '2017-08-15 10:58:37', '苹果', 'upload/20170901/f091748ac6dc4afc92a3c3aa2af23b59.jpg');
180+
INSERT INTO `测试表格` VALUES ('120', '文本1', '12', '2017-08-15 10:58:37', '香蕉', 'upload/20170901/ea3fc2ed0f504509978a5c30965fa8c2.jpg');
181+
INSERT INTO `测试表格` VALUES ('207', '测试文本', '123', '2017-08-25 00:00:00', '苹果', 'upload/20170901/442e9cb01e9b429fa4c0d1539dbf6a57.jpg');
182+
INSERT INTO `测试表格` VALUES ('208', '123', '123', '2017-09-13 00:00:00', '香蕉', 'upload/20170902/df9197cb693245838e690e784cc6b6f0.jpg;upload/20170902/cf8cc82585354de38997ed85ce585de9.jpg;upload/20170902/28ecdfad30634a66b2cf967d347fddb3.jpg');
183+
INSERT INTO `测试表格` VALUES ('209', '123', '3', '2017-09-02 00:00:00', '', 'upload/20170902/47731aa624154e73849f545d34977a8f.jpg;upload/20170902/d88d2772aaa94038a00f1e05cdddf50c.jpg');
184+
INSERT INTO `测试表格` VALUES ('210', '234', '245', '2017-09-07 00:00:00', '香蕉', 'upload/20170902/2133891c8f994ef5b4466a4283487c90.jpg;upload/20170902/65f69e2f0061407ea0c076e83e923151.jpg;upload/20170902/93a3dad8141b477aa7af0b603147bc74.jpg;upload/20170902/2c868fb1e1204d30abdbb26463b9b0b1.jpg');
185+
INSERT INTO `测试表格` VALUES ('211', '345', '345', '2017-09-13 00:00:00', '香蕉', 'upload/20170902/5481fcb4eb6a4fdf821149dab297e9ba.jpg;upload/20170902/5007be51b80045adab772e0a498ed0ea.jpg;upload/20170902/a04c2928242040628343c85a11aec091.jpg');
186+
INSERT INTO `测试表格` VALUES ('212', '456', '456', '2017-09-02 10:47:42', '香蕉', 'upload/20170902/f04b70b1563c4e22884a1b54452be60c.jpg;upload/20170902/87246c505fda4a528ee9fb2ac439cfe9.jpg;upload/20170902/c0f6fa2bd85f46668930786a7d6fa6b1.jpg');
187+
INSERT INTO `测试表格` VALUES ('213', '123', '123', '2017-09-04 10:48:08', '香蕉', 'upload/20170902/c2df7ffc14814584bb60c534c7c69a81.jpg;upload/20170902/f720ad2b3d7b43368ae466a8a81464a6.jpg;upload/20170902/e744d8ba3a8a460fa1e317f11e8dbfb3.jpg;upload/20170902/d0563eee7d614c4382a136a02d483b10.jpg;upload/20170908/bb2194f2ecfd49b3b9fd430baeaf645c.jpg');
188+
INSERT INTO `测试表格` VALUES ('214', '123', '123', '2017-09-22 12:00:00', '香蕉', 'upload/20170902/5ca4d197337d4656a7f1216657bb5c35.jpg');
189+
INSERT INTO `测试表格` VALUES ('216', '123', '123', '2017-08-29 00:00:00', '', 'upload/20170902/248c8d67696948c6983a64bddf094aca.jpg;upload/20170902/f202662674224f9ea3d5107e836715c7.jpg');
190+
INSERT INTO `测试表格` VALUES ('217', 'as返回北京开始部分进口设备防控技术部分加扣税大部分可就是打不开机房刷卡缴费不上课简单方便会计师部分开始加班', '123', '2017-09-14 00:00:00', '', '');

framework/app.js

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
var express = require('express');
2+
var fs = require('fs');
3+
var bodyParser = require('body-parser');
4+
var session = require('express-session');
5+
var admin = require('../service/admin')
6+
var webResult = require('../util/webResult')
7+
var util = require('../util/util')
8+
var path = require('path')
9+
var app = express();
10+
11+
app.use(bodyParser.json());
12+
app.use(bodyParser.urlencoded({ extended: false }));
13+
//配置静态目录,vue-cli打包后的文件放置在这个目录
14+
app.use(express.static('public'));
15+
app.use(session({
16+
secret: 'Back', //secret的值建议使用随机字符串
17+
cookie: {maxAge: 60 * 1000 * 30} // 过期时间(毫秒)
18+
}));
19+
20+
var port = normalizePort(process.env.PORT || '3982');
21+
app.set('port', port);
22+
//首页重定向
23+
app.get('/', function (req, res) {
24+
res.redirect(302, '/index.html');
25+
});
26+
//登录验证
27+
app.use('/login', function(req, res, next){
28+
var data = JSON.parse(req.param("data"))
29+
admin.login(data.username,data.password,function (result) {
30+
if(result.code == 200){
31+
req.session.token={
32+
username:data.username,
33+
password:data.password
34+
}
35+
}
36+
webResult.createResponse(res,result)
37+
})
38+
});
39+
//注销
40+
app.use('/logout', function(req, res, next){
41+
req.session.token = {}
42+
webResult.createResponse(res,webResult.createResult(200,"注销成功"))
43+
});
44+
//用户修改密码
45+
app.use('/update', function(req, res, next){
46+
if(util.isEmptyObject(req.session.token)){
47+
webResult.createResponse(res,webResult.createResult(300,"请先登录"))
48+
}else{
49+
var data = JSON.parse(req.params.data)
50+
admin.update(req.session.token.username,data.newpassword,function (result) {
51+
webResult.createResponse(res,result)
52+
})
53+
}
54+
});
55+
//系统构建时需要的数据
56+
app.use('/create', function(req, res){
57+
if(util.isEmptyObject(req.session.token)){
58+
webResult.createResponse(res,webResult.createResult(300,"请先登录"))
59+
}else{
60+
admin.create(req.session.token.username,function (result) {
61+
req.session.token.roleCode = result.data.loginInfo.roleCode
62+
webResult.createResponse(res,result)
63+
})
64+
}
65+
});
66+
//HTTP请求拦截器,权限验证
67+
app.use('/admin', function(req, res, next){
68+
if(util.isEmptyObject(req.session.token)){
69+
webResult.createResponse(res,webResult.createResult(300,"请先登录"))
70+
}else{
71+
admin.permissionMatch(req.session.token.username,req.session.token.roleCode,"admin"+req.url,function (result) {
72+
if(result.code == 200){
73+
next()
74+
}else{
75+
webResult.createResponse(res,result)
76+
}
77+
})
78+
}
79+
});
80+
81+
// 路由加载
82+
var files = fs.readdirSync('./routes');
83+
files.forEach((val,index)=>{
84+
var router = require('../routes/' + val);
85+
app.use('/admin', router);
86+
});
87+
//数据目录加载
88+
if (!fs.existsSync(path.join(__dirname, '../public/upload/tmp'))) {
89+
fs.mkdir(path.join(__dirname, '../public/upload/tmp'));
90+
}
91+
if (!fs.existsSync(path.join(__dirname, '../public/excel/tmp'))) {
92+
fs.mkdir(path.join(__dirname, '../public/upload/tmp'));
93+
}
94+
95+
function normalizePort(val) {
96+
var port = parseInt(val, 10);
97+
98+
if (isNaN(port)) {
99+
// named pipe
100+
return val;
101+
}
102+
103+
if (port >= 0) {
104+
// port number
105+
return port;
106+
}
107+
108+
return false;
109+
}
110+
111+
module.exports = app
112+

0 commit comments

Comments
 (0)