diff --git a/dsAiTeachingModel/api/controller/UserController.py b/dsAiTeachingModel/api/controller/UserController.py index e23d8f5f..2b1d1a3f 100644 --- a/dsAiTeachingModel/api/controller/UserController.py +++ b/dsAiTeachingModel/api/controller/UserController.py @@ -3,6 +3,7 @@ import re from fastapi import APIRouter, Request, Response, Depends from auth.dependencies import * +from utils.CommonUtil import md5_encrypt from utils.Database import * from utils.ParseRequest import * @@ -20,7 +21,7 @@ async def modify_telephone(request: Request): # 校验手机号码是否已被注册 select_telephone_sql: str = "select * from t_sys_loginperson where b_use = 1 and telephone = '" + telephone + "' and person_id <> '" + person_id + "'" userlist = await find_by_sql(select_telephone_sql, ()) - if len(userlist) > 0: + if userlist is not None: return {"success": False, "message": "手机号码已被注册"} else: update_telephone_sql: str = "update t_sys_loginperson set telephone = '" + telephone + "' where person_id = '" + person_id + "'" @@ -29,4 +30,21 @@ async def modify_telephone(request: Request): # 【Base-User-2】维护用户密码 -# @router.post("/modifyPassword") +@router.post("/modifyPassword") +async def modify_password(request: Request): + person_id = await get_request_str_param(request, "person_id", True, True) + old_password = await get_request_str_param(request, "old_password", True, True) + password = await get_request_str_param(request, "password", True, True) + # 校验旧密码是否正确 + select_password_sql: str = "select pwdmd5 from t_sys_loginperson where person_id = '" + person_id + "' and b_use = 1" + userlist = await find_by_sql(select_password_sql, ()) + if len(userlist) == 0: + return {"success": False, "message": "用户不存在"} + else: + if userlist[0]["pwdmd5"] != md5_encrypt(old_password): + return {"success": False, "message": "旧密码错误"} + else: + update_password_sql: str = "update t_sys_loginperson set original_pwd = '" + password + "',pwdmd5 = '" + md5_encrypt(password) + "' where person_id = '" + person_id + "'" + await execute_sql(update_password_sql) + return {"success": True, "message": "修改成功"} + diff --git a/dsLightRag/WxGzh/T2_GetArticleList.py b/dsLightRag/WxGzh/T2_GetArticleList.py index 001c2ec3..d958d01d 100644 --- a/dsLightRag/WxGzh/T2_GetArticleList.py +++ b/dsLightRag/WxGzh/T2_GetArticleList.py @@ -17,7 +17,6 @@ import requests from Util.PostgreSQLUtil import init_postgres_pool from Util.WxGzhUtil import init_wechat_browser, get_article_content - # 在程序开始时添加以下配置 logging.basicConfig( level=logging.INFO, # 设置日志级别为INFO @@ -31,6 +30,7 @@ handler = logging.StreamHandler() handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')) logger.addHandler(handler) + async def get_wechat_sources(): """从t_wechat_source表获取微信公众号列表""" try: @@ -65,9 +65,10 @@ async def is_article_exist(pool, article_url): try: async with pool.acquire() as conn: row = await conn.fetchrow(''' - SELECT 1 FROM t_wechat_articles - WHERE url = $1 LIMIT 1 - ''', article_url) + SELECT 1 + FROM t_wechat_articles + WHERE url = $1 LIMIT 1 + ''', article_url) return row is not None except Exception as e: logging.error(f"检查文章存在性失败: {e}") @@ -79,15 +80,15 @@ async def save_article_to_db(pool, article_title, account_name, article_url, pub if await is_article_exist(pool, article_url): logging.info(f"文章已存在,跳过保存: {article_url}") return - + try: async with pool.acquire() as conn: await conn.execute(''' - INSERT INTO t_wechat_articles - (title, source, url, publish_time, content, source_id) - VALUES ($1, $2, $3, $4, $5, $6) - ''', article_title, account_name, article_url, - publish_time, content, id) + INSERT INTO t_wechat_articles + (title, source, url, publish_time, content, source_id) + VALUES ($1, $2, $3, $4, $5, $6) + ''', article_title, account_name, article_url, + publish_time, content, id) except Exception as e: logging.error(f"保存文章失败: {e}") @@ -105,7 +106,7 @@ if __name__ == '__main__': # 换算出过期时间 expiry_time = time.localtime(expiry) expiry_date = time.strftime("%Y-%m-%d %H:%M:%S", expiry_time) - logger.info("cookies的过期时间一般是4天,cookies过期时间:", expiry_date) + logger.info(f"cookies的过期时间一般是4天,cookies过期时间:%s" % expiry_date) # 获取当前时间戳 current_timestamp = time.time() # 检查是否已过期