新增修改个人形象照接口

master
冯凯 2023-11-01 09:45:18 +08:00
parent 4a9cbf35f7
commit 33b22a5cb6
2 changed files with 25 additions and 1 deletions

View File

@ -112,7 +112,7 @@
<dependency>
<groupId>com.health</groupId>
<artifactId>health-common-core</artifactId>
<version>3.6.8</version>
<version>3.6.9</version>
</dependency>
<dependency>
<groupId>com.dtflys.forest</groupId>

View File

@ -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);
}
}
}