perf: User status api

This commit is contained in:
fit2cloud-chenyw
2025-07-27 15:03:18 +08:00
parent c4188a056c
commit db7fbca31d
5 changed files with 32 additions and 13 deletions
+14 -1
View File
@@ -5,7 +5,7 @@ from apps.system.crud.user import check_account_exists, check_email_exists, chec
from apps.system.models.system_model import UserWsModel
from apps.system.models.user import UserModel
from apps.system.schemas.auth import CacheName, CacheNamespace
from apps.system.schemas.system_schema import PwdEditor, UserCreator, UserEditor, UserGrid, UserLanguage, UserWs
from apps.system.schemas.system_schema import PwdEditor, UserCreator, UserEditor, UserGrid, UserLanguage, UserStatus, UserWs
from common.core.deps import CurrentUser, SessionDep, Trans
from common.core.pagination import Paginator
from common.core.schemas import PaginatedResponse, PaginationParams
@@ -218,4 +218,17 @@ async def pwdUpdate(session: SessionDep, current_user: CurrentUser, editor: PwdE
raise Exception(f"pwd [{editor.pwd}] error")
db_user.password = md5pwd(new_pwd)
session.add(db_user)
session.commit()
@router.patch("/status")
@clear_cache(namespace=CacheNamespace.AUTH_INFO, cacheName=CacheName.USER_INFO, keyExpression="statusDto.id")
async def langChange(session: SessionDep, current_user: CurrentUser, statusDto: UserStatus):
if not current_user.isAdmin:
raise Exception("no permission to execute")
status = statusDto.status
if status not in [0, 1]:
return {"message": "status not supported"}
db_user: UserModel = get_db_user(session=session, user_id=statusDto.id)
db_user.status = status
session.add(db_user)
session.commit()
+3 -3
View File
@@ -14,9 +14,9 @@ PWD_REGEX = re.compile(
r"(?=.*[~!@#$%^&*()_+\-={}|:\"<>?`\[\];',./])"
r"[A-Za-z\d~!@#$%^&*()_+\-={}|:\"<>?`\[\];',./]{8,20}$"
)
class model_status(BaseModel):
status: bool
ids: list[int]
class UserStatus(BaseCreatorDTO):
status: int = 1
class UserLanguage(BaseModel):
+1
View File
@@ -25,4 +25,5 @@ export const userApi = {
deleteBatch: (data: any) => request.delete(`/user`, { data }),
get: (key: string) => request.get(`/user/${key}`),
pwd: (id: any) => request.patch(`/user/pwd/${id}`),
status: (data: any) => request.patch('/user/status', data),
}
+1 -1
View File
@@ -359,7 +359,7 @@ const handleEmbedded = (row: any) => {
scriptElement.value = `g-#script
async
defer
id="${row.id}"
id="sqlbot-assistant-float-script-${row.id}"
src="${origin + pathname}assistant.js?id=${row.id}"k-*g-#/scriptk-*`
.replaceAll('g-#', '<')
.replaceAll('k-*', '>')
+13 -8
View File
@@ -124,17 +124,17 @@
</el-icon>
</el-tooltip>
<el-popover
:ref="
(el: any) => {
setPopoverRef(el, scope.row)
}
"
placement="right"
virtual-triggering
:width="300"
:virtual-ref="scope.row.buttonRef"
trigger="click"
show-arrow
:ref="
(el: any) => {
setPopoverRef(el, scope.row)
}
"
>
<div class="reset-pwd-confirm">
<div class="confirm-header">
@@ -147,7 +147,7 @@
</div>
<div class="confirm-content">
<span>SQLBot@123456</span>
<el-button @click="copyText" style="margin-left: 4px" text>{{
<el-button style="margin-left: 4px" text @click="copyText">{{
t('datasource.copy')
}}</el-button>
</div>
@@ -620,8 +620,13 @@ const editHandler = (row: any) => {
}
const statusHandler = (row: any) => {
state.form = { ...row }
editTerm()
/* state.form = { ...row }
editTerm() */
const param = {
id: row.id,
status: row.status,
}
userApi.status(param)
}
const cancelDelete = () => {