|
20 | 20 | logger = logging.getLogger(__name__) |
21 | 21 |
|
22 | 22 | mysql_client = MysqlUtil() |
23 | | -pool = get_db_pool() |
| 23 | +# pool = get_db_pool() |
24 | 24 |
|
25 | 25 |
|
26 | 26 | async def authenticate_user(username, password): |
27 | 27 | """验证用户凭据并返回用户信息或 None""" |
28 | | - with pool.get_session() as session: |
29 | | - session: Session = session |
30 | | - user_dict = model_to_dict( |
31 | | - session.query(TUser).filter(TUser.userName == username).filter(TUser.password == password).first() |
32 | | - ) |
33 | | - if user_dict: |
34 | | - return user_dict |
35 | | - # sql = f"""select * from t_user where userName='{username}' and password='{password}'""" |
36 | | - # report_dict = MysqlUtil().query_mysql_dict(sql) |
37 | | - # if len(report_dict) > 0: |
38 | | - # return report_dict[0] |
39 | | - # else: |
40 | | - # return False |
| 28 | + # with pool.get_session() as session: |
| 29 | + # session: Session = session |
| 30 | + # user_dict = model_to_dict( |
| 31 | + # session.query(TUser).filter(TUser.userName == username).filter(TUser.password == password).first() |
| 32 | + # ) |
| 33 | + # if user_dict: |
| 34 | + # return user_dict |
| 35 | + sql = f"""select * from t_user where userName='{username}' and password='{password}'""" |
| 36 | + report_dict = MysqlUtil().query_mysql_dict(sql) |
| 37 | + if len(report_dict) > 0: |
| 38 | + return report_dict[0] |
| 39 | + else: |
| 40 | + return False |
41 | 41 |
|
42 | 42 |
|
43 | 43 | async def generate_jwt_token(user_id, username): |
@@ -265,13 +265,13 @@ def query_user_qa_record(chat_id): |
265 | 265 | :param chat_id: |
266 | 266 | :return: |
267 | 267 | """ |
268 | | - with pool.get_session() as session: |
269 | | - records = ( |
270 | | - session.query(TUserQaRecord).filter(TUserQaRecord.chat_id == chat_id).order_by(TUserQaRecord.id.desc()) |
271 | | - ) |
272 | | - return model_to_dict(records) |
273 | | - # sql = f"select * from t_user_qa_record where chat_id='{chat_id}' order by id desc limit 1" |
274 | | - # return mysql_client.query_mysql_dict(sql) |
| 268 | + # with pool.get_session() as session: |
| 269 | + # records = ( |
| 270 | + # session.query(TUserQaRecord).filter(TUserQaRecord.chat_id == chat_id).order_by(TUserQaRecord.id.desc()) |
| 271 | + # ) |
| 272 | + # return model_to_dict(records) |
| 273 | + sql = f"select * from t_user_qa_record where chat_id='{chat_id}' order by id desc limit 1" |
| 274 | + return mysql_client.query_mysql_dict(sql) |
275 | 275 |
|
276 | 276 |
|
277 | 277 | async def send_dify_feedback(chat_id, rating): |
|
0 commit comments