| | |
| | | import com.ruoyi.system.domain.SysOss; |
| | | import com.ruoyi.system.service.ISysOssService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import io.swagger.annotations.*; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | public AjaxResult<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile file) { |
| | | Map<String,Object> ajax = new HashMap<>(); |
| | | if (!file.isEmpty()) { |
| | | SysUser user = SecurityUtils.getUser(); |
| | | SysOss oss = iSysOssService.upload(file); |
| | | String avatar = oss.getUrl(); |
| | | if (userService.updateUserAvatar(user.getUserName(), avatar)) { |
| | | if (userService.updateUserAvatar(getUsername(), avatar)) { |
| | | ajax.put("imgUrl", avatar); |
| | | return AjaxResult.success(ajax); |
| | | } |