Showing
4 changed files
with
66 additions
and
66 deletions
1 | /** | 1 | /** |
2 | * | 2 | * |
3 | - * @author: jiangfeng<jeff.jiang@yoho.cn> | ||
4 | - * @date: 16/8/22 | 3 | + * @author: shijian<jian.shi@yoho.cn> |
4 | + * @date: 17/5/31 | ||
5 | */ | 5 | */ |
6 | 6 | ||
7 | 'use strict'; | 7 | 'use strict'; |
8 | 8 | ||
9 | const Router = require('koa-router'); | 9 | const Router = require('koa-router'); |
10 | const moment = require('moment'); | 10 | const moment = require('moment'); |
11 | +const redisStore = require('koa-redis'); | ||
12 | +const redis = require("redis"); | ||
13 | +const client = redis.createClient(); | ||
14 | +const multi = client.multi(); | ||
15 | + | ||
16 | +client.on("error", function (err) { | ||
17 | + console.log("Error " + err); | ||
18 | +}); | ||
11 | 19 | ||
12 | const { | 20 | const { |
13 | OperationLogger | 21 | OperationLogger |
@@ -15,46 +23,46 @@ const { | @@ -15,46 +23,46 @@ const { | ||
15 | 23 | ||
16 | const r = new Router(); | 24 | const r = new Router(); |
17 | 25 | ||
18 | -r.get('/', async(ctx) => { | ||
19 | - await ctx.render('action/keywords'); | ||
20 | -}); | 26 | +const setData = ()=>{ |
27 | + client.set('keywords_mana:aaa', 'aaa'); | ||
28 | + client.set('keywords_mana:bbb', 'bbb'); | ||
29 | + let arr = ['keywords_mana:aaa', 'keywords_mana:bbb']; | ||
21 | 30 | ||
22 | -// r.post('/log/query', async(ctx) => { | 31 | + for (var i=0; i<arr.length; i++) { |
32 | + multi.sadd('keywords_mana_list', arr[i]); | ||
33 | + } | ||
23 | 34 | ||
24 | -// let q = ctx.request.body; | 35 | + multi.exec(function(errors, results) { |
25 | 36 | ||
26 | -// let start = parseInt(q.start || 0, 10); | ||
27 | -// let length = parseInt(q.length || 10, 10); | ||
28 | -// let draw = parseInt(q.draw, 10); | 37 | + }); |
38 | +} | ||
29 | 39 | ||
30 | -// let sort = {time: -1}; | ||
31 | -// if (q.order && q.order.length > 0) { | ||
32 | -// let col = q.order[0].column; | ||
33 | -// let dir = q.order[0].dir === 'desc' ? -1 : 1; | 40 | +const getData = async(key)=>{ |
41 | + multi.smembers(key); | ||
42 | + return new Promise(function (resolve, reject) { | ||
43 | + multi.exec(function(errors, results) { | ||
44 | + resolve(results); | ||
45 | + }); | ||
46 | + }); | ||
47 | +} | ||
34 | 48 | ||
35 | -// col = parseInt(col, 10); | ||
36 | -// if (q.columns && q.columns.length > col) { | ||
37 | -// sort = {}; | ||
38 | -// sort[q.columns[col].data] = dir; | ||
39 | -// } | ||
40 | -// } | 49 | +r.get('/', async(ctx) => { |
50 | + await ctx.render('action/keywords'); | ||
51 | +}); | ||
52 | + | ||
53 | +r.get('/getKeywords', async(ctx) => { | ||
41 | 54 | ||
42 | -// let logs = await OperationLogger.cfind({}).sort(sort).skip(start).limit(length).exec(); | ||
43 | -// let total = await OperationLogger.count(); | 55 | + let q = ctx.request.query; |
44 | 56 | ||
45 | -// logs.forEach(l => { | ||
46 | -// l.username = l.user.username; | ||
47 | -// l.time = moment(l.time).format('YYYY-MM-DD HH:mm:ss.sss'); | ||
48 | -// l.meta = JSON.stringify(l.meta || {}); | ||
49 | -// }); | 57 | + let r = await getData("keywords_mana_list"); |
50 | 58 | ||
51 | -// ctx.body = { | ||
52 | -// draw: draw, | ||
53 | -// recordsTotal: total, | ||
54 | -// recordsFiltered: total, | ||
55 | -// data: logs | ||
56 | -// }; | 59 | + ctx.body = { |
60 | + code: 200, | ||
61 | + message: 'success', | ||
62 | + data: r[0] | ||
63 | + }; | ||
57 | 64 | ||
58 | -// }); | 65 | + |
66 | +}); | ||
59 | 67 | ||
60 | module.exports = r; | 68 | module.exports = r; |
@@ -14,41 +14,25 @@ | @@ -14,41 +14,25 @@ | ||
14 | <!-- media --> | 14 | <!-- media --> |
15 | </div> | 15 | </div> |
16 | 16 | ||
17 | -<div class="contentpanel project-index-page"> | 17 | +<div class="contentpanel project-index-page" style="padding-bottom:0;"> |
18 | <div class="panel panel-default"> | 18 | <div class="panel panel-default"> |
19 | <div class="panel-body"> | 19 | <div class="panel-body"> |
20 | - <table id="table-oper-log" class="table table-striped table-bordered building-table"> | ||
21 | - <thead> | ||
22 | - <tr> | ||
23 | - <th>操作用户</th> | ||
24 | - <th>时间</th> | ||
25 | - <th>动作</th> | ||
26 | - <th>描述</th> | ||
27 | - <th>数据</th> | ||
28 | - </tr> | ||
29 | - </thead> | ||
30 | - </table> | 20 | + <label style="margin-right:20px;"><input type="checkbox" style="margin-right:5px;">全选</label> |
21 | + <button class="btn btn-default" type="submit" style="margin-right:10px;">增加</button> | ||
22 | + <button class="btn btn-default" type="submit">删除</button> | ||
31 | </div> | 23 | </div> |
32 | </div> | 24 | </div> |
33 | </div> | 25 | </div> |
34 | 26 | ||
35 | -<div class="contentpanel project-index-page"> | 27 | +<div class="contentpanel project-index-page" style="padding-top:0;"> |
36 | <div class="panel panel-default"> | 28 | <div class="panel panel-default"> |
37 | - <div class="panel-heading"> | ||
38 | - <div class="pull-right"> | ||
39 | - <a href="" class="tooltips panel-minimize"><i class="fa fa-minus"></i></a> | ||
40 | - </div> | ||
41 | - <h4 class="panel-title">操作日志</h4> | ||
42 | - </div> | ||
43 | <div class="panel-body"> | 29 | <div class="panel-body"> |
44 | <table id="table-oper-log" class="table table-striped table-bordered building-table"> | 30 | <table id="table-oper-log" class="table table-striped table-bordered building-table"> |
45 | <thead> | 31 | <thead> |
46 | <tr> | 32 | <tr> |
47 | - <th>操作用户</th> | ||
48 | - <th>时间</th> | ||
49 | - <th>动作</th> | ||
50 | - <th>描述</th> | ||
51 | - <th>数据</th> | 33 | + <th>ID</th> |
34 | + <th>关键词</th> | ||
35 | + <th>操作</th> | ||
52 | </tr> | 36 | </tr> |
53 | </thead> | 37 | </thead> |
54 | </table> | 38 | </table> |
@@ -59,24 +43,30 @@ | @@ -59,24 +43,30 @@ | ||
59 | <script> | 43 | <script> |
60 | 44 | ||
61 | $(document).on('ready pjax:success', function() { | 45 | $(document).on('ready pjax:success', function() { |
62 | - $("#table-oper-log").DataTable({ | 46 | + /**$("#table-oper-log").DataTable({ |
63 | pageLength: 25, | 47 | pageLength: 25, |
64 | retrieve: true, | 48 | retrieve: true, |
65 | responsive: true, | 49 | responsive: true, |
66 | processing: true, | 50 | processing: true, |
67 | serverSide: true, | 51 | serverSide: true, |
68 | ajax: { | 52 | ajax: { |
69 | - url: '/operation/log/query', | ||
70 | - type: "POST" | 53 | + url: '/keywords/getKeywords', |
54 | + type: "GET" | ||
71 | }, | 55 | }, |
72 | columns: [ | 56 | columns: [ |
73 | - {data: "username"}, | ||
74 | - {data: "time"}, | ||
75 | - {data: "action"}, | ||
76 | - {data: "description"}, | ||
77 | - {data: "meta"} | 57 | + {data: "datas"}, |
58 | + {data: "datas"}, | ||
59 | + {data: "datas"} | ||
78 | ], | 60 | ], |
79 | order: [[1, 'desc']] | 61 | order: [[1, 'desc']] |
62 | + });**/ | ||
63 | + $.get('/keywords/getKeywords', function(data){console.log(data); | ||
64 | + var html=''; | ||
65 | + let datas=data.data; | ||
66 | + datas.forEach(function(item, index){ | ||
67 | + html+='<tr><td>'+index+'</td><td>'+item+'</td><td><button class="btn btn-default" type="submit">编辑</button><button class="btn btn-default" type="submit">删除</button></td></tr>'; | ||
68 | + }); | ||
69 | + $('#table-oper-log').html($('#table-oper-log').html()+html); | ||
80 | }); | 70 | }); |
81 | }); | 71 | }); |
82 | </script> | 72 | </script> |
package-lock.json
0 → 100644
This diff could not be displayed because it is too large.
@@ -39,6 +39,7 @@ | @@ -39,6 +39,7 @@ | ||
39 | "koa-body": "^1.4.0", | 39 | "koa-body": "^1.4.0", |
40 | "koa-convert": "^1.2.0", | 40 | "koa-convert": "^1.2.0", |
41 | "koa-mount": "^2.0.0", | 41 | "koa-mount": "^2.0.0", |
42 | + "koa-redis": "^3.0.0", | ||
42 | "koa-router": "^7.0.1", | 43 | "koa-router": "^7.0.1", |
43 | "koa-session": "^3.3.1", | 44 | "koa-session": "^3.3.1", |
44 | "koa-static": "^3.0.0", | 45 | "koa-static": "^3.0.0", |
@@ -57,6 +58,7 @@ | @@ -57,6 +58,7 @@ | ||
57 | "qcloudapi-sdk": "^0.1.5", | 58 | "qcloudapi-sdk": "^0.1.5", |
58 | "qn": "^1.3.0", | 59 | "qn": "^1.3.0", |
59 | "qs": "^6.2.0", | 60 | "qs": "^6.2.0", |
61 | + "redis": "^2.7.1", | ||
60 | "request-promise": "^4.1.1", | 62 | "request-promise": "^4.1.1", |
61 | "shelljs": "^0.7.0", | 63 | "shelljs": "^0.7.0", |
62 | "socket.io": "^1.4.6", | 64 | "socket.io": "^1.4.6", |
-
Please register or login to post a comment