设置 权限流水
This commit is contained in:
@@ -1,16 +0,0 @@
|
|||||||
{
|
|
||||||
"enabled": true,
|
|
||||||
"name": "Python代码风格检查",
|
|
||||||
"description": "写 Python 代码前,提醒严格遵守 Python 端代码开发风格文档中的规范",
|
|
||||||
"version": "1",
|
|
||||||
"when": {
|
|
||||||
"type": "preToolUse",
|
|
||||||
"toolTypes": [
|
|
||||||
"write"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"then": {
|
|
||||||
"type": "askAgent",
|
|
||||||
"prompt": "写 Python 代码前请严格遵守 offerpie_python_ai/.kiro/steering/代码开发风格文档.md 中的所有规范。特别注意:紧凑风格(链式调用尽量一行)、所有函数必须有类型注解、模块级 docstring 说明用途/依赖/使用表、异步规范(async/await)、AI 输出统一用 parse_llm_json 解析。"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,7 @@ class FuncPermission(Base):
|
|||||||
__tablename__ = "bg_func_permission"
|
__tablename__ = "bg_func_permission"
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
||||||
func_code: Mapped[str] = mapped_column(String(12), nullable=False, comment="权限编码")
|
func_code: Mapped[str] = mapped_column(String(36), nullable=False, comment="权限编码")
|
||||||
func_name: Mapped[str] = mapped_column(String(64), nullable=False, comment="功能名称")
|
func_name: Mapped[str] = mapped_column(String(64), nullable=False, comment="功能名称")
|
||||||
daily_free_count: Mapped[int] = mapped_column(Integer, default=0, comment="每日免费次数,0表示无免费额度")
|
daily_free_count: Mapped[int] = mapped_column(Integer, default=0, comment="每日免费次数,0表示无免费额度")
|
||||||
status: Mapped[int] = mapped_column(Integer, default=1, comment="状态 1=启用 0=禁用")
|
status: Mapped[int] = mapped_column(Integer, default=1, comment="状态 1=启用 0=禁用")
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class UserFuncPermissionStock(Base):
|
|||||||
|
|
||||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True)
|
||||||
user_id: Mapped[int] = mapped_column(BigInteger, nullable=False, comment="用户ID")
|
user_id: Mapped[int] = mapped_column(BigInteger, nullable=False, comment="用户ID")
|
||||||
func_code: Mapped[str] = mapped_column(String(12), nullable=False, comment="权限编码")
|
func_code: Mapped[str] = mapped_column(String(36), nullable=False, comment="权限编码")
|
||||||
time_limit: Mapped[int] = mapped_column(Integer, default=0, comment="0=不限时 1=限时")
|
time_limit: Mapped[int] = mapped_column(Integer, default=0, comment="0=不限时 1=限时")
|
||||||
count_limit: Mapped[int] = mapped_column(Integer, default=0, comment="0=不限次 1=限次")
|
count_limit: Mapped[int] = mapped_column(Integer, default=0, comment="0=不限次 1=限次")
|
||||||
expire_time: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True, comment="过期时间")
|
expire_time: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True, comment="过期时间")
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class UserFuncUsageLog(Base):
|
|||||||
"""用户功能使用记录表 bg_user_func_usage_log"""
|
"""用户功能使用记录表 bg_user_func_usage_log"""
|
||||||
__tablename__ = "bg_user_func_usage_log"
|
__tablename__ = "bg_user_func_usage_log"
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=False)
|
||||||
user_id: Mapped[int] = mapped_column(BigInteger, nullable=False, comment="用户ID")
|
user_id: Mapped[int] = mapped_column(BigInteger, nullable=False, comment="用户ID")
|
||||||
func_code: Mapped[str] = mapped_column(String(12), nullable=False, comment="功能编码")
|
func_code: Mapped[str] = mapped_column(String(36), nullable=False, comment="功能编码")
|
||||||
create_time: Mapped[datetime] = mapped_column(DateTime, default=datetime.now, comment="使用时间")
|
create_time: Mapped[datetime] = mapped_column(DateTime, default=datetime.now, comment="使用时间")
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
|||||||
from app.models.func_permission import FuncPermission
|
from app.models.func_permission import FuncPermission
|
||||||
from app.models.user_func_permission_stock import UserFuncPermissionStock
|
from app.models.user_func_permission_stock import UserFuncPermissionStock
|
||||||
from app.models.user_func_usage_log import UserFuncUsageLog
|
from app.models.user_func_usage_log import UserFuncUsageLog
|
||||||
|
from app.tool.snowflake import next_id
|
||||||
|
|
||||||
|
|
||||||
class FuncPermissionService:
|
class FuncPermissionService:
|
||||||
@@ -75,7 +76,7 @@ class FuncPermissionService:
|
|||||||
|
|
||||||
async def _insert_usage_log(self, user_id: int, func_code: str) -> int:
|
async def _insert_usage_log(self, user_id: int, func_code: str) -> int:
|
||||||
"""插入使用记录,返回记录ID"""
|
"""插入使用记录,返回记录ID"""
|
||||||
usage_log = UserFuncUsageLog(user_id=user_id, func_code=func_code)
|
usage_log = UserFuncUsageLog(id=next_id(), user_id=user_id, func_code=func_code)
|
||||||
self.session.add(usage_log)
|
self.session.add(usage_log)
|
||||||
await self.session.flush()
|
await self.session.flush()
|
||||||
return usage_log.id
|
return usage_log.id
|
||||||
|
|||||||
Reference in New Issue
Block a user