diff --git a/backend/apps/system/api/user.py b/backend/apps/system/api/user.py index 8d697a44..d048ef6f 100644 --- a/backend/apps/system/api/user.py +++ b/backend/apps/system/api/user.py @@ -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() \ No newline at end of file diff --git a/backend/apps/system/schemas/system_schema.py b/backend/apps/system/schemas/system_schema.py index ecec9ed2..7ea29e67 100644 --- a/backend/apps/system/schemas/system_schema.py +++ b/backend/apps/system/schemas/system_schema.py @@ -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): diff --git a/frontend/src/api/user.ts b/frontend/src/api/user.ts index 041cf605..ed2e32c0 100644 --- a/frontend/src/api/user.ts +++ b/frontend/src/api/user.ts @@ -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), } diff --git a/frontend/src/views/system/embedded/index.vue b/frontend/src/views/system/embedded/index.vue index a0966878..20a3369d 100644 --- a/frontend/src/views/system/embedded/index.vue +++ b/frontend/src/views/system/embedded/index.vue @@ -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-*', '>') diff --git a/frontend/src/views/system/user/User.vue b/frontend/src/views/system/user/User.vue index d74f816a..0ee8da38 100644 --- a/frontend/src/views/system/user/User.vue +++ b/frontend/src/views/system/user/User.vue @@ -124,17 +124,17 @@
@@ -147,7 +147,7 @@
SQLBot@123456 - {{ + {{ t('datasource.copy') }}
@@ -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 = () => {