| | |
| | | private ResourceService resourceService; |
| | | @Autowired |
| | | private RoleResourceService roleResourceService; |
| | | @Autowired |
| | | private HostService hostService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | @RequestMapping("/login.action") |
| | | @ManagerAuth(value = ManagerAuth.Auth.NONE, memo = "登录") |
| | |
| | | userLogin.setToken(token); |
| | | userLogin.setCreateTime(new Date()); |
| | | userLogin.setSystem(system); |
| | | if (user.getRoleId() == 2) { |
| | | userLogin.setHostId(hostService.getTop1().getId()); |
| | | } |
| | | userLoginService.save(userLogin); |
| | | Map<String, Object> res = new HashMap<>(); |
| | | res.put("username", user.getUsername()); |
| | | res.put("token", token); |
| | | return R.ok(res); |
| | | } |
| | | |
| | | @RequestMapping("/show/host.action") |
| | | @ManagerAuth |
| | | public R showHosts() { |
| | | Long hostId = getHostId(); |
| | | String hostName = null; |
| | | if (hostId != null) { |
| | | Host host = hostService.getById(hostId); |
| | | if (host != null) { |
| | | hostName = host.getName(); |
| | | } |
| | | } |
| | | return R.ok().add(Cools |
| | | .add("root", getUser().getRoleId() == 2) |
| | | .add("host", getHostId() == null) |
| | | .add("hostName", hostName) |
| | | ); |
| | | } |
| | | |
| | | @RequestMapping(value = "/root/change/host/auth") |
| | | @ManagerAuth |
| | | public R rootChangeHost(@RequestParam Long hostId) { |
| | | UserLogin userLogin = userLoginService.getOne(new LambdaQueryWrapper<UserLogin>().eq(UserLogin::getUserId, getUserId()).eq(UserLogin::getSystem, String.valueOf(LoginSystemType.WMS))); |
| | | if (userLogin != null) { |
| | | userLogin.setHostId(hostId); |
| | | if (!userLoginService.updateById(userLogin)) { |
| | | throw new CoolException("修改商户失败"); |
| | | } |
| | | return R.ok(); |
| | | } else { |
| | | return R.error(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping("/code/switch.action") |
| | |
| | | oneLevel = resourceService.list(new LambdaQueryWrapper<Resource>().eq(Resource::getLevel, 1).orderByAsc(Resource::getSort)); |
| | | resourceWrapper = new LambdaQueryWrapper<Resource>().eq(Resource::getLevel, 2).eq(Resource::getStatus, 1).orderByAsc(Resource::getSort); |
| | | } else { |
| | | // 激活码验证 |
| | | if (!SystemProperties.SYSTEM_ACTIVATION) { |
| | | return R.ok(); |
| | | } |
| | | oneLevel = resourceService.list(new LambdaQueryWrapper<Resource>().eq(Resource::getLevel, 1).eq(Resource::getStatus, 1).orderByAsc(Resource::getSort)); |
| | | // 获取当前用户的所有二级菜单 |
| | | user = userService.getById(getUserId()); |
| | |
| | | // 是否拥有查看权限 |
| | | if (getUserId() != 9527) { |
| | | Resource view = resourceService.getOne(new LambdaQueryWrapper<Resource>().eq(Resource::getResourceId, resource.getId()).like(Resource::getCode, "#view")); |
| | | if (!Cools.isEmpty(view)){ |
| | | if (!Cools.isEmpty(view)) { |
| | | RoleResource param = new RoleResource(); |
| | | param.setResourceId(view.getId()); |
| | | param.setRoleId(user.getRoleId()); |
| | | if (null == roleResourceService.getOne(new LambdaQueryWrapper<>(param))){ |
| | | if (null == roleResourceService.getOne(new LambdaQueryWrapper<>(param))) { |
| | | continue; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | @RequestMapping("/loginInformation") |
| | | public R getLoginPageInformation() { |
| | | Config loginLogo = configService.selectByCode("loginLogo"); |
| | | Config loginCopyrightText = configService.selectByCode("loginCopyrightText"); |
| | | Config loginCopyrightImg1 = configService.selectByCode("loginCopyrightImg1"); |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("loginLogo", loginLogo.getValue()); |
| | | map.put("loginCopyrightText", loginCopyrightText.getValue()); |
| | | map.put("loginCopyrightImg1", loginCopyrightImg1.getStatus() == 1 ? loginCopyrightImg1.getValue() : ""); |
| | | |
| | | return R.ok().add(map); |
| | | } |
| | | |
| | | @PostMapping(value = "/system/secret/auth") |
| | | @ManagerAuth |
| | | public R systemSecret(@RequestParam(value = "secret") String secret) { |