|
1
|
package com.ruoyi.web.controller.system;
|
1
|
package com.ruoyi.web.controller.system;
|
|
2
|
|
2
|
|
|
3
|
-import java.io.IOException;
|
|
|
|
4
|
import org.springframework.beans.factory.annotation.Autowired;
|
3
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
5
|
import org.springframework.web.bind.annotation.GetMapping;
|
4
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
6
|
import org.springframework.web.bind.annotation.PostMapping;
|
5
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -21,6 +20,7 @@ import com.ruoyi.common.enums.BusinessType; |
|
@@ -21,6 +20,7 @@ import com.ruoyi.common.enums.BusinessType; |
|
21
|
import com.ruoyi.common.utils.SecurityUtils;
|
20
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
22
|
import com.ruoyi.common.utils.StringUtils;
|
21
|
import com.ruoyi.common.utils.StringUtils;
|
|
23
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
22
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
|
23
|
+import com.ruoyi.common.utils.file.MimeTypeUtils;
|
|
24
|
import com.ruoyi.framework.web.service.TokenService;
|
24
|
import com.ruoyi.framework.web.service.TokenService;
|
|
25
|
import com.ruoyi.system.service.ISysUserService;
|
25
|
import com.ruoyi.system.service.ISysUserService;
|
|
26
|
|
26
|
|
|
@@ -121,12 +121,12 @@ public class SysProfileController extends BaseController |
|
@@ -121,12 +121,12 @@ public class SysProfileController extends BaseController |
|
121
|
*/
|
121
|
*/
|
|
122
|
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
122
|
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
|
|
123
|
@PostMapping("/avatar")
|
123
|
@PostMapping("/avatar")
|
|
124
|
- public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws IOException
|
124
|
+ public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception
|
|
125
|
{
|
125
|
{
|
|
126
|
if (!file.isEmpty())
|
126
|
if (!file.isEmpty())
|
|
127
|
{
|
127
|
{
|
|
128
|
LoginUser loginUser = getLoginUser();
|
128
|
LoginUser loginUser = getLoginUser();
|
|
129
|
- String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
|
129
|
+ String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION);
|
|
130
|
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
|
130
|
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
|
|
131
|
{
|
131
|
{
|
|
132
|
AjaxResult ajax = AjaxResult.success();
|
132
|
AjaxResult ajax = AjaxResult.success();
|