mirror of
https://github.com/ccmjga/zhilu-admin
synced 2026-03-24 11:53:41 +08:00
init
This commit is contained in:
38
frontend/src/composables/position/usePositionBind.ts
Normal file
38
frontend/src/composables/position/usePositionBind.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import client from "@/api/client";
|
||||
|
||||
export function usePositionBind() {
|
||||
const bindPosition = async (userId: number, positionIds: number[]) => {
|
||||
try {
|
||||
await client.POST("/iam/position/bind", {
|
||||
body: {
|
||||
userId,
|
||||
positionIds,
|
||||
},
|
||||
});
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error("Error binding positions:", error);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const unbindPosition = async (userId: number, positionIds: number[]) => {
|
||||
try {
|
||||
await client.POST("/iam/position/unbind", {
|
||||
body: {
|
||||
userId,
|
||||
positionIds,
|
||||
},
|
||||
});
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error("Error unbinding positions:", error);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
bindPosition,
|
||||
unbindPosition,
|
||||
};
|
||||
}
|
||||
18
frontend/src/composables/position/usePositionDelete.ts
Normal file
18
frontend/src/composables/position/usePositionDelete.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import client from "@/api/client";
|
||||
|
||||
export const usePositionDelete = () => {
|
||||
const deletePosition = async (positionId: number) => {
|
||||
await client.DELETE("/position", {
|
||||
params: {
|
||||
query: {
|
||||
id: positionId,
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
return {
|
||||
deletePosition,
|
||||
};
|
||||
};
|
||||
|
||||
export default usePositionDelete;
|
||||
45
frontend/src/composables/position/usePositionQuery.ts
Normal file
45
frontend/src/composables/position/usePositionQuery.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import client from "@/api/client";
|
||||
import { ref } from "vue";
|
||||
import type { components } from "../../api/types/schema";
|
||||
|
||||
export const usePositionQuery = () => {
|
||||
const total = ref<number>(0);
|
||||
const positions = ref<components["schemas"]["PositionRespDto"][]>([]);
|
||||
const allPositions = ref<components["schemas"]["Position"][]>([]);
|
||||
|
||||
const fetchAllPositions = async () => {
|
||||
const { data } = await client.GET("/position/query");
|
||||
allPositions.value = data ?? [];
|
||||
};
|
||||
const fetchPositionWith = async (
|
||||
param: {
|
||||
name?: string;
|
||||
enable?: boolean;
|
||||
userId?: number;
|
||||
bindState?: "ALL" | "BIND" | "UNBIND";
|
||||
},
|
||||
page = 1,
|
||||
size = 10,
|
||||
) => {
|
||||
const { data } = await client.GET("/position/page-query", {
|
||||
params: {
|
||||
query: {
|
||||
pageRequestDto: {
|
||||
page,
|
||||
size,
|
||||
},
|
||||
positionQueryDto: param,
|
||||
},
|
||||
},
|
||||
});
|
||||
total.value = !data || !data.total ? 0 : data.total;
|
||||
positions.value = data?.data ?? [];
|
||||
};
|
||||
return {
|
||||
total,
|
||||
positions,
|
||||
allPositions,
|
||||
fetchPositionWith,
|
||||
fetchAllPositions,
|
||||
};
|
||||
};
|
||||
16
frontend/src/composables/position/usePositionUpsert.ts
Normal file
16
frontend/src/composables/position/usePositionUpsert.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import client from "../../api/client";
|
||||
import type { components } from "../../api/types/schema";
|
||||
|
||||
export const usePositionUpsert = () => {
|
||||
const upsertPosition = async (
|
||||
position: components["schemas"]["Position"],
|
||||
) => {
|
||||
await client.POST("/position", {
|
||||
body: position,
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
upsertPosition,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user