forked from ci4s/ci4sManagement-cloud
用户同步功能开发
This commit is contained in:
parent
0fc9095f8c
commit
c17c4e4f2d
|
|
@ -19,10 +19,10 @@ public interface RemoteMmpService {
|
|||
@PostMapping("/gitLink/resetPwd")
|
||||
public GenericsAjaxResult<String> resetPwd(@RequestBody SysUser sysUser) throws Exception;
|
||||
|
||||
@PostMapping("/gitLink/resetEmail")
|
||||
@PutMapping("/gitLink/resetEmail")
|
||||
public GenericsAjaxResult<String> resetEmail(@RequestBody SysUser sysUser) throws Exception;
|
||||
|
||||
@PostMapping("/gitLink/resetPhoneNum")
|
||||
@PutMapping("/gitLink/resetPhoneNum")
|
||||
public GenericsAjaxResult<String> resetPhoneNum(@RequestBody SysUser sysUser) throws Exception;
|
||||
|
||||
@DeleteMapping("/gitLink/deleteGitLinkUser")
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.ruoyi.auth.service;
|
|||
|
||||
import com.ruoyi.auth.domain.OauthAccount;
|
||||
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.domain.SysUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -31,7 +32,9 @@ public class Oauth2Service {
|
|||
OauthAccount oauthAccount = new OauthAccount();
|
||||
oauthAccount.setClientId(clientId);
|
||||
oauthAccount.setUsername(user.getUserName());
|
||||
oauthAccount.setPassword(user.getPassword());
|
||||
if (StringUtils.isNotEmpty(user.getPassword())) {
|
||||
oauthAccount.setPassword(user.getPassword());
|
||||
}
|
||||
oauthAccount.setMobile(user.getPhonenumber());
|
||||
oauthAccount.setEmail(user.getEmail());
|
||||
if (Constant.DelFlag.equals(user.getDelFlag())) {
|
||||
|
|
|
|||
|
|
@ -127,10 +127,12 @@ public class NewHttpUtils {
|
|||
throw new IOException("HTTP request failed with response code: " + statusCode);
|
||||
}
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -63,8 +63,7 @@ public class SysProfileController extends BaseController
|
|||
*/
|
||||
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult updateProfile(@RequestBody SysUser user)
|
||||
{
|
||||
public AjaxResult updateProfile(@RequestBody SysUser user) throws Exception {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
SysUser currentUser = loginUser.getSysUser();
|
||||
currentUser.setNickName(user.getNickName());
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ public interface ISysUserService
|
|||
* @param user 用户信息
|
||||
* @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.stream.Collectors;
|
||||
|
||||
import static com.ruoyi.common.security.utils.SecurityUtils.decrypt;
|
||||
import static com.ruoyi.common.security.utils.SecurityUtils.encrypt;
|
||||
|
||||
/**
|
||||
|
|
@ -291,8 +290,6 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateUser(SysUser user) throws Exception {
|
||||
Long userId = user.getUserId();
|
||||
SysUser oldUser = userMapper.selectUserById(userId);
|
||||
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.deleteUserRoleByUserId(userId);
|
||||
// 新增用户与角色管理
|
||||
|
|
@ -302,37 +299,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
// 新增用户与岗位管理
|
||||
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);
|
||||
}
|
||||
|
|
@ -368,7 +335,41 @@ public class SysUserServiceImpl implements ISysUserService {
|
|||
* @return 结果
|
||||
*/
|
||||
@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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue