| | |
| | | private String menuName; |
| | | |
| | | /** 父菜单名称 */ |
| | | @TableField(exist = false) |
| | | private String parentName; |
| | | |
| | | /** 父菜单ID */ |
| | |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysMenuMapper extends BaseMapper<SysMenu> { |
| | | /** |
| | | * 查询系统菜单列表 |
| | | * |
| | | * @param menu 菜单信息 |
| | | * @return 菜单列表 |
| | | */ |
| | | public List<SysMenu> selectMenuList(SysMenu menu); |
| | | |
| | | /** |
| | | * 根据用户所有权限 |
| | |
| | | */ |
| | | public List<Integer> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly); |
| | | |
| | | /** |
| | | * 根据菜单ID查询信息 |
| | | * |
| | | * @param menuId 菜单ID |
| | | * @return 菜单信息 |
| | | */ |
| | | public SysMenu selectMenuById(Long menuId); |
| | | |
| | | /** |
| | | * 是否存在菜单子节点 |
| | | * |
| | | * @param menuId 菜单ID |
| | | * @return 结果 |
| | | */ |
| | | public int hasChildByMenuId(Long menuId); |
| | | |
| | | /** |
| | | * 新增菜单信息 |
| | | * |
| | | * @param menu 菜单信息 |
| | | * @return 结果 |
| | | */ |
| | | public int insertMenu(SysMenu menu); |
| | | |
| | | /** |
| | | * 修改菜单信息 |
| | | * |
| | | * @param menu 菜单信息 |
| | | * @return 结果 |
| | | */ |
| | | public int updateMenu(SysMenu menu); |
| | | |
| | | /** |
| | | * 删除菜单管理信息 |
| | | * |
| | | * @param menuId 菜单ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteMenuById(Long menuId); |
| | | |
| | | /** |
| | | * 校验菜单名称是否唯一 |
| | | * |
| | | * @param menuName 菜单名称 |
| | | * @param parentId 父菜单ID |
| | | * @return 结果 |
| | | */ |
| | | public SysMenu checkMenuNameUnique(@Param("menuName") String menuName, @Param("parentId") Long parentId); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.system.domain.SysRoleDept; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色与部门关联表 数据层 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysRoleDeptMapper extends BaseMapper<SysRoleDept> { |
| | | /** |
| | | * 通过角色ID删除角色和部门关联 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteRoleDeptByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * 批量删除角色部门关联信息 |
| | | * |
| | | * @param ids 需要删除的数据ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteRoleDept(Long[] ids); |
| | | |
| | | /** |
| | | * 查询部门使用数量 |
| | | * |
| | | * @param deptId 部门ID |
| | | * @return 结果 |
| | | */ |
| | | public int selectCountRoleDeptByDeptId(Long deptId); |
| | | |
| | | /** |
| | | * 批量新增角色部门信息 |
| | | * |
| | | * @param roleDeptList 角色部门列表 |
| | | * @return 结果 |
| | | */ |
| | | public int batchRoleDept(List<SysRoleDept> roleDeptList); |
| | | } |
| | |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysRoleMapper extends BaseMapper<SysRole> { |
| | | /** |
| | | * 根据条件分页查询角色数据 |
| | | * |
| | | * @param role 角色信息 |
| | | * @return 角色数据集合信息 |
| | | */ |
| | | public List<SysRole> selectRoleList(SysRole role); |
| | | |
| | | |
| | | /** |
| | | * 根据用户ID查询角色 |
| | |
| | | */ |
| | | public List<SysRole> selectRolePermissionByUserId(Long userId); |
| | | |
| | | /** |
| | | * 查询所有角色 |
| | | * |
| | | * @return 角色列表 |
| | | */ |
| | | public List<SysRole> selectRoleAll(); |
| | | |
| | | /** |
| | | * 根据用户ID获取角色选择框列表 |
| | |
| | | public List<Integer> selectRoleListByUserId(Long userId); |
| | | |
| | | /** |
| | | * 通过角色ID查询角色 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 角色对象信息 |
| | | */ |
| | | public SysRole selectRoleById(Long roleId); |
| | | |
| | | /** |
| | | * 根据用户ID查询角色 |
| | | * |
| | | * @param userName 用户名 |
| | |
| | | */ |
| | | public List<SysRole> selectRolesByUserName(String userName); |
| | | |
| | | /** |
| | | * 校验角色名称是否唯一 |
| | | * |
| | | * @param roleName 角色名称 |
| | | * @return 角色信息 |
| | | */ |
| | | public SysRole checkRoleNameUnique(String roleName); |
| | | |
| | | /** |
| | | * 校验角色权限是否唯一 |
| | | * |
| | | * @param roleKey 角色权限 |
| | | * @return 角色信息 |
| | | */ |
| | | public SysRole checkRoleKeyUnique(String roleKey); |
| | | |
| | | /** |
| | | * 修改角色信息 |
| | | * |
| | | * @param role 角色信息 |
| | | * @return 结果 |
| | | */ |
| | | public int updateRole(SysRole role); |
| | | |
| | | /** |
| | | * 新增角色信息 |
| | | * |
| | | * @param role 角色信息 |
| | | * @return 结果 |
| | | */ |
| | | public int insertRole(SysRole role); |
| | | |
| | | /** |
| | | * 通过角色ID删除角色 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteRoleById(Long roleId); |
| | | |
| | | /** |
| | | * 批量删除角色信息 |
| | | * |
| | | * @param roleIds 需要删除的角色ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteRoleByIds(Long[] roleIds); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.system.domain.SysRoleMenu; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 角色与菜单关联表 数据层 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysRoleMenuMapper extends BaseMapper<SysRoleMenu> { |
| | | /** |
| | | * 查询菜单使用数量 |
| | | * |
| | | * @param menuId 菜单ID |
| | | * @return 结果 |
| | | */ |
| | | public int checkMenuExistRole(Long menuId); |
| | | |
| | | /** |
| | | * 通过角色ID删除角色和菜单关联 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteRoleMenuByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * 批量删除角色菜单关联信息 |
| | | * |
| | | * @param ids 需要删除的数据ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteRoleMenu(Long[] ids); |
| | | |
| | | /** |
| | | * 批量新增角色菜单信息 |
| | | * |
| | | * @param roleMenuList 角色菜单列表 |
| | | * @return 结果 |
| | | */ |
| | | public int batchRoleMenu(List<SysRoleMenu> roleMenuList); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | */ |
| | | public SysUser selectUserById(Long userId); |
| | | |
| | | /** |
| | | * 新增用户信息 |
| | | * |
| | | * @param user 用户信息 |
| | | * @return 结果 |
| | | */ |
| | | public int insertUser(SysUser user); |
| | | |
| | | /** |
| | | * 修改用户信息 |
| | | * |
| | | * @param user 用户信息 |
| | | * @return 结果 |
| | | */ |
| | | public int updateUser(SysUser user); |
| | | |
| | | /** |
| | | * 修改用户头像 |
| | | * |
| | | * @param userName 用户名 |
| | | * @param avatar 头像地址 |
| | | * @return 结果 |
| | | */ |
| | | public int updateUserAvatar(@Param("userName") String userName, @Param("avatar") String avatar); |
| | | |
| | | /** |
| | | * 重置用户密码 |
| | | * |
| | | * @param userName 用户名 |
| | | * @param password 密码 |
| | | * @return 结果 |
| | | */ |
| | | public int resetUserPwd(@Param("userName") String userName, @Param("password") String password); |
| | | |
| | | /** |
| | | * 通过用户ID删除用户 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteUserById(Long userId); |
| | | |
| | | /** |
| | | * 批量删除用户信息 |
| | | * |
| | | * @param userIds 需要删除的用户ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteUserByIds(Long[] userIds); |
| | | |
| | | /** |
| | | * 校验用户名称是否唯一 |
| | | * |
| | | * @param userName 用户名称 |
| | | * @return 结果 |
| | | */ |
| | | public int checkUserNameUnique(String userName); |
| | | |
| | | /** |
| | | * 校验手机号码是否唯一 |
| | | * |
| | | * @param phonenumber 手机号码 |
| | | * @return 结果 |
| | | */ |
| | | public SysUser checkPhoneUnique(String phonenumber); |
| | | |
| | | /** |
| | | * 校验email是否唯一 |
| | | * |
| | | * @param email 用户邮箱 |
| | | * @return 结果 |
| | | */ |
| | | public SysUser checkEmailUnique(String email); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.system.domain.SysUserPost; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户与岗位关联表 数据层 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysUserPostMapper extends BaseMapper<SysUserPost> { |
| | | /** |
| | | * 通过用户ID删除用户和岗位关联 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteUserPostByUserId(Long userId); |
| | | |
| | | /** |
| | | * 批量删除用户和岗位关联 |
| | | * |
| | | * @param ids 需要删除的数据ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteUserPost(Long[] ids); |
| | | |
| | | /** |
| | | * 批量新增用户岗位信息 |
| | | * |
| | | * @param userPostList 用户角色列表 |
| | | * @return 结果 |
| | | */ |
| | | public int batchUserPost(List<SysUserPost> userPostList); |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户与角色关联表 数据层 |
| | |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysUserRoleMapper extends BaseMapper<SysUserRole> { |
| | | /** |
| | | * 通过用户ID删除用户和角色关联 |
| | | * |
| | | * @param userId 用户ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteUserRoleByUserId(Long userId); |
| | | |
| | | /** |
| | | * 批量删除用户和角色关联 |
| | | * |
| | | * @param ids 需要删除的数据ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteUserRole(Long[] ids); |
| | | |
| | | /** |
| | | * 通过角色ID查询角色使用数量 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @return 结果 |
| | | */ |
| | | public int countUserRoleByRoleId(Long roleId); |
| | | |
| | | /** |
| | | * 批量新增用户角色信息 |
| | | * |
| | | * @param userRoleList 用户角色列表 |
| | | * @return 结果 |
| | | */ |
| | | public int batchUserRole(List<SysUserRole> userRoleList); |
| | | |
| | | /** |
| | | * 删除用户和角色关联信息 |
| | | * |
| | | * @param userRole 用户和角色关联信息 |
| | | * @return 结果 |
| | | */ |
| | | public int deleteUserRoleInfo(SysUserRole userRole); |
| | | |
| | | /** |
| | | * 批量取消授权用户角色 |
| | | * |
| | | * @param roleId 角色ID |
| | | * @param userIds 需要删除的用户数据ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") Long[] userIds); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public List<Integer> selectDeptListByRoleId(Long roleId) { |
| | | SysRole role = roleMapper.selectRoleById(roleId); |
| | | SysRole role = roleMapper.selectById(roleId); |
| | | return baseMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly()); |
| | | } |
| | | |
| | |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.TreeSelect; |
| | |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.system.domain.SysRoleMenu; |
| | | import com.ruoyi.system.domain.vo.MetaVo; |
| | | import com.ruoyi.system.domain.vo.RouterVo; |
| | | import com.ruoyi.system.mapper.SysMenuMapper; |
| | |
| | | @Service |
| | | public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements ISysMenuService { |
| | | public static final String PREMISSION_STRING = "perms[\"{0}\"]"; |
| | | |
| | | @Autowired |
| | | private SysMenuMapper menuMapper; |
| | | |
| | | @Autowired |
| | | private SysRoleMapper roleMapper; |
| | |
| | | List<SysMenu> menuList = null; |
| | | // 管理员显示所有菜单信息 |
| | | if (SysUser.isAdmin(userId)) { |
| | | menuList = menuMapper.selectMenuList(menu); |
| | | menuList = list(new LambdaQueryWrapper<SysMenu>() |
| | | .like(StrUtil.isNotBlank(menu.getMenuName()),SysMenu::getMenuName,menu.getMenuName()) |
| | | .eq(StrUtil.isNotBlank(menu.getVisible()),SysMenu::getVisible,menu.getVisible()) |
| | | .eq(StrUtil.isNotBlank(menu.getStatus()),SysMenu::getStatus,menu.getStatus()) |
| | | .orderByAsc(SysMenu::getParentId) |
| | | .orderByAsc(SysMenu::getOrderNum)); |
| | | } else { |
| | | menu.getParams().put("userId", userId); |
| | | menuList = menuMapper.selectMenuListByUserId(menu); |
| | | menuList = baseMapper.selectMenuListByUserId(menu); |
| | | } |
| | | return menuList; |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public Set<String> selectMenuPermsByUserId(Long userId) { |
| | | List<String> perms = menuMapper.selectMenuPermsByUserId(userId); |
| | | List<String> perms = baseMapper.selectMenuPermsByUserId(userId); |
| | | Set<String> permsSet = new HashSet<>(); |
| | | for (String perm : perms) { |
| | | if (Validator.isNotEmpty(perm)) { |
| | |
| | | public List<SysMenu> selectMenuTreeByUserId(Long userId) { |
| | | List<SysMenu> menus = null; |
| | | if (SecurityUtils.isAdmin(userId)) { |
| | | menus = menuMapper.selectMenuTreeAll(); |
| | | menus = baseMapper.selectMenuTreeAll(); |
| | | } else { |
| | | menus = menuMapper.selectMenuTreeByUserId(userId); |
| | | menus = baseMapper.selectMenuTreeByUserId(userId); |
| | | } |
| | | return getChildPerms(menus, 0); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public List<Integer> selectMenuListByRoleId(Long roleId) { |
| | | SysRole role = roleMapper.selectRoleById(roleId); |
| | | return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly()); |
| | | SysRole role = roleMapper.selectById(roleId); |
| | | return baseMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly()); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public SysMenu selectMenuById(Long menuId) { |
| | | return menuMapper.selectMenuById(menuId); |
| | | return getById(menuId); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public boolean hasChildByMenuId(Long menuId) { |
| | | int result = menuMapper.hasChildByMenuId(menuId); |
| | | int result = count(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId,menuId)); |
| | | return result > 0 ? true : false; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public boolean checkMenuExistRole(Long menuId) { |
| | | int result = roleMenuMapper.checkMenuExistRole(menuId); |
| | | int result = roleMenuMapper.selectCount(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId,menuId)); |
| | | return result > 0 ? true : false; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public int insertMenu(SysMenu menu) { |
| | | return menuMapper.insertMenu(menu); |
| | | return baseMapper.insert(menu); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public int updateMenu(SysMenu menu) { |
| | | return menuMapper.updateMenu(menu); |
| | | return baseMapper.updateById(menu); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public int deleteMenuById(Long menuId) { |
| | | return menuMapper.deleteMenuById(menuId); |
| | | return baseMapper.deleteById(menuId); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public String checkMenuNameUnique(SysMenu menu) { |
| | | Long menuId = Validator.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); |
| | | SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId()); |
| | | SysMenu info = getOne(new LambdaQueryWrapper<SysMenu>() |
| | | .eq(SysMenu::getMenuName,menu.getMenuName()) |
| | | .eq(SysMenu::getParentId,menu.getParentId()) |
| | | .last("limit 1")); |
| | | if (Validator.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import com.ruoyi.system.domain.SysRoleDept; |
| | | import com.ruoyi.system.domain.SysRoleMenu; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.mapper.SysRoleDeptMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMenuMapper; |
| | |
| | | */ |
| | | @Service |
| | | public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements ISysRoleService { |
| | | @Autowired |
| | | private SysRoleMapper roleMapper; |
| | | |
| | | @Autowired |
| | | private SysRoleMenuMapper roleMenuMapper; |
| | |
| | | @Override |
| | | @DataScope(deptAlias = "d") |
| | | public List<SysRole> selectRoleList(SysRole role) { |
| | | return roleMapper.selectRoleList(role); |
| | | Map<String, Object> params = role.getParams(); |
| | | Object dataScope = params.get("dataScope"); |
| | | return list(new LambdaQueryWrapper<SysRole>() |
| | | .like(StrUtil.isNotBlank(role.getRoleName()), SysRole::getRoleName, role.getRoleName()) |
| | | .eq(StrUtil.isNotBlank(role.getStatus()), SysRole::getStatus, role.getStatus()) |
| | | .like(StrUtil.isNotBlank(role.getRoleKey()), SysRole::getRoleKey, role.getRoleKey()) |
| | | .apply(Validator.isNotEmpty(params.get("beginTime")), |
| | | "date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')", |
| | | params.get("beginTime")) |
| | | .apply(Validator.isNotEmpty(params.get("endTime")), |
| | | "date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')", |
| | | params.get("endTime")) |
| | | .apply(dataScope != null, dataScope != null ? dataScope.toString() : null) |
| | | .orderByAsc(SysRole::getRoleSort)); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public Set<String> selectRolePermissionByUserId(Long userId) { |
| | | List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId); |
| | | List<SysRole> perms = baseMapper.selectRolePermissionByUserId(userId); |
| | | Set<String> permsSet = new HashSet<>(); |
| | | for (SysRole perm : perms) { |
| | | if (Validator.isNotNull(perm)) { |
| | |
| | | */ |
| | | @Override |
| | | public List<Integer> selectRoleListByUserId(Long userId) { |
| | | return roleMapper.selectRoleListByUserId(userId); |
| | | return baseMapper.selectRoleListByUserId(userId); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public SysRole selectRoleById(Long roleId) { |
| | | return roleMapper.selectRoleById(roleId); |
| | | return getById(roleId); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public String checkRoleNameUnique(SysRole role) { |
| | | Long roleId = Validator.isNull(role.getRoleId()) ? -1L : role.getRoleId(); |
| | | SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName()); |
| | | SysRole info = getOne(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleName, role.getRoleName()).last("limit 1")); |
| | | if (Validator.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | @Override |
| | | public String checkRoleKeyUnique(SysRole role) { |
| | | Long roleId = Validator.isNull(role.getRoleId()) ? -1L : role.getRoleId(); |
| | | SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey()); |
| | | SysRole info = getOne(new LambdaQueryWrapper<SysRole>() |
| | | .eq(SysRole::getRoleKey, role.getRoleKey()).last("limit 1")); |
| | | if (Validator.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public int countUserRoleByRoleId(Long roleId) { |
| | | return userRoleMapper.countUserRoleByRoleId(roleId); |
| | | return userRoleMapper.selectCount(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getRoleId, roleId)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Transactional |
| | | public int insertRole(SysRole role) { |
| | | // 新增角色信息 |
| | | roleMapper.insertRole(role); |
| | | baseMapper.insert(role); |
| | | return insertRoleMenu(role); |
| | | } |
| | | |
| | |
| | | @Transactional |
| | | public int updateRole(SysRole role) { |
| | | // 修改角色信息 |
| | | roleMapper.updateRole(role); |
| | | baseMapper.updateById(role); |
| | | // 删除角色与菜单关联 |
| | | roleMenuMapper.deleteRoleMenuByRoleId(role.getRoleId()); |
| | | roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, role.getRoleId())); |
| | | return insertRoleMenu(role); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public int updateRoleStatus(SysRole role) { |
| | | return roleMapper.updateRole(role); |
| | | return baseMapper.updateById(role); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Transactional |
| | | public int authDataScope(SysRole role) { |
| | | // 修改角色信息 |
| | | roleMapper.updateRole(role); |
| | | baseMapper.updateById(role); |
| | | // 删除角色与部门关联 |
| | | roleDeptMapper.deleteRoleDeptByRoleId(role.getRoleId()); |
| | | roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().eq(SysRoleDept::getRoleId, role.getRoleId())); |
| | | // 新增角色和部门信息(数据权限) |
| | | return insertRoleDept(role); |
| | | } |
| | |
| | | * @param role 角色对象 |
| | | */ |
| | | public int insertRoleMenu(SysRole role) { |
| | | int rows = 1; |
| | | int rows = 0; |
| | | // 新增用户与角色管理 |
| | | List<SysRoleMenu> list = new ArrayList<SysRoleMenu>(); |
| | | for (Long menuId : role.getMenuIds()) { |
| | |
| | | list.add(rm); |
| | | } |
| | | if (list.size() > 0) { |
| | | rows = roleMenuMapper.batchRoleMenu(list); |
| | | for (SysRoleMenu sysRoleMenu : list) { |
| | | rows += roleMenuMapper.insert(sysRoleMenu); |
| | | } |
| | | } |
| | | return rows; |
| | | } |
| | |
| | | * @param role 角色对象 |
| | | */ |
| | | public int insertRoleDept(SysRole role) { |
| | | int rows = 1; |
| | | int rows = 0; |
| | | // 新增角色与部门(数据权限)管理 |
| | | List<SysRoleDept> list = new ArrayList<SysRoleDept>(); |
| | | for (Long deptId : role.getDeptIds()) { |
| | |
| | | list.add(rd); |
| | | } |
| | | if (list.size() > 0) { |
| | | rows = roleDeptMapper.batchRoleDept(list); |
| | | for (SysRoleDept sysRoleDept : list) { |
| | | rows += roleDeptMapper.insert(sysRoleDept); |
| | | } |
| | | } |
| | | return rows; |
| | | } |
| | |
| | | @Transactional |
| | | public int deleteRoleById(Long roleId) { |
| | | // 删除角色与菜单关联 |
| | | roleMenuMapper.deleteRoleMenuByRoleId(roleId); |
| | | roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, roleId)); |
| | | // 删除角色与部门关联 |
| | | roleDeptMapper.deleteRoleDeptByRoleId(roleId); |
| | | return roleMapper.deleteRoleById(roleId); |
| | | roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().eq(SysRoleDept::getRoleId, roleId)); |
| | | return baseMapper.deleteById(roleId); |
| | | } |
| | | |
| | | /** |
| | |
| | | throw new CustomException(String.format("%1$s已分配,不能删除", role.getRoleName())); |
| | | } |
| | | } |
| | | List<Long> ids = Arrays.asList(roleIds); |
| | | // 删除角色与菜单关联 |
| | | roleMenuMapper.deleteRoleMenu(roleIds); |
| | | roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, ids)); |
| | | // 删除角色与部门关联 |
| | | roleDeptMapper.deleteRoleDept(roleIds); |
| | | return roleMapper.deleteRoleByIds(roleIds); |
| | | roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().in(SysRoleDept::getRoleId, ids)); |
| | | return baseMapper.deleteBatchIds(ids); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import cn.hutool.core.lang.Validator; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public String checkUserNameUnique(String userName) { |
| | | int count = userMapper.checkUserNameUnique(userName); |
| | | int count = count(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName).last("limit 1")); |
| | | if (count > 0) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | @Override |
| | | public String checkPhoneUnique(SysUser user) { |
| | | Long userId = Validator.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); |
| | | SysUser info = getOne(new LambdaQueryWrapper<SysUser>() |
| | | .select(SysUser::getUserId, SysUser::getPhonenumber) |
| | | .eq(SysUser::getPhonenumber, user.getPhonenumber()).last("limit 1")); |
| | | if (Validator.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | @Override |
| | | public String checkEmailUnique(SysUser user) { |
| | | Long userId = Validator.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | SysUser info = userMapper.checkEmailUnique(user.getEmail()); |
| | | SysUser info = getOne(new LambdaQueryWrapper<SysUser>() |
| | | .select(SysUser::getUserId, SysUser::getEmail) |
| | | .eq(SysUser::getEmail, user.getEmail()).last("limit 1")); |
| | | if (Validator.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { |
| | | return UserConstants.NOT_UNIQUE; |
| | | } |
| | |
| | | @Transactional |
| | | public int insertUser(SysUser user) { |
| | | // 新增用户信息 |
| | | int rows = userMapper.insertUser(user); |
| | | int rows = userMapper.insert(user); |
| | | // 新增用户岗位关联 |
| | | insertUserPost(user); |
| | | // 新增用户与角色管理 |
| | |
| | | public int updateUser(SysUser user) { |
| | | Long userId = user.getUserId(); |
| | | // 删除用户与角色关联 |
| | | userRoleMapper.deleteUserRoleByUserId(userId); |
| | | userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId,userId)); |
| | | // 新增用户与角色管理 |
| | | insertUserRole(user); |
| | | // 删除用户与岗位关联 |
| | | userPostMapper.deleteUserPostByUserId(userId); |
| | | userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getUserId,userId)); |
| | | // 新增用户与岗位管理 |
| | | insertUserPost(user); |
| | | return userMapper.updateUser(user); |
| | | return userMapper.updateById(user); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public int updateUserStatus(SysUser user) { |
| | | return userMapper.updateUser(user); |
| | | return userMapper.updateById(user); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public int updateUserProfile(SysUser user) { |
| | | return userMapper.updateUser(user); |
| | | return userMapper.updateById(user); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public boolean updateUserAvatar(String userName, String avatar) { |
| | | return userMapper.updateUserAvatar(userName, avatar) > 0; |
| | | return userMapper.update(null, |
| | | new LambdaUpdateWrapper<SysUser>() |
| | | .set(SysUser::getAvatar,avatar) |
| | | .eq(SysUser::getUserName,userName)) > 0; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public int resetPwd(SysUser user) { |
| | | return userMapper.updateUser(user); |
| | | return userMapper.updateById(user); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public int resetUserPwd(String userName, String password) { |
| | | return userMapper.resetUserPwd(userName, password); |
| | | return userMapper.update(null, |
| | | new LambdaUpdateWrapper<SysUser>() |
| | | .set(SysUser::getPassword,password) |
| | | .eq(SysUser::getUserName,userName)); |
| | | } |
| | | |
| | | /** |
| | |
| | | list.add(ur); |
| | | } |
| | | if (list.size() > 0) { |
| | | userRoleMapper.batchUserRole(list); |
| | | for (SysUserRole sysUserRole : list) { |
| | | userRoleMapper.insert(sysUserRole); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | list.add(up); |
| | | } |
| | | if (list.size() > 0) { |
| | | userPostMapper.batchUserPost(list); |
| | | for (SysUserPost sysUserPost : list) { |
| | | userPostMapper.insert(sysUserPost); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | @Transactional |
| | | public int deleteUserById(Long userId) { |
| | | // 删除用户与角色关联 |
| | | userRoleMapper.deleteUserRoleByUserId(userId); |
| | | userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId,userId)); |
| | | // 删除用户与岗位表 |
| | | userPostMapper.deleteUserPostByUserId(userId); |
| | | return userMapper.deleteUserById(userId); |
| | | userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getUserId,userId)); |
| | | return userMapper.deleteById(userId); |
| | | } |
| | | |
| | | /** |
| | |
| | | for (Long userId : userIds) { |
| | | checkUserAllowed(new SysUser(userId)); |
| | | } |
| | | List<Long> ids = Arrays.asList(userIds); |
| | | // 删除用户与角色关联 |
| | | userRoleMapper.deleteUserRole(userIds); |
| | | // 删除用户与岗位关联 |
| | | userPostMapper.deleteUserPost(userIds); |
| | | return userMapper.deleteUserByIds(userIds); |
| | | userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId,ids)); |
| | | // 删除用户与岗位表 |
| | | userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().in(SysUserPost::getUserId,ids)); |
| | | return userMapper.deleteBatchIds(ids); |
| | | } |
| | | |
| | | /** |
| | |
| | | from sys_menu |
| | | </sql> |
| | | |
| | | <select id="selectMenuList" parameterType="SysMenu" resultMap="SysMenuResult"> |
| | | <include refid="selectMenuVo"/> |
| | | <where> |
| | | <if test="menuName != null and menuName != ''"> |
| | | AND menu_name like concat('%', #{menuName}, '%') |
| | | </if> |
| | | <if test="visible != null and visible != ''"> |
| | | AND visible = #{visible} |
| | | </if> |
| | | <if test="status != null and status != ''"> |
| | | AND status = #{status} |
| | | </if> |
| | | </where> |
| | | order by parent_id, order_num |
| | | </select> |
| | | |
| | | <select id="selectMenuTreeAll" resultMap="SysMenuResult"> |
| | | select distinct m.menu_id, |
| | |
| | | and r.status = '0' |
| | | and ur.user_id = #{userId} |
| | | </select> |
| | | |
| | | <select id="selectMenuById" parameterType="Long" resultMap="SysMenuResult"> |
| | | <include refid="selectMenuVo"/> |
| | | where menu_id = #{menuId} |
| | | </select> |
| | | |
| | | <select id="hasChildByMenuId" resultType="Integer"> |
| | | select count(1) |
| | | from sys_menu |
| | | where parent_id = #{menuId} |
| | | </select> |
| | | |
| | | <select id="checkMenuNameUnique" parameterType="SysMenu" resultMap="SysMenuResult"> |
| | | <include refid="selectMenuVo"/> |
| | | where menu_name=#{menuName} and parent_id = #{parentId} limit 1 |
| | | </select> |
| | | |
| | | <update id="updateMenu" parameterType="SysMenu"> |
| | | update sys_menu |
| | | <set> |
| | | <if test="menuName != null and menuName != ''">menu_name = #{menuName},</if> |
| | | <if test="parentId != null">parent_id = #{parentId},</if> |
| | | <if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if> |
| | | <if test="path != null and path != ''">path = #{path},</if> |
| | | <if test="component != null">component = #{component},</if> |
| | | <if test="isFrame != null and isFrame != ''">is_frame = #{isFrame},</if> |
| | | <if test="isCache != null and isCache != ''">is_cache = #{isCache},</if> |
| | | <if test="menuType != null and menuType != ''">menu_type = #{menuType},</if> |
| | | <if test="visible != null">visible = #{visible},</if> |
| | | <if test="status != null">status = #{status},</if> |
| | | <if test="perms !=null">perms = #{perms},</if> |
| | | <if test="icon !=null and icon != ''">icon = #{icon},</if> |
| | | <if test="remark != null and remark != ''">remark = #{remark},</if> |
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
| | | update_time = sysdate() |
| | | </set> |
| | | where menu_id = #{menuId} |
| | | </update> |
| | | |
| | | <insert id="insertMenu" parameterType="SysMenu"> |
| | | insert into sys_menu( |
| | | <if test="menuId != null and menuId != 0">menu_id,</if> |
| | | <if test="parentId != null and parentId != 0">parent_id,</if> |
| | | <if test="menuName != null and menuName != ''">menu_name,</if> |
| | | <if test="orderNum != null and orderNum != ''">order_num,</if> |
| | | <if test="path != null and path != ''">path,</if> |
| | | <if test="component != null and component != ''">component,</if> |
| | | <if test="isFrame != null and isFrame != ''">is_frame,</if> |
| | | <if test="isCache != null and isCache != ''">is_cache,</if> |
| | | <if test="menuType != null and menuType != ''">menu_type,</if> |
| | | <if test="visible != null">visible,</if> |
| | | <if test="status != null">status,</if> |
| | | <if test="perms !=null and perms != ''">perms,</if> |
| | | <if test="icon != null and icon != ''">icon,</if> |
| | | <if test="remark != null and remark != ''">remark,</if> |
| | | <if test="createBy != null and createBy != ''">create_by,</if> |
| | | create_time |
| | | )values( |
| | | <if test="menuId != null and menuId != 0">#{menuId},</if> |
| | | <if test="parentId != null and parentId != 0">#{parentId},</if> |
| | | <if test="menuName != null and menuName != ''">#{menuName},</if> |
| | | <if test="orderNum != null and orderNum != ''">#{orderNum},</if> |
| | | <if test="path != null and path != ''">#{path},</if> |
| | | <if test="component != null and component != ''">#{component},</if> |
| | | <if test="isFrame != null and isFrame != ''">#{isFrame},</if> |
| | | <if test="isCache != null and isCache != ''">#{isCache},</if> |
| | | <if test="menuType != null and menuType != ''">#{menuType},</if> |
| | | <if test="visible != null">#{visible},</if> |
| | | <if test="status != null">#{status},</if> |
| | | <if test="perms !=null and perms != ''">#{perms},</if> |
| | | <if test="icon != null and icon != ''">#{icon},</if> |
| | | <if test="remark != null and remark != ''">#{remark},</if> |
| | | <if test="createBy != null and createBy != ''">#{createBy},</if> |
| | | sysdate() |
| | | ) |
| | | </insert> |
| | | |
| | | <delete id="deleteMenuById" parameterType="Long"> |
| | | delete |
| | | from sys_menu |
| | | where menu_id = #{menuId} |
| | | </delete> |
| | | |
| | | </mapper> |
| | |
| | | <result property="deptId" column="dept_id"/> |
| | | </resultMap> |
| | | |
| | | <delete id="deleteRoleDeptByRoleId" parameterType="Long"> |
| | | delete |
| | | from sys_role_dept |
| | | where role_id = #{roleId} |
| | | </delete> |
| | | |
| | | <select id="selectCountRoleDeptByDeptId" resultType="Integer"> |
| | | select count(1) |
| | | from sys_role_dept |
| | | where dept_id = #{deptId} |
| | | </select> |
| | | |
| | | <delete id="deleteRoleDept" parameterType="Long"> |
| | | delete from sys_role_dept where role_id in |
| | | <foreach collection="array" item="roleId" open="(" separator="," close=")"> |
| | | #{roleId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <insert id="batchRoleDept"> |
| | | insert into sys_role_dept(role_id, dept_id) values |
| | | <foreach item="item" index="index" collection="list" separator=","> |
| | | (#{item.roleId},#{item.deptId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | </mapper> |
| | |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | </sql> |
| | | |
| | | <select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult"> |
| | | <include refid="selectRoleVo"/> |
| | | where r.del_flag = '0' |
| | | <if test="roleName != null and roleName != ''"> |
| | | AND r.role_name like concat('%', #{roleName}, '%') |
| | | </if> |
| | | <if test="status != null and status != ''"> |
| | | AND r.status = #{status} |
| | | </if> |
| | | <if test="roleKey != null and roleKey != ''"> |
| | | AND r.role_key like concat('%', #{roleKey}, '%') |
| | | </if> |
| | | <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> |
| | | and date_format(r.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') |
| | | </if> |
| | | <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 --> |
| | | and date_format(r.create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d') |
| | | </if> |
| | | <!-- 数据范围过滤 --> |
| | | ${params.dataScope} |
| | | order by r.role_sort |
| | | </select> |
| | | |
| | | <select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult"> |
| | | <include refid="selectRoleVo"/> |
| | | WHERE r.del_flag = '0' and ur.user_id = #{userId} |
| | | </select> |
| | | |
| | | <select id="selectRoleAll" resultMap="SysRoleResult"> |
| | | <include refid="selectRoleVo"/> |
| | | </select> |
| | | |
| | | <select id="selectRoleListByUserId" parameterType="Long" resultType="Integer"> |
| | |
| | | where u.user_id = #{userId} |
| | | </select> |
| | | |
| | | <select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult"> |
| | | <include refid="selectRoleVo"/> |
| | | where r.role_id = #{roleId} |
| | | </select> |
| | | |
| | | <select id="selectRolesByUserName" parameterType="String" resultMap="SysRoleResult"> |
| | | <include refid="selectRoleVo"/> |
| | | WHERE r.del_flag = '0' and u.user_name = #{userName} |
| | | </select> |
| | | |
| | | <select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult"> |
| | | <include refid="selectRoleVo"/> |
| | | where r.role_name=#{roleName} limit 1 |
| | | </select> |
| | | |
| | | <select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult"> |
| | | <include refid="selectRoleVo"/> |
| | | where r.role_key=#{roleKey} limit 1 |
| | | </select> |
| | | |
| | | <insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId"> |
| | | insert into sys_role( |
| | | <if test="roleId != null and roleId != 0">role_id,</if> |
| | | <if test="roleName != null and roleName != ''">role_name,</if> |
| | | <if test="roleKey != null and roleKey != ''">role_key,</if> |
| | | <if test="roleSort != null and roleSort != ''">role_sort,</if> |
| | | <if test="dataScope != null and dataScope != ''">data_scope,</if> |
| | | <if test="menuCheckStrictly != null">menu_check_strictly,</if> |
| | | <if test="deptCheckStrictly != null">dept_check_strictly,</if> |
| | | <if test="status != null and status != ''">status,</if> |
| | | <if test="remark != null and remark != ''">remark,</if> |
| | | <if test="createBy != null and createBy != ''">create_by,</if> |
| | | create_time |
| | | )values( |
| | | <if test="roleId != null and roleId != 0">#{roleId},</if> |
| | | <if test="roleName != null and roleName != ''">#{roleName},</if> |
| | | <if test="roleKey != null and roleKey != ''">#{roleKey},</if> |
| | | <if test="roleSort != null and roleSort != ''">#{roleSort},</if> |
| | | <if test="dataScope != null and dataScope != ''">#{dataScope},</if> |
| | | <if test="menuCheckStrictly != null">#{menuCheckStrictly},</if> |
| | | <if test="deptCheckStrictly != null">#{deptCheckStrictly},</if> |
| | | <if test="status != null and status != ''">#{status},</if> |
| | | <if test="remark != null and remark != ''">#{remark},</if> |
| | | <if test="createBy != null and createBy != ''">#{createBy},</if> |
| | | sysdate() |
| | | ) |
| | | </insert> |
| | | |
| | | <update id="updateRole" parameterType="SysRole"> |
| | | update sys_role |
| | | <set> |
| | | <if test="roleName != null and roleName != ''">role_name = #{roleName},</if> |
| | | <if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if> |
| | | <if test="roleSort != null and roleSort != ''">role_sort = #{roleSort},</if> |
| | | <if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if> |
| | | <if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if> |
| | | <if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if> |
| | | <if test="status != null and status != ''">status = #{status},</if> |
| | | <if test="remark != null">remark = #{remark},</if> |
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
| | | update_time = sysdate() |
| | | </set> |
| | | where role_id = #{roleId} |
| | | </update> |
| | | |
| | | <delete id="deleteRoleById" parameterType="Long"> |
| | | update sys_role |
| | | set del_flag = '2' |
| | | where role_id = #{roleId} |
| | | </delete> |
| | | |
| | | <delete id="deleteRoleByIds" parameterType="Long"> |
| | | update sys_role set del_flag = '2' where role_id in |
| | | <foreach collection="array" item="roleId" open="(" separator="," close=")"> |
| | | #{roleId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | </mapper> |
| | |
| | | <result property="menuId" column="menu_id"/> |
| | | </resultMap> |
| | | |
| | | <select id="checkMenuExistRole" resultType="Integer"> |
| | | select count(1) |
| | | from sys_role_menu |
| | | where menu_id = #{menuId} |
| | | </select> |
| | | |
| | | <delete id="deleteRoleMenuByRoleId" parameterType="Long"> |
| | | delete |
| | | from sys_role_menu |
| | | where role_id = #{roleId} |
| | | </delete> |
| | | |
| | | <delete id="deleteRoleMenu" parameterType="Long"> |
| | | delete from sys_role_menu where role_id in |
| | | <foreach collection="array" item="roleId" open="(" separator="," close=")"> |
| | | #{roleId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <insert id="batchRoleMenu"> |
| | | insert into sys_role_menu(role_id, menu_id) values |
| | | <foreach item="item" index="index" collection="list" separator=","> |
| | | (#{item.roleId},#{item.menuId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | </mapper> |
| | |
| | | where u.user_id = #{userId} |
| | | </select> |
| | | |
| | | <select id="checkUserNameUnique" parameterType="String" resultType="int"> |
| | | select count(1) |
| | | from sys_user |
| | | where user_name = #{userName} limit 1 |
| | | </select> |
| | | |
| | | <select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult"> |
| | | select user_id, phonenumber |
| | | from sys_user |
| | | where phonenumber = #{phonenumber} limit 1 |
| | | </select> |
| | | |
| | | <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult"> |
| | | select user_id, email |
| | | from sys_user |
| | | where email = #{email} limit 1 |
| | | </select> |
| | | |
| | | <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> |
| | | insert into sys_user( |
| | | <if test="userId != null and userId != 0">user_id,</if> |
| | | <if test="deptId != null and deptId != 0">dept_id,</if> |
| | | <if test="userName != null and userName != ''">user_name,</if> |
| | | <if test="nickName != null and nickName != ''">nick_name,</if> |
| | | <if test="email != null and email != ''">email,</if> |
| | | <if test="avatar != null and avatar != ''">avatar,</if> |
| | | <if test="phonenumber != null and phonenumber != ''">phonenumber,</if> |
| | | <if test="sex != null and sex != ''">sex,</if> |
| | | <if test="password != null and password != ''">password,</if> |
| | | <if test="status != null and status != ''">status,</if> |
| | | <if test="createBy != null and createBy != ''">create_by,</if> |
| | | <if test="remark != null and remark != ''">remark,</if> |
| | | create_time |
| | | )values( |
| | | <if test="userId != null and userId != ''">#{userId},</if> |
| | | <if test="deptId != null and deptId != ''">#{deptId},</if> |
| | | <if test="userName != null and userName != ''">#{userName},</if> |
| | | <if test="nickName != null and nickName != ''">#{nickName},</if> |
| | | <if test="email != null and email != ''">#{email},</if> |
| | | <if test="avatar != null and avatar != ''">#{avatar},</if> |
| | | <if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if> |
| | | <if test="sex != null and sex != ''">#{sex},</if> |
| | | <if test="password != null and password != ''">#{password},</if> |
| | | <if test="status != null and status != ''">#{status},</if> |
| | | <if test="createBy != null and createBy != ''">#{createBy},</if> |
| | | <if test="remark != null and remark != ''">#{remark},</if> |
| | | sysdate() |
| | | ) |
| | | </insert> |
| | | |
| | | <update id="updateUser" parameterType="SysUser"> |
| | | update sys_user |
| | | <set> |
| | | <if test="deptId != null and deptId != 0">dept_id = #{deptId},</if> |
| | | <if test="userName != null and userName != ''">user_name = #{userName},</if> |
| | | <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if> |
| | | <if test="email != null ">email = #{email},</if> |
| | | <if test="phonenumber != null ">phonenumber = #{phonenumber},</if> |
| | | <if test="sex != null and sex != ''">sex = #{sex},</if> |
| | | <if test="avatar != null and avatar != ''">avatar = #{avatar},</if> |
| | | <if test="password != null and password != ''">password = #{password},</if> |
| | | <if test="status != null and status != ''">status = #{status},</if> |
| | | <if test="loginIp != null and loginIp != ''">login_ip = #{loginIp},</if> |
| | | <if test="loginDate != null">login_date = #{loginDate},</if> |
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
| | | <if test="remark != null">remark = #{remark},</if> |
| | | update_time = sysdate() |
| | | </set> |
| | | where user_id = #{userId} |
| | | </update> |
| | | |
| | | <update id="updateUserStatus" parameterType="SysUser"> |
| | | update sys_user |
| | | set status = #{status} |
| | | where user_id = #{userId} |
| | | </update> |
| | | |
| | | <update id="updateUserAvatar" parameterType="SysUser"> |
| | | update sys_user |
| | | set avatar = #{avatar} |
| | | where user_name = #{userName} |
| | | </update> |
| | | |
| | | <update id="resetUserPwd" parameterType="SysUser"> |
| | | update sys_user |
| | | set password = #{password} |
| | | where user_name = #{userName} |
| | | </update> |
| | | |
| | | <delete id="deleteUserById" parameterType="Long"> |
| | | update sys_user |
| | | set del_flag = '2' |
| | | where user_id = #{userId} |
| | | </delete> |
| | | |
| | | <delete id="deleteUserByIds" parameterType="Long"> |
| | | update sys_user set del_flag = '2' where user_id in |
| | | <foreach collection="array" item="userId" open="(" separator="," close=")"> |
| | | #{userId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | </mapper> |
| | |
| | | <result property="postId" column="post_id"/> |
| | | </resultMap> |
| | | |
| | | <delete id="deleteUserPostByUserId" parameterType="Long"> |
| | | delete |
| | | from sys_user_post |
| | | where user_id = #{userId} |
| | | </delete> |
| | | |
| | | <delete id="deleteUserPost" parameterType="Long"> |
| | | delete from sys_user_post where user_id in |
| | | <foreach collection="array" item="userId" open="(" separator="," close=")"> |
| | | #{userId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <insert id="batchUserPost"> |
| | | insert into sys_user_post(user_id, post_id) values |
| | | <foreach item="item" index="index" collection="list" separator=","> |
| | | (#{item.userId},#{item.postId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | </mapper> |
| | |
| | | <result property="roleId" column="role_id"/> |
| | | </resultMap> |
| | | |
| | | <delete id="deleteUserRoleByUserId" parameterType="Long"> |
| | | delete |
| | | from sys_user_role |
| | | where user_id = #{userId} |
| | | </delete> |
| | | |
| | | <select id="countUserRoleByRoleId" resultType="Integer"> |
| | | select count(1) |
| | | from sys_user_role |
| | | where role_id = #{roleId} |
| | | </select> |
| | | |
| | | <delete id="deleteUserRole" parameterType="Long"> |
| | | delete from sys_user_role where user_id in |
| | | <foreach collection="array" item="userId" open="(" separator="," close=")"> |
| | | #{userId} |
| | | </foreach> |
| | | </delete> |
| | | |
| | | <insert id="batchUserRole"> |
| | | insert into sys_user_role(user_id, role_id) values |
| | | <foreach item="item" index="index" collection="list" separator=","> |
| | | (#{item.userId},#{item.roleId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <delete id="deleteUserRoleInfo" parameterType="SysUserRole"> |
| | | delete |
| | | from sys_user_role |
| | | where user_id = #{userId} |
| | | and role_id = #{roleId} |
| | | </delete> |
| | | |
| | | <delete id="deleteUserRoleInfos"> |
| | | delete from sys_user_role where role_id=#{roleId} and user_id in |
| | | <foreach collection="userIds" item="userId" open="(" separator="," close=")"> |
| | | #{userId} |
| | | </foreach> |
| | | </delete> |
| | | </mapper> |