From 2a51b4bae8f6872a7fdad2b57a5cf32a5211c7c6 Mon Sep 17 00:00:00 2001 From: apan Date: Thu, 28 Jul 2022 18:19:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A8=A1=E6=9D=BF=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db_logic/medicament_template.py | 13 ++++++++----- db_logic/user.py | 12 +++++------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/db_logic/medicament_template.py b/db_logic/medicament_template.py index 807f554..de3f991 100644 --- a/db_logic/medicament_template.py +++ b/db_logic/medicament_template.py @@ -22,14 +22,17 @@ class BllMedicamentTemplate(Repository): # 获取所有模板列表 def getAllTemplateList(self, client_id, page_param): - sql_all = "select %s from rms_medicament_template where is_wait_export=1 " + sql_all = "select * from rms_medicament_template where is_wait_export=1 " end_sql = "order by create_date desc" if client_id: sql_all = sql_all + f"and client_id='{client_id}'" - - page_param.totalRecords = self.execute(sql_all% ("count(*)")).fetchone()[0] - sql_all = Utils.sql_paging_assemble(sql_all % "*" + end_sql, page_param) - data = self.execute(sql_all % "*").fetchall() + try: + count_number = len(self.execute(sql_all).fetchall()) + except Exception: + count_number = 0 + page_param.totalRecords = count_number + sql_all = Utils.sql_paging_assemble(sql_all + end_sql, page_param) + data = self.execute(sql_all).fetchall() return data # 批量或删除单个模板 diff --git a/db_logic/user.py b/db_logic/user.py index 0281d53..5e77da0 100644 --- a/db_logic/user.py +++ b/db_logic/user.py @@ -23,13 +23,11 @@ class BllUser(Repository): #用户账号密码登录 def login(self, user_name, password): user_info = self.findEntity(EntityUser.account == user_name) - if user_info.is_enabled: - if user_info.check_password(password): - return self.get_jwt(user_info) - else: - return False - else: - return False + if user_info: + if user_info.is_enabled: + if user_info.check_password(password): + return self.get_jwt(user_info) + return False def get_jwt(self, obj, expires_in=36000): '''用户登录后,发放有效的 JWT'''