| @@ -19,10 +19,10 @@ public interface RemoteMmpService { | |||||
| @PostMapping("/gitLink/resetPwd") | @PostMapping("/gitLink/resetPwd") | ||||
| public GenericsAjaxResult<String> resetPwd(@RequestBody SysUser sysUser) throws Exception; | public GenericsAjaxResult<String> resetPwd(@RequestBody SysUser sysUser) throws Exception; | ||||
| @PostMapping("/gitLink/resetEmail") | |||||
| @PutMapping("/gitLink/resetEmail") | |||||
| public GenericsAjaxResult<String> resetEmail(@RequestBody SysUser sysUser) throws Exception; | public GenericsAjaxResult<String> resetEmail(@RequestBody SysUser sysUser) throws Exception; | ||||
| @PostMapping("/gitLink/resetPhoneNum") | |||||
| @PutMapping("/gitLink/resetPhoneNum") | |||||
| public GenericsAjaxResult<String> resetPhoneNum(@RequestBody SysUser sysUser) throws Exception; | public GenericsAjaxResult<String> resetPhoneNum(@RequestBody SysUser sysUser) throws Exception; | ||||
| @DeleteMapping("/gitLink/deleteGitLinkUser") | @DeleteMapping("/gitLink/deleteGitLinkUser") | ||||
| @@ -2,6 +2,7 @@ package com.ruoyi.auth.service; | |||||
| import com.ruoyi.auth.domain.OauthAccount; | import com.ruoyi.auth.domain.OauthAccount; | ||||
| import com.ruoyi.auth.mapper.Oauth2Mapper; | import com.ruoyi.auth.mapper.Oauth2Mapper; | ||||
| import com.ruoyi.common.core.utils.StringUtils; | |||||
| import com.ruoyi.system.api.constant.Constant; | import com.ruoyi.system.api.constant.Constant; | ||||
| import com.ruoyi.system.api.domain.SysUser; | import com.ruoyi.system.api.domain.SysUser; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -31,7 +32,9 @@ public class Oauth2Service { | |||||
| OauthAccount oauthAccount = new OauthAccount(); | OauthAccount oauthAccount = new OauthAccount(); | ||||
| oauthAccount.setClientId(clientId); | oauthAccount.setClientId(clientId); | ||||
| oauthAccount.setUsername(user.getUserName()); | oauthAccount.setUsername(user.getUserName()); | ||||
| oauthAccount.setPassword(user.getPassword()); | |||||
| if (StringUtils.isNotEmpty(user.getPassword())) { | |||||
| oauthAccount.setPassword(user.getPassword()); | |||||
| } | |||||
| oauthAccount.setMobile(user.getPhonenumber()); | oauthAccount.setMobile(user.getPhonenumber()); | ||||
| oauthAccount.setEmail(user.getEmail()); | oauthAccount.setEmail(user.getEmail()); | ||||
| if (Constant.DelFlag.equals(user.getDelFlag())) { | if (Constant.DelFlag.equals(user.getDelFlag())) { | ||||
| @@ -127,10 +127,12 @@ public class NewHttpUtils { | |||||
| throw new IOException("HTTP request failed with response code: " + statusCode); | throw new IOException("HTTP request failed with response code: " + statusCode); | ||||
| } | } | ||||
| log.info("Response: " + result); | log.info("Response: " + result); | ||||
| Map<String, Object> resultMap = JsonUtils.jsonToMap(result); | |||||
| Integer status = (Integer) resultMap.get("status"); | |||||
| if (status != null && status != 0) { | |||||
| throw new Exception((String) resultMap.get("message")); | |||||
| if (result.startsWith("{")) { | |||||
| Map<String, Object> resultMap = JsonUtils.jsonToMap(result); | |||||
| Integer status = (Integer) resultMap.get("status"); | |||||
| if (status != null && status != 0 && status != 1) { | |||||
| throw new Exception((String) resultMap.get("message")); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } catch (URISyntaxException e) { | } catch (URISyntaxException e) { | ||||
| @@ -63,8 +63,7 @@ public class SysProfileController extends BaseController | |||||
| */ | */ | ||||
| @Log(title = "个人信息", businessType = BusinessType.UPDATE) | @Log(title = "个人信息", businessType = BusinessType.UPDATE) | ||||
| @PutMapping | @PutMapping | ||||
| public AjaxResult updateProfile(@RequestBody SysUser user) | |||||
| { | |||||
| public AjaxResult updateProfile(@RequestBody SysUser user) throws Exception { | |||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| SysUser currentUser = loginUser.getSysUser(); | SysUser currentUser = loginUser.getSysUser(); | ||||
| currentUser.setNickName(user.getNickName()); | currentUser.setNickName(user.getNickName()); | ||||
| @@ -151,7 +151,7 @@ public interface ISysUserService | |||||
| * @param user 用户信息 | * @param user 用户信息 | ||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| public int updateUserProfile(SysUser user); | |||||
| public int updateUserProfile(SysUser user) throws Exception; | |||||
| /** | /** | ||||
| * 修改用户头像 | * 修改用户头像 | ||||
| @@ -31,7 +31,6 @@ import java.util.ArrayList; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| import static com.ruoyi.common.security.utils.SecurityUtils.decrypt; | |||||
| import static com.ruoyi.common.security.utils.SecurityUtils.encrypt; | import static com.ruoyi.common.security.utils.SecurityUtils.encrypt; | ||||
| /** | /** | ||||
| @@ -291,8 +290,6 @@ public class SysUserServiceImpl implements ISysUserService { | |||||
| @Transactional(rollbackFor = Exception.class) | @Transactional(rollbackFor = Exception.class) | ||||
| public int updateUser(SysUser user) throws Exception { | public int updateUser(SysUser user) throws Exception { | ||||
| Long userId = user.getUserId(); | Long userId = user.getUserId(); | ||||
| SysUser oldUser = userMapper.selectUserById(userId); | |||||
| // 删除用户与角色关联 | // 删除用户与角色关联 | ||||
| userRoleMapper.deleteUserRoleByUserId(userId); | userRoleMapper.deleteUserRoleByUserId(userId); | ||||
| // 新增用户与角色管理 | // 新增用户与角色管理 | ||||
| @@ -302,37 +299,7 @@ public class SysUserServiceImpl implements ISysUserService { | |||||
| // 新增用户与岗位管理 | // 新增用户与岗位管理 | ||||
| insertUserPost(user); | insertUserPost(user); | ||||
| // 更新gitlink用户 | |||||
| if (!oldUser.getEmail().equals(user.getEmail())) { | |||||
| GenericsAjaxResult<String> result = remoteMmpService.resetEmail(user); | |||||
| if (result.getCode() != 200) { | |||||
| throw new Exception(result.getMsg()); | |||||
| } | |||||
| } | |||||
| if (!oldUser.getPhonenumber().equals(user.getPhonenumber())) { | |||||
| GenericsAjaxResult<String> result = remoteMmpService.resetPhoneNum(user); | |||||
| if (result.getCode() != 200) { | |||||
| throw new Exception(result.getMsg()); | |||||
| } | |||||
| } | |||||
| if (StringUtils.isNotEmpty(user.getPassword())) { | |||||
| GenericsAjaxResult<String> result = remoteMmpService.resetPwd(user); | |||||
| if (result.getCode() != 200) { | |||||
| throw new Exception(result.getMsg()); | |||||
| } | |||||
| } | |||||
| if (StringUtils.isNotEmpty(user.getPassword())) { | |||||
| user.setOriginPassword(encrypt(user.getPassword())); | |||||
| user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); | |||||
| } | |||||
| // 更新oauth2用户 | |||||
| remoteAuthService.edit(user); | |||||
| // todo 更新火石平台用户 | |||||
| updateUserProfile(user); | |||||
| return userMapper.updateUser(user); | return userMapper.updateUser(user); | ||||
| } | } | ||||
| @@ -368,7 +335,41 @@ public class SysUserServiceImpl implements ISysUserService { | |||||
| * @return 结果 | * @return 结果 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| public int updateUserProfile(SysUser user) { | |||||
| public int updateUserProfile(SysUser user) throws Exception { | |||||
| SysUser oldUser = userMapper.selectUserById(user.getUserId()); | |||||
| // 更新gitlink用户 | |||||
| if (!oldUser.getEmail().equals(user.getEmail())) { | |||||
| GenericsAjaxResult<String> result = remoteMmpService.resetEmail(user); | |||||
| if (result.getCode() != 200) { | |||||
| throw new Exception(result.getMsg()); | |||||
| } | |||||
| } | |||||
| if (!oldUser.getPhonenumber().equals(user.getPhonenumber())) { | |||||
| GenericsAjaxResult<String> result = remoteMmpService.resetPhoneNum(user); | |||||
| if (result.getCode() != 200) { | |||||
| throw new Exception(result.getMsg()); | |||||
| } | |||||
| } | |||||
| if (StringUtils.isNotEmpty(user.getPassword())) { | |||||
| GenericsAjaxResult<String> result = remoteMmpService.resetPwd(user); | |||||
| if (result.getCode() != 200) { | |||||
| throw new Exception(result.getMsg()); | |||||
| } | |||||
| } | |||||
| if (StringUtils.isNotEmpty(user.getPassword())) { | |||||
| user.setOriginPassword(encrypt(user.getPassword())); | |||||
| user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); | |||||
| } | |||||
| // 更新oauth2用户 | |||||
| remoteAuthService.edit(user); | |||||
| // todo 更新火石平台用户 | |||||
| return userMapper.updateUser(user); | return userMapper.updateUser(user); | ||||
| } | } | ||||