完成项目管理模块的接口测试
This commit is contained in:
@ -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
|
||||
|
@ -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")
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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] = []
|
||||
|
@ -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)
|
||||
|
@ -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"}
|
||||
|
@ -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:
|
||||
|
@ -6,19 +6,14 @@
|
||||
# @desc : 主要接口文件
|
||||
|
||||
from redis.asyncio import Redis
|
||||
from fastapi import APIRouter, Depends, Body, UploadFile, Form, Request
|
||||
from fastapi import APIRouter, Depends, Body
|
||||
from motor.motor_asyncio import AsyncIOMotorDatabase
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from application.settings import ALIYUN_OSS
|
||||
from core.database import db_getter, redis_getter, mongo_getter
|
||||
from utils.file.aliyun_oss import AliyunOSS, BucketConf
|
||||
from utils.huawei_obs import ObsClient
|
||||
from utils.file.file_manage import FileManage
|
||||
from core.database import redis_getter, mongo_getter
|
||||
from utils.response import SuccessResponse, ErrorResponse
|
||||
from utils.sms.code import CodeSMS
|
||||
from . import schemas, crud
|
||||
from core.dependencies import IdList
|
||||
from apps.vadmin.auth.utils.current import AllUserAuth, FullAdminAuth, OpenAuth
|
||||
from apps.vadmin.auth.utils.current import AllUserAuth, OpenAuth
|
||||
from apps.vadmin.auth.utils.validation.auth import Auth
|
||||
from .params import DictTypeParams, DictDetailParams, TaskParams
|
||||
from apps.vadmin.auth import crud as vadmin_auth_crud
|
||||
|
Reference in New Issue
Block a user