| | |
| | | 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; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | */ |
| | | @Validated |
| | | @Api(value = "个人信息控制器", tags = {"个人信息管理"}) |
| | | @RequiredArgsConstructor(onConstructor_ = @Autowired) |
| | | @RequiredArgsConstructor |
| | | @RestController |
| | | @RequestMapping("/system/user/profile") |
| | | public class SysProfileController extends BaseController { |
| | | |
| | | private final ISysUserService userService; |
| | | private final ISysOssService iSysOssService; |
| | | private final ISysOssService iSysOssService; |
| | | |
| | | /** |
| | | * 个人信息 |
| | |
| | | @ApiOperation("个人信息") |
| | | @GetMapping |
| | | public AjaxResult<Map<String, Object>> profile() { |
| | | SysUser user = userService.getById(getUserId()); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("user", user); |
| | | SysUser user = userService.selectUserById(getUserId()); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | ajax.put("user", user); |
| | | ajax.put("roleGroup", userService.selectUserRoleGroup(user.getUserName())); |
| | | ajax.put("postGroup", userService.selectUserPostGroup(user.getUserName())); |
| | | return AjaxResult.success(ajax); |
| | |
| | | @PutMapping |
| | | public AjaxResult<Void> updateProfile(@RequestBody SysUser user) { |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { |
| | | return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | if (StringUtils.isNotEmpty(user.getEmail()) |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | && UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { |
| | | return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); |
| | | } |
| | | user.setUserId(getUserId()); |
| | |
| | | @Log(title = "用户头像", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/avatar") |
| | | public AjaxResult<Map<String, Object>> avatar(@RequestPart("avatarfile") MultipartFile file) { |
| | | Map<String,Object> ajax = new HashMap<>(); |
| | | Map<String, Object> ajax = new HashMap<>(); |
| | | if (!file.isEmpty()) { |
| | | SysOss oss = iSysOssService.upload(file); |
| | | String avatar = oss.getUrl(); |
| | | SysOss oss = iSysOssService.upload(file); |
| | | String avatar = oss.getUrl(); |
| | | if (userService.updateUserAvatar(getUsername(), avatar)) { |
| | | ajax.put("imgUrl", avatar); |
| | | return AjaxResult.success(ajax); |