提交 0c8d478e5ebf9bdf4accfb07004e7fc4254fe2e1
Merge branch 'master' of http://gitlab.ctune.cn/weijunh/DMapManager
正在显示
3 个修改的文件
包含
21 行增加
和
18 行删除
... | ... | @@ -14,6 +14,8 @@ import configure |
14 | 14 | from app.decorators.auth_decorator import auth_decorator |
15 | 15 | import time |
16 | 16 | from app.models import SM3, AESHelper |
17 | +from app.util.component.StructurePrint import StructurePrint | |
18 | +import traceback | |
17 | 19 | |
18 | 20 | |
19 | 21 | def current_user(): |
... | ... | @@ -184,26 +186,29 @@ class DataManager(BlueprintApi): |
184 | 186 | @staticmethod |
185 | 187 | @bp.route("/init", methods=["GET"]) |
186 | 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 | 206 | @staticmethod |
202 | 207 | @bp.route("/translate", methods=["GET"]) |
203 | 208 | def translate(): |
204 | - password = ['esri@123','admin','DMap@123','passwd'] | |
209 | + password = ['esri@123', 'admin', 'DMap@123', 'passwd'] | |
205 | 210 | result = {} |
206 | 211 | for p in password: |
207 | 212 | new_pwd = SM3.encode(p) |
208 | 213 | result[p] = new_pwd |
209 | - return result | |
\ No newline at end of file | ||
214 | + return result | ... | ... |
请
注册
或
登录
后发表评论