From f405d7cd127c94f4776ff774b1bef3deff2723a2 Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期二, 20 八月 2024 14:43:11 +0800
Subject: [PATCH] #
---
zy-asrs-common/src/main/java/com/zy/asrs/common/web/AuthController.java | 72 ++++++++++++++++++++++++++++++++----
1 files changed, 64 insertions(+), 8 deletions(-)
diff --git a/zy-asrs-common/src/main/java/com/zy/asrs/common/web/AuthController.java b/zy-asrs-common/src/main/java/com/zy/asrs/common/web/AuthController.java
index df4a984..ee490b6 100644
--- a/zy-asrs-common/src/main/java/com/zy/asrs/common/web/AuthController.java
+++ b/zy-asrs-common/src/main/java/com/zy/asrs/common/web/AuthController.java
@@ -11,6 +11,7 @@
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;
@@ -44,10 +45,19 @@
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, 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);
@@ -67,9 +77,9 @@
return R.parse(CodeRes.USER_10003);
}
String system = null;//鐧婚檰绯荤粺
- if (wms) {
+ if (wms != null && wms) {
system = String.valueOf(LoginSystemType.WMS);
- }else {
+ } else {
system = String.valueOf(LoginSystemType.WCS);
}
String token = Cools.enToken(System.currentTimeMillis() + username, user.getPassword());
@@ -79,11 +89,47 @@
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")
@@ -130,10 +176,6 @@
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());
@@ -158,11 +200,11 @@
// 鏄惁鎷ユ湁鏌ョ湅鏉冮檺
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;
}
}
@@ -324,6 +366,20 @@
}
}
+ @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) {
--
Gitblit v1.9.1