|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.common.domain.dto.PowerDto; | 
|---|
|  |  |  | import com.zy.asrs.common.domain.entity.Parameter; | 
|---|
|  |  |  | import com.zy.asrs.common.domain.enums.HtmlNavIconType; | 
|---|
|  |  |  | import com.zy.asrs.common.domain.enums.LoginSystemType; | 
|---|
|  |  |  | import com.zy.asrs.common.properties.OSinfo; | 
|---|
|  |  |  | import com.zy.asrs.common.properties.SystemProperties; | 
|---|
|  |  |  | import com.zy.asrs.common.sys.entity.*; | 
|---|
|  |  |  | import com.zy.asrs.common.sys.service.*; | 
|---|
|  |  |  | import com.zy.asrs.common.timer.LicenseTimer; | 
|---|
|  |  |  | import com.zy.asrs.common.utils.RandomValidateCodeUtil; | 
|---|
|  |  |  | import com.zy.asrs.framework.annotations.ManagerAuth; | 
|---|
|  |  |  | import com.zy.asrs.framework.common.AesUtils; | 
|---|
|  |  |  | 
|---|
|  |  |  | private ResourceService resourceService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RoleResourceService roleResourceService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private HostService hostService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ConfigService configService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LicenseTimer licenseTimer; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping("/login.action") | 
|---|
|  |  |  | @ManagerAuth(value = ManagerAuth.Auth.NONE, memo = "登录") | 
|---|
|  |  |  | public R loginAction(String username, String password){ | 
|---|
|  |  |  | public R loginAction(String username, String password, Boolean wms) { | 
|---|
|  |  |  | if (!licenseTimer.getSystemSupport()) {//许可证已失效 | 
|---|
|  |  |  | return R.parse(CodeRes.SYSTEM_20001); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (username.equals("super") && password.equals(Cools.md5(superPwd))) { | 
|---|
|  |  |  | Map<String, Object> res = new HashMap<>(); | 
|---|
|  |  |  | res.put("username", username); | 
|---|
|  |  |  | 
|---|
|  |  |  | LambdaQueryWrapper<User> userWrapper = new LambdaQueryWrapper<>(); | 
|---|
|  |  |  | userWrapper.eq(User::getUsername, username); | 
|---|
|  |  |  | User user = userService.getOne(userWrapper); | 
|---|
|  |  |  | if (Cools.isEmpty(user)){ | 
|---|
|  |  |  | if (Cools.isEmpty(user)) { | 
|---|
|  |  |  | return R.parse(CodeRes.USER_10001); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (user.getStatus()!=1){ | 
|---|
|  |  |  | if (user.getStatus() != 1) { | 
|---|
|  |  |  | return R.parse(CodeRes.USER_10002); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!user.getPassword().equals(password)){ | 
|---|
|  |  |  | if (!user.getPassword().equals(password)) { | 
|---|
|  |  |  | return R.parse(CodeRes.USER_10003); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String system = null;//登陆系统 | 
|---|
|  |  |  | if (wms != null && wms) { | 
|---|
|  |  |  | system = String.valueOf(LoginSystemType.WMS); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | system = String.valueOf(LoginSystemType.WCS); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String token = Cools.enToken(System.currentTimeMillis() + username, user.getPassword()); | 
|---|
|  |  |  | userLoginService.remove(new LambdaQueryWrapper<UserLogin>().eq(UserLogin::getUserId, user.getId())); | 
|---|
|  |  |  | userLoginService.remove(new LambdaQueryWrapper<UserLogin>().eq(UserLogin::getUserId, user.getId()).eq(UserLogin::getSystem, system)); | 
|---|
|  |  |  | UserLogin userLogin = new UserLogin(); | 
|---|
|  |  |  | userLogin.setUserId(user.getId()); | 
|---|
|  |  |  | 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) { | 
|---|