diff --git a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application.Contracts/Identity/Dtos/Account/UpdateIconDto.cs b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application.Contracts/Identity/Dtos/Account/UpdateIconDto.cs new file mode 100644 index 00000000..c0e0e2a3 --- /dev/null +++ b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application.Contracts/Identity/Dtos/Account/UpdateIconDto.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Yi.RBAC.Application.Contracts.Identity.Dtos.Account +{ + public class UpdateIconDto + { + public string? Icon { get; set; } + } +} diff --git a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/ApplicationSwaggerDoc.xml b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/ApplicationSwaggerDoc.xml index 38916e3c..8ef4cb44 100644 --- a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/ApplicationSwaggerDoc.xml +++ b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/ApplicationSwaggerDoc.xml @@ -73,6 +73,13 @@ + + + 更新头像 + + + + Dept服务实现 diff --git a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/Identity/AccountService.cs b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/Identity/AccountService.cs index 399b23e5..8d08f302 100644 --- a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/Identity/AccountService.cs +++ b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Application/Identity/AccountService.cs @@ -28,6 +28,7 @@ using Yi.RBAC.Domain.Identity.Repositories; using Yi.RBAC.Domain.Shared.Identity.ConstClasses; using Yi.RBAC.Domain.Shared.Identity.Dtos; using Yi.RBAC.Domain.Shared.Identity.Etos; +using System.Net.WebSockets; namespace Yi.RBAC.Application.Identity { @@ -188,5 +189,19 @@ namespace Yi.RBAC.Application.Identity await _accountManager.RestPasswordAsync(userId, input.Password); return true; } + + /// + /// 更新头像 + /// + /// + /// + public async Task UpdateIconAsync(UpdateIconDto input) + { + var entity = await _userRepository.GetByIdAsync(_currentUser.Id); + entity.Icon = input.Icon; + await _userRepository.UpdateAsync(entity); + + return true; + } } } diff --git a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/wwwroot/File/1628642335514562560 b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/wwwroot/File/1628642335514562560 new file mode 100644 index 00000000..2d3f458d Binary files /dev/null and b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/wwwroot/File/1628642335514562560 differ diff --git a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/wwwroot/File/1628645021437792256 b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/wwwroot/File/1628645021437792256 new file mode 100644 index 00000000..d66859d7 Binary files /dev/null and b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/wwwroot/File/1628645021437792256 differ diff --git a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/yi-sqlsugar-dev.db b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/yi-sqlsugar-dev.db index 578acc3b..7071674f 100644 Binary files a/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/yi-sqlsugar-dev.db and b/Yi.Framework.Net6/src/project/rbac/Yi.RBAC.Web/yi-sqlsugar-dev.db differ diff --git a/Yi.RuoYi.Vue3/src/api/file.js b/Yi.RuoYi.Vue3/src/api/file.js index 2dc681e9..d80d58e6 100644 --- a/Yi.RuoYi.Vue3/src/api/file.js +++ b/Yi.RuoYi.Vue3/src/api/file.js @@ -1,9 +1,9 @@ import request from '@/utils/request' export function - upload(type,data){ + upload(data){ return request({ - url: `/file/upload/${type}`, + url: `/file`, headers:{"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}, method: 'POST', data:data diff --git a/Yi.RuoYi.Vue3/src/api/system/user.js b/Yi.RuoYi.Vue3/src/api/system/user.js index d930f452..8302e52b 100644 --- a/Yi.RuoYi.Vue3/src/api/system/user.js +++ b/Yi.RuoYi.Vue3/src/api/system/user.js @@ -82,6 +82,15 @@ export function updateUserProfile(data) { data: data }) } +// 只修改用户头像 +export function updateUserIcon(data) { + return request({ + url: `/account/icon`, + method: 'put', + data:{icon:data} + }) +} + // 用户密码重置 export function updateUserPwd(oldPassword, newPassword) { diff --git a/Yi.RuoYi.Vue3/src/views/system/user/profile/userAvatar.vue b/Yi.RuoYi.Vue3/src/views/system/user/profile/userAvatar.vue index 7f1c4834..71b1a787 100644 --- a/Yi.RuoYi.Vue3/src/views/system/user/profile/userAvatar.vue +++ b/Yi.RuoYi.Vue3/src/views/system/user/profile/userAvatar.vue @@ -54,7 +54,7 @@ import "vue-cropper/dist/index.css"; import { VueCropper } from "vue-cropper"; import { upload } from "@/api/file"; -import { updateUserProfile } from "@/api/system/user"; +import { updateUserIcon } from "@/api/system/user"; import useUserStore from '@/store/modules/user' const userStore = useUserStore() @@ -116,14 +116,11 @@ function uploadImg() { proxy.$refs.cropper.getCropBlob(data => { let formData = new FormData(); formData.append("file", data); - upload("image",formData).then(response => { + upload(formData).then(response => { open.value = false; - options.img = import.meta.env.VITE_APP_BASE_API +"/file/"+response.data[0]; + options.img = import.meta.env.VITE_APP_BASE_API +"/file/"+response.data[0].id; userStore.avatar = options.img; - - - - updateUserProfile({icon:response.data[0]}).then(response2=>{ + updateUserIcon(response.data[0].id).then(response2=>{ proxy.$modal.msgSuccess("修改成功"); visible.value = false; })