feat: add role ID validation messages and update batch delete logic in user management

This commit is contained in:
wxg0103 2025-12-24 15:09:11 +08:00
parent 31903a36c2
commit bfc43fcb52
6 changed files with 38 additions and 8 deletions

View File

@ -8880,4 +8880,13 @@ msgid "Import knowledge workflow"
msgstr ""
msgid "Export knowledge workflow"
msgstr ""
msgid "Role IDs cannot be empty"
msgstr ""
msgid "Role IDs"
msgstr ""
msgid "Some roles do not exist"
msgstr ""

View File

@ -9007,3 +9007,12 @@ msgstr "导入知识工作流"
msgid "Export knowledge workflow"
msgstr "导出知识工作流"
msgid "Role IDs cannot be empty"
msgstr "角色 ID 不能为空"
msgid "Role IDs"
msgstr "角色 ID"
msgid "Some roles do not exist"
msgstr "部分角色不存在"

View File

@ -9007,3 +9007,12 @@ msgstr "匯入知識工作流"
msgid "Export knowledge workflow"
msgstr "匯出知識工作流"
msgid "Role IDs cannot be empty"
msgstr "角色 ID 不能为空"
msgid "Role IDs"
msgstr "角色 ID"
msgid "Some roles do not exist"
msgstr "部分角色不存在"

View File

@ -578,12 +578,10 @@ class UserManageSerializer(serializers.Serializer):
ids = serializers.ListField(required=True, label=_('User IDs'))
def batch_delete(self, with_valid=True):
if with_valid:
self.is_valid(raise_exception=True)
ids = self.data.get('ids')
if not ids:
user_ids = self.data.get('ids')
if not user_ids:
raise AppApiException(1004, _('User IDs cannot be empty'))
User.objects.filter(id__in=ids).delete()
User.objects.filter(id__in=user_ids).exclude(id='f0dd8f71-e4ee-11ee-8c84-a8a1595801ab').delete()
return True
def get_all_user_list(self):

View File

@ -247,7 +247,7 @@ class UserManage(APIView):
@log(menu='User management', operate='Batch delete user',
get_operation_object=lambda r, k: get_user_operation_object(k.get('user_id')))
def post(self, request: Request):
return result.success(UserManageSerializer.BatchDelete(data=request.data).batch_delete(with_valid=True))
return result.success(UserManageSerializer.BatchDelete({'ids': request.data}).batch_delete(with_valid=True))
class RePassword(APIView):
authentication_classes = [TokenAuth]

View File

@ -66,7 +66,6 @@ const putUserManagePassword: (
}
/**
*
*/
@ -90,6 +89,12 @@ const getValid: (
return get(`/valid/${valid_type}/${valid_count}`, undefined, loading)
}
const batchDelete: (
ids: string[],
loading?: Ref<boolean>
) => Promise<Result<any>> = (ids, loading) => {
return post(`/user_manage/batch_delete`, ids, {}, loading)
}
export default {
getUserManage,
@ -99,5 +104,5 @@ export default {
putUserManagePassword,
getSystemDefaultPassword,
getValid,
batchDelete
}