feat:【antd】【ele】统一 api 的 system、infra 实现

This commit is contained in:
YunaiV
2025-09-22 12:58:22 +08:00
parent 6ca2b0f1ca
commit a1e756c0e5
12 changed files with 37 additions and 52 deletions

View File

@@ -58,11 +58,12 @@ export function exportJob(params: any) {
/** 任务状态修改 */ /** 任务状态修改 */
export function updateJobStatus(id: number, status: number) { export function updateJobStatus(id: number, status: number) {
const params = { return requestClient.put('/infra/job/update-status', undefined, {
id, params: {
status, id,
}; status,
return requestClient.put('/infra/job/update-status', {}, { params }); },
});
} }
/** 定时任务立即执行一次 */ /** 定时任务立即执行一次 */

View File

@@ -58,7 +58,7 @@ export function deleteMailTemplate(id: number) {
return requestClient.delete(`/system/mail-template/delete?id=${id}`); return requestClient.delete(`/system/mail-template/delete?id=${id}`);
} }
/** 批量删除邮件模 */ /** 批量删除邮件模 */
export function deleteMailTemplateList(ids: number[]) { export function deleteMailTemplateList(ids: number[]) {
return requestClient.delete( return requestClient.delete(
`/system/mail-template/delete-list?ids=${ids.join(',')}`, `/system/mail-template/delete-list?ids=${ids.join(',')}`,

View File

@@ -3,7 +3,7 @@ import { requestClient } from '#/api/request';
/** OAuth2.0 授权信息响应 */ /** OAuth2.0 授权信息响应 */
export namespace SystemOAuth2ClientApi { export namespace SystemOAuth2ClientApi {
/** 授权信息 */ /** 授权信息 */
export interface AuthorizeInfoResp { export interface AuthorizeInfoRespVO {
client: { client: {
logo: string; logo: string;
name: string; name: string;
@@ -17,7 +17,7 @@ export namespace SystemOAuth2ClientApi {
/** 获得授权信息 */ /** 获得授权信息 */
export function getAuthorize(clientId: string) { export function getAuthorize(clientId: string) {
return requestClient.get<SystemOAuth2ClientApi.AuthorizeInfoResp>( return requestClient.get<SystemOAuth2ClientApi.AuthorizeInfoRespVO>(
`/system/oauth2/authorize?clientId=${clientId}`, `/system/oauth2/authorize?clientId=${clientId}`,
); );
} }

View File

@@ -32,10 +32,3 @@ export function deleteOAuth2Token(accessToken: string) {
`/system/oauth2-token/delete?accessToken=${accessToken}`, `/system/oauth2-token/delete?accessToken=${accessToken}`,
); );
} }
/** 批量删除 OAuth2.0 令牌 */
export function deleteOAuth2TokenList(accessTokens: string[]) {
return requestClient.delete(
`/system/oauth2-token/delete-list?accessTokens=${accessTokens.join(',')}`,
);
}

View File

@@ -2,19 +2,19 @@ import { requestClient } from '#/api/request';
export namespace SystemPermissionApi { export namespace SystemPermissionApi {
/** 分配用户角色请求 */ /** 分配用户角色请求 */
export interface AssignUserRoleReq { export interface AssignUserRoleReqVO {
userId: number; userId: number;
roleIds: number[]; roleIds: number[];
} }
/** 分配角色菜单请求 */ /** 分配角色菜单请求 */
export interface AssignRoleMenuReq { export interface AssignRoleMenuReqVO {
roleId: number; roleId: number;
menuIds: number[]; menuIds: number[];
} }
/** 分配角色数据权限请求 */ /** 分配角色数据权限请求 */
export interface AssignRoleDataScopeReq { export interface AssignRoleDataScopeReqVO {
roleId: number; roleId: number;
dataScope: number; dataScope: number;
dataScopeDeptIds: number[]; dataScopeDeptIds: number[];
@@ -30,14 +30,14 @@ export async function getRoleMenuList(roleId: number) {
/** 赋予角色菜单权限 */ /** 赋予角色菜单权限 */
export async function assignRoleMenu( export async function assignRoleMenu(
data: SystemPermissionApi.AssignRoleMenuReq, data: SystemPermissionApi.AssignRoleMenuReqVO,
) { ) {
return requestClient.post('/system/permission/assign-role-menu', data); return requestClient.post('/system/permission/assign-role-menu', data);
} }
/** 赋予角色数据权限 */ /** 赋予角色数据权限 */
export async function assignRoleDataScope( export async function assignRoleDataScope(
data: SystemPermissionApi.AssignRoleDataScopeReq, data: SystemPermissionApi.AssignRoleDataScopeReqVO,
) { ) {
return requestClient.post('/system/permission/assign-role-data-scope', data); return requestClient.post('/system/permission/assign-role-data-scope', data);
} }
@@ -51,7 +51,7 @@ export async function getUserRoleList(userId: number) {
/** 赋予用户角色 */ /** 赋予用户角色 */
export async function assignUserRole( export async function assignUserRole(
data: SystemPermissionApi.AssignUserRoleReq, data: SystemPermissionApi.AssignUserRoleReqVO,
) { ) {
return requestClient.post('/system/permission/assign-user-role', data); return requestClient.post('/system/permission/assign-user-role', data);
} }

View File

@@ -20,14 +20,14 @@ export namespace SystemSocialUserApi {
} }
/** 社交绑定请求 */ /** 社交绑定请求 */
export interface SocialUserBindReq { export interface SocialUserBindReqVO {
type: number; type: number;
code: string; code: string;
state: string; state: string;
} }
/** 取消社交绑定请求 */ /** 取消社交绑定请求 */
export interface SocialUserUnbindReq { export interface SocialUserUnbindReqVO {
type: number; type: number;
openid: string; openid: string;
} }
@@ -49,12 +49,12 @@ export function getSocialUser(id: number) {
} }
/** 社交绑定,使用 code 授权码 */ /** 社交绑定,使用 code 授权码 */
export function socialBind(data: SystemSocialUserApi.SocialUserBindReq) { export function socialBind(data: SystemSocialUserApi.SocialUserBindReqVO) {
return requestClient.post<boolean>('/system/social-user/bind', data); return requestClient.post<boolean>('/system/social-user/bind', data);
} }
/** 取消社交绑定 */ /** 取消社交绑定 */
export function socialUnbind(data: SystemSocialUserApi.SocialUserUnbindReq) { export function socialUnbind(data: SystemSocialUserApi.SocialUserUnbindReqVO) {
return requestClient.delete<boolean>('/system/social-user/unbind', { data }); return requestClient.delete<boolean>('/system/social-user/unbind', { data });
} }

View File

@@ -2,7 +2,7 @@ import { requestClient } from '#/api/request';
export namespace SystemUserProfileApi { export namespace SystemUserProfileApi {
/** 用户个人中心信息 */ /** 用户个人中心信息 */
export interface UserProfileResp { export interface UserProfileRespVO {
id: number; id: number;
username: string; username: string;
nickname: string; nickname: string;
@@ -19,13 +19,13 @@ export namespace SystemUserProfileApi {
} }
/** 更新密码请求 */ /** 更新密码请求 */
export interface UpdatePasswordReq { export interface UpdatePasswordReqVO {
oldPassword: string; oldPassword: string;
newPassword: string; newPassword: string;
} }
/** 更新个人信息请求 */ /** 更新个人信息请求 */
export interface UpdateProfileReq { export interface UpdateProfileReqVO {
nickname?: string; nickname?: string;
email?: string; email?: string;
mobile?: string; mobile?: string;
@@ -36,19 +36,21 @@ export namespace SystemUserProfileApi {
/** 获取登录用户信息 */ /** 获取登录用户信息 */
export function getUserProfile() { export function getUserProfile() {
return requestClient.get<SystemUserProfileApi.UserProfileResp>( return requestClient.get<SystemUserProfileApi.UserProfileRespVO>(
'/system/user/profile/get', '/system/user/profile/get',
); );
} }
/** 修改用户个人信息 */ /** 修改用户个人信息 */
export function updateUserProfile(data: SystemUserProfileApi.UpdateProfileReq) { export function updateUserProfile(
data: SystemUserProfileApi.UpdateProfileReqVO,
) {
return requestClient.put('/system/user/profile/update', data); return requestClient.put('/system/user/profile/update', data);
} }
/** 修改用户个人密码 */ /** 修改用户个人密码 */
export function updateUserPassword( export function updateUserPassword(
data: SystemUserProfileApi.UpdatePasswordReq, data: SystemUserProfileApi.UpdatePasswordReqVO,
) { ) {
return requestClient.put('/system/user/profile/update-password', data); return requestClient.put('/system/user/profile/update-password', data);
} }

View File

@@ -19,7 +19,7 @@ const authStore = useAuthStore();
const activeName = ref('basicInfo'); const activeName = ref('basicInfo');
/** 加载个人信息 */ /** 加载个人信息 */
const profile = ref<SystemUserProfileApi.UserProfileResp>(); const profile = ref<SystemUserProfileApi.UserProfileRespVO>();
async function loadProfile() { async function loadProfile() {
profile.value = await getUserProfile(); profile.value = await getUserProfile();
} }

View File

@@ -15,7 +15,7 @@ import { useVbenForm, z } from '#/adapter/form';
import { updateUserProfile } from '#/api/system/user/profile'; import { updateUserProfile } from '#/api/system/user/profile';
const props = defineProps<{ const props = defineProps<{
profile?: SystemUserProfileApi.UserProfileResp; profile?: SystemUserProfileApi.UserProfileRespVO;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'success'): void; (e: 'success'): void;
@@ -78,7 +78,7 @@ async function handleSubmit(values: Recordable<any>) {
try { try {
formApi.setLoading(true); formApi.setLoading(true);
// 提交表单 // 提交表单
await updateUserProfile(values as SystemUserProfileApi.UpdateProfileReq); await updateUserProfile(values as SystemUserProfileApi.UpdateProfileReqVO);
// 关闭并提示 // 关闭并提示
emit('success'); emit('success');
message.success($t('ui.actionMessage.operationSuccess')); message.success($t('ui.actionMessage.operationSuccess'));

View File

@@ -14,7 +14,7 @@ import { CropperAvatar } from '#/components/cropper';
import { useUpload } from '#/components/upload/use-upload'; import { useUpload } from '#/components/upload/use-upload';
const props = defineProps<{ const props = defineProps<{
profile?: SystemUserProfileApi.UserProfileResp; profile?: SystemUserProfileApi.UserProfileRespVO;
}>(); }>();
const emit = defineEmits<{ const emit = defineEmits<{

View File

@@ -58,11 +58,12 @@ export function exportJob(params: any) {
/** 任务状态修改 */ /** 任务状态修改 */
export function updateJobStatus(id: number, status: number) { export function updateJobStatus(id: number, status: number) {
const params = { return requestClient.put('/infra/job/update-status', undefined, {
id, params: {
status, id,
}; status,
return requestClient.put('/infra/job/update-status', { params }); },
});
} }
/** 定时任务立即执行一次 */ /** 定时任务立即执行一次 */

View File

@@ -34,15 +34,3 @@ export function getMailLogPage(params: PageParam) {
{ params }, { params },
); );
} }
/** 查询邮件日志详情 */
export function getMailLog(id: number) {
return requestClient.get<SystemMailLogApi.MailLog>(
`/system/mail-log/get?id=${id}`,
);
}
/** 重新发送邮件 */
export function resendMail(id: number) {
return requestClient.put(`/system/mail-log/resend?id=${id}`);
}