chenjunkai 6 jaren geleden
bovenliggende
commit
d70d39a3fa

+ 1 - 0
.gitignore

@@ -4,3 +4,4 @@
 /web/.idea/
 /object/__pycache__
 /langer/__pycache__
+/controller/__pycache__

+ 1 - 1
controller/LangArea.py

@@ -23,6 +23,7 @@ from django.contrib.auth.hashers import make_password, check_password
 from model.models import UserModel, LangSetModel, LangAreaModel, LangValModel, LangKeyModel
 import time
 from object.TokenObject import TokenObject
+from django.http import StreamingHttpResponse
 
 
 class LangAreaView(TemplateView):
@@ -158,7 +159,6 @@ class LangAreaView(TemplateView):
                 # 正则表达式
                 # re.sub("[a-z]+", "$", "123abc78ab9cdeg00t8")
                 content = content + '<string name="' + lk + '">' + res[l] + '</string>\n'
-        from django.http import StreamingHttpResponse
         response = StreamingHttpResponse(content)
         response['Content-Type'] = 'application/octet-stream'
         response['Content-Disposition'] = 'attachment;filename="lang.txt"'

+ 8 - 1
controller/LangWord.py

@@ -11,7 +11,7 @@
 @file: LangArea.py
 @Contact: chanjunkai@163.com
 """
-
+from var_dump import var_dump
 import json
 from django.http import HttpResponse
 
@@ -74,6 +74,12 @@ class LangWordView(TemplateView):
             'updTime': nowTime
         }
         try:
+            # var_dump(lang_key_dict)
+            lk = LangKeyModel.objects.filter(word_key=word_key)
+            if lk.exists():
+                var_dump(list(lk))
+
+                return response.json(473,'key已存在')
             lk = LangKeyModel.objects.create(**lang_key_dict)
             for w in word_arr:
                 LangValModel.objects.create(la_id=w['la_id'], lk_id=lk.id, addTime=nowTime, updTime=nowTime,
@@ -156,6 +162,7 @@ class LangWordView(TemplateView):
             if searchKey and searchVal:
                 if searchKey == 'key':
                     lk_qs = lk_qs.filter(word_key__contains=searchVal)
+                    # lk_qs = lk_qs.filter(word_key=searchVal)
                 else:
                     lk_qs = lk_qs.filter(langvalmodel__word_val__contains=searchVal, langvalmodel__la__lang=searchKey)
             count = lk_qs.count()

BIN
controller/__pycache__/LangArea.cpython-36.pyc


BIN
controller/__pycache__/LangWord.cpython-36.pyc


BIN
controller/__pycache__/User.cpython-36.pyc


+ 2 - 1
object/ResponseObject.py

@@ -15,7 +15,8 @@ class ResponseObject(object):
             403: 'permission denied',
             404: 'Server error',
             414: 'Invalid request path !',
-            444: 'Wrong Parameter!'
+            444: 'Wrong Parameter!',
+            473: 'The same value exists !'
         }
         result = {'code': code, 'msg': msg_data[code], 'res': res}
         if extra:

+ 28 - 8
web/index.html

@@ -283,12 +283,28 @@
     let lw_data
 
     function queryData(page) {
-        let post_data = {
-            'token': $.cookie('access_token'),
-            'page': page,
-            'line': 10,
-            'orderByupdate': orderByupdate
-        };
+        let searchKey = $('input[name="optionsRadios"]:checked').val();
+        let searchVal = $('#searchInput').val()
+        var post_data = {}
+        if(searchVal) {
+            post_data = {
+                'token': $.cookie('access_token'),
+                'page': page,
+                'line': 10,
+                'orderByupdate': orderByupdate,
+                'searchKey': searchKey,
+                'searchVal': searchVal
+            };
+        }else {
+            post_data = {
+                'token': $.cookie('access_token'),
+                'page': page,
+                'line': 10,
+                'orderByupdate': orderByupdate
+            };
+        }
+
+
         $.postJSON(
             http_ip_prot + 'langWord/query', JSON.stringify(post_data),
             function (data) {
@@ -528,6 +544,10 @@
     }
 
     function searchKeyAction() {
+        var page = GetUrlParam('page')
+        if (!page) {
+            page = 1
+        }
         let searchKey = $('input[name="optionsRadios"]:checked').val();
         let searchVal = $('#searchInput').val()
         console.log('-------------------------------')
@@ -538,7 +558,7 @@
         if (searchVal && searchKey) {
             post_data = {
                 'token': $.cookie('access_token'),
-                'page': 1,
+                'page': page,
                 'line': 10,
                 'searchKey': searchKey,
                 'searchVal': searchVal
@@ -546,7 +566,7 @@
         } else {
             post_data = {
                 'token': $.cookie('access_token'),
-                'page': 1,
+                'page': page,
                 'line': 10,
             };
         }