New file |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.system.pojo.dto.AppUserPageDTO; |
| | | import com.ruoyi.system.pojo.vo.AppUserPageVO; |
| | | import com.ruoyi.system.pojo.vo.BannerPageVO; |
| | | import com.ruoyi.system.service.AppUserService; |
| | | import com.ruoyi.system.service.BannerService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/system/appUser") |
| | | @Api( tags = "后台-系统设置-用户管理") |
| | | public class AppUserController { |
| | | |
| | | @Resource |
| | | private AppUserService appUserService; |
| | | |
| | | /** |
| | | * 分页查询 |
| | | */ |
| | | @PostMapping("/getAppUserPage") |
| | | @ApiOperation(value = "appUser分页") |
| | | @PreAuthorize("@ss.hasPermi('appuser:manage')") |
| | | public R<IPage<AppUserPageVO>> getAppUserPage(@RequestBody AppUserPageDTO getAppUserPage) { |
| | | return R.ok(appUserService.getAppUserPage(getAppUserPage)); |
| | | } |
| | | |
| | | /** |
| | | * 查看详情 |
| | | */ |
| | | |
| | | /** |
| | | * 冻结/解冻 |
| | | */ |
| | | |
| | | } |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.system.pojo.vo.SysDeptPageVO; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | |
| | | /** |
| | | * 获取部门列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:list')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:dept:list')") |
| | | @GetMapping("/list") |
| | | public AjaxResult list(SysDept dept) |
| | | { |
| | | List<SysDept> depts = deptService.selectDeptList(dept); |
| | | return success(depts); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 查询部门列表(排除节点) |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:list')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:dept:list')") |
| | | @GetMapping("/list/exclude/{deptId}") |
| | | public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) |
| | | { |
| | | List<SysDept> depts = deptService.selectDeptList(new SysDept()); |
| | | depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + "")); |
| | | return success(depts); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 根据部门编号获取详细信息 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:query')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:dept:query')") |
| | | @GetMapping(value = "/{deptId}") |
| | | public AjaxResult getInfo(@PathVariable Long deptId) |
| | | { |
| | | deptService.checkDeptDataScope(deptId); |
| | | return success(deptService.selectDeptById(deptId)); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 新增部门 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:add')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:dept:add')") |
| | | @Log(title = "部门管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysDept dept) |
| | |
| | | } |
| | | dept.setCreateBy(getUsername()); |
| | | return toAjax(deptService.insertDept(dept)); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 修改部门 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:edit')") |
| | | /*@PreAuthorize("@ss.hasPermi('system:dept:edit')") |
| | | @Log(title = "部门管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysDept dept) |
| | |
| | | } |
| | | dept.setUpdateBy(getUsername()); |
| | | return toAjax(deptService.updateDept(dept)); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 删除部门 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:dept:remove')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:dept:remove')") |
| | | @Log(title = "部门管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{deptId}") |
| | | public AjaxResult remove(@PathVariable Long deptId) |
| | |
| | | } |
| | | deptService.checkDeptDataScope(deptId); |
| | | return toAjax(deptService.deleteDeptById(deptId)); |
| | | }*/ |
| | | |
| | | /** |
| | | * 部门分页 |
| | | */ |
| | | |
| | | @GetMapping("/page") |
| | | @PreAuthorize("@ss.hasPermi('permission:dept')") |
| | | @ApiOperation(value = "部门管理-分页列表", tags = "系统后台-权限管理") |
| | | public R<IPage<SysDeptPageVO>> page(@RequestParam(value = "pageNum",defaultValue = "0")Integer pageNum, |
| | | @RequestParam(value = "pageSize",defaultValue="10")Integer pageSize, |
| | | @RequestParam(value = "name",required = false)String name) { |
| | | IPage<SysDeptPageVO> iPage = new Page<>(pageNum, pageSize); |
| | | return R.ok(deptService.page(iPage,name)); |
| | | } |
| | | /** |
| | | * 回显 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('permission:dept')") |
| | | @ApiOperation(value = "部门管理-查看部门(回显)", tags = "系统后台-权限管理") |
| | | @GetMapping("/{deptId}") |
| | | public AjaxResult detail(@PathVariable("deptId") Long deptId) { |
| | | SysDept sysDept = deptService.selectDeptById(deptId); |
| | | return success(sysDept); |
| | | } |
| | | |
| | | /** |
| | | * 新增 |
| | | */ |
| | | /** |
| | | * 新增部门 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('permission:dept')") |
| | | @Log(title = "部门管理", businessType = BusinessType.INSERT) |
| | | @ApiOperation(value = "部门管理-新增部门", tags = "系统后台-权限管理") |
| | | @GetMapping("/add") |
| | | public AjaxResult add(@RequestParam("name")String name) { |
| | | deptService.add(name); |
| | | return success(); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('permission:dept')") |
| | | @Log(title = "部门管理", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "部门管理-修改部门", tags = "系统后台-权限管理") |
| | | @PutMapping("/edit") |
| | | public AjaxResult edit(@RequestParam("id")Long id, |
| | | @RequestParam("name")String name) { |
| | | //查看id是否存在 |
| | | SysDept sysDept = deptService.selectDeptById(id); |
| | | if (sysDept==null){ |
| | | throw new ServiceException("该部门未找到"); |
| | | } |
| | | //修改部门名称 |
| | | sysDept.setDeptName(name); |
| | | deptService.updateDeptName(sysDept); |
| | | return success(); |
| | | } |
| | | /** |
| | | * 删除部门 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('permission:dept')") |
| | | @Log(title = "部门管理", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "部门管理-删除部门", tags = "系统后台-权限管理") |
| | | @DeleteMapping("/{deptId}") |
| | | public AjaxResult remove(@PathVariable Long deptId) { |
| | | return toAjax(deptService.deleteDeptById(deptId)); |
| | | } |
| | | } |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Slf4j |
| | | @RequestMapping("/system") |
| | | @Api( tags = "后台-登录控制器") |
| | | @RestController |
| | | public class SysLoginController |
| | | { |
| | |
| | | * @return 结果 |
| | | */ |
| | | @PostMapping("/login") |
| | | @ApiOperation(value = "登录") |
| | | public AjaxResult login(@RequestBody LoginBody loginBody) |
| | | { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | |
| | | ajax.put("user", user); |
| | | ajax.put("roles", roles); |
| | | ajax.put("permissions", permissions); |
| | | ajax.put("isDefaultModifyPwd", initPasswordIsModify(user.getPwdUpdateDate())); |
| | | ajax.put("isPasswordExpired", passwordIsExpiration(user.getPwdUpdateDate())); |
| | | /* ajax.put("isDefaultModifyPwd", initPasswordIsModify(user.getPwdUpdateDate())); |
| | | ajax.put("isPasswordExpired", passwordIsExpiration(user.getPwdUpdateDate()));*/ |
| | | return ajax; |
| | | } |
| | | |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.Map; |
| | | |
| | | import com.ruoyi.system.pojo.dto.UpdatePwdDTO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | |
| | | import javax.validation.Valid; |
| | | |
| | | /** |
| | | * 个人信息 业务处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @RestController |
| | | @Slf4j |
| | | @Api( tags = "后台-个人信息") |
| | | @RequestMapping("/system/user/profile") |
| | | public class SysProfileController extends BaseController |
| | | { |
| | |
| | | * 个人信息 |
| | | */ |
| | | @GetMapping |
| | | @ApiOperation(value = "个人信息") |
| | | public AjaxResult profile() |
| | | { |
| | | LoginUser loginUser = getLoginUser(); |
| | |
| | | /** |
| | | * 修改用户 |
| | | */ |
| | | @Log(title = "个人信息", businessType = BusinessType.UPDATE) |
| | | /* @Log(title = "个人信息", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult updateProfile(@RequestBody SysUser user) |
| | | { |
| | |
| | | return success(); |
| | | } |
| | | return error("修改个人信息异常,请联系管理员"); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 重置密码 |
| | | */ |
| | | @Log(title = "个人信息", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/updatePwd") |
| | | public AjaxResult updatePwd(@RequestBody Map<String, String> params) |
| | | @ApiOperation(value = "修改密码") |
| | | public AjaxResult updatePwd(@RequestBody @Valid UpdatePwdDTO updatePwdDTO) |
| | | { |
| | | String oldPassword = params.get("oldPassword"); |
| | | String newPassword = params.get("newPassword"); |
| | | String oldPassword = updatePwdDTO.getOldPassword(); |
| | | String newPassword = updatePwdDTO.getNewPassword(); |
| | | LoginUser loginUser = getLoginUser(); |
| | | String userName = loginUser.getUsername(); |
| | | String password = loginUser.getPassword(); |
| | |
| | | /** |
| | | * 头像上传 |
| | | */ |
| | | @Log(title = "用户头像", businessType = BusinessType.UPDATE) |
| | | /*@Log(title = "用户头像", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/avatar") |
| | | public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception |
| | | { |
| | |
| | | } |
| | | } |
| | | return error("上传图片异常,请联系管理员"); |
| | | } |
| | | }*/ |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.system.pojo.dto.AddSysRoleDTO; |
| | | import com.ruoyi.system.pojo.dto.EditSysRoleDTO; |
| | | import com.ruoyi.system.pojo.vo.MenuTreeVO; |
| | | import com.ruoyi.system.pojo.vo.SysRolePageVO; |
| | | import com.ruoyi.system.pojo.vo.SysRoleVO; |
| | | import com.ruoyi.system.service.ISysMenuService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | |
| | | @Autowired |
| | | private ISysDeptService deptService; |
| | | |
| | | @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysRole role) |
| | | { |
| | | startPage(); |
| | | List<SysRole> list = roleService.selectRoleList(role); |
| | | return getDataTable(list); |
| | | } |
| | | }*/ |
| | | |
| | | @Log(title = "角色管理", businessType = BusinessType.EXPORT) |
| | | /* @Log(title = "角色管理", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:role:export')") |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, SysRole role) |
| | |
| | | List<SysRole> list = roleService.selectRoleList(role); |
| | | ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); |
| | | util.exportExcel(response, list, "角色数据"); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 根据角色编号获取详细信息 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | @GetMapping(value = "/{roleId}") |
| | | public AjaxResult getInfo(@PathVariable Long roleId) |
| | | { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return success(roleService.selectRoleById(roleId)); |
| | | } |
| | | |
| | | */ |
| | | /** |
| | | * 新增角色 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:add')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:role:add')") |
| | | @Log(title = "角色管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysRole role) |
| | |
| | | role.setCreateBy(getUsername()); |
| | | return toAjax(roleService.insertRole(role)); |
| | | |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 修改保存角色 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysRole role) |
| | |
| | | return success(); |
| | | } |
| | | return error("修改角色'" + role.getRoleName() + "'失败,请联系管理员"); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 修改保存数据权限 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | /*@PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/dataScope") |
| | | public AjaxResult dataScope(@RequestBody SysRole role) |
| | |
| | | roleService.checkRoleAllowed(role); |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | | return toAjax(roleService.authDataScope(role)); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | /*@PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "角色管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysRole role) |
| | |
| | | roleService.checkRoleDataScope(role.getRoleId()); |
| | | role.setUpdateBy(getUsername()); |
| | | return toAjax(roleService.updateRoleStatus(role)); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 删除角色 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:remove')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:role:remove')") |
| | | @Log(title = "角色管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{roleIds}") |
| | | public AjaxResult remove(@PathVariable Long[] roleIds) |
| | | { |
| | | return toAjax(roleService.deleteRoleByIds(roleIds)); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 获取角色选择框列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | @GetMapping("/optionselect") |
| | | public AjaxResult optionselect() |
| | | { |
| | | return success(roleService.selectRoleAll()); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 查询已分配用户角色列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | @GetMapping("/authUser/allocatedList") |
| | | public TableDataInfo allocatedList(SysUser user) |
| | | { |
| | | startPage(); |
| | | List<SysUser> list = userService.selectAllocatedList(user); |
| | | return getDataTable(list); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 查询未分配用户角色列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | @GetMapping("/authUser/unallocatedList") |
| | | public TableDataInfo unallocatedList(SysUser user) |
| | | { |
| | |
| | | List<SysUser> list = userService.selectUnallocatedList(user); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | */ |
| | | /** |
| | | * 取消授权用户 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | /*@PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancel") |
| | | public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) |
| | | { |
| | | return toAjax(roleService.deleteAuthUser(userRole)); |
| | | } |
| | | |
| | | */ |
| | | /** |
| | | * 批量取消授权用户 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/cancelAll") |
| | | public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) |
| | | { |
| | | return toAjax(roleService.deleteAuthUsers(roleId, userIds)); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 批量选择用户授权 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:role:edit')") |
| | | @Log(title = "角色管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authUser/selectAll") |
| | | public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds) |
| | | { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return toAjax(roleService.insertAuthUsers(roleId, userIds)); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 获取对应角色部门树列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | @GetMapping(value = "/deptTree/{roleId}") |
| | | public AjaxResult deptTree(@PathVariable("roleId") Long roleId) |
| | | { |
| | |
| | | ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId)); |
| | | ajax.put("depts", deptService.selectDeptTreeList(new SysDept())); |
| | | return ajax; |
| | | }*/ |
| | | |
| | | /** |
| | | * 分页查询 |
| | | */ |
| | | |
| | | @GetMapping("/page") |
| | | @PreAuthorize("@ss.hasPermi('permission:role')") |
| | | @ApiOperation(value = "角色管理-分页列表", tags = "系统后台-权限管理") |
| | | public R<IPage<SysRolePageVO>> page(@RequestParam(value = "pageNum",defaultValue = "0")Integer pageNum, |
| | | @RequestParam(value = "pageSize",defaultValue="10")Integer pageSize, |
| | | @RequestParam(value = "name",required = false)String name) { |
| | | IPage<SysRolePageVO> iPage = new Page<>(pageNum, pageSize); |
| | | return R.ok(roleService.page(iPage,name)); |
| | | } |
| | | |
| | | @Autowired |
| | | private ISysMenuService menuService; |
| | | /** |
| | | * 菜单项结构(下拉框) |
| | | */ |
| | | @GetMapping("/tree") |
| | | @ApiOperation(value = "角色管理-菜单列表树", tags = {"系统后台-权限管理","系统后台-首页"}) |
| | | public R<List<MenuTreeVO>> tree() { |
| | | LoginUser loginUser = (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); |
| | | return R.ok(menuService.tree(loginUser.getUserId())); |
| | | } |
| | | /** |
| | | * 新增 |
| | | */ |
| | | @ApiOperation(value = "新增角色", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('permission:role')") |
| | | @Log(title = "角色管理", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | | public R<Void> add(@Valid @RequestBody AddSysRoleDTO dto) { |
| | | roleService.add(dto); |
| | | return R.ok(); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 查看详情 |
| | | */ |
| | | @ApiOperation(value = "查看详情", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('permission:role')") |
| | | @Log(title = "角色管理", businessType = BusinessType.DELETE) |
| | | @GetMapping("/{roleId}") |
| | | public R<SysRoleVO> getById(@PathVariable Long roleId) { |
| | | |
| | | return R.ok(roleService.getById(roleId)); |
| | | } |
| | | /** |
| | | * 修改 |
| | | */ |
| | | @ApiOperation(value = "修改角色", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('permission:role')") |
| | | @Log(title = "角色管理", businessType = BusinessType.INSERT) |
| | | @PutMapping("/edit") |
| | | public R<Void> edit(@Valid @RequestBody EditSysRoleDTO dto) { |
| | | roleService.edit(dto); |
| | | // 更新缓存用户权限 |
| | | LoginUser loginUser = getLoginUser(); |
| | | if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) { |
| | | loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName())); |
| | | loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); |
| | | tokenService.setLoginUser(loginUser); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 删除角色 |
| | | */ |
| | | @ApiOperation(value = "删除角色", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('permission:role')") |
| | | @Log(title = "角色管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{roleId}") |
| | | public R<Void> remove(@PathVariable Long roleId) { |
| | | roleService.deleteRoleById(roleId); |
| | | return R.ok(); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.system.pojo.dto.AddSysUserDTO; |
| | | import com.ruoyi.system.pojo.dto.EditSysUserDTO; |
| | | import com.ruoyi.system.pojo.vo.SysDeptPageVO; |
| | | import com.ruoyi.system.pojo.vo.SysRoleVO; |
| | | import com.ruoyi.system.pojo.vo.SysUserPageListVO; |
| | | import com.ruoyi.system.pojo.vo.SysUserVO; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | |
| | | /** |
| | | * 获取用户列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:list')") |
| | | /*@PreAuthorize("@ss.hasPermi('system:user:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(SysUser user) |
| | | { |
| | | startPage(); |
| | | List<SysUser> list = userService.selectUserList(user); |
| | | return getDataTable(list); |
| | | } |
| | | }*/ |
| | | |
| | | @Log(title = "用户管理", businessType = BusinessType.EXPORT) |
| | | /* @Log(title = "用户管理", businessType = BusinessType.EXPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:user:export')") |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, SysUser user) |
| | |
| | | List<SysUser> list = userService.selectUserList(user); |
| | | ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | | util.exportExcel(response, list, "用户数据"); |
| | | } |
| | | }*/ |
| | | |
| | | /* |
| | | @Log(title = "用户管理", businessType = BusinessType.IMPORT) |
| | | @PreAuthorize("@ss.hasPermi('system:user:import')") |
| | | @PostMapping("/importData") |
| | |
| | | String message = userService.importUser(userList, updateSupport, operName); |
| | | return success(message); |
| | | } |
| | | */ |
| | | |
| | | @PostMapping("/importTemplate") |
| | | /* @PostMapping("/importTemplate") |
| | | public void importTemplate(HttpServletResponse response) |
| | | { |
| | | ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | | util.importTemplateExcel(response, "用户数据"); |
| | | } |
| | | |
| | | */ |
| | | /** |
| | | * 根据用户编号获取详细信息 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:query')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:user:query')") |
| | | @GetMapping(value = { "/", "/{userId}" }) |
| | | public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) |
| | | { |
| | |
| | | ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); |
| | | ajax.put("posts", postService.selectPostAll()); |
| | | return ajax; |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 新增用户 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:add')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:user:add')") |
| | | @Log(title = "用户管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@Validated @RequestBody SysUser user) |
| | |
| | | user.setCreateBy(getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | return toAjax(userService.insertUser(user)); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 修改用户 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@Validated @RequestBody SysUser user) |
| | |
| | | } |
| | | user.setUpdateBy(getUsername()); |
| | | return toAjax(userService.updateUser(user)); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 删除用户 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:remove')") |
| | | /*@PreAuthorize("@ss.hasPermi('system:user:remove')") |
| | | @Log(title = "用户管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{userIds}") |
| | | public AjaxResult remove(@PathVariable Long[] userIds) |
| | |
| | | } |
| | | return toAjax(userService.deleteUserByIds(userIds)); |
| | | } |
| | | |
| | | */ |
| | | /** |
| | | * 重置密码 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:resetPwd')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:user:resetPwd')") |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/resetPwd") |
| | | public AjaxResult resetPwd(@RequestBody SysUser user) |
| | |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | user.setUpdateBy(getUsername()); |
| | | return toAjax(userService.resetPwd(user)); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysUser user) |
| | |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | user.setUpdateBy(getUsername()); |
| | | return toAjax(userService.updateUserStatus(user)); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 根据用户编号获取授权角色 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:query')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:user:query')") |
| | | @GetMapping("/authRole/{userId}") |
| | | public AjaxResult authRole(@PathVariable("userId") Long userId) |
| | | { |
| | |
| | | ajax.put("user", user); |
| | | ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); |
| | | return ajax; |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 用户授权角色 |
| | | */ |
| | | /* *//* |
| | | @PreAuthorize("@ss.hasPermi('system:user:edit')") |
| | | @Log(title = "用户管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authRole") |
| | |
| | | roleService.checkRoleDataScope(roleIds); |
| | | userService.insertUserAuth(userId, roleIds); |
| | | return success(); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 获取部门树列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:user:list')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:user:list')") |
| | | @GetMapping("/deptTree") |
| | | public AjaxResult deptTree(SysDept dept) |
| | | { |
| | | return success(deptService.selectDeptTreeList(dept)); |
| | | }*/ |
| | | |
| | | /** |
| | | * 分页 |
| | | */ |
| | | @ApiOperation(value = "账号管理-获取账号分页列表", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('permission:account')") |
| | | @GetMapping("/list") |
| | | public R<IPage<SysUserPageListVO>> getSysUserPageList(@RequestParam("pageNum")Integer pageNum, |
| | | @RequestParam("pageSize")Integer pageSize, |
| | | @RequestParam("nickName")String nickName, |
| | | @RequestParam("phone")Integer phone, |
| | | @RequestParam("status")String status) { |
| | | IPage<SysUserPageListVO> page=new Page<>(pageNum,pageSize); |
| | | return R.ok(userService.getSysUserPageList(page,nickName,phone,status)); |
| | | } |
| | | |
| | | /** |
| | | * 角色下拉框 |
| | | */ |
| | | @ApiOperation(value = "账号管理-获取角色下拉框", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('permission:account')") |
| | | @GetMapping("/getOptionSelect") |
| | | public R<List<SysRoleVO>> getOptionSelect() { |
| | | return R.ok(roleService.getOptionSelect()); |
| | | } |
| | | |
| | | /** |
| | | * 部门下拉框 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('permission:account')") |
| | | @ApiOperation(value = "账号管理-部门选择框", tags = "系统后台-权限管理") |
| | | @GetMapping("/list") |
| | | public AjaxResult list() { |
| | | List<SysDeptPageVO> list = deptService.getDeptList(); |
| | | return success(list); |
| | | } |
| | | /** |
| | | * 根据用户编号回显 |
| | | */ |
| | | @ApiOperation(value = "账号管理-查看详情(回显)", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('permission:account')") |
| | | @GetMapping(value ="/{userId}") |
| | | public R<SysUserVO> getInfo(@PathVariable(value = "userId") Long userId) { |
| | | return userService.getInfo(userId); |
| | | |
| | | } |
| | | /** |
| | | * 新增 |
| | | */ |
| | | @ApiOperation(value = "账号管理-查看详情(回显)", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('permission:account')") |
| | | @Log(title = "账号管理", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | | public R<Void> add(@Valid @RequestBody AddSysUserDTO dto) { |
| | | userService.add(dto); |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 编辑 |
| | | */ |
| | | @ApiOperation(value = "账号管理-修改用户", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('permission:account')") |
| | | @Log(title = "账号管理", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/edit") |
| | | public R<Void> edit(@Valid @RequestBody EditSysUserDTO dto) { |
| | | userService.edit(dto); |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 冻结 |
| | | */ |
| | | @ApiOperation(value = "账号管理-状态修改", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('permission:account')") |
| | | @Log(title = "账号管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus/{userId}") |
| | | public R<Void> changeStatus(@PathVariable("userId") Long userId) { |
| | | if (Objects.equals(userId, getUserId())) { |
| | | return R.fail("当前用户不能操作"); |
| | | } |
| | | userService.changeStatus(userId); |
| | | return R.ok(); |
| | | } |
| | | /** |
| | | * 删除 |
| | | */ |
| | | @ApiOperation(value = "账号管理-删除用户", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('permission:account')") |
| | | @Log(title = "账号管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{userId}") |
| | | public R remove(@PathVariable("userId") Long userId) { |
| | | if (Objects.equals(userId, getUserId())) { |
| | | return R.fail("当前用户不能删除"); |
| | | } |
| | | return R.ok(userService.deleteUserById(userId)); |
| | | } |
| | | |
| | | /** |
| | | * 重置密码 |
| | | */ |
| | | @ApiOperation(value = "账号管理-重置密码", tags = "系统后台-权限管理") |
| | | @PreAuthorize("@ss.hasPermi('permission:account')") |
| | | @Log(title = "账号管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/resetPassword/{userId}") |
| | | public R<Void> resetPassword(@PathVariable("userId") Long userId) { |
| | | userService.resetPassword(userId); |
| | | return R.ok(); |
| | | } |
| | | } |
| | |
| | | * 密码长度限制 |
| | | */ |
| | | public static final int PASSWORD_MIN_LENGTH = 5; |
| | | public static final int PASSWORD_MAX_LENGTH = 20; |
| | | public static final int PASSWORD_MAX_LENGTH = 32; |
| | | } |
| | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.ruoyi.common.utils.sign.Md5Utils; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | |
| | | .anyMatch(x -> Constants.SUPER_ADMIN.equals(x) || PatternMatchUtils.simpleMatch(x, role)); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String hash = Md5Utils.hash("123456"); |
| | | System.out.println(hash); |
| | | System.out.println(encryptPassword(hash)); |
| | | |
| | | System.out.println(matchesPassword(hash, "$2a$10$VhdvkOtOTUq1NndvwPC36./D9bPVhDJWbt.tVWtGdqW3.sA07Ikx.")); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.system.domain.Agreement; |
| | | import com.ruoyi.system.domain.User; |
| | | import com.ruoyi.system.pojo.dto.AppUserPageDTO; |
| | | import com.ruoyi.system.pojo.vo.AppUserPageVO; |
| | | import com.ruoyi.system.pojo.vo.SysDeptPageVO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | @Mapper |
| | | public interface AppUserMapper extends BaseMapper<User> { |
| | | IPage<AppUserPageVO> getAppUserPage(@Param("page") IPage<SysDeptPageVO> iPage, @Param("dto") AppUserPageDTO dto); |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.system.pojo.vo.SysDeptPageVO; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | |
| | |
| | | * @param deptId 部门ID |
| | | * @return 结果 |
| | | */ |
| | | public int deleteDeptById(Long deptId); |
| | | public int deleteDeptById(@Param("deptId")Long deptId); |
| | | |
| | | IPage<SysDeptPageVO> page(@Param("page")IPage<SysDeptPageVO> page, @Param("name")String name); |
| | | |
| | | SysDept selectDeptByName(@Param("name")String name); |
| | | |
| | | void updateDeptName(@Param("sysDept")SysDept sysDept); |
| | | |
| | | List<SysDeptPageVO> getDeptList(); |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.ruoyi.system.pojo.vo.MenuTreeVO; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | |
| | |
| | | * @return 结果 |
| | | */ |
| | | public SysMenu checkMenuNameUnique(@Param("menuName") String menuName, @Param("parentId") Long parentId); |
| | | |
| | | List<MenuTreeVO> selectMenusByParentId(@Param("menuId")Long menuId); |
| | | |
| | | List<MenuTreeVO> getAllRootMenu(); |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.system.pojo.vo.SysRolePageVO; |
| | | import com.ruoyi.system.pojo.vo.SysRoleVO; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | /** |
| | | * 角色表 数据层 |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int deleteRoleByIds(Long[] roleIds); |
| | | |
| | | IPage<SysRolePageVO> page(@Param("page")IPage<SysRolePageVO> page, @Param("name")String name); |
| | | |
| | | List<SysRoleVO> getOptionSelect(); |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.system.domain.SysRoleMenu; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | |
| | | /** |
| | | * 角色与菜单关联表 数据层 |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int batchRoleMenu(List<SysRoleMenu> roleMenuList); |
| | | |
| | | List<Long> selectMenuIdsByRoleIds(@Param("roleList") List<Long> roleList); |
| | | |
| | | void insert(@Param("roleId") Long roleId, @Param("menuIds") List<Long> menuIds); |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.system.pojo.vo.SysUserPageListVO; |
| | | import com.ruoyi.system.pojo.vo.SysUserVO; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | |
| | | /** |
| | | * 用户表 数据层 |
| | |
| | | * @return 结果 |
| | | */ |
| | | public SysUser checkEmailUnique(String email); |
| | | |
| | | IPage<SysUserPageListVO> getSysUserPageList(@Param("page") IPage<SysUserPageListVO> page, @Param("nickName") String nickName,@Param("phone") Integer phone, @Param("status") String status); |
| | | |
| | | R<SysUserVO> getSysUserVO(@Param("userId") Long userId); |
| | | |
| | | SysUser selectuserByPhone(@Param("phonenumber") String phonenumber); |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | /** |
| | | * 用户与角色关联表 数据层 |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int deleteUserRoleInfos(@Param("roleId") Long roleId, @Param("userIds") Long[] userIds); |
| | | |
| | | void insert(@Param("userId")Long userId, @Param("roleId")Long roleId); |
| | | |
| | | SysRole selectRoleByUserId(@Param("userId")Long userId); |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.pojo.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @ApiModel("添加角色DTO") |
| | | public class AddSysRoleDTO { |
| | | @ApiModelProperty("角色名称") |
| | | @NotEmpty(message = "角色名称不能为空") |
| | | private String roleName; |
| | | @ApiModelProperty("菜单权限集合") |
| | | @NotEmpty(message = "菜单权限集合不能为空") |
| | | private List<Long> menuIds; |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.pojo.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | @Data |
| | | @ApiModel("添加用户DTO") |
| | | public class AddSysUserDTO{ |
| | | @ApiModelProperty(value = "姓名") |
| | | @NotEmpty(message = "姓名不能为空") |
| | | private String nickName; |
| | | @ApiModelProperty(value = "联系电话") |
| | | @NotEmpty(message = "联系电话不能为空") |
| | | private String phonenumber; |
| | | @ApiModelProperty(value = "所在部门id") |
| | | @NotNull(message = "所在部门不能为空") |
| | | private Long deptId; |
| | | @ApiModelProperty(value = "所属角色id") |
| | | @NotNull(message = "所属角色不能为空") |
| | | private Long roleId; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.pojo.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | @ApiModel("app用户分页DTO") |
| | | public class AppUserPageDTO { |
| | | @ApiModelProperty("页码") |
| | | private Integer pageNum=0; |
| | | @ApiModelProperty("分页大小") |
| | | private Integer pageSize=10; |
| | | @ApiModelProperty("用户姓名") |
| | | private String username; |
| | | @ApiModelProperty("联系电话") |
| | | private String phone; |
| | | @ApiModelProperty("状态") |
| | | private Integer status; |
| | | @ApiModelProperty("起始时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime startTime; |
| | | @ApiModelProperty("结束时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime endTime; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.pojo.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | |
| | | @Getter |
| | | @Setter |
| | | @ApiModel("编辑角色DTO") |
| | | public class EditSysRoleDTO extends AddSysRoleDTO { |
| | | @ApiModelProperty("角色id") |
| | | private Long roleId; |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.pojo.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | |
| | | import javax.validation.constraints.NotNull; |
| | | |
| | | @Getter |
| | | @Setter |
| | | @ApiModel("编辑用户DTO") |
| | | public class EditSysUserDTO extends AddSysUserDTO { |
| | | @ApiModelProperty(value = "用户id") |
| | | @NotNull(message = "用户id不能为空") |
| | | private Long userId; |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.pojo.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import javax.validation.constraints.NotEmpty; |
| | | |
| | | @Data |
| | | @ApiModel("修改密码DTO") |
| | | public class UpdatePwdDTO { |
| | | @NotEmpty(message = "旧密码不能为空") |
| | | @ApiModelProperty("旧密码") |
| | | private String oldPassword; |
| | | @NotEmpty(message = "新密码不能为空") |
| | | @ApiModelProperty("新密码") |
| | | private String newPassword; |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.pojo.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | @ApiModel("appUser分页VO") |
| | | public class AppUserPageVO { |
| | | @ApiModelProperty("用户id") |
| | | private String id; |
| | | @ApiModelProperty("用户名") |
| | | private String userName; |
| | | @ApiModelProperty("联系电话") |
| | | private String phone; |
| | | @ApiModelProperty("注册时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | @ApiModelProperty("账户余额") |
| | | private BigDecimal balance; |
| | | @ApiModelProperty("已绑定用户数") |
| | | private Integer bingDingUser; |
| | | @ApiModelProperty("买公司完成次数") |
| | | private Integer buyNum; |
| | | @ApiModelProperty("卖公司完成次数") |
| | | private Integer sellNum; |
| | | @ApiModelProperty("状态(1正常 2冻结 3注销) ") |
| | | private Integer status; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.pojo.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @ApiModel("菜单树VO") |
| | | public class MenuTreeVO { |
| | | /** 菜单ID */ |
| | | @ApiModelProperty("菜单ID") |
| | | private Long menuId; |
| | | /** 菜单名称 */ |
| | | @ApiModelProperty("菜单名称") |
| | | private String menuName; |
| | | /** 路由地址 */ |
| | | @ApiModelProperty("路由地址") |
| | | private String path; |
| | | /** 类型(M目录 C菜单 F按钮) */ |
| | | @ApiModelProperty("类型(M目录 C菜单 F按钮)") |
| | | private String menuType; |
| | | /** 子菜单 */ |
| | | @ApiModelProperty("子菜单") |
| | | private List<MenuTreeVO> children = new ArrayList<MenuTreeVO>(); |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.pojo.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel("部门分页VO") |
| | | public class SysDeptPageVO { |
| | | @ApiModelProperty("部门id") |
| | | private Long deptId; |
| | | |
| | | @ApiModelProperty("部门名称") |
| | | private String deptName; |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.pojo.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel("角色分页列表") |
| | | public class SysRolePageVO { |
| | | @ApiModelProperty("角色序号") |
| | | private Long roleId; |
| | | |
| | | @ApiModelProperty("角色名称") |
| | | private String roleName; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.pojo.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @ApiModel("查看角色详情VO") |
| | | public class SysRoleVO { |
| | | @ApiModelProperty("角色id") |
| | | private Long roleId; |
| | | @ApiModelProperty("角色名称") |
| | | private String roleName; |
| | | @ApiModelProperty("菜单权限集合") |
| | | private List<Long> menuIdList; |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.pojo.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | @ApiModel("用户账号分页列表VO") |
| | | public class SysUserPageListVO { |
| | | @ApiModelProperty(value = "用户id") |
| | | private Long userId; |
| | | @ApiModelProperty(value = "用户名称") |
| | | private String nickName; |
| | | @ApiModelProperty(value = "联系电话") |
| | | private String phonenumber; |
| | | |
| | | @ApiModelProperty(value = "所在部门") |
| | | private String deptName; |
| | | |
| | | @ApiModelProperty(value = "所属角色") |
| | | private String roleName; |
| | | @ApiModelProperty(value = "账号状态 0=正常,1=停用") |
| | | private String status; |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.pojo.vo; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | |
| | | @Getter |
| | | @Setter |
| | | @ApiModel("用户账号分页列表VO") |
| | | public class SysUserVO extends SysUserPageListVO{ |
| | | @ApiModelProperty(value = "所在部门id") |
| | | private Long deptId; |
| | | @ApiModelProperty(value = "所属角色id") |
| | | private Long roleId; |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.system.domain.Agreement; |
| | | import com.ruoyi.system.domain.User; |
| | | import com.ruoyi.system.pojo.dto.AddAgreementDTO; |
| | | import com.ruoyi.system.pojo.dto.AppUserPageDTO; |
| | | import com.ruoyi.system.pojo.vo.AppUserPageVO; |
| | | |
| | | |
| | | public interface AppUserService extends IService<User> { |
| | | IPage<AppUserPageVO> getAppUserPage(AppUserPageDTO getAppUserPage); |
| | | } |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.common.core.domain.TreeSelect; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.system.pojo.vo.SysDeptPageVO; |
| | | |
| | | /** |
| | | * 部门管理 服务层 |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int deleteDeptById(Long deptId); |
| | | |
| | | IPage<SysDeptPageVO> page(IPage<SysDeptPageVO> iPage, String name); |
| | | |
| | | void add(String name); |
| | | |
| | | void updateDeptName(SysDept sysDept); |
| | | |
| | | List<SysDeptPageVO> getDeptList(); |
| | | } |
| | |
| | | import com.ruoyi.common.core.domain.TreeSelect; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | | import com.ruoyi.system.domain.vo.RouterVo; |
| | | import com.ruoyi.system.pojo.vo.MenuTreeVO; |
| | | |
| | | /** |
| | | * 菜单 业务层 |
| | |
| | | * @return 结果 |
| | | */ |
| | | public boolean checkMenuNameUnique(SysMenu menu); |
| | | |
| | | List<MenuTreeVO> tree(Long userId); |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.pojo.dto.AddSysRoleDTO; |
| | | import com.ruoyi.system.pojo.dto.EditSysRoleDTO; |
| | | import com.ruoyi.system.pojo.vo.SysRolePageVO; |
| | | import com.ruoyi.system.pojo.vo.SysRoleVO; |
| | | |
| | | import javax.validation.Valid; |
| | | |
| | | /** |
| | | * 角色业务层 |
| | |
| | | * @return 结果 |
| | | */ |
| | | public int insertAuthUsers(Long roleId, Long[] userIds); |
| | | |
| | | IPage<SysRolePageVO> page(IPage<SysRolePageVO> iPage, String name); |
| | | |
| | | void add( AddSysRoleDTO dto); |
| | | |
| | | SysRoleVO getById(Long roleId); |
| | | |
| | | void edit(EditSysRoleDTO dto); |
| | | |
| | | List<SysRoleVO> getOptionSelect(); |
| | | } |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.system.pojo.dto.AddSysUserDTO; |
| | | import com.ruoyi.system.pojo.dto.EditSysUserDTO; |
| | | import com.ruoyi.system.pojo.vo.SysUserPageListVO; |
| | | import com.ruoyi.system.pojo.vo.SysUserVO; |
| | | |
| | | import javax.validation.Valid; |
| | | |
| | | /** |
| | | * 用户 业务层 |
| | |
| | | * @return 结果 |
| | | */ |
| | | public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName); |
| | | |
| | | IPage<SysUserPageListVO> getSysUserPageList(IPage<SysUserPageListVO> page, String nickName, Integer phone, String status); |
| | | |
| | | R<SysUserVO> getInfo(Long userId); |
| | | |
| | | void add( AddSysUserDTO dto); |
| | | |
| | | void edit( EditSysUserDTO dto); |
| | | |
| | | void changeStatus(Long userId); |
| | | |
| | | void resetPassword(Long userId); |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.system.domain.Agreement; |
| | | import com.ruoyi.system.domain.User; |
| | | import com.ruoyi.system.mapper.AgreementMapper; |
| | | import com.ruoyi.system.mapper.AppUserMapper; |
| | | import com.ruoyi.system.pojo.dto.AddAgreementDTO; |
| | | import com.ruoyi.system.pojo.dto.AppUserPageDTO; |
| | | import com.ruoyi.system.pojo.vo.AppUserPageVO; |
| | | import com.ruoyi.system.pojo.vo.SysDeptPageVO; |
| | | import com.ruoyi.system.service.AgreementService; |
| | | import com.ruoyi.system.service.AppUserService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Service |
| | | public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, User> implements AppUserService { |
| | | |
| | | |
| | | @Override |
| | | public IPage<AppUserPageVO> getAppUserPage(AppUserPageDTO dto) { |
| | | IPage<SysDeptPageVO> iPage = new Page<>(dto.getPageNum(), dto.getPageSize()); |
| | | return this.baseMapper.getAppUserPage(iPage,dto); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.system.pojo.vo.SysDeptPageVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | |
| | | return deptMapper.deleteDeptById(deptId); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 递归列表 |
| | | */ |
| | |
| | | { |
| | | return getChildList(list, t).size() > 0; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public IPage<SysDeptPageVO> page(IPage<SysDeptPageVO> iPage, String name) { |
| | | return deptMapper.page(iPage,name); |
| | | } |
| | | |
| | | @Override |
| | | public void add(String name) { |
| | | SysDept sysDept=deptMapper.selectDeptByName(name); |
| | | if (sysDept != null){ |
| | | throw new ServiceException("该部门已存在"); |
| | | } |
| | | sysDept=new SysDept(); |
| | | sysDept.setDeptName(name); |
| | | deptMapper.insertDept(sysDept); |
| | | } |
| | | |
| | | @Override |
| | | public void updateDeptName(SysDept sysDept) { |
| | | deptMapper.updateDeptName(sysDept); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysDeptPageVO> getDeptList() { |
| | | return deptMapper.getDeptList(); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashSet; |
| | | import java.util.Iterator; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.ruoyi.system.pojo.vo.MenuTreeVO; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.common.constant.Constants; |
| | |
| | | return StringUtils.replaceEach(path, new String[] { Constants.HTTP, Constants.HTTPS, Constants.WWW, ".", ":" }, |
| | | new String[] { "", "", "", "/", "/" }); |
| | | } |
| | | |
| | | @Override |
| | | public List<MenuTreeVO> tree(Long userId) { |
| | | // 构建菜单树 |
| | | return buildMenuTree(userId); |
| | | } |
| | | |
| | | /** |
| | | * 构建菜单树(递归实现) |
| | | * @return 菜单树列表 |
| | | */ |
| | | public List<MenuTreeVO> buildMenuTree(Long userId) { |
| | | // 1. 根据用户ID查询角色ID集合 |
| | | List<Long> roleList = roleMapper.selectRoleListByUserId(userId); |
| | | // 2. 查询角色关联的菜单ID |
| | | List<Long> menuIds = roleMenuMapper.selectMenuIdsByRoleIds(roleList); |
| | | // 获取所有菜单 |
| | | List<MenuTreeVO> rootMenus = menuMapper.getAllRootMenu(); |
| | | // 递归构建子菜单 |
| | | List<MenuTreeVO> list = rootMenus.stream() |
| | | .map(x -> convertToMenuTreeVO(x,menuIds)) |
| | | .collect(Collectors.toList()); |
| | | return list.stream().filter(this::shouldIncludeMenu).collect(Collectors.toList()); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 递归转换菜单并构建子菜单树 |
| | | */ |
| | | private MenuTreeVO convertToMenuTreeVO(MenuTreeVO menu,List<Long> menuIds) { |
| | | MenuTreeVO vo = new MenuTreeVO(); |
| | | BeanUtils.copyProperties(menu, vo, "children"); // 复制基本属性,忽略children字段 |
| | | |
| | | // 获取当前菜单的子菜单 |
| | | List<MenuTreeVO> childMenus = menuMapper.selectMenusByParentId(menu.getMenuId()); |
| | | |
| | | // 递归处理子菜单 |
| | | if (!childMenus.isEmpty()) { |
| | | childMenus = childMenus.stream() |
| | | .filter(x -> !("C".equals(x.getMenuType()) && !menuIds.contains(x.getMenuId()))) |
| | | .collect(Collectors.toList()); |
| | | |
| | | List<MenuTreeVO> filteredChildren = childMenus.stream() |
| | | .map(x -> convertToMenuTreeVO(x,menuIds)) |
| | | .filter(this::shouldIncludeMenu) // 过滤子菜单 |
| | | .collect(Collectors.toList()); |
| | | |
| | | vo.setChildren(filteredChildren); |
| | | } |
| | | |
| | | return vo; |
| | | } |
| | | |
| | | /** |
| | | * 判断菜单是否应该被包含在结果中 |
| | | * - 如果是M类型且没有子菜单,则不包含 |
| | | * - 否则包含 |
| | | */ |
| | | private boolean shouldIncludeMenu(MenuTreeVO menu) { |
| | | // 如果菜单类型是M(目录)且没有子菜单,则过滤掉 |
| | | return !("M".equals(menu.getMenuType()) && (menu.getChildren() == null || menu.getChildren().isEmpty())); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | import java.util.*; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.system.pojo.dto.AddSysRoleDTO; |
| | | import com.ruoyi.system.pojo.dto.EditSysRoleDTO; |
| | | import com.ruoyi.system.pojo.vo.SysRolePageVO; |
| | | import com.ruoyi.system.pojo.vo.SysRoleVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | |
| | | // 删除角色与菜单关联 |
| | | roleMenuMapper.deleteRoleMenuByRoleId(roleId); |
| | | // 删除角色与部门关联 |
| | | roleDeptMapper.deleteRoleDeptByRoleId(roleId); |
| | | // roleDeptMapper.deleteRoleDeptByRoleId(roleId); |
| | | return roleMapper.deleteRoleById(roleId); |
| | | } |
| | | |
| | |
| | | } |
| | | return userRoleMapper.batchUserRole(list); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<SysRolePageVO> page(IPage<SysRolePageVO> page, String name) { |
| | | return roleMapper.page(page,name); |
| | | } |
| | | |
| | | @Override |
| | | public void add(AddSysRoleDTO dto) { |
| | | //判断角色名称是否存在 |
| | | SysRole sysRole = new SysRole(); |
| | | sysRole.setRoleName(dto.getRoleName()); |
| | | List<SysRole> sysRoles = roleMapper.selectRoleList(sysRole); |
| | | if (sysRoles!=null && !sysRoles.isEmpty()){ |
| | | throw new ServiceException("该角色名称重复"); |
| | | } |
| | | //添加角色 |
| | | sysRole.setStatus("0"); |
| | | LoginUser loginUser = (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); |
| | | sysRole.setCreateBy(loginUser.getUsername()); |
| | | sysRole.setCreateTime(DateUtils.getNowDate()); |
| | | roleMapper.insertRole(sysRole); |
| | | //添加角色菜单 |
| | | roleMenuMapper.insert(sysRole.getRoleId(),dto.getMenuIds()); |
| | | } |
| | | |
| | | @Override |
| | | public SysRoleVO getById(Long roleId) { |
| | | SysRoleVO sysRoleVO = new SysRoleVO(); |
| | | SysRole sysRole = roleMapper.selectRoleById(roleId); |
| | | if (sysRole==null||sysRole.getDelFlag().equals("1")){ |
| | | throw new ServiceException("该角色不存在"); |
| | | } |
| | | sysRoleVO.setRoleName(sysRole.getRoleName()); |
| | | sysRoleVO.setRoleId(roleId); |
| | | ArrayList<Long> roleIds = new ArrayList<>(); |
| | | roleIds.add(roleId); |
| | | List<Long> menuIds = roleMenuMapper.selectMenuIdsByRoleIds(roleIds); |
| | | sysRoleVO.setMenuIdList(menuIds); |
| | | return sysRoleVO; |
| | | } |
| | | |
| | | @Override |
| | | public void edit(EditSysRoleDTO dto) { |
| | | //判断角色id是否存在 |
| | | SysRole sysRole1 = roleMapper.selectRoleById(dto.getRoleId()); |
| | | if (sysRole1==null||sysRole1.getDelFlag().equals("1")){ |
| | | throw new ServiceException("该角色不存在"); |
| | | } |
| | | //判断角色名称是否存在 |
| | | SysRole sysRole = new SysRole(); |
| | | sysRole.setRoleName(dto.getRoleName()); |
| | | List<SysRole> sysRoles = roleMapper.selectRoleList(sysRole); |
| | | if (sysRoles!=null && !sysRoles.isEmpty()){ |
| | | throw new ServiceException("该角色名称重复"); |
| | | } |
| | | //删除之前的 |
| | | roleMenuMapper.deleteRoleMenuByRoleId(dto.getRoleId()); |
| | | //添加角色菜单 |
| | | roleMenuMapper.insert(sysRole.getRoleId(),dto.getMenuIds()); |
| | | } |
| | | |
| | | @Override |
| | | public List<SysRoleVO> getOptionSelect() { |
| | | return roleMapper.getOptionSelect(); |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | import javax.validation.Validator; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.utils.sign.Md5Utils; |
| | | import com.ruoyi.system.pojo.dto.AddSysUserDTO; |
| | | import com.ruoyi.system.pojo.dto.EditSysUserDTO; |
| | | import com.ruoyi.system.pojo.vo.SysUserPageListVO; |
| | | import com.ruoyi.system.pojo.vo.SysUserVO; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | // 删除用户与角色关联 |
| | | userRoleMapper.deleteUserRoleByUserId(userId); |
| | | // 删除用户与岗位表 |
| | | userPostMapper.deleteUserPostByUserId(userId); |
| | | // userPostMapper.deleteUserPostByUserId(userId); |
| | | return userMapper.deleteUserById(userId); |
| | | } |
| | | |
| | |
| | | } |
| | | return successMsg.toString(); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<SysUserPageListVO> getSysUserPageList(IPage<SysUserPageListVO> page, String nickName, Integer phone, String status) { |
| | | return userMapper.getSysUserPageList(page,nickName,phone,status); |
| | | } |
| | | |
| | | @Override |
| | | public R<SysUserVO> getInfo(Long userId) { |
| | | return userMapper.getSysUserVO(userId); |
| | | } |
| | | |
| | | @Override |
| | | public void add(AddSysUserDTO dto) { |
| | | //检查手机号是否重复 |
| | | SysUser sysUser= userMapper.selectuserByPhone(dto.getPhonenumber()); |
| | | if (sysUser != null){ |
| | | throw new ServiceException("手机号重复"); |
| | | } |
| | | //部门是否存在 |
| | | SysDept sysDept = deptService.selectDeptById(dto.getDeptId()); |
| | | if (sysDept == null){ |
| | | throw new ServiceException("部门不存在"); |
| | | } |
| | | //角色是否存在 |
| | | SysRole sysRole = roleMapper.selectRoleById(dto.getRoleId()); |
| | | if (sysRole == null){ |
| | | throw new ServiceException("角色不存在"); |
| | | } |
| | | //手机号作为登录 |
| | | sysUser = new SysUser(); |
| | | sysUser.setUserName(dto.getPhonenumber()); |
| | | sysUser.setPhonenumber(dto.getPhonenumber()); |
| | | sysUser.setNickName(dto.getNickName()); |
| | | //后六位为默认密码 |
| | | sysUser.setPassword(SecurityUtils.encryptPassword(Md5Utils.hash(dto.getPhonenumber().substring(6,12)))); |
| | | sysUser.setStatus("0"); |
| | | sysUser.setDeptId(dto.getDeptId()); //添加用户-部门关系 |
| | | userMapper.insertUser(sysUser); |
| | | //添加用户-角色关系 |
| | | userRoleMapper.insert(sysUser.getUserId(),dto.getRoleId()); |
| | | } |
| | | |
| | | @Override |
| | | public void edit(EditSysUserDTO dto) { |
| | | //检查用户是否存在 |
| | | SysUser sysUser = userMapper.selectUserById(dto.getUserId()); |
| | | if (sysUser==null){ |
| | | throw new ServiceException("该用户不存在"); |
| | | } |
| | | |
| | | if (!Objects.equals(dto.getPhonenumber(), sysUser.getPhonenumber())){ |
| | | //修改手机号 |
| | | //检查手机号是否重复 |
| | | SysUser phoneUser= userMapper.selectuserByPhone(dto.getPhonenumber()); |
| | | if (phoneUser != null){ |
| | | throw new ServiceException("手机号重复"); |
| | | } |
| | | sysUser.setPhonenumber(dto.getPhonenumber()); |
| | | sysUser.setUserName(dto.getPhonenumber()); |
| | | } |
| | | |
| | | if (!Objects.equals(dto.getDeptId(), sysUser.getDeptId())){ |
| | | //部门是否存在 |
| | | SysDept sysDept = deptService.selectDeptById(dto.getDeptId()); |
| | | if (sysDept == null){ |
| | | throw new ServiceException("部门不存在"); |
| | | } |
| | | sysUser.setDeptId(dto.getDeptId()); |
| | | } |
| | | |
| | | SysRole sysRole= userRoleMapper.selectRoleByUserId(dto.getUserId()); |
| | | if (!Objects.equals(sysRole.getRoleId(), dto.getRoleId())){ |
| | | //角色是否存在 |
| | | SysRole selectRole = roleMapper.selectRoleById(dto.getRoleId()); |
| | | if (selectRole == null){ |
| | | throw new ServiceException("角色不存在"); |
| | | } |
| | | sysUser.setRoleId(dto.getRoleId()); |
| | | //修改用户-角色关系 |
| | | userRoleMapper.deleteUserRoleByUserId(dto.getUserId()); |
| | | userRoleMapper.insert(sysUser.getUserId(),dto.getRoleId()); |
| | | } |
| | | sysUser.setNickName(dto.getNickName()); |
| | | userMapper.updateUser(sysUser); |
| | | } |
| | | |
| | | @Override |
| | | public void changeStatus(Long userId) { |
| | | //检查用户是否存在 |
| | | SysUser sysUser = userMapper.selectUserById(userId); |
| | | if (sysUser==null){ |
| | | throw new ServiceException("该用户不存在"); |
| | | } |
| | | sysUser.setStatus(Objects.equals(sysUser.getStatus(), "1") ?"0":"1"); |
| | | userMapper.updateUser(sysUser); |
| | | } |
| | | |
| | | @Override |
| | | public void resetPassword(Long userId) { |
| | | //重置密码 |
| | | //检查用户是否存在 |
| | | SysUser sysUser = userMapper.selectUserById(userId); |
| | | if (sysUser==null){ |
| | | throw new ServiceException("该用户不存在"); |
| | | } |
| | | sysUser.setPassword(SecurityUtils.encryptPassword(Md5Utils.hash(sysUser.getPassword().substring(6,12)))); |
| | | userMapper.updateUser(sysUser); |
| | | } |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.system.mapper.AppUserMapper"> |
| | | |
| | | |
| | | <select id="getAppUserPage" resultType="com.ruoyi.system.pojo.vo.AppUserPageVO"> |
| | | select |
| | | tbu.id, |
| | | tbu.user_name, |
| | | tbu.phone, |
| | | tbu.create_time, |
| | | tbu.balance, |
| | | tbu.status, |
| | | ifnull(bingding.num , 0) as bingDingUser, |
| | | ifnull(buy.num , 0) as buyNum, |
| | | ifnull(sell.num , 0) as sellNum |
| | | from tb_user tbu |
| | | LEFT JOIN tb_user u2 ON u1.id = u2.invite_id |
| | | left join (select user_id, count(1) as num from tb_order where status = 6 group by user_id) buy on tbu.id=buy.user_id |
| | | </select> |
| | | </mapper> |
| | |
| | | select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, |
| | | (select dept_name from sys_dept where dept_id = d.parent_id) parent_name |
| | | from sys_dept d |
| | | where d.dept_id = #{deptId} |
| | | where d.dept_id = #{deptId} and del_flag = '0' |
| | | </select> |
| | | |
| | | <select id="checkDeptExistUser" parameterType="Long" resultType="int"> |
| | |
| | | <include refid="selectDeptVo"/> |
| | | where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1 |
| | | </select> |
| | | |
| | | <select id="page" resultType="com.ruoyi.system.pojo.vo.SysDeptPageVO"> |
| | | select |
| | | dept_id,dept_name |
| | | from sys_dept |
| | | where |
| | | del_flag='0' |
| | | <if test="name!=null and name!='' "> |
| | | and `dept_name` like concat('%',#{name},'%') |
| | | </if> |
| | | </select> |
| | | <select id="selectDeptByName" resultType="com.ruoyi.common.core.domain.entity.SysDept"> |
| | | select dept_id from sys_dept where del_flag='0' and dept_name like #{name} |
| | | </select> |
| | | <select id="getDeptList" resultType="com.ruoyi.system.pojo.vo.SysDeptPageVO"> |
| | | select |
| | | dept_id,dept_name |
| | | from sys_dept |
| | | where |
| | | del_flag='0' |
| | | |
| | | </select> |
| | | |
| | | <insert id="insertDept" parameterType="SysDept"> |
| | | insert into sys_dept( |
| | | <if test="deptId != null and deptId != 0">dept_id,</if> |
| | |
| | | #{deptId} |
| | | </foreach> |
| | | </update> |
| | | |
| | | <update id="updateDeptName">update sys_dept set dept_name = #{sysDept.deptName} where dept_id = #{sysDept.deptId}</update> |
| | | |
| | | <delete id="deleteDeptById" parameterType="Long"> |
| | | update sys_dept set del_flag = '2' where dept_id = #{deptId} |
| | | </delete> |
| | |
| | | <include refid="selectMenuVo"/> |
| | | where menu_name=#{menuName} and parent_id = #{parentId} limit 1 |
| | | </select> |
| | | |
| | | <select id="selectMenusByParentId" resultType="com.ruoyi.system.pojo.vo.MenuTreeVO"> |
| | | select menu_id,menu_name,path,menu_type from sys_menu |
| | | where parent_id = #{menuId} order by order_num asc |
| | | </select> |
| | | <select id="getAllRootMenu" resultType="com.ruoyi.system.pojo.vo.MenuTreeVO"> |
| | | select distinct sm.menu_id,sm.menu_name,sm.path,sm.menu_type |
| | | from sys_menu sm |
| | | where |
| | | sm.parent_id = 0 order by sm.order_num asc |
| | | </select> |
| | | |
| | | <update id="updateMenu" parameterType="SysMenu"> |
| | | update sys_menu |
| | | <set> |
| | |
| | | <include refid="selectRoleVo"/> |
| | | where r.role_key=#{roleKey} and r.del_flag = '0' limit 1 |
| | | </select> |
| | | |
| | | <insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId"> |
| | | <select id="page" resultType="com.ruoyi.system.pojo.vo.SysRolePageVO"> |
| | | select role_id, role_name from sys_role where del_flag=0 |
| | | <if test="name!=null and name!='' "> |
| | | and `role_name` like concat('%',#{name},'%') |
| | | </if> |
| | | order by role_sort asc |
| | | </select> |
| | | <select id="getOptionSelect" resultType="com.ruoyi.system.pojo.vo.SysRoleVO"> |
| | | select role_id,role_name from sys_role where del_flag=0 |
| | | </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> |
| | |
| | | <select id="checkMenuExistRole" resultType="Integer"> |
| | | select count(1) from sys_role_menu where menu_id = #{menuId} |
| | | </select> |
| | | <select id="selectMenuIdsByRoleIds" resultType="java.lang.Long"> |
| | | select menu_id from sys_role_menu where role_id in |
| | | <foreach collection="roleList" item="roleId" open="(" separator="," close=")"> |
| | | #{roleId} |
| | | </foreach> |
| | | </select> |
| | | |
| | | <delete id="deleteRoleMenuByRoleId" parameterType="Long"> |
| | | <delete id="deleteRoleMenuByRoleId" parameterType="Long"> |
| | | delete from sys_role_menu where role_id=#{roleId} |
| | | </delete> |
| | | |
| | |
| | | (#{item.roleId},#{item.menuId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <insert id="insert"> |
| | | INSERT INTO sys_role_menu (role_id, menu_id) |
| | | VALUES |
| | | <foreach collection="menuIds" item="menuId" separator=","> |
| | | (#{roleId}, #{menuId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | </mapper> |
| | |
| | | </resultMap> |
| | | |
| | | <sql id="selectUserVo"> |
| | | select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.pwd_update_date, u.create_by, u.create_time, u.remark, |
| | | select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.pwd_update_date, u.create_by, u.create_time, u.remark, |
| | | d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status, |
| | | r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status |
| | | from sys_user u |
| | |
| | | <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult"> |
| | | select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1 |
| | | </select> |
| | | |
| | | <select id="getSysUserPageList" resultType="com.ruoyi.system.pojo.vo.SysUserPageListVO"> |
| | | select |
| | | su.user_id, |
| | | su.nick_name, |
| | | su.phonenumber, |
| | | sd.dept_id, |
| | | sd.dept_name, |
| | | sr.role_id, |
| | | sr.role_name, |
| | | su.status |
| | | from sys_user su |
| | | |
| | | left join sys_dept sd on su.dept_id = sd.dept_id |
| | | left join sys_user_role sur on su.user_id = sur.user_id |
| | | left join sys_role sr on sur.role_id =sr.role_id |
| | | where |
| | | su.del_flag='0' |
| | | <if test="nickName!=null and nickName!= '' "> |
| | | and su.nick_name like concat('%',#{nickName},'%') |
| | | </if> |
| | | <if test="phone!=null and phone!= '' "> |
| | | and su.phonenumber like concat('%',#{phone},'%') |
| | | </if> |
| | | <if test="status!=null and status!= '' "> |
| | | and su.status =#{status} |
| | | </if> |
| | | </select> |
| | | <select id="getSysUserVO" resultType="com.ruoyi.system.pojo.vo.SysUserVO"> |
| | | select |
| | | su.user_id, |
| | | su.nick_name, |
| | | su.phonenumber, |
| | | sd.dept_id, |
| | | sd.dept_name, |
| | | sr.role_id, |
| | | sr.role_name, |
| | | su.status |
| | | from sys_user su |
| | | left join sys_dept sd on su.dept_id = sd.dept_id |
| | | left join sys_user_role sur on su.user_id = sur.user_id |
| | | left join sys_role sr on sur.role_id =sr.role_id |
| | | where |
| | | su.del_flag='0' |
| | | and su.user_id=#{userId} |
| | | </select> |
| | | <select id="selectuserByPhone" resultType="com.ruoyi.common.core.domain.entity.SysUser"> |
| | | select * from sys_user where del_flag='0' and phonenumber =#{phonenumber} |
| | | </select> |
| | | |
| | | <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> |
| | | insert into sys_user( |
| | | <if test="userId != null and userId != 0">user_id,</if> |
| | |
| | | <select id="countUserRoleByRoleId" resultType="Integer"> |
| | | select count(1) from sys_user_role where role_id=#{roleId} |
| | | </select> |
| | | |
| | | <select id="selectRoleByUserId" resultType="com.ruoyi.common.core.domain.entity.SysRole"> |
| | | select * from sys_user_role where user_id=#{userId} |
| | | </select> |
| | | |
| | | <delete id="deleteUserRole" parameterType="Long"> |
| | | delete from sys_user_role where user_id in |
| | | <foreach collection="array" item="userId" open="(" separator="," close=")"> |
| | |
| | | (#{item.userId},#{item.roleId}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <delete id="deleteUserRoleInfo" parameterType="SysUserRole"> |
| | | <insert id="insert"> |
| | | insert into sys_user_role(user_id, role_id) value |
| | | (#{userId},#{roleId}) |
| | | </insert> |
| | | |
| | | <delete id="deleteUserRoleInfo" parameterType="SysUserRole"> |
| | | delete from sys_user_role where user_id=#{userId} and role_id=#{roleId} |
| | | </delete> |
| | | |