myapp_sjy 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. package/Dockerfile +7 -0
  2. package/app.js +58 -0
  3. package/bin/www +92 -0
  4. package/package.json +100 -0
  5. package/pkg.zip +0 -0
  6. package/public/css/layui.css +1 -0
  7. package/public/css/modules/code.css +1 -0
  8. package/public/css/modules/laydate/default/laydate.css +1 -0
  9. package/public/css/modules/layer/default/icon-ext.png +0 -0
  10. package/public/css/modules/layer/default/icon.png +0 -0
  11. package/public/css/modules/layer/default/layer.css +1 -0
  12. package/public/css/modules/layer/default/loading-0.gif +0 -0
  13. package/public/css/modules/layer/default/loading-1.gif +0 -0
  14. package/public/css/modules/layer/default/loading-2.gif +0 -0
  15. package/public/font/iconfont.eot +0 -0
  16. package/public/font/iconfont.svg +554 -0
  17. package/public/font/iconfont.ttf +0 -0
  18. package/public/font/iconfont.woff +0 -0
  19. package/public/font/iconfont.woff2 +0 -0
  20. package/public/layui.js +5 -0
  21. package/public/stylesheets/style.css +8 -0
  22. package/routes/api.js +642 -0
  23. package/routes/datatime.js +16 -0
  24. package/routes/db.js +145 -0
  25. package/routes/index.js +28 -0
  26. package/routes/nppBackup/sql.js.2024-07-08_082213.bak +25 -0
  27. package/routes/nppBackup/sql.js.2024-07-08_082214.bak +25 -0
  28. package/routes/sql.js +25 -0
  29. package/routes/switch.js +33 -0
  30. package/routes/switch1.js +12 -0
  31. package/views/addroom.ejs +223 -0
  32. package/views/addstu.ejs +318 -0
  33. package/views/error.ejs +3 -0
  34. package/views/hisinfo.ejs +442 -0
  35. package/views/hisinfo1.ejs +291 -0
  36. package/views/login.ejs +227 -0
  37. package/views/modroom.ejs +365 -0
  38. package/views/modstu.ejs +375 -0
  39. package/views/rtinfo.ejs +342 -0
  40. package/views/rtinfo1.ejs +268 -0
package/routes/db.js ADDED
@@ -0,0 +1,145 @@
1
+ var express = require('express');
2
+ var router = express.Router();
3
+ const db = require('./sql.js');
4
+
5
+ router.get('/init', (req, res, next) => {
6
+ db.query('DELETE FROM records;', (err, result) => {
7
+ if (err) {
8
+ console.error('Error initializing database:', err);
9
+ res.status(500).send('Database initialization failed');
10
+ } else {
11
+ next();
12
+ }
13
+ });
14
+ }, (req, res) => {
15
+ res.redirect(301, '/#tab1=111');
16
+ });
17
+
18
+
19
+ router.post('/insert_user', (req, res, next) => {
20
+ db.query('INSERT INTO members (stuid,name,cardid,type) VALUES (?,?,?,?);', [req.body.insertstuid, req.body.insertname, req.body.insertcardid, req.body.inserttype], function (err, result) {
21
+ if (err == null) {
22
+ res.send({'status': 'ok', 'err': null});
23
+ } else {
24
+ console.log('insert user failed, the reason is ' + err);
25
+ res.send({'status': 'error', 'err': err.toString()});
26
+ }
27
+ });
28
+ });
29
+
30
+ router.post('/insert_room', (req, res, next) => {
31
+ db.query('INSERT INTO rooms (num,mac) VALUES (?,?);', [req.body.insertnum, req.body.insertmac], function (err, result) {
32
+ if (err == null) {
33
+ res.send({'status': 'ok', 'err': null});
34
+ } else {
35
+ console.log('insert user failed, the reason is ' + err);
36
+ res.send({'status': 'error', 'err': err.toString()});
37
+ }
38
+ });
39
+ });
40
+
41
+ router.post('/insert_admin', (req, res, next) => {
42
+ db.query('INSERT INTO admins (username,password) VALUES (?,?);', [req.body.insertusername, req.body.insertpassword], function (err, result) {
43
+ if (err == null) {
44
+ res.send('ok');
45
+ } else {
46
+ console.log('insert user failed, the reason is ' + err);
47
+ res.send('error');
48
+ }
49
+ });
50
+ });
51
+
52
+ router.post('/delete_users', (req, res, next) => {
53
+ var id = parseInt(req.body.id);
54
+ db.query('DELETE FROM members WHERE id = ?', id, function (err, result) {
55
+ if (err) {
56
+ console.log(err);
57
+ } else {
58
+ res.send({ 'status': 'success' });
59
+ }
60
+ });
61
+ });
62
+
63
+ router.post('/delete_rooms', (req, res, next) => {
64
+ var id = parseInt(req.body.id);
65
+ db.query('DELETE FROM rooms WHERE id = ?', id, function (err, result) {
66
+ if (err) {
67
+ console.log(err);
68
+ } else {
69
+ res.send({ 'status': 'success' });
70
+ }
71
+ });
72
+ });
73
+
74
+ router.post('/delete_admins', (req, res, next) => {
75
+ var id = parseInt(req.body.id);
76
+ db.query('DELETE FROM admins WHERE id = ?', id, function (err, result) {
77
+ if (err) {
78
+ console.log(err);
79
+ } else {
80
+ res.send({ 'status': 'success' });
81
+ }
82
+ });
83
+ });
84
+
85
+ router.post('/update_users', (req, res, next) => {
86
+ var stuid = req.body.stuid;
87
+ var name = req.body.name;
88
+ var cardid = req.body.cardid;
89
+ var type = req.body.type;
90
+ db.query('SELECT * FROM members WHERE cardid =?', req.body.cardid, function (error, row){
91
+ if (error) {
92
+ console.error(error);
93
+ }
94
+ else{
95
+ if (row.length > 0){
96
+ db.query('UPDATE members SET name = ?, type = ? WHERE stuid =?', [name, type, stuid], function (err, result) {
97
+ if (err == null) {
98
+ res.send({'status': 'ok', 'err': null});
99
+ } else {
100
+ console.log('insert user failed, the reason is ' + err);
101
+ res.send({'status': 'error', 'err': err.toString()});
102
+ }
103
+ });
104
+ }
105
+ else{
106
+ db.query('UPDATE members SET cardid = ?, name = ?, type = ? WHERE stuid =?', [cardid, name, type, stuid], function (err, result) {
107
+ if (err == null) {
108
+ res.send({'status': 'ok', 'err': null});
109
+ } else {
110
+ console.log('insert user failed, the reason is ' + err);
111
+ res.send({'status': 'error', 'err': err.toString()});
112
+ }
113
+ });
114
+ }
115
+ }
116
+ });
117
+
118
+
119
+ });
120
+
121
+ router.post('/update_rooms', (req, res, next) => {
122
+ db.query('UPDATE rooms SET mac = ? WHERE num =?', [req.body.mac, req.body.num]);
123
+ res.send({ 'status': 'ok' });
124
+ });
125
+
126
+ router.post('/update_admins', (req, res, next) => {
127
+ db.query('SELECT * FROM admins WHERE username = ?;', req.body.oldusername, (err, row) => {
128
+ if (req.body.oldpassword == row[0].password) {
129
+ if (req.body.newpassword == '') {
130
+ db.query('UPDATE admins SET username = ? WHERE id = ?', [req.body.newusername, req.body.id]);
131
+ res.send({ 'status': 'success', 'sign': 0 });
132
+ }
133
+ else {
134
+ db.query('UPDATE admins SET username = ?, password = ? WHERE id = ?', [req.body.newusername, req.body.newpassword, req.body.id]);
135
+ res.send({ 'status': 'success', 'sign': 0 });
136
+ }
137
+ }
138
+ else {
139
+ res.send({ 'status': 'success', 'sign': 1 });
140
+ }
141
+ });
142
+ });
143
+
144
+
145
+ module.exports = router;
@@ -0,0 +1,28 @@
1
+ var express = require('express');
2
+ var router = express.Router();
3
+ var EventEmitter = require('events').EventEmitter;
4
+ var event = new EventEmitter();
5
+
6
+ /* GET home page. */
7
+ router.get('/', function(req, res, next) {
8
+ res.render('login');
9
+ });
10
+
11
+ router.post('/', function(req, res, next) {
12
+ // let data = '';
13
+ // req.on('data', chunk => {
14
+ // data += chunk;
15
+ // console.log(data);
16
+ // });
17
+
18
+ // req.on('end', () => {
19
+ // const jsonData = JSON.parse(data);
20
+
21
+ // var mac = jsonData.mac;
22
+ // var uid = jsonData.uid;
23
+
24
+ // event.emit('MyJsonData', mac, uid);
25
+ // });
26
+ });
27
+
28
+ module.exports = router;
@@ -0,0 +1,25 @@
1
+ var express = require('express');
2
+ var router = express.Router();
3
+ var mysql = require('mysql');
4
+
5
+ /* GET home page. */
6
+ router.get('/', function (req, res, next) {
7
+ res.render('index', { title: 'Express' });
8
+ });
9
+
10
+ const connection = mysql.createConnection({
11
+ host: 'localhost',
12
+ user: 'root',
13
+ password: '123', /* 123456 */
14
+ database: 'example'
15
+ });
16
+
17
+ connection.connect(function (err) {
18
+ if (err) {
19
+ console.error('连接错误: ' + err.stack);
20
+ return;
21
+ }
22
+ console.log('连接ID:' + connection.threadId);
23
+ });
24
+
25
+ module.exports = connection;
@@ -0,0 +1,25 @@
1
+ var express = require('express');
2
+ var router = express.Router();
3
+ var mysql = require('mysql');
4
+
5
+ /* GET home page. */
6
+ router.get('/', function (req, res, next) {
7
+ res.render('index', { title: 'Express' });
8
+ });
9
+
10
+ const connection = mysql.createConnection({
11
+ host: 'localhost',
12
+ user: 'root',
13
+ password: '123456', /* 123456 */
14
+ database: 'example'
15
+ });
16
+
17
+ connection.connect(function (err) {
18
+ if (err) {
19
+ console.error('连接错误: ' + err.stack);
20
+ return;
21
+ }
22
+ console.log('连接ID:' + connection.threadId);
23
+ });
24
+
25
+ module.exports = connection;
package/routes/sql.js ADDED
@@ -0,0 +1,25 @@
1
+ var express = require('express');
2
+ var router = express.Router();
3
+ var mysql = require('mysql');
4
+
5
+ /* GET home page. */
6
+ router.get('/', function (req, res, next) {
7
+ res.render('index', { title: 'Express' });
8
+ });
9
+
10
+ const connection = mysql.createConnection({
11
+ host: 'localhost',
12
+ user: 'root',
13
+ password: '69775&',
14
+ database: 'example'
15
+ });
16
+
17
+ connection.connect(function (err) {
18
+ if (err) {
19
+ console.error('连接错误: ' + err.stack);
20
+ return;
21
+ }
22
+ console.log('连接ID:' + connection.threadId);
23
+ });
24
+
25
+ module.exports = connection;
@@ -0,0 +1,33 @@
1
+ var express = require('express');
2
+ var router = express.Router();
3
+
4
+ /* GET home page. */
5
+ router.get('/index2', function(req, res, next) {
6
+ res.render('index2');
7
+ });
8
+
9
+ router.get('/', function(req, res, next) {
10
+ res.render('rtinfo');
11
+ });
12
+
13
+ router.get('/hisinfo', function(req, res, next) {
14
+ res.render('hisinfo');
15
+ });
16
+
17
+ router.get('/modstu', function(req, res, next) {
18
+ res.render('modstu');
19
+ });
20
+
21
+ router.get('/addstu', function(req, res, next) {
22
+ res.render('addstu');
23
+ });
24
+
25
+ router.get('/modroom', function(req, res, next) {
26
+ res.render('modroom');
27
+ });
28
+
29
+ router.get('/addroom', function(req, res, next) {
30
+ res.render('addroom');
31
+ });
32
+
33
+ module.exports = router;
@@ -0,0 +1,12 @@
1
+ var express = require('express');
2
+ var router = express.Router();
3
+
4
+ router.get('/', function(req, res, next) {
5
+ res.render('rtinfo1');
6
+ });
7
+
8
+ router.get('/hisinfo', function(req, res, next) {
9
+ res.render('hisinfo1');
10
+ });
11
+
12
+ module.exports = router;
@@ -0,0 +1,223 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <title>签到管理系统</title>
7
+ <meta name="renderer" content="webkit">
8
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1">
10
+ <link href="/css/layui.css" rel="stylesheet">
11
+ <style>
12
+ .layui-header {
13
+ height: 60px;
14
+ background-color: #10081a !important; /* 深蓝色 */
15
+ }
16
+ .layui-layout-left {
17
+ margin-left: 0 !important;
18
+ }
19
+
20
+ .layui-layout-right {
21
+ margin-right: 0 !important;
22
+ }
23
+
24
+ body {
25
+ font-size: 16px;
26
+ /*字体大小*/
27
+ color: #010704;
28
+ /*字体颜色*/
29
+ }
30
+
31
+ .footer-bg {
32
+ background-image: url('https://p2.ssl.qhimgs1.com/t017677196113fc982c.jpg');
33
+ background-size: cover;
34
+ background-position: center;
35
+ height: 200px;
36
+ }
37
+
38
+ .layui-side {
39
+ background-color: #9ca58d !important;
40
+ }
41
+ </style>
42
+ </head>
43
+
44
+ <body style="background-image: url('https://p2.ssl.qhimgs1.com/t017677196113fc982c.jpg'); background-size: cover; background-repeat: no-repeat; background-position: center; background-attachment: fixed;">
45
+ <div class="layui-layout layui-layout-admin">
46
+ <div class="header-bg">
47
+ <!-- 顶部导航栏 -->
48
+ <div class="layui-header">
49
+ <div class="layui-logo layui-hide-xs layui-bg-black">签到管理系统</div>
50
+
51
+ <!-- 导航菜单 -->
52
+ <ul class="layui-nav layui-layout-left">
53
+ <li class="layui-nav-item">
54
+ <a href="javascript:;"><i class="layui-icon layui-icon-user"></i> 学生信息管理</a>
55
+ <dl class="layui-nav-child">
56
+ <dd><a href="modstu"><i class="layui-icon layui-icon-edit"></i> 查询与更新</a></dd>
57
+ <dd><a href="addstu"><i class="layui-icon layui-icon-add-1"></i> 新增学生信息</a></dd>
58
+ </dl>
59
+ </li>
60
+ <li class="layui-nav-item">
61
+ <a href="javascript:;"><i class="layui-icon layui-icon-set"></i> 设备标识管理</a>
62
+ <dl class="layui-nav-child">
63
+ <dd><a href="modroom"><i class="layui-icon layui-icon-edit"></i> 查询与更新</a></dd>
64
+ <dd><a href="addroom"><i class="layui-icon layui-icon-add-1"></i> 新增设备信息</a></dd>
65
+ </dl>
66
+ </li>
67
+ </ul>
68
+
69
+ <!-- 右侧用户菜单 -->
70
+ <ul class="layui-nav layui-layout-right">
71
+ <li class="layui-nav-item layui-hide layui-show-sm-inline-block">
72
+ <a href="javascript:;">
73
+ <img src="https://pic.rmb.bdstatic.com/359341f4f00ad8453f6eb04b433c35ad.jpeg" class="layui-nav-img">
74
+ <!-- tester -->
75
+ </a>
76
+ <dl class="layui-nav-child">
77
+ <!-- <dd><a href="javascript:;">修改登录密码</a></dd>
78
+ <dd><a href="javascript:;">修改绑定手机</a></dd> -->
79
+ <dd><a href="/">登出</a></dd>
80
+ </dl>
81
+ </li>
82
+ <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
83
+ <a href="javascript:;">
84
+ <i class="layui-icon layui-icon-more-vertical"></i>
85
+ </a>
86
+ </li>
87
+ </ul>
88
+ </div>
89
+ </div>
90
+
91
+ <!-- 左侧导航栏 -->
92
+ <div class="layui-side layui-bg-black">
93
+ <ul class="layui-nav layui-nav-tree" lay-filter="test">
94
+ <li class="layui-nav-item">
95
+ <a href="/switch"><i class="layui-icon layui-icon-ok"></i> 实时签到信息</a>
96
+ </li>
97
+ <li class="layui-nav-item">
98
+ <a href="hisinfo"><i class="layui-icon layui-icon-chart"></i> 历史签到信息</a>
99
+ </li>
100
+ </ul>
101
+ </div>
102
+
103
+ <div class="center">
104
+ <div class="layui-body" style="width: 50%; height: 100%">
105
+ <div class="layui-row" id="insert_room">
106
+ <div class="layui-col-md11">
107
+ <form class="layui-form" action="" id="insert2" name="insert2">
108
+ <div class="layui-form-item layui-row" style="margin-top: 40px;">
109
+ <label class="layui-form-label">房间号:</label>
110
+ <div class="layui-input-inline">
111
+ <input type="text" id="insertnum" name="insertnum" class="layui-input"
112
+ lay-verify="required|number|roomnum" style="width: 350px">
113
+ </div>
114
+ </div>
115
+ <div class="layui-form-item layui-row">
116
+ <label class="layui-form-label">mac:</label>
117
+ <div class="layui-input-inline">
118
+ <input type="text" id="insertmac" name="insertmac" class="layui-input" lay-verify="mac"
119
+ style="width: 350px">
120
+ </div>
121
+ </div>
122
+ <div class=" layui-form-item layui-row">
123
+ <div class="layui-input-block">
124
+ <button class="layui-btn" lay-submit lay-filter="formDemo2">提交</button>
125
+ <button type="reset" class="layui-btn layui-btn-primary">重置</button>
126
+ </div>
127
+ </div>
128
+ </form>
129
+ </div>
130
+ </div>
131
+ </div>
132
+ </div>
133
+
134
+ <div class="layui-footer">
135
+ 不积跬步,无以至千里。
136
+ </div>
137
+ </div>
138
+
139
+ <script src="/layui.js"></script>
140
+ <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.js"></script>
141
+
142
+ <script>
143
+ //JS
144
+ layui.use(['element', 'layer', 'util', 'table', 'laydate', 'form'], function () {
145
+ var element = layui.element;
146
+ var layer = layui.layer;
147
+ var util = layui.util;
148
+ var table = layui.table;
149
+ var laydate = layui.laydate;
150
+ var $ = layui.$;
151
+ var form = layui.form;
152
+
153
+ function checkExistence(url, fieldName) {
154
+ return function (value, item) {
155
+ var checkResult = "";
156
+ if (value === "") {
157
+ return "不能为空";
158
+ }
159
+ $.ajax({
160
+ url: url,
161
+ type: "POST",
162
+ data: {
163
+ idinput: value
164
+ },
165
+ async: false,
166
+ success: function (result) {
167
+ if (result.sign == 0) {
168
+ checkResult = `${fieldName}已存在`;
169
+ }
170
+ },
171
+ error: function (xhr, status, error) {
172
+ layer.msg("服务器响应错误");
173
+ }
174
+ });
175
+ return checkResult;
176
+ };
177
+ }
178
+
179
+ form.verify({
180
+ roomnum: checkExistence("/api/inputcheck2", "房间号"),
181
+ mac: checkExistence("/api/inputcheck3", "机器码")
182
+ });
183
+
184
+ form.on('submit(formDemo2)', function (data) {
185
+ $.ajax({
186
+ type: 'post',
187
+ url: '/db/insert_room',
188
+ data: data.field,
189
+ success: function (data) {
190
+ if (data.status == 'ok') {
191
+ layer.msg('添加成功!');
192
+ } else if (data.status == 'error') {
193
+ layer.msg('添加失败! 原因是:' + data.err);
194
+ }
195
+ }
196
+ });
197
+ return false;
198
+ });
199
+
200
+ //头部事件
201
+ util.event('lay-header-event', {
202
+ menuLeft: function (othis) { // 左侧菜单事件
203
+ layer.msg('展开左侧菜单的操作', { icon: 0 });
204
+ },
205
+ menuRight: function () { // 右侧菜单事件
206
+ layer.open({
207
+ type: 1,
208
+ title: '作者',
209
+ content: '<div style="padding: 15px;">信息工程学院<br/>李秉蔚、蒋金鹏</div>',
210
+ area: ['150px', '100%'],
211
+ offset: 'rt', // 右上角
212
+ anim: 'slideLeft', // 从右侧抽屉滑出
213
+ shadeClose: true,
214
+ scrollbar: false
215
+ });
216
+ }
217
+ });
218
+ });
219
+ </script>
220
+
221
+ </body>
222
+
223
+ </html>