完成项目管理模块的接口测试

This commit is contained in:
2025-04-18 17:22:57 +08:00
parent 434e1af3e8
commit 7a9e571a96
16 changed files with 91 additions and 74 deletions

View File

@ -18,7 +18,7 @@ from sqlalchemy import select, false, and_
from core.crud import DalBase
from sqlalchemy.ext.asyncio import AsyncSession
from core.validator import vali_telephone
from utils.huawei_obs import ObsClient
from utils.huawei_obs import MyObs
from utils.excel.import_manage import ImportManage, FieldType
from utils.excel.write_xlsx import WriteXlsx
from utils.send_email import EmailSender
@ -221,8 +221,6 @@ class UserDal(DalBase):
value = getattr(user, field, "")
if field == "is_active":
value = "可用" if value else "停用"
elif field == "is_staff":
value = "" if value else ""
elif field == "gender":
result = list(filter(lambda i: i["value"] == value, options["gender_options"]))
value = result[0]["label"] if result else ""
@ -397,7 +395,7 @@ class UserDal(DalBase):
:param file:
:return:
"""
success, key, url = await ObsClient().put_object("avatar"+"/"+user.name+file.filename, file)
success, key, url = MyObs().put_object("avatar"+"/"+user.name+file.filename, file)
user.avatar = url
await self.flush(user)
return url

View File

@ -37,7 +37,6 @@ class VadminUser(BaseModel):
)
last_ip: Mapped[str | None] = mapped_column(String(50), comment="最后一次登录IP")
last_login: Mapped[datetime | None] = mapped_column(DateTime, comment="最近一次登录时间")
is_staff: Mapped[bool] = mapped_column(Boolean, default=False, comment="是否为工作人员")
wx_server_openid: Mapped[str | None] = mapped_column(String(255), comment="服务端微信平台openid")
is_wx_server_openid: Mapped[bool] = mapped_column(Boolean, default=False, comment="是否已有服务端微信平台openid")

View File

@ -24,7 +24,6 @@ class UserParams(QueryParams):
telephone: str | None = Query(None, title="手机号"),
email: str | None = Query(None, title="邮箱"),
is_active: bool | None = Query(None, title="是否可用"),
is_staff: bool | None = Query(None, title="是否为工作人员"),
params: Paging = Depends()
):
super().__init__(params)
@ -32,6 +31,5 @@ class UserParams(QueryParams):
self.telephone = ("like", telephone)
self.email = ("like", email)
self.is_active = is_active
self.is_staff = is_staff

View File

@ -21,7 +21,6 @@ class User(BaseModel):
nickname: str | None = None
avatar: str | None = None
is_active: bool | None = True
is_staff: bool | None = True
gender: str | None = "0"
is_wx_server_openid: bool | None = False
@ -56,7 +55,6 @@ class UserUpdate(User):
nickname: str | None = None
avatar: str | None = None
is_active: bool | None = True
is_staff: bool | None = False
gender: str | None = "0"
role_ids: list[int] = []
dept_ids: list[int] = []

View File

@ -103,8 +103,7 @@ class FullAdminAuth(AuthValidation):
telephone=telephone,
password=password,
v_return_none=True,
v_options=options,
is_staff=True
v_options=options
)
result = await self.validate_user(request, user, db, is_all=False)
permissions = self.get_user_permissions(user)

View File

@ -57,8 +57,6 @@ async def api_login_for_access_token(
raise CustomException(status_code=error_code, code=error_code, msg="手机号或密码错误")
if not user.is_active:
raise CustomException(status_code=error_code, code=error_code, msg="此手机号已被冻结")
elif not user.is_staff:
raise CustomException(status_code=error_code, code=error_code, msg="此手机号无权限")
access_token = LoginManage.create_token({"sub": user.telephone, "password": user.password})
record = LoginForm(platform='2', method='0', telephone=data.username, password=data.password)
resp = {"access_token": access_token, "token_type": "bearer"}

View File

@ -80,7 +80,7 @@ class LoginValidation:
await db.flush()
elif not user.is_active:
self.result.msg = "此手机号已被冻结!"
elif data.platform in ["0", "1"] and not user.is_staff:
elif data.platform in ["0", "1"]:
self.result.msg = "此手机号无权限!"
else:
if not DEMO and count: