update 重构 头像上传改为先上传oss后更新用户数据

This commit is contained in:
疯狂的狮子Li
2026-06-05 16:41:12 +08:00
parent 18b3e6af87
commit 62694b1554
6 changed files with 43 additions and 21 deletions

View File

@@ -1,7 +1,7 @@
import type { PageResult } from '@/api/types';
import type { AxiosPromise } from '@/utils/api-types';
import request from '@/utils/request';
import type { OssQuery, OssVO } from './types';
import type { OssQuery, OssUploadVO, OssVO } from './types';
// 查询OSS对象存储列表
export function listOss(query: OssQuery): AxiosPromise<PageResult<OssVO>> {
@@ -20,6 +20,15 @@ export function listByIds(ossId: string | number): AxiosPromise<OssVO[]> {
});
}
// 上传OSS对象存储
export function uploadOss(data: FormData): AxiosPromise<OssUploadVO> {
return request({
url: '/resource/oss/upload',
method: 'post',
data
});
}
// 删除OSS对象存储
export function delOss(ossId: string | number | Array<string | number>) {
return request({

View File

@@ -8,6 +8,12 @@ export interface OssVO extends BaseEntity {
service: string;
}
export interface OssUploadVO {
url: string;
fileName: string;
ossId: string;
}
export interface OssQuery extends PageQuery {
fileName: string;
originalName: string;

View File

@@ -4,7 +4,7 @@ import type { AxiosPromise } from '@/utils/api-types';
import request from '@/utils/request';
import { parseStrEmpty } from '@/utils/ruoyi';
import type { DeptTreeVO } from './../dept/types';
import type { UserForm, UserInfoVO, UserQuery, UserVO } from './types';
import type { UserForm, UserInfoVO, UserProfileForm, UserQuery, UserVO } from './types';
/**
* 查询用户列表
@@ -136,7 +136,7 @@ export const getUserProfile = (): AxiosPromise<UserInfoVO> => {
* 修改用户个人信息
* @param data 用户信息
*/
export const updateUserProfile = (data: UserForm) => {
export const updateUserProfile = (data: UserProfileForm) => {
return request({
url: '/system/user/profile',
method: 'put',
@@ -165,18 +165,6 @@ export const updateUserPwd = (oldPassword: string, newPassword: string) => {
});
};
/**
* 用户头像上传
* @param data 头像文件
*/
export const uploadAvatar = (data: FormData) => {
return request({
url: '/system/user/profile/avatar',
method: 'post',
data: data
});
};
/**
* 查询授权角色
* @param userId 用户ID
@@ -234,7 +222,6 @@ export default {
getUserProfile,
updateUserProfile,
updateUserPwd,
uploadAvatar,
getAuthRole,
updateAuthRole,
deptTreeSelect,

View File

@@ -71,6 +71,17 @@ export interface UserForm {
roleIds: string[];
}
/**
* 个人资料表单类型
*/
export interface UserProfileForm {
nickName?: string;
phoneNumber?: string;
email?: string;
gender?: string;
avatar?: string | number;
}
export interface UserInfoVO {
user: UserVO;
roles: RoleVO[];