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