| | |
| | | package com.ruoyi.system.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | |
| | | public AjaxResult add(@Validated(InsertGroup.class) @RequestBody SysUserDTO dto) { |
| | | SysUser user = BeanUtils.copyBean(dto, SysUser.class); |
| | | user.setUserId(null); |
| | | user.setUserType("01"); |
| | | // 添加为平台管理员 |
| | | user.setUserType("00"); |
| | | user.setUserName(user.getPhonenumber()); |
| | | if(!org.springframework.util.StringUtils.hasLength(user.getNickName())){ |
| | | user.setNickName(user.getPhonenumber()); |
| | |
| | | ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); |
| | | ajax.put("Dept", deptService.selectDeptList(null)); |
| | | if (StringUtils.isNotNull(userId)) { |
| | | SysUser sysUser = userService.selectUserById(userId); |
| | | SysUser sysUser = userService.getById(userId); |
| | | ajax.put(AjaxResult.DATA_TAG, sysUser); |
| | | ajax.put("Dept", sysUser.getDept()); |
| | | ajax.put("roleId", sysUser.getRoleId()); |
| | | ajax.put("roleName", sysUser.getRoleName()); |
| | | } |
| | | return AjaxResult.success(ajax); |
| | | return ajax; |
| | | } |
| | | |
| | | |
| | |
| | | SysRole byId = roleService.selectRoleById(dto.getRoleId()); |
| | | user.setRoleName(byId.getRoleName()); |
| | | user.setRoleId(dto.getRoleId()); |
| | | // 原来的role |
| | | SysUserRole one = userRoleService.getOne(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId,dto.getUserId() )); |
| | | one.setRoleId(dto.getRoleId()); |
| | | //更新新的role |
| | | userRoleService.updateSysUserRole(one); |
| | | return toAjax(userService.updateById(user)); |
| | | } |
| | | |
| | |
| | | |
| | | @PostMapping("/getUserSupplierList") |
| | | public R<List<SysUser>> getUserSupplierList(@RequestBody getVolumeProductionRkQuery getVolumeProductionRkQuery) { |
| | | List<SysUser> list = userService.list(new LambdaQueryWrapper<SysUser>().like(SysUser::getNickName, getVolumeProductionRkQuery.getSupplierName()).like(SysUser::getPhonenumber,getVolumeProductionRkQuery.getSupplierPhone())); |
| | | LambdaQueryWrapper<SysUser> like1 = new LambdaQueryWrapper<SysUser>(); |
| | | if (getVolumeProductionRkQuery.getSupplierName()!=null){ |
| | | like1.like(SysUser::getNickName, getVolumeProductionRkQuery.getSupplierName()); |
| | | }if (getVolumeProductionRkQuery.getSupplierPhone()!=null){ |
| | | like1.like(SysUser::getPhonenumber,getVolumeProductionRkQuery.getSupplierPhone()); |
| | | } |
| | | List<SysUser> list = userService.list(like1); |
| | | return R.ok(list); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | @Log(title = "用户管理", businessType = BusinessType.EXPORT) |
| | | @RequiresPermissions("system:user:export") |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, SysUser user) { |
| | | List<SysUser> list = userService.selectUserList(user); |
| | |
| | | } |
| | | |
| | | @Log(title = "用户管理", businessType = BusinessType.IMPORT) |
| | | @RequiresPermissions("system:user:import") |
| | | @PostMapping("/importData") |
| | | public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception { |
| | | ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); |
| | |
| | | /** |
| | | * 重置密码 |
| | | */ |
| | | @RequiresPermissions("system:user:edit") |
| | | @ApiOperation("重置密码") |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/resetPwd") |
| | | public AjaxResult resetPwd(@RequestBody ResetPwdDTO dto) { |
| | | SysUser user = userService.lambdaQuery().eq(SysUser::getUserId, dto.getUserId()) |
| | | .in(SysUser::getUserType, "00", "02").one(); |
| | | .in(SysUser::getUserType, "00", "01", "02", "03").one(); |
| | | if (StringUtils.isNull(user)) { |
| | | throw new ServiceException("账号不存在"); |
| | | } |
| | | |
| | | userService.checkUserAllowed(user); |
| | | userService.checkUserDataScope(user.getUserId()); |
| | | user.setPassword(SecurityUtils.encryptPassword(dto.getPassword())); |
| | | user.setPassword(SecurityUtils.encryptPassword("a123456")); |
| | | user.setUpdateBy(SecurityUtils.getUsername()); |
| | | return toAjax(userService.resetPwd(user)); |
| | | } |
| | | |
| | | @ApiOperation("修改密码") |
| | | @PostMapping("/updatePwd") |
| | | public AjaxResult updatePwd(@RequestBody ResetPwdDTO dto) { |
| | | // 判断旧密码是否和当前密码是否匹配 |
| | | SysUser one = userService.getOne(new QueryWrapper<SysUser>() |
| | | .eq("phonenumber", dto.getPhonenumber()) |
| | | .eq("del_flag", 0)); |
| | | if (one == null){ |
| | | return AjaxResult.error("账号不存在"); |
| | | } |
| | | if (SecurityUtils.matchesPassword(dto.getPassword(),one.getPassword())) { |
| | | return AjaxResult.error("新密码不能和旧密码一致"); |
| | | } |
| | | if (SecurityUtils.matchesPassword(dto.getOldPassword(),one.getPassword())){ |
| | | return AjaxResult.error("旧密码错误"); |
| | | } |
| | | userService.updateById(one); |
| | | return AjaxResult.success(); |
| | | } |
| | | /** |
| | | * 获取当前用户信息 |
| | | */ |
| | |
| | | /** |
| | | * 状态修改 |
| | | */ |
| | | @RequiresPermissions("system:user:edit") |
| | | @Log(title = "用户管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping("/changeStatus") |
| | | public AjaxResult changeStatus(@RequestBody SysUser user) { |
| | |
| | | /** |
| | | * 根据用户编号获取授权角色 |
| | | */ |
| | | @RequiresPermissions("system:user:query") |
| | | @GetMapping("/authRole/{userId}") |
| | | public AjaxResult authRole(@PathVariable("userId") Long userId) { |
| | | AjaxResult ajax = AjaxResult.success(); |
| | |
| | | /** |
| | | * 用户授权角色 |
| | | */ |
| | | @RequiresPermissions("system:user:edit") |
| | | @Log(title = "用户管理", businessType = BusinessType.GRANT) |
| | | @PutMapping("/authRole") |
| | | public AjaxResult insertAuthRole(Long userId, Long[] roleIds) { |
| | |
| | | /** |
| | | * 获取部门树列表 |
| | | */ |
| | | @RequiresPermissions("system:user:list") |
| | | @GetMapping("/deptTree") |
| | | public AjaxResult deptTree(SysDept dept) { |
| | | return success(deptService.selectDeptTreeList(dept)); |
| | |
| | | return R.ok(userService.getSupplierPage(query)); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取供应商不分页列表", notes = "获取供应商不分页列表") |
| | | @PostMapping("/supplier-page1") |
| | | public R<List<SysUser>> getSupplierPage1() { |
| | | return R.ok(userService.getSupplierPage1()); |
| | | } |
| | | |
| | | /** |
| | | * 添加/编辑供应商 |
| | | * |
| | |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "获取管理员分页列表", notes = "获取管理员分页列表") |
| | | @ApiOperation(value = "获取仓库管理员分页列表", notes = "获取仓库管理分页列表") |
| | | @PostMapping("/conservator-page") |
| | | public R<PageDTO<ConservatorVO>> getConservatorPage(@Validated @RequestBody ConservatorQuery query) { |
| | | return R.ok(userService.getConservatorPage(query)); |
| | | } |
| | | @ApiOperation(value = "根据仓库等级和所在地获取管理员列表--不分页", notes = "获取仓库管理分页列表") |
| | | @PostMapping("/conservator-page2") |
| | | public R<List<SysUser>> getConservatorPage2(@RequestBody ConservatorQueryA query) { |
| | | return R.ok(userService.getConservatorPage2(query)); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取仓库管理员不分页列表", notes = "获取仓库管理分页列表") |
| | | @GetMapping("/conservator-page1/{grade}") |
| | | public R<List<SysUser>> getConservatorPage1(@PathVariable("grade") String grade) { |
| | | return R.ok(userService.getConservatorPage1(grade)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @param dto 供应商数据传输对象 |
| | | */ |
| | | @Log(title = "管理员", businessType = BusinessType.UPDATE) |
| | | @ApiOperation(value = "添加/编辑管理员", notes = "添加/编辑管理员") |
| | | @ApiOperation(value = "添加/编辑仓库管理", notes = "添加/编辑仓库管理") |
| | | @PostMapping("/save-conservator") |
| | | public R<?> saveConservator(@Validated @RequestBody ConservatorDTO dto) { |
| | | userService.saveConservator(dto); |
| | |
| | | * |
| | | * @param id 供应商id |
| | | */ |
| | | @ApiOperation(value = "删除管理员", notes = "删除管理员") |
| | | @ApiOperation(value = "删除仓库管理", notes = "删除仓库管理") |
| | | @DeleteMapping("/delete-conservator/{id}") |
| | | public R<?> deleteConservator(@PathVariable("id") Long id) { |
| | | userService.deleteConservator(id); |