Commit e430c585 by zzrdark

1.用户模块

parent 9c2372bb
......@@ -19,7 +19,7 @@ public interface SysRoleDeptDao extends BaseMapper<SysRoleDeptEntity> {
/**
* 根据角色ID,获取部门ID列表
*/
List<Long> queryDeptIdList(Long[] roleIds);
List<Long> queryDeptId(Long roleId);
/**
* 根据角色ID数组,批量删除
......
......@@ -23,6 +23,6 @@ public interface SysRoleFuncDao extends BaseMapper<SysRoleFuncEntity> {
/**
* 根据角色ID,获取菜单ID列表
*/
List<Long> queryMenuIdList(Long roleId);
List<Long> queryFuncId(Long roleId);
}
......@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mx.cneeds.server.entity.SysUserDeptEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 部门与角色映射表
*
......@@ -17,4 +19,9 @@ public interface SysUserDeptDao extends BaseMapper<SysUserDeptEntity> {
* 根据角色ID数组,批量删除
*/
int deleteBatch(Long[] roleIds);
/**
* 根据角色ID,获取部门ID列表
*/
List<Long> queryDeptIdList(Long userId);
}
......@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mx.cneeds.server.entity.SysUserFuncEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 功能与角色映射表
*
......@@ -17,4 +19,10 @@ public interface SysUserFuncDao extends BaseMapper<SysUserFuncEntity> {
* 根据角色ID数组,批量删除
*/
int deleteBatch(Long[] roleIds);
/**
* 根据角色ID,获取菜单ID列表
*/
List<Long> queryFuncIdList(Long roleId);
}
......@@ -17,9 +17,9 @@ import java.util.List;
public interface SysUserRoleDao extends BaseMapper<SysUserRoleEntity> {
/**
* 根据用户ID,获取角色ID列表
* 根据用户ID,获取角色ID
*/
List<Long> queryRoleIdList(Long userId);
Long queryRoleId(Long userId);
/**
* 根据角色ID数组,批量删除
......
......@@ -11,11 +11,9 @@
</resultMap>
<select id="queryDeptIdList" resultType="long">
select dept_id from sys_role_dept where role_id in
<foreach item="roleId" collection="array" open="(" separator="," close=")">
#{roleId}
</foreach>
<select id="queryDeptId" resultType="long">
select dept_id from sys_role_dept where role_id = #{roleId}
</select>
<delete id="deleteBatch">
......
......@@ -18,7 +18,7 @@
</foreach>
</delete>
<select id="queryMenuIdList" resultType="long">
select func_id from sys_role_func where role_id = #{value}
<select id="queryFuncId" resultType="long">
select func_id from sys_role_func where role_id = #{roleId}
</select>
</mapper>
\ No newline at end of file
......@@ -18,5 +18,9 @@
</foreach>
</delete>
<select id="queryDeptIdList" resultType="long">
select dept_id from sys_user_dept where user_id = #{userId}
</select>
</mapper>
\ No newline at end of file
......@@ -16,4 +16,8 @@
#{userId}
</foreach>
</delete>
<select id="queryFuncIdList" resultType="long">
select func_id from sys_user_func where user_id = #{userId}
</select>
</mapper>
\ No newline at end of file
......@@ -10,7 +10,7 @@
<result property="roleId" column="role_id"/>
</resultMap>
<select id="queryRoleIdList" resultType="long">
<select id="queryRoleId" resultType="long">
select role_id from sys_user_role where user_id = #{value}
</select>
......
......@@ -3,6 +3,7 @@ package com.mx.cneeds.common.vo;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @ClassName SysUser
......@@ -12,10 +13,43 @@ import java.io.Serializable;
**/
@Data
public class UserVo implements Serializable {
/**
* 用户id
*/
private Long userId;
/**
* 用户名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 加密盐
*/
private String salt;
/**
* 邮箱
*/
private String email;
/**
* 手机
*/
private String mobile;
/**
* 账户状态 0:禁用 1:正常
*/
private Integer status;
/**
* 部门id
*/
private Long deptId;
private List<Long> funcIdList;
private List<Long> deptIdList;
private Long roleId;
}
......@@ -86,6 +86,11 @@ public interface UserClient {
@PostMapping("/sys/role/delete")
void deleteRole(@RequestBody List<Long> ids);
@PostMapping("/sys/role/listAll")
List<RoleDto> roleListAll();
/**
*
* @param page
......@@ -103,4 +108,15 @@ public interface UserClient {
@PostMapping("/sys/user/userinfo")
UserDto userInfo(@RequestParam String username);
@PostMapping("/sys/user/save")
void addUser(@RequestBody UserDto dto);
@PostMapping("/sys/user/update")
void updateUser(@RequestBody UserDto dto);
@PostMapping("/sys/user/delete")
void deleteUser(@RequestBody List<Long> ids);
}
......@@ -37,7 +37,7 @@ public class FeignInterceptor implements RequestInterceptor {
String authString = RequestParamterConverter.authorizationConverter("clientapp","112233");
requestTemplate.header("Authorization",authString);
}else{
requestTemplate.query("username",username);
requestTemplate.query("login_username",username);
}
}
......
......@@ -6,10 +6,7 @@ import com.mx.cneeds.common.dto.*;
import com.mx.cneeds.common.generate.CascaderToolUtils;
import com.mx.cneeds.common.generate.TreeToolUtils;
import com.mx.cneeds.common.result.R;
import com.mx.cneeds.common.vo.CascaderVo;
import com.mx.cneeds.common.vo.DepartmentVo;
import com.mx.cneeds.common.vo.RoleVo;
import com.mx.cneeds.common.vo.TreeVo;
import com.mx.cneeds.common.vo.*;
import com.mx.cneeds.server.datashow.client.UserClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
......@@ -317,6 +314,13 @@ public class SystemController {
return R.ok();
}
@PostMapping("/role/listAll")
public R selectRole(){
List<RoleDto> roleDtos = userClient.roleListAll();
return new R().put("data",roleDtos);
}
@PostMapping("/user/list")
public R userList(@RequestParam(required = false) Integer page,
@RequestParam(required = false) Integer pageSize,
......@@ -348,4 +352,32 @@ public class SystemController {
return new R().put("data",pageDto);
}
@RequestMapping("/user/info")
public R infoRole(String username){
UserDto dto = userClient.userInfo(username);
return R.ok().put("data",dto);
}
@RequestMapping("/user/add")
public R addUser(UserVo vo){
UserDto dto = new UserDto();
BeanUtils.copyProperties(vo,dto);
userClient.addUser(dto);
return R.ok();
}
@PostMapping("/user/update")
public R editUser(UserVo vo){
UserDto dto = new UserDto();
BeanUtils.copyProperties(vo,dto);
userClient.updateUser(dto);
return R.ok();
}
@PostMapping("/user/delete")
public R deleteUser(@RequestParam(value = "ids",required = false) List<Long> ids){
userClient.deleteUser(ids);
return R.ok();
}
}
......@@ -59,7 +59,7 @@ public class DataFilterAspect {
public void dataFilter(JoinPoint point){
Object params = point.getArgs()[0];
if(params != null && params instanceof Map){
String username = (String) ((Map) params).get("username");
String username = (String) ((Map) params).get("login_username");
//如果不是超级管理员,则进行数据过滤
if(!Constant.STRING_SUPER_ADMIN.equals(username)){
Map map = (Map)params;
......@@ -89,9 +89,9 @@ public class DataFilterAspect {
SysUserEntity sysUserEntity = sysUserService.queryUserByUsername(username);
//用户角色对应的部门ID列表
List<Long> roleIdList = sysUserRoleService.queryRoleIdList(sysUserEntity.getUserId());
if(roleIdList.size() > 0){
List<Long> userDeptIdList = sysRoleDeptService.queryDeptIdList(roleIdList.toArray(new Long[roleIdList.size()]));
Long roleId = sysUserRoleService.queryRoleId(sysUserEntity.getUserId());
if(roleId != null){
List<Long> userDeptIdList = sysRoleDeptService.queryDeptId(roleId);
deptIdList.addAll(userDeptIdList);
}
......
......@@ -22,7 +22,7 @@ public interface SysRoleDeptService extends IService<SysRoleDeptEntity> {
/**
* 根据角色ID,获取部门ID列表
*/
List<Long> queryDeptIdList(Long[] roleIds) ;
List<Long> queryDeptId(Long roleIds) ;
void saveOrUpdate(Long roleId, List<Long> deptIdList);
......
......@@ -23,6 +23,6 @@ public interface SysRoleFuncService extends IService<SysRoleFuncEntity> {
int deleteBatch(Long[] roleIds);
List<Long> queryMenuIdList(Long roleId);
List<Long> queryFuncId(Long roleId);
}
......@@ -22,5 +22,7 @@ public interface SysUserDeptService extends IService<SysUserDeptEntity> {
int deleteBatch(Long[] userIds);
void saveOrUpdate(Long userId, List<Long> deptIdList);
List<Long> queryDeptIdList(Long userId);
}
......@@ -22,5 +22,7 @@ public interface SysUserFuncService extends IService<SysUserFuncEntity> {
int deleteBatch(Long[] userIds);
void saveOrUpdate(Long userId, List<Long> menuIdList);
List<Long> queryFuncIdList(Long user);
}
......@@ -22,7 +22,7 @@ public interface SysUserRoleService extends IService<SysUserRoleEntity> {
* 根据用户ID,获取角色ID列表
* @param userId
*/
List<Long> queryRoleIdList(Long userId);
Long queryRoleId(Long userId);
int deleteBatch(Long[] roleIds);
......
......@@ -29,8 +29,8 @@ public class SysRoleDeptServiceImpl extends ServiceImpl<SysRoleDeptDao, SysRoleD
}
@Override
public List<Long> queryDeptIdList(Long[] roleIds) {
return baseMapper.queryDeptIdList(roleIds);
public List<Long> queryDeptId(Long roleId) {
return baseMapper.queryDeptId(roleId);
}
......
......@@ -54,8 +54,8 @@ public class SysRoleFuncServiceImpl extends ServiceImpl<SysRoleFuncDao, SysRoleF
}
@Override
public List<Long> queryMenuIdList(Long roleId) {
return baseMapper.queryMenuIdList(roleId);
public List<Long> queryFuncId(Long roleId) {
return baseMapper.queryFuncId(roleId);
}
}
......@@ -55,4 +55,9 @@ public class SysUserDeptServiceImpl extends ServiceImpl<SysUserDeptDao, SysUserD
}
}
@Override
public List<Long> queryDeptIdList(Long userId) {
return baseMapper.queryDeptIdList(userId);
}
}
......@@ -56,4 +56,9 @@ public class SysUserFuncServiceImpl extends ServiceImpl<SysUserFuncDao, SysUserF
}
}
@Override
public List<Long> queryFuncIdList(Long userId) {
return baseMapper.queryFuncIdList(userId);
}
}
......@@ -28,8 +28,8 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleDao, SysUserR
}
@Override
public List<Long> queryRoleIdList(Long userId) {
return baseMapper.queryRoleIdList(userId);
public Long queryRoleId(Long userId) {
return baseMapper.queryRoleId(userId);
}
@Override
......
......@@ -100,11 +100,11 @@ public class SysRoleController {
//查询角色对应的菜单
List<Long> funcIdList = sysRoleFuncService.queryMenuIdList(roleId);
List<Long> funcIdList = sysRoleFuncService.queryFuncId(roleId);
roleDto.setFuncIdList(funcIdList);
//查询角色对应的部门
List<Long> deptIdList = sysRoleDeptService.queryDeptIdList(new Long[]{roleId});
List<Long> deptIdList = sysRoleDeptService.queryDeptId(roleId);
roleDto.setDeptIdList(deptIdList);
return roleDto;
......
......@@ -6,12 +6,16 @@ import com.mx.cneeds.common.result.R;
import com.mx.cneeds.common.validator.ValidatorUtils;
import com.mx.cneeds.common.vo.UserVo;
import com.mx.cneeds.server.entity.SysUserEntity;
import com.mx.cneeds.server.user.service.SysUserDeptService;
import com.mx.cneeds.server.user.service.SysUserFuncService;
import com.mx.cneeds.server.user.service.SysUserRoleService;
import com.mx.cneeds.server.user.service.SysUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
//import org.apache.shiro.authz.annotation.RequiresPermissions;
......@@ -30,6 +34,17 @@ public class SysUserController {
@Autowired
private SysUserService sysUserService;
@Autowired
private SysUserRoleService sysUserRoleService;
@Autowired
private SysUserDeptService sysUserDeptService;
@Autowired
private SysUserFuncService sysUserFuncService;
/**
* 列表
......@@ -54,8 +69,12 @@ public class SysUserController {
@PostMapping("/userinfo")
public UserDto infoByUsername(@RequestParam("username") String username){
SysUserEntity sysUser = sysUserService.queryUserByUsername(username);
Long roleId = sysUserRoleService.queryRoleId(sysUser.getUserId());
UserDto userDto = new UserDto();
BeanUtils.copyProperties(sysUser,userDto);
userDto.setRoleId(roleId);
userDto.setDeptIdList(sysUserDeptService.queryDeptIdList(sysUser.getUserId()));
userDto.setFuncIdList(sysUserFuncService.queryFuncIdList(sysUser.getUserId()));
return userDto;
}
......@@ -83,7 +102,7 @@ public class SysUserController {
BeanUtils.copyProperties(dto,sysUser);
ValidatorUtils.validateEntity(sysUser);
sysUserService.update(sysUser, dto.getFuncIdList(), dto.getDeptIdList());
return R.ok();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment