|
@@ -14,6 +14,8 @@ import configure |
|
@@ -14,6 +14,8 @@ import configure |
14
|
from app.decorators.auth_decorator import auth_decorator
|
14
|
from app.decorators.auth_decorator import auth_decorator
|
15
|
import time
|
15
|
import time
|
16
|
from app.models import SM3, AESHelper
|
16
|
from app.models import SM3, AESHelper
|
|
|
17
|
+from app.util.component.StructurePrint import StructurePrint
|
|
|
18
|
+import traceback
|
17
|
|
19
|
|
18
|
|
20
|
|
19
|
def current_user():
|
21
|
def current_user():
|
|
@@ -184,26 +186,29 @@ class DataManager(BlueprintApi): |
|
@@ -184,26 +186,29 @@ class DataManager(BlueprintApi): |
184
|
@staticmethod
|
186
|
@staticmethod
|
185
|
@bp.route("/init", methods=["GET"])
|
187
|
@bp.route("/init", methods=["GET"])
|
186
|
def init():
|
188
|
def init():
|
187
|
- username = 'admin'
|
|
|
188
|
- password = SM3.encode('DMap@123')
|
|
|
189
|
- if not User.query.filter_by(username=username).one_or_none():
|
|
|
190
|
- user = User(username=username, password=password, role='admin',
|
|
|
191
|
- phone='', company='', position='', email='',
|
|
|
192
|
- create_time=time.strftime(
|
|
|
193
|
- "%Y-%m-%d %H:%M:%S", time.localtime()),
|
|
|
194
|
- update_time=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
|
|
|
195
|
- db.sesion.add(user)
|
|
|
196
|
- db.session.commit()
|
|
|
197
|
- return "创建默认用户成功"
|
|
|
198
|
- else:
|
|
|
199
|
- return "默认用户已存在"
|
|
|
200
|
-
|
189
|
+ try:
|
|
|
190
|
+ username = 'admin'
|
|
|
191
|
+ password = SM3.encode('DMap@123')
|
|
|
192
|
+ if not User.query.filter_by(username=username).one_or_none():
|
|
|
193
|
+ user = User(username=username, password=password, role='admin',
|
|
|
194
|
+ phone='', company='', position='', email='',
|
|
|
195
|
+ create_time=time.strftime(
|
|
|
196
|
+ "%Y-%m-%d %H:%M:%S", time.localtime()),
|
|
|
197
|
+ update_time=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
|
|
|
198
|
+ db.session.add(user)
|
|
|
199
|
+ db.session.commit()
|
|
|
200
|
+ return "创建默认用户成功"
|
|
|
201
|
+ else:
|
|
|
202
|
+ return "默认用户已存在"
|
|
|
203
|
+ except Exception as e:
|
|
|
204
|
+ StructurePrint().print(e.__str__()+":" + traceback.format_exc(), "error")
|
|
|
205
|
+
|
201
|
@staticmethod
|
206
|
@staticmethod
|
202
|
@bp.route("/translate", methods=["GET"])
|
207
|
@bp.route("/translate", methods=["GET"])
|
203
|
def translate():
|
208
|
def translate():
|
204
|
- password = ['esri@123','admin','DMap@123','passwd']
|
209
|
+ password = ['esri@123', 'admin', 'DMap@123', 'passwd']
|
205
|
result = {}
|
210
|
result = {}
|
206
|
for p in password:
|
211
|
for p in password:
|
207
|
new_pwd = SM3.encode(p)
|
212
|
new_pwd = SM3.encode(p)
|
208
|
result[p] = new_pwd
|
213
|
result[p] = new_pwd
|
209
|
- return result |
|
|
|
|
214
|
+ return result |