Browse Source

解决查询日志异常

tanghongbin 4 năm trước cách đây
mục cha
commit
80fd531d50
3 tập tin đã thay đổi với 24 bổ sung4 xóa
  1. 21 1
      Controller/LogController.py
  2. 2 2
      web/UM-admin/js/jqhttpsdk.js
  3. 1 1
      web/UM-admin/umlog.html

+ 21 - 1
Controller/LogController.py

@@ -40,12 +40,14 @@ class LogView(View):
             return self.do_query_all(request_dict, token, response)
         elif operation == 'delete':
             return self.do_delete(request_dict, response)
+        elif operation == 'adminQuery':
+            return self.do_admin_query(request_dict, token, response)
         else:
             return response.json(404)
 
     def do_query(self, request_dict, token: TokenObject, response):
         page = request_dict.get('page', None)
-        line = request_dict.get('limit', None)
+        line = request_dict.get('line', None)
 
         if page and line:
             log_qs = LogModel.objects.filter(user__id=token.userID).values('id', 'operation', 'time', 'ip', 'user__username')
@@ -75,5 +77,23 @@ class LogView(View):
         if id:
             LogModel.objects.filter(id=id).delete()
             return response.json(0)
+        else:
+            return response.json(444)
+
+    def do_admin_query(self, request_dict, token: TokenObject, response):
+        page = request_dict.get('page', None)
+        line = request_dict.get('limit', None)
+
+        if page and line:
+            log_qs = LogModel.objects.filter(user__id=token.userID).values('id', 'operation', 'time', 'ip', 'user__username')
+            if log_qs.exists():
+                page = int(page)
+                line = int(line)
+                start = (page - 1) * line
+                count = log_qs.count()
+                data = log_qs[start:(start + line)]
+                return response.json(0, {'count': count, 'data': list(data)})
+            else:
+                return response.json(0, {'count': 0, 'data': []})
         else:
             return response.json(444)

+ 2 - 2
web/UM-admin/js/jqhttpsdk.js

@@ -2,8 +2,8 @@
  * 获取数据ajax-get请求
  * @author chanjunkai
  */
-http_ip_port = 'http://47.107.129.126:6639'
-// http_ip_port = 'http://192.168.136.35:8800'
+http_ip_port = 'http://47.107.129.126:6639';
+// http_ip_port = 'http://192.168.136.35:8800';
 $.GetJSON = function (url,data,callback){
     $.ajax({
         url:url,

+ 1 - 1
web/UM-admin/umlog.html

@@ -54,7 +54,7 @@
             elem: '#tablelistdata',
             //height: 600,
             height: 'full',
-            url: http_ip_port + '/log/query', //数据接口
+            url: http_ip_port + '/log/adminQuery', //数据接口
             page: true, //开启分页
             limit: 10,
             cols: [[ //表头