Commit 90b23a3c by huangjinxin

fix:用户禁用,新增,修改,删除优化

1 parent 35f0d99d
...@@ -122,7 +122,7 @@ public interface IUser { ...@@ -122,7 +122,7 @@ public interface IUser {
* @return * @return
*/ */
@RequestMapping(value = "/pea-user/delete", method = RequestMethod.POST) @RequestMapping(value = "/pea-user/delete", method = RequestMethod.POST)
Result<Boolean> deleteUser(@RequestParam("id") String userId); Result<Boolean> deleteUser(@RequestBody UserInfoSearch search);
/** /**
* 注册用户 * 注册用户
...@@ -159,7 +159,7 @@ public interface IUser { ...@@ -159,7 +159,7 @@ public interface IUser {
* @param search 查询条件 * @param search 查询条件
* @return * @return
*/ */
@RequestMapping(value = "/pea-user/ban", method = RequestMethod.GET) @RequestMapping(value = "/pea-user/ban", method = RequestMethod.POST)
Result<Boolean> ban(UserInfoSearch search); Result<Boolean> ban(@RequestBody UserInfoSearch search);
} }
...@@ -109,7 +109,8 @@ public class UserController implements IUser { ...@@ -109,7 +109,8 @@ public class UserController implements IUser {
} }
@Override @Override
public Result<Boolean> deleteUser(String userId) { public Result<Boolean> deleteUser(UserInfoSearch search) {
String userId = search.getId();
if (StringUtils.isBlank(userId)) { if (StringUtils.isBlank(userId)) {
return Result.failed(StatusCodeEnum.COMMON_PARAM_EMPTY, null); return Result.failed(StatusCodeEnum.COMMON_PARAM_EMPTY, null);
} }
......
...@@ -17,12 +17,11 @@ import com.dituhui.pea.user.dao.*; ...@@ -17,12 +17,11 @@ import com.dituhui.pea.user.dao.*;
import com.dituhui.pea.user.entity.*; import com.dituhui.pea.user.entity.*;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.hibernate.query.internal.NativeQueryImpl; import org.hibernate.query.internal.NativeQueryImpl;
import org.hibernate.transform.Transformers; import org.hibernate.transform.Transformers;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -296,6 +295,7 @@ public class UserService { ...@@ -296,6 +295,7 @@ public class UserService {
userEntity.setPassword(SecureUtil.md5(userInfo.getPassword())); userEntity.setPassword(SecureUtil.md5(userInfo.getPassword()));
// 保存用户信息 // 保存用户信息
userEntity = userDao.save(userEntity); userEntity = userDao.save(userEntity);
userInfo.setId(userEntity.getId());
savaUserRoleAndOrgInfo(userInfo); savaUserRoleAndOrgInfo(userInfo);
UserInfo info = BeanUtil.copyProperties(userEntity, UserInfo.class); UserInfo info = BeanUtil.copyProperties(userEntity, UserInfo.class);
info.setPassword(null); info.setPassword(null);
...@@ -469,11 +469,17 @@ public class UserService { ...@@ -469,11 +469,17 @@ public class UserService {
userRoleDao.save(userRoleEntity); userRoleDao.save(userRoleEntity);
} }
} }
if (MapUtils.isNotEmpty(userRoleMap)) {
for (String roleId : userRoleMap.keySet()) {
UserRoleEntity userRoleEntity = userRoleMap.get(roleId);
userRoleDao.deleteById(userRoleEntity.getId());
}
}
} }
//处理用户机构关联信息 //处理用户机构关联信息
if (CollectionUtils.isNotEmpty(userInfo.getOrgIds()) && null != userInfo.getOrgIds()) { if (CollectionUtils.isNotEmpty(userInfo.getOrgIds()) && null != userInfo.getOrgIds()) {
userOrgDao.deleteByUserId(userInfo.getId());
for (Integer orgId : userInfo.getOrgIds()) { for (Integer orgId : userInfo.getOrgIds()) {
userOrgDao.deleteByUserId(userInfo.getId());
UserOrgEntity userOrgEntity = new UserOrgEntity(); UserOrgEntity userOrgEntity = new UserOrgEntity();
userOrgEntity.setUserId(userInfo.getId()); userOrgEntity.setUserId(userInfo.getId());
userOrgEntity.setOrgId(orgId); userOrgEntity.setOrgId(orgId);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!