user
This commit is contained in:
@@ -80,8 +80,8 @@ public class UserController {
|
||||
@ApiOperation("修改用户")
|
||||
@PutMapping
|
||||
// @SaCheckPermission("user:edit")
|
||||
public ResponseEntity<Object> update( @RequestBody SysUser resources) throws Exception {
|
||||
userService.saveOrUpdate(resources);
|
||||
public ResponseEntity<Object> update( @RequestBody Map resources) throws Exception {
|
||||
userService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ public interface ISysDeptService extends IService<SysDept> {
|
||||
* @param deptIds
|
||||
*/
|
||||
void saveUserDeptRelation(String UserId, Collection<String> deptIds);
|
||||
void delUserDeptRelation(String user);
|
||||
|
||||
/**
|
||||
* 更新部门:同时更新节点
|
||||
|
||||
@@ -24,6 +24,7 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
|
||||
* @param deptId
|
||||
*/
|
||||
void saveDeptRelation(@Param("user") String UserId,@Param("depts") Collection<String> deptId);
|
||||
void delDeptRelation(@Param("user") String UserId);
|
||||
|
||||
List<Map> getDeptRelation(@Param("deptIds") Collection<String> deptIds);
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
(#{user},#{dept})
|
||||
</foreach>
|
||||
</insert>
|
||||
<delete id="delDeptRelation">
|
||||
delete from sys_user_dept where user_id = #{user}
|
||||
</delete>
|
||||
|
||||
<update id="updateSubCount">
|
||||
update sys_dept set sub_count =
|
||||
(select m.count from (select count(*) count from sys_dept where pid = #{pid}) as m)
|
||||
|
||||
@@ -113,6 +113,11 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
sysDeptMapper.saveDeptRelation(userId,deptIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delUserDeptRelation(String user) {
|
||||
sysDeptMapper.delDeptRelation(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDept(SysDept dept) {
|
||||
|
||||
@@ -60,4 +60,5 @@ public interface ISysRoleService extends IService<SysRole> {
|
||||
* @param deptIds
|
||||
*/
|
||||
void saveUserRoleRelation(String UserId, List<String> deptIds);
|
||||
void delUserRoleRelation(String UserId);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Set;
|
||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
|
||||
void saveRoleRelation(@Param("user") String UserId, @Param("roles") Collection<String> roles);
|
||||
void delRoleRelation(@Param("user") String UserId);
|
||||
|
||||
void deleteRoleMenuBatchRoleIds(Collection<String> ids);
|
||||
|
||||
|
||||
@@ -8,6 +8,12 @@
|
||||
(#{user},#{role})
|
||||
</foreach>
|
||||
</insert>
|
||||
<delete id="delRoleRelation">
|
||||
delete from sys_users_roles where user_id = #{user}
|
||||
</delete>
|
||||
|
||||
|
||||
|
||||
<insert id="insertRoleMenu">
|
||||
insert into sys_roles_menus values
|
||||
<foreach collection="menuIds" item="menuId" separator=",">
|
||||
|
||||
@@ -7,10 +7,12 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
@@ -20,6 +22,7 @@ import org.nl.system.service.role.dao.mapper.SysRoleMapper;
|
||||
import org.nl.system.service.menu.dao.mapper.SysMenuMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -133,8 +136,15 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveUserRoleRelation(String UserId, List<String> deptIds) {
|
||||
|
||||
public void saveUserRoleRelation(String user, List<String> roles) {
|
||||
if (StringUtils.isEmpty(user) || CollectionUtils.isEmpty(roles)){
|
||||
return;
|
||||
}
|
||||
roleMapper.saveRoleRelation(user,roles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delUserRoleRelation(String user) {
|
||||
roleMapper.delRoleRelation(user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,6 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
|
||||
void create(Map userDetail);
|
||||
|
||||
void update(Map userDetail);
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.common.config.FileProperties;
|
||||
import org.nl.modules.common.utils.FileUtil;
|
||||
@@ -25,13 +26,11 @@ import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -94,7 +93,29 @@ public class ISysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> imp
|
||||
deptService.saveUserDeptRelation(userId,(List)userDetail.get("depts"));
|
||||
};
|
||||
if (userDetail.get("roles") !=null){
|
||||
roleService.saveUserRoleRelation(userId,(List)userDetail.get("depts"));
|
||||
roleService.saveUserRoleRelation(userId,(List)userDetail.get("roles"));
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
@Transactional
|
||||
public void update(Map userDetail) {
|
||||
if(CollectionUtils.isEmpty(userDetail)|| userDetail.get("userId")==null){
|
||||
return;
|
||||
}
|
||||
SysUser sysUser = new SysUser();
|
||||
BeanUtils.populate(sysUser,userDetail);
|
||||
sysUser.setUpdateTime(new Date());
|
||||
sysUser.setUpdateId(SecurityUtils.getCurrentUserId());
|
||||
this.updateById(sysUser);
|
||||
if (userDetail.get("depts") !=null){
|
||||
deptService.delUserDeptRelation(sysUser.getUserId());
|
||||
deptService.saveUserDeptRelation(sysUser.getUserId(),(List)userDetail.get("depts"));
|
||||
};
|
||||
if (userDetail.get("roles") !=null){
|
||||
roleService.delUserRoleRelation(sysUser.getUserId());
|
||||
roleService.saveUserRoleRelation(sysUser.getUserId(),(List)userDetail.get("roles"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user