|
@@ -16,6 +16,7 @@ import com.google.gson.Gson;
|
|
|
import com.jeeplus.aop.demo.annotation.DemoMode;
|
|
|
import com.jeeplus.aop.logging.annotation.ApiLog;
|
|
|
import com.jeeplus.common.beanvalidator.BeanValidators;
|
|
|
+import com.jeeplus.common.redis.RedisUtils;
|
|
|
import com.jeeplus.common.utils.FileUtils;
|
|
|
import com.jeeplus.common.utils.ResponseUtil;
|
|
|
import com.jeeplus.config.properties.FileProperties;
|
|
@@ -24,6 +25,7 @@ import com.jeeplus.core.excel.ExportMode;
|
|
|
import com.jeeplus.core.excel.utils.EasyPoiUtil;
|
|
|
import com.jeeplus.core.query.QueryWrapperGenerator;
|
|
|
import com.jeeplus.security.util.SecurityUtils;
|
|
|
+import com.jeeplus.sys.constant.CacheNames;
|
|
|
import com.jeeplus.sys.constant.CommonConstants;
|
|
|
import com.jeeplus.sys.domain.Office;
|
|
|
import com.jeeplus.sys.domain.User;
|
|
@@ -88,6 +90,12 @@ public class UserController {
|
|
|
@Autowired
|
|
|
private OfficeWrapper officeWrapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private RestTemplateService2 restTemplateService2;
|
|
|
+
|
|
|
+ @Value("${IS_USE_CAS_LOGIN}")
|
|
|
+ private String isUseCasLogin;
|
|
|
+
|
|
|
/**
|
|
|
* 根据id查询用户
|
|
|
*
|
|
@@ -98,7 +106,7 @@ public class UserController {
|
|
|
@GetMapping("queryById")
|
|
|
@ApiOperation(value = "查询用户")
|
|
|
public ResponseEntity queryById(@RequestParam("id") String id) {
|
|
|
- UserDTO userDTO = userService.get ( id );
|
|
|
+ /*UserDTO userDTO = userService.get ( id );
|
|
|
if(StringUtils.isNotBlank(userDTO.getManageOfficeIds())){
|
|
|
//获取当前人管理的部门id
|
|
|
List<String> manageOfficeIdList=Arrays.asList(userDTO.getManageOfficeIds().split(","));
|
|
@@ -147,7 +155,12 @@ public class UserController {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- return ResponseEntity.ok ( userDTO );
|
|
|
+ return ResponseEntity.ok ( userDTO );*/
|
|
|
+ //调用人力资源系统的查询用户功能
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
+ paramMap.put("id", id);
|
|
|
+ Object userInfo = restTemplateService2.getHuman("/sys/user/queryById", "", paramMap);
|
|
|
+ return ResponseEntity.ok ( userInfo );
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -165,7 +178,7 @@ public class UserController {
|
|
|
QueryWrapper <UserDTO> queryWrapper = QueryWrapperGenerator.buildQueryCondition ( userDTO, UserDTO.class );
|
|
|
// 管理员查询不限制
|
|
|
if (!UserUtils.getCurrentUserDTO().isAdmin()) {
|
|
|
- queryWrapper.isNull("a.is_admin");
|
|
|
+// queryWrapper.isNull("a.is_admin");
|
|
|
if (ObjectUtil.isNotEmpty(userDTO)){
|
|
|
if (ObjectUtil.isNotEmpty(userDTO.getCompanyDTO()) && ObjectUtil.isNotEmpty(userDTO.getOfficeDTO())) {
|
|
|
OfficeDTO officeDTO = UserUtils.getCurrentUserDTO().getOfficeDTO();
|
|
@@ -225,6 +238,22 @@ public class UserController {
|
|
|
}
|
|
|
}
|
|
|
IPage <UserDTO> result = userService.findPage ( page, queryWrapper );
|
|
|
+ List<UserDTO> records = result.getRecords();
|
|
|
+
|
|
|
+ StringBuffer buffer = new StringBuffer();
|
|
|
+ for (int i=0;i<records.size();i++){
|
|
|
+ buffer.append(records.get(i).getId());
|
|
|
+ if (i==records.size()-1){
|
|
|
+
|
|
|
+ } else {
|
|
|
+ buffer.append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //调用人力资源系统的查询用户信息功能,
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
+ paramMap.put("buffer", buffer);
|
|
|
+ List<UserDTO> userInfo = (List<UserDTO>) restTemplateService2.getHuman("/sys/user/getAllUserInfo", "", paramMap);
|
|
|
+ result.setRecords(userInfo);
|
|
|
return ResponseEntity.ok ( result );
|
|
|
}
|
|
|
|
|
@@ -531,7 +560,7 @@ public class UserController {
|
|
|
@RequestMapping("savePwd")
|
|
|
@ApiOperation(value = "修改密码")
|
|
|
public ResponseEntity savePwd(String oldPassword, String newPassword) {
|
|
|
- UserDTO userDTO = UserUtils.getCurrentUserDTO ( );
|
|
|
+ /*UserDTO userDTO = UserUtils.getCurrentUserDTO ( );
|
|
|
if ( StrUtil.isNotBlank ( oldPassword ) && StrUtil.isNotBlank ( newPassword ) ) {
|
|
|
if ( SecurityUtils.validatePassword ( oldPassword, userDTO.getPassword ( ) ) ) {
|
|
|
User user = new User ( userDTO.getId ( ) );
|
|
@@ -544,7 +573,41 @@ public class UserController {
|
|
|
return ResponseEntity.badRequest ( ).body ( "修改密码失败,旧密码错误!" );
|
|
|
}
|
|
|
}
|
|
|
- return ResponseEntity.badRequest ( ).body ( "参数错误!" );
|
|
|
+ return ResponseEntity.badRequest ( ).body ( "参数错误!" );*/
|
|
|
+ UserDTO userDTO = UserUtils.getCurrentUserDTO ( );
|
|
|
+ //判断是否启用了cas登录
|
|
|
+ if (isUseCasLogin.equals("true")){
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
+ paramMap.put("name", userDTO.getName());
|
|
|
+ paramMap.put("password", newPassword);
|
|
|
+ paramMap.put("mobile", userDTO.getMobile());
|
|
|
+ String token = "";
|
|
|
+ Object res = restTemplateService2.getCas("/test/update", token, paramMap);
|
|
|
+ String s = res.toString();
|
|
|
+ if (s.equals("true")){
|
|
|
+ User user = new User ( userDTO.getId ( ) );
|
|
|
+ user.setPassword ( SecurityUtils.encryptPassword ( newPassword ) );
|
|
|
+ userService.updateById(user);
|
|
|
+ return ResponseEntity.ok ( "修改密码成功!" );
|
|
|
+ }else {
|
|
|
+ return ResponseEntity.ok ( "修改密码失败!" );
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //向人力资源系统发送修改密码请求
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
+ paramMap.put("mobile", userDTO.getMobile());
|
|
|
+ paramMap.put("newPassword", newPassword);
|
|
|
+ Object userInfo = restTemplateService2.getHuman("/sys/user/savePwdChild", "", paramMap);
|
|
|
+ String s = userInfo.toString();
|
|
|
+ if (s.equals("true")){
|
|
|
+ User user = new User ( userDTO.getId ( ) );
|
|
|
+ user.setPassword ( SecurityUtils.encryptPassword ( newPassword ) );
|
|
|
+ userService.updateById(user);
|
|
|
+ return ResponseEntity.ok ( "修改密码成功!" );
|
|
|
+ } else {
|
|
|
+ return ResponseEntity.ok ( "修改密码失败!" );
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -776,7 +839,15 @@ public class UserController {
|
|
|
public ResponseEntity<Boolean> isUpdatePassword() {
|
|
|
// 返回结果 true为以修改 false为未修改
|
|
|
UserDTO userDTO = UserUtils.getCurrentUserDTO();
|
|
|
- Boolean updatePassword = userService.isUpdatePassword(userDTO.getId());
|
|
|
+ //从redis中获取当前用户信息
|
|
|
+ Boolean updatePassword;
|
|
|
+ UserDTO dto = (UserDTO) RedisUtils.getInstance().get(CacheNames.USER_CACHE_LOGIN_ONLINE_LOGIN_NAME + userDTO.getLoginName());
|
|
|
+ if (dto.getUpPassword().equals("true")){
|
|
|
+ updatePassword = true;
|
|
|
+ } else {
|
|
|
+ updatePassword = false;
|
|
|
+ }
|
|
|
+// Boolean updatePassword = userService.isUpdatePassword(userDTO.getId());
|
|
|
return ResponseEntity.ok(updatePassword);
|
|
|
}
|
|
|
}
|