diff --git a/base-system-server/pom.xml b/base-system-server/pom.xml index d07c36d..0660f1c 100644 --- a/base-system-server/pom.xml +++ b/base-system-server/pom.xml @@ -112,7 +112,7 @@ com.health health-common-core - 3.6.8 + 3.6.9 com.dtflys.forest diff --git a/base-system-server/src/main/java/com/health/system/server/controller/SysProfileController.java b/base-system-server/src/main/java/com/health/system/server/controller/SysProfileController.java index cbb5b8d..8bab41b 100644 --- a/base-system-server/src/main/java/com/health/system/server/controller/SysProfileController.java +++ b/base-system-server/src/main/java/com/health/system/server/controller/SysProfileController.java @@ -1,9 +1,11 @@ package com.health.system.server.controller; import com.health.common.core.domain.Result; +import com.health.common.core.exception.ServiceException; import com.health.common.core.utils.StringUtils; import com.health.common.core.utils.file.FileTypeUtils; import com.health.common.core.utils.file.MimeTypeUtils; +import com.health.common.core.utils.file.OssFileUtils; import com.health.common.core.web.controller.BaseController; import com.health.common.log.annotation.Log; import com.health.common.log.enums.BusinessType; @@ -18,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; @@ -136,4 +139,25 @@ public class SysProfileController extends BaseController { } return error("上传图片异常,请联系管理员"); } + + /** + * @description: 修改用户形象照 + * @param: * @param avatar + * @return: Result + * @author 冯凯 + * @date: 2023/11/1 8:59 + */ + @PostMapping("/update/avatar") + public Result updateAvatar(@RequestParam("avatar") MultipartFile avatar) throws IOException { + String avatarUrl=""; + if (avatar.isEmpty()){ + throw new ServiceException("请选择一张个人形象照进行上传"); + } + try { + avatarUrl = OssFileUtils.ossUpd(avatar); + return Result.success(avatarUrl,"上传成功"); + } catch (Exception e) { + throw new RuntimeException(e); + } + } }