com.ruoyi.common.constant.UserConstants Java Examples
The following examples show how to use
com.ruoyi.common.constant.UserConstants.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SysPostController.java From supplierShop with MIT License | 6 votes |
/** * 新增保存岗位 */ @RequiresPermissions("system:post:add") @Log(title = "岗位管理", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody public AjaxResult addSave(@Validated SysPost post) { if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); } else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) { return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); } post.setCreateBy(ShiroUtils.getLoginName()); return toAjax(postService.insertPost(post)); }
Example #2
Source File: SysDeptServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 对象转部门树 * * @param deptList 部门列表 * @param roleDeptList 角色已存在菜单列表 * @return 树结构列表 */ public List<Ztree> initZtree(List<SysDept> deptList, List<String> roleDeptList) { List<Ztree> ztrees = new ArrayList<Ztree>(); boolean isCheck = StringUtils.isNotNull(roleDeptList); for (SysDept dept : deptList) { if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) { Ztree ztree = new Ztree(); ztree.setId(dept.getDeptId()); ztree.setpId(dept.getParentId()); ztree.setName(dept.getDeptName()); ztree.setTitle(dept.getDeptName()); if (isCheck) { ztree.setChecked(roleDeptList.contains(dept.getDeptId() + dept.getDeptName())); } ztrees.add(ztree); } } return ztrees; }
Example #3
Source File: SysUserController.java From RuoYi with Apache License 2.0 | 6 votes |
@ApiOperation("新增用户") @ApiImplicitParam(name = "user", value = "新增用户信息", dataType = "SysUser") @RequiresPermissions("system:user:add") @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping("/add") @Transactional(rollbackFor = Exception.class) @ResponseBody public AjaxResult addSave(SysUser user) { if (ObjectUtil.isNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId())) { return error("不允许修改超级管理员用户"); } if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName()))){ return error("保存用户'" + user.getLoginName() + "'失败,账号已存在"); } user.setSalt(ShiroUtils.randomSalt()); user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); user.setCreateBy(ShiroUtils.getLoginName()); return toAjax(userService.insertUser(user)); }
Example #4
Source File: SysDeptServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 修改保存部门信息 * * @param dept 部门信息 * @return 结果 */ @Override @Transactional public int updateDept(SysDept dept) { SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); SysDept oldDept = selectDeptById(dept.getDeptId()); if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) { String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); String oldAncestors = oldDept.getAncestors(); dept.setAncestors(newAncestors); updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); } int result = deptMapper.updateDept(dept); if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) { // 如果该部门是启用状态,则启用该部门的所有上级部门 updateParentDeptStatus(dept); } return result; }
Example #5
Source File: SysDeptServiceImpl.java From ruoyiplus with MIT License | 6 votes |
/** * 修改保存部门信息 * * @param dept 部门信息 * @return 结果 */ @Override public int updateDept(SysDept dept) { SysDept info = deptMapper.selectDeptById(dept.getParentId()); if (StringUtils.isNotNull(info)) { String ancestors = info.getAncestors() + "," + info.getDeptId(); dept.setAncestors(ancestors); updateDeptChildren(dept.getDeptId(), ancestors); } int result = deptMapper.updateDept(dept); if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) { // 如果该部门是启用状态,则启用该部门的所有上级部门 updateParentDeptStatus(dept); } return result; }
Example #6
Source File: SysDeptServiceImpl.java From ruoyiplus with MIT License | 6 votes |
/** * 新增保存部门信息 * * @param dept 部门信息 * @return 结果 */ @Override public int insertDept(SysDept dept) { if(dept.getParentId()==0){ dept.setAncestors("0"); return deptMapper.insertDept(dept); }else { SysDept info = deptMapper.selectDeptById(dept.getParentId()); // 如果父节点不为"正常"状态,则不允许新增子节点 if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { throw new BusinessException("部门停用,不允许新增"); } dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); return deptMapper.insertDept(dept); } }
Example #7
Source File: SysPostController.java From RuoYi-Vue with MIT License | 6 votes |
/** * 新增岗位 */ @PreAuthorize("@ss.hasPermi('system:post:add')") @Log(title = "岗位管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody SysPost post) { if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在"); } else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) { return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); } post.setCreateBy(SecurityUtils.getUsername()); return toAjax(postService.insertPost(post)); }
Example #8
Source File: SysDeptServiceImpl.java From RuoYi with Apache License 2.0 | 6 votes |
/** * 对象转部门树 * * @param deptList 部门列表 * @param roleDeptList 角色已存在菜单列表 * @return 部门树 */ private List<Ztree> initZtree(List<SysDept> deptList, List<String> roleDeptList) { List<Ztree> ztrees = new ArrayList<>(); boolean isCheck = CollectionUtil.isNotEmpty(roleDeptList); if(CollectionUtil.isNotEmpty(deptList)){ deptList.stream() .filter(dept-> UserConstants.DEPT_NORMAL.equals(dept.getStatus())) .forEach(dept->{ Ztree ztree = new Ztree(); ztree.setId(dept.getDeptId()); ztree.setPId(dept.getParentId()); ztree.setName(dept.getDeptName()); ztree.setTitle(dept.getDeptName()); if (isCheck){ ztree.setChecked(roleDeptList.contains(dept.getDeptId() + dept.getDeptName())); } ztrees.add(ztree); }); } return ztrees; }
Example #9
Source File: SysDeptServiceImpl.java From RuoYi-Vue with MIT License | 6 votes |
/** * 修改保存部门信息 * * @param dept 部门信息 * @return 结果 */ @Override public int updateDept(SysDept dept) { SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId()); if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) { String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); String oldAncestors = oldDept.getAncestors(); dept.setAncestors(newAncestors); updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); } int result = deptMapper.updateDept(dept); if (UserConstants.DEPT_NORMAL.equals(dept.getStatus())) { // 如果该部门是启用状态,则启用该部门的所有上级部门 updateParentDeptStatus(dept); } return result; }
Example #10
Source File: SysDictTypeServiceImpl.java From supplierShop with MIT License | 6 votes |
/** * 查询字典类型树 * * @param dictType 字典类型 * @return 所有字典类型 */ public List<Ztree> selectDictTree(SysDictType dictType) { List<Ztree> ztrees = new ArrayList<Ztree>(); List<SysDictType> dictList = dictTypeMapper.selectDictTypeList(dictType); for (SysDictType dict : dictList) { if (UserConstants.DICT_NORMAL.equals(dict.getStatus())) { Ztree ztree = new Ztree(); ztree.setId(dict.getDictId()); ztree.setName(transDictName(dict)); ztree.setTitle(dict.getDictType()); ztrees.add(ztree); } } return ztrees; }
Example #11
Source File: SysDeptController.java From RuoYi-Vue with MIT License | 6 votes |
/** * 修改部门 */ @PreAuthorize("@ss.hasPermi('system:dept:edit')") @Log(title = "部门管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody SysDept dept) { if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); } else if (dept.getParentId().equals(dept.getDeptId())) { return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); } else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0) { return AjaxResult.error("该部门包含未停用的子部门!"); } dept.setUpdateBy(SecurityUtils.getUsername()); return toAjax(deptService.updateDept(dept)); }
Example #12
Source File: SysRoleController.java From RuoYi-Vue with MIT License | 6 votes |
/** * 新增角色 */ @PreAuthorize("@ss.hasPermi('system:role:add')") @Log(title = "角色管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@Validated @RequestBody SysRole role) { if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); } else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); } role.setCreateBy(SecurityUtils.getUsername()); return toAjax(roleService.insertRole(role)); }
Example #13
Source File: SysDeptServiceImpl.java From RuoYi with Apache License 2.0 | 6 votes |
/** * 修改保存部门信息 * * @param dept 部门信息 * @return 结果 */ @Override public int updateDept(SysDept dept) { SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); SysDept oldDept = selectDeptById(dept.getDeptId()); if (ObjectUtil.isNotNull(newParentDept) && ObjectUtil.isNotNull(oldDept)) { String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); String oldAncestors = oldDept.getAncestors(); dept.setAncestors(newAncestors); updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); } int result = deptMapper.updateDept(dept); if(UserConstants.DEPT_NORMAL.equals(dept.getStatus())){ //如果该部门是启用状态,这启用该部门的所有上级部门 updateParentDeptStatus(dept); } return result; }
Example #14
Source File: SysPostController.java From supplierShop with MIT License | 6 votes |
/** * 修改保存岗位 */ @RequiresPermissions("system:post:edit") @Log(title = "岗位管理", businessType = BusinessType.UPDATE) @PostMapping("/edit") @ResponseBody public AjaxResult editSave(@Validated SysPost post) { if (UserConstants.POST_NAME_NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在"); } else if (UserConstants.POST_CODE_NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) { return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); } post.setUpdateBy(ShiroUtils.getLoginName()); return toAjax(postService.updatePost(post)); }
Example #15
Source File: SysUserController.java From supplierShop with MIT License | 6 votes |
/** * 修改保存用户 */ @RequiresPermissions("system:user:edit") @Log(title = "用户管理", businessType = BusinessType.UPDATE) @PostMapping("/edit") @ResponseBody public AjaxResult editSave(@Validated SysUser user) { if (StringUtils.isNotNull(user.getUserId()) && SysUser.isAdmin(user.getUserId())) { return error("不允许修改超级管理员用户"); } else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { return error("修改用户'" + user.getLoginName() + "'失败,手机号码已存在"); } else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { return error("修改用户'" + user.getLoginName() + "'失败,邮箱账号已存在"); } user.setUpdateBy(ShiroUtils.getLoginName()); return toAjax(userService.updateUser(user)); }
Example #16
Source File: SysUserController.java From supplierShop with MIT License | 6 votes |
/** * 新增保存用户 */ @RequiresPermissions("system:user:add") @Log(title = "用户管理", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody public AjaxResult addSave(@Validated SysUser user) { if (UserConstants.USER_NAME_NOT_UNIQUE.equals(userService.checkLoginNameUnique(user.getLoginName()))) { return error("新增用户'" + user.getLoginName() + "'失败,登录账号已存在"); } else if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) { return error("新增用户'" + user.getLoginName() + "'失败,手机号码已存在"); } else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user))) { return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在"); } user.setSalt(ShiroUtils.randomSalt()); user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt())); user.setCreateBy(ShiroUtils.getLoginName()); return toAjax(userService.insertUser(user)); }
Example #17
Source File: SysDeptController.java From supplierShop with MIT License | 6 votes |
/** * 保存 */ @Log(title = "部门管理", businessType = BusinessType.UPDATE) @RequiresPermissions("system:dept:edit") @PostMapping("/edit") @ResponseBody public AjaxResult editSave(@Validated SysDept dept) { if (UserConstants.DEPT_NAME_NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) { return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); } else if (dept.getParentId().equals(dept.getDeptId())) { return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); } dept.setUpdateBy(ShiroUtils.getLoginName()); return toAjax(deptService.updateDept(dept)); }
Example #18
Source File: SysMenuServiceImpl.java From RuoYi-Vue with MIT License | 6 votes |
/** * 获取路由地址 * * @param menu 菜单信息 * @return 路由地址 */ public String getRouterPath(SysMenu menu) { String routerPath = menu.getPath(); // 非外链并且是一级目录(类型为目录) if (0 == menu.getParentId().intValue() && UserConstants.TYPE_DIR.equals(menu.getMenuType()) && UserConstants.NO_FRAME.equals(menu.getIsFrame())) { routerPath = "/" + menu.getPath(); } // 非外链并且是一级目录(类型为菜单) else if (isMeunFrame(menu)) { routerPath = "/"; } return routerPath; }
Example #19
Source File: SysRoleController.java From supplierShop with MIT License | 6 votes |
/** * 修改保存角色 */ @RequiresPermissions("system:role:edit") @Log(title = "角色管理", businessType = BusinessType.UPDATE) @PostMapping("/edit") @ResponseBody public AjaxResult editSave(@Validated SysRole role) { if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); } else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); } role.setUpdateBy(ShiroUtils.getLoginName()); ShiroUtils.clearCachedAuthorizationInfo(); return toAjax(roleService.updateRole(role)); }
Example #20
Source File: SysRoleController.java From supplierShop with MIT License | 6 votes |
/** * 新增保存角色 */ @RequiresPermissions("system:role:add") @Log(title = "角色管理", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody public AjaxResult addSave(@Validated SysRole role) { if (UserConstants.ROLE_NAME_NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); } else if (UserConstants.ROLE_KEY_NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); } role.setCreateBy(ShiroUtils.getLoginName()); ShiroUtils.clearCachedAuthorizationInfo(); return toAjax(roleService.insertRole(role)); }
Example #21
Source File: SysMenuController.java From RuoYi-Vue with MIT License | 6 votes |
/** * 修改菜单 */ @PreAuthorize("@ss.hasPermi('system:menu:edit')") @Log(title = "菜单管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody SysMenu menu) { if (UserConstants.NOT_UNIQUE.equals(menuService.checkMenuNameUnique(menu))) { return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); } else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS)) { return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,地址必须以http(s)://开头"); } menu.setUpdateBy(SecurityUtils.getUsername()); return toAjax(menuService.updateMenu(menu)); }
Example #22
Source File: SysRoleController.java From RuoYi-Vue with MIT License | 6 votes |
/** * 修改保存角色 */ @PreAuthorize("@ss.hasPermi('system:role:edit')") @Log(title = "角色管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@Validated @RequestBody SysRole role) { roleService.checkRoleAllowed(role); if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); } else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); } role.setUpdateBy(SecurityUtils.getUsername()); return toAjax(roleService.updateRole(role)); }
Example #23
Source File: SysRoleServiceImpl.java From RuoYi-Vue with MIT License | 5 votes |
/** * 校验角色名称是否唯一 * * @param role 角色信息 * @return 结果 */ @Override public String checkRoleNameUnique(SysRole role) { Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName()); if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; }
Example #24
Source File: SysMenuServiceImpl.java From ruoyiplus with MIT License | 5 votes |
/** * 校验菜单名称是否唯一 * * @param menu 菜单信息 * @return 结果 */ @Override public String checkMenuNameUnique(SysMenu menu) { Long menuId = StringUtils.isNull(menu.getMenuId()) ? -1L : menu.getMenuId(); SysMenu info = menuMapper.checkMenuNameUnique(menu.getMenuName(), menu.getParentId()); if (StringUtils.isNotNull(info) && info.getMenuId().longValue() != menuId.longValue()) { return UserConstants.MENU_NAME_NOT_UNIQUE; } return UserConstants.MENU_NAME_UNIQUE; }
Example #25
Source File: SysUserServiceImpl.java From RuoYi-Vue with MIT License | 5 votes |
/** * 校验用户名称是否唯一 * * @param user 用户信息 * @return */ @Override public String checkPhoneUnique(SysUser user) { Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; }
Example #26
Source File: SysDeptServiceImpl.java From RuoYi-Vue with MIT License | 5 votes |
/** * 新增保存部门信息 * * @param dept 部门信息 * @return 结果 */ @Override public int insertDept(SysDept dept) { SysDept info = deptMapper.selectDeptById(dept.getParentId()); // 如果父节点不为正常状态,则不允许新增子节点 if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) { throw new CustomException("部门停用,不允许新增"); } dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); return deptMapper.insertDept(dept); }
Example #27
Source File: SysUserServiceImpl.java From RuoYi-Vue with MIT License | 5 votes |
/** * 校验用户名称是否唯一 * * @param userName 用户名称 * @return 结果 */ @Override public String checkUserNameUnique(String userName) { int count = userMapper.checkUserNameUnique(userName); if (count > 0) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; }
Example #28
Source File: SysDeptServiceImpl.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 新增保存部门信息 * * @param dept 部门信息 * @return 结果 */ @Override public int insertDept(SysDept dept) { SysDept info = deptMapper.selectDeptById(dept.getParentId()); //如果父节点不为"正常"状态,则不允许新增子节点 if(!UserConstants.DEPT_NORMAL.equals(info.getStatus())){ throw new BusinessException("上级部门不为正常状态,新增失败!"); } dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); return deptMapper.insertDept(dept); }
Example #29
Source File: SysUserServiceImpl.java From RuoYi-Vue with MIT License | 5 votes |
/** * 校验email是否唯一 * * @param user 用户信息 * @return */ @Override public String checkEmailUnique(SysUser user) { Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); SysUser info = userMapper.checkEmailUnique(user.getEmail()); if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; }
Example #30
Source File: SysDeptServiceImpl.java From RuoYi-Vue with MIT License | 5 votes |
/** * 校验部门名称是否唯一 * * @param dept 部门信息 * @return 结果 */ @Override public String checkDeptNameUnique(SysDept dept) { Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; }