| | |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.security.annotation.InnerAuth; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.system.api.domain.SysDept; |
| | | import com.ruoyi.system.api.domain.SysRole; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | | import com.ruoyi.system.api.domain.getVolumeProductionRkQuery; |
| | | import com.ruoyi.system.api.feignClient.ManagementClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import com.ruoyi.system.api.validate.InsertGroup; |
| | | import com.ruoyi.system.api.validate.UpdateGroup; |
| | |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | public class SysUserController extends BaseController { |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Autowired |
| | | private ISysRoleService roleService; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private ISysUserRoleService sysUserRoleService; |
| | | @Autowired |
| | | private ManagementClient managementClient; |
| | | /** |
| | | * 获取用户列表 |
| | | */ |
| | | @PostMapping("/list") |
| | | @ApiOperation("账号管理列表") |
| | | public AjaxResult list(@Validated @RequestBody SysUserQuery query) { |
| | | tokenService.getLoginUser(); |
| | | PageInfo<SysUser> pageInfo = new PageInfo<>(query.getPageCurr(), query.getPageSize()); |
| | | PageInfo<SysUser> page = userService.getList(pageInfo, query.getNickName(), |
| | | query.getPhonenumber(), query.getStatus(),query.getDeptId()); |
| | |
| | | @ApiOperation("添加账号") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AjaxResult add(@Validated(InsertGroup.class) @RequestBody SysUserDTO dto) { |
| | | tokenService.getLoginUser(); |
| | | SysUser user = BeanUtils.copyBean(dto, SysUser.class); |
| | | user.setUserId(null); |
| | | // 添加为平台管理员 |
| | |
| | | user.setUserName(user.getPhonenumber()); |
| | | if(!org.springframework.util.StringUtils.hasLength(user.getNickName())){ |
| | | user.setNickName(user.getPhonenumber()); |
| | | } |
| | | SysUser one = userService.getOne(new QueryWrapper<SysUser>() |
| | | .ne("user_type", "02") |
| | | .eq("phonenumber", dto.getPhonenumber()) |
| | | .eq("del_flag", "0")); |
| | | if (one!=null){ |
| | | if (one.getUserType().equals("03")){ |
| | | return error("添加失败,该账号为仓库管理员账号"); |
| | | }else{ |
| | | return error("手机号已开通账号"); |
| | | } |
| | | } |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) { |
| | | return error("手机号已开通账号"); |
| | |
| | | @GetMapping("/{userId}") |
| | | public AjaxResult getInfo( |
| | | @ApiParam(value = "用户ID", required = true) @PathVariable(value = "userId", required = true) Long userId) { |
| | | tokenService.getLoginUser(); |
| | | userService.checkUserDataScope(userId); |
| | | AjaxResult ajax = AjaxResult.success(); |
| | | List<SysRole> roles = roleService.selectRoleAll(); |
| | |
| | | @PutMapping("/update") |
| | | @ApiOperation("编辑账号") |
| | | public AjaxResult edit(@Validated(UpdateGroup.class) @RequestBody SysUserDTO dto) { |
| | | tokenService.getLoginUser(); |
| | | SysUser two = userService.getOne(new QueryWrapper<SysUser>() |
| | | .ne("user_type", "02") |
| | | .eq("phonenumber", dto.getPhonenumber()) |
| | | .eq("del_flag", "0")); |
| | | if (two!=null){ |
| | | if (two.getUserType().equals("03")){ |
| | | return error("添加失败,该账号为仓库管理员账号"); |
| | | }else{ |
| | | return error("手机号已开通账号"); |
| | | } |
| | | } |
| | | SysUser user = BeanUtils.copyBean(dto, SysUser.class); |
| | | user.setUserName(user.getPhonenumber()); |
| | | if(!org.springframework.util.StringUtils.hasLength(user.getNickName())){ |
| | |
| | | if (StringUtils.isNull(sysUser)) { |
| | | return R.fail("用户名或密码错误"); |
| | | } |
| | | String data = managementClient.isHaveCKZY(sysUser.getUserId().toString()).getData(); |
| | | LoginUser sysUserVo = new LoginUser(); |
| | | sysUser.setIsHaveCk(data); |
| | | sysUserVo.setSysUser(sysUser); |
| | | if (sysUser.getUserType().equals("00")) { |
| | | // 角色集合 |
| | |
| | | if (SecurityUtils.matchesPassword(dto.getPassword(),one.getPassword())) { |
| | | return AjaxResult.error("新密码不能和旧密码一致"); |
| | | } |
| | | if (SecurityUtils.matchesPassword(dto.getOldPassword(),one.getPassword())){ |
| | | if (!SecurityUtils.matchesPassword(dto.getOldPassword(),one.getPassword())){ |
| | | return AjaxResult.error("旧密码错误"); |
| | | } |
| | | one.setPassword(SecurityUtils.encryptPassword(dto.getPassword())); |
| | | userService.updateById(one); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取当前用户信息 |
| | | */ |
| | |
| | | @ApiOperation(value = "根据仓库等级和所在地获取管理员列表--不分页", notes = "获取仓库管理分页列表") |
| | | @PostMapping("/conservator-page2") |
| | | public R<List<SysUser>> getConservatorPage2(@RequestBody ConservatorQueryA query) { |
| | | tokenService.getLoginUser(); |
| | | return R.ok(userService.getConservatorPage2(query)); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取仓库管理员不分页列表", notes = "获取仓库管理分页列表") |
| | | @GetMapping("/conservator-page1/{grade}") |
| | | public R<List<SysUser>> getConservatorPage1(@PathVariable("grade") String grade) { |
| | | tokenService.getLoginUser(); |
| | | return R.ok(userService.getConservatorPage1(grade)); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "添加/编辑仓库管理", notes = "添加/编辑仓库管理") |
| | | @PostMapping("/save-conservator") |
| | | public R<?> saveConservator(@Validated @RequestBody ConservatorDTO dto) { |
| | | userService.saveConservator(dto); |
| | | return R.ok(); |
| | | |
| | | return userService.saveConservator(dto); |
| | | } |
| | | |
| | | /** |