diff --git a/README.md b/README.md index 9fec6a0..d1695f5 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@

logo

-

RuoYi-Vue3-FastAPI v1.7.0

+

RuoYi-Vue3-FastAPI v1.7.1

基于RuoYi-Vue3+FastAPI前后端分离的快速开发框架

- + diff --git a/ruoyi-fastapi-backend/.env.dev b/ruoyi-fastapi-backend/.env.dev index 397c44a..a792ea9 100644 --- a/ruoyi-fastapi-backend/.env.dev +++ b/ruoyi-fastapi-backend/.env.dev @@ -10,7 +10,7 @@ APP_HOST = '0.0.0.0' # 应用端口 APP_PORT = 9099 # 应用版本 -APP_VERSION= '1.7.0' +APP_VERSION= '1.7.1' # 应用是否开启热重载 APP_RELOAD = true # 应用是否开启IP归属区域查询 diff --git a/ruoyi-fastapi-backend/.env.prod b/ruoyi-fastapi-backend/.env.prod index 11b8303..e932e39 100644 --- a/ruoyi-fastapi-backend/.env.prod +++ b/ruoyi-fastapi-backend/.env.prod @@ -10,7 +10,7 @@ APP_HOST = '0.0.0.0' # 应用端口 APP_PORT = 9099 # 应用版本 -APP_VERSION= '1.7.0' +APP_VERSION= '1.7.1' # 应用是否开启热重载 APP_RELOAD = false # 应用是否开启IP归属区域查询 diff --git a/ruoyi-fastapi-backend/module_generator/templates/python/controller.py.jinja2 b/ruoyi-fastapi-backend/module_generator/templates/python/controller.py.jinja2 index 4d5a12e..13cc466 100644 --- a/ruoyi-fastapi-backend/module_generator/templates/python/controller.py.jinja2 +++ b/ruoyi-fastapi-backend/module_generator/templates/python/controller.py.jinja2 @@ -1,10 +1,14 @@ {% set pkField = pkColumn.python_field %} {% set pk_field = pkColumn.python_field | camel_to_snake %} +{% set need_import_datetime = namespace(has_datetime=False) %} {% for column in columns %} -{% if column.python_field == "createTime" %} -from datetime import datetime +{% if column.python_field in ["createTime", "updatetime"] %} +{% set need_import_datetime.has_datetime = True %} {% endif %} {% endfor %} +{% if need_import_datetime.has_datetime %} +from datetime import datetime +{% endif %} from fastapi import APIRouter, Depends, Form, Request from pydantic_validation_decorator import ValidateFields from sqlalchemy.ext.asyncio import AsyncSession @@ -82,8 +86,13 @@ async def edit_{{ moduleName }}_{{ businessName }}( query_db: AsyncSession = Depends(get_db), current_user: CurrentUserModel = Depends(LoginService.get_current_user), ): + {% for column in columns %} + {% if column.python_field == "updateBy" %} edit_{{ businessName }}.update_by = current_user.user.user_name + {% elif column.python_field == "updateTime" %} edit_{{ businessName }}.update_time = datetime.now() + {% endif %} + {% endfor %} edit_{{ businessName }}_result = await {{ BusinessName }}Service.edit_{{ businessName }}_services(query_db, edit_{{ businessName }}) logger.info(edit_{{ businessName }}_result.message) diff --git a/ruoyi-fastapi-backend/module_generator/templates/python/do.py.jinja2 b/ruoyi-fastapi-backend/module_generator/templates/python/do.py.jinja2 index 22c23c4..c7ea757 100644 --- a/ruoyi-fastapi-backend/module_generator/templates/python/do.py.jinja2 +++ b/ruoyi-fastapi-backend/module_generator/templates/python/do.py.jinja2 @@ -13,6 +13,7 @@ class {{ ClassName }}(Base): """ __tablename__ = '{{ tableName }}' + __table_args__ = {'comment': '{{ tableComment }}'} {% for column in columns %} {{ column.column_name }} = Column({{ column.column_type | get_sqlalchemy_type }}, {% if column.pk %}primary_key=True, {% endif %}{% if column.increment %}autoincrement=True, {% endif %}{% if column.required or column.pk %}nullable=False{% else %}nullable=True{% endif %}, comment='{{ column.column_comment }}') diff --git a/ruoyi-fastapi-backend/requirements-pg.txt b/ruoyi-fastapi-backend/requirements-pg.txt index c9d1c24..9dbf1fd 100644 --- a/ruoyi-fastapi-backend/requirements-pg.txt +++ b/ruoyi-fastapi-backend/requirements-pg.txt @@ -2,12 +2,12 @@ alembic==1.16.4 APScheduler==3.11.0 async-lru==2.0.5 asyncpg==0.30.0 +bcrypt==5.0.0 DateTime==5.5 fastapi[all]==0.116.1 loguru==0.7.3 openpyxl==3.1.5 pandas==2.3.2 -passlib[bcrypt]==1.7.4 Pillow==11.3.0 psutil==7.0.0 pydantic-validation-decorator==0.1.4 diff --git a/ruoyi-fastapi-backend/requirements.txt b/ruoyi-fastapi-backend/requirements.txt index 9040b49..af66bc7 100644 --- a/ruoyi-fastapi-backend/requirements.txt +++ b/ruoyi-fastapi-backend/requirements.txt @@ -2,12 +2,12 @@ alembic==1.16.4 APScheduler==3.11.0 async-lru==2.0.5 asyncmy==0.2.10 +bcrypt==5.0.0 DateTime==5.5 fastapi[all]==0.116.1 loguru==0.7.3 openpyxl==3.1.5 pandas==2.3.2 -passlib[bcrypt]==1.7.4 Pillow==11.3.0 psutil==7.0.0 pydantic-validation-decorator==0.1.4 diff --git a/ruoyi-fastapi-backend/utils/pwd_util.py b/ruoyi-fastapi-backend/utils/pwd_util.py index 86e9c27..c3f91ce 100644 --- a/ruoyi-fastapi-backend/utils/pwd_util.py +++ b/ruoyi-fastapi-backend/utils/pwd_util.py @@ -1,6 +1,4 @@ -from passlib.context import CryptContext - -pwd_context = CryptContext(schemes=['bcrypt'], deprecated='auto') +import bcrypt class PwdUtil: @@ -9,7 +7,7 @@ class PwdUtil: """ @classmethod - def verify_password(cls, plain_password, hashed_password): + def verify_password(cls, plain_password: str, hashed_password: str) -> bool: """ 工具方法:校验当前输入的密码与数据库存储的密码是否一致 @@ -17,7 +15,9 @@ class PwdUtil: :param hashed_password: 数据库存储的密码 :return: 校验结果 """ - return pwd_context.verify(plain_password, hashed_password) + return ( + bcrypt.checkpw(plain_password.encode('utf-8'), hashed_password.encode('utf-8')) if hashed_password else None + ) @classmethod def get_password_hash(cls, input_password): @@ -27,4 +27,4 @@ class PwdUtil: :param input_password: 输入的密码 :return: 加密成功的密码 """ - return pwd_context.hash(input_password) + return bcrypt.hashpw(input_password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8') diff --git a/ruoyi-fastapi-backend/utils/template_util.py b/ruoyi-fastapi-backend/utils/template_util.py index 6765bd0..afe5c41 100644 --- a/ruoyi-fastapi-backend/utils/template_util.py +++ b/ruoyi-fastapi-backend/utils/template_util.py @@ -73,6 +73,7 @@ class TemplateUtils: context = { 'tplCategory': tpl_category, 'tableName': gen_table.table_name, + 'tableComment': gen_table.table_comment, 'functionName': function_name if StringUtil.is_not_empty(function_name) else '【请填写功能名称】', 'ClassName': class_name, 'className': class_name.lower(), diff --git a/ruoyi-fastapi-frontend/package.json b/ruoyi-fastapi-frontend/package.json index 9ba7998..aaec05c 100644 --- a/ruoyi-fastapi-frontend/package.json +++ b/ruoyi-fastapi-frontend/package.json @@ -1,6 +1,6 @@ { "name": "vfadmin", - "version": "1.7.0", + "version": "1.7.1", "description": "vfadmin管理系统", "author": "insistence", "license": "MIT",