|
@@ -1,5 +1,5 @@
|
|
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
|
|
-import { tenantClient } from '../api/tenantClient';
|
|
|
|
|
|
|
+import { tenantClientManager, tenantClient } from '../api/tenantClient';
|
|
|
import { toast } from 'sonner';
|
|
import { toast } from 'sonner';
|
|
|
|
|
|
|
|
export interface UseTenantsOptions {
|
|
export interface UseTenantsOptions {
|
|
@@ -22,7 +22,7 @@ export function useTenants(options: UseTenantsOptions = {}) {
|
|
|
const query = useQuery({
|
|
const query = useQuery({
|
|
|
queryKey: ['tenants', page, pageSize, keyword, filters],
|
|
queryKey: ['tenants', page, pageSize, keyword, filters],
|
|
|
queryFn: async () => {
|
|
queryFn: async () => {
|
|
|
- const res = await tenantClient.index.$get({
|
|
|
|
|
|
|
+ const res = await tenantClientManager.get().index.$get({
|
|
|
query: {
|
|
query: {
|
|
|
page,
|
|
page,
|
|
|
pageSize,
|
|
pageSize,
|
|
@@ -41,7 +41,7 @@ export function useTenants(options: UseTenantsOptions = {}) {
|
|
|
|
|
|
|
|
const createMutation = useMutation({
|
|
const createMutation = useMutation({
|
|
|
mutationFn: async (data: Parameters<typeof tenantClient.index.$post>[0]['json']) => {
|
|
mutationFn: async (data: Parameters<typeof tenantClient.index.$post>[0]['json']) => {
|
|
|
- const res = await tenantClient.index.$post({ json: data });
|
|
|
|
|
|
|
+ const res = await tenantClientManager.get().index.$post({ json: data });
|
|
|
if (res.status !== 201) {
|
|
if (res.status !== 201) {
|
|
|
throw new Error('创建租户失败');
|
|
throw new Error('创建租户失败');
|
|
|
}
|
|
}
|
|
@@ -58,7 +58,7 @@ export function useTenants(options: UseTenantsOptions = {}) {
|
|
|
|
|
|
|
|
const updateMutation = useMutation({
|
|
const updateMutation = useMutation({
|
|
|
mutationFn: async ({ id, data }: { id: number; data: Parameters<typeof tenantClient[':id']['$put']>[0]['json'] }) => {
|
|
mutationFn: async ({ id, data }: { id: number; data: Parameters<typeof tenantClient[':id']['$put']>[0]['json'] }) => {
|
|
|
- const res = await tenantClient[':id']['$put']({
|
|
|
|
|
|
|
+ const res = await tenantClientManager.get()[':id']['$put']({
|
|
|
param: { id },
|
|
param: { id },
|
|
|
json: data
|
|
json: data
|
|
|
});
|
|
});
|
|
@@ -78,7 +78,7 @@ export function useTenants(options: UseTenantsOptions = {}) {
|
|
|
|
|
|
|
|
const deleteMutation = useMutation({
|
|
const deleteMutation = useMutation({
|
|
|
mutationFn: async (id: number) => {
|
|
mutationFn: async (id: number) => {
|
|
|
- const res = await tenantClient[':id']['$delete']({
|
|
|
|
|
|
|
+ const res = await tenantClientManager.get()[':id']['$delete']({
|
|
|
param: { id }
|
|
param: { id }
|
|
|
});
|
|
});
|
|
|
if (res.status !== 204) {
|
|
if (res.status !== 204) {
|