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'''