Commit 90b23a3c by huangjinxin

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

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