From d6d25613f504d8fc4c6ffa8a1854beb4dac044d0 Mon Sep 17 00:00:00 2001
From: chen.llin <1442464845@qq.comm>
Date: 星期日, 18 一月 2026 09:16:24 +0800
Subject: [PATCH] 菜单
---
src/main/java/com/zy/common/web/AuthController.java | 154 ++++++++++++++++++++++++++++++---------------------
1 files changed, 90 insertions(+), 64 deletions(-)
diff --git a/src/main/java/com/zy/common/web/AuthController.java b/src/main/java/com/zy/common/web/AuthController.java
index 32e4d76..6ef203c 100644
--- a/src/main/java/com/zy/common/web/AuthController.java
+++ b/src/main/java/com/zy/common/web/AuthController.java
@@ -4,19 +4,19 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.core.annotations.ManagerAuth;
-import com.core.common.*;
+import com.core.common.Cools;
+import com.core.common.R;
import com.core.exception.CoolException;
import com.zy.common.CodeRes;
import com.zy.common.entity.Parameter;
import com.zy.common.model.PowerDto;
import com.zy.common.model.enums.HtmlNavIconType;
-import com.zy.common.properties.OSinfo;
import com.zy.common.properties.SystemProperties;
import com.zy.common.utils.RandomValidateCodeUtil;
import com.zy.system.entity.*;
-import com.zy.system.entity.license.LicenseVerify;
import com.zy.system.service.*;
import com.zy.system.timer.LicenseTimer;
+import com.zy.system.timer.LoadingConfigTimer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
@@ -49,6 +49,8 @@
private RolePermissionService rolePermissionService;
@Autowired
private LicenseTimer licenseTimer;
+ @Autowired
+ private LoadingConfigTimer loadingConfigTimer;
@PostMapping("/login.action")
@ManagerAuth(value = ManagerAuth.Auth.NONE, memo = "鐧诲綍")
@@ -76,7 +78,9 @@
return R.parse(CodeRes.USER_10003);
}
String token = Cools.enToken(System.currentTimeMillis() + param.get("username"), user.getPassword());
- userLoginService.delete(new EntityWrapper<UserLogin>().eq("user_id", user.getId()));
+ if (loadingConfigTimer.getTokenNumber() == 1) {
+ userLoginService.delete(new EntityWrapper<UserLogin>().eq("user_id", user.getId()).eq("system", "WMS"));
+ }
UserLogin userLogin = new UserLogin();
userLogin.setUserId(user.getId());
userLogin.setToken(token);
@@ -142,7 +146,11 @@
user = userService.selectById(getUserId());
List<RoleResource> roleResources = roleResourceService.selectList(new EntityWrapper<RoleResource>().eq("role_id", user.getRoleId()));
List<Long> resourceIds = new ArrayList<>();
- roleResources.forEach(roleResource -> resourceIds.add(roleResource.getResourceId()));
+ roleResources.forEach(roleResource -> {
+ if (roleResource.getResourceId() != null) {
+ resourceIds.add(roleResource.getResourceId());
+ }
+ });
if (resourceIds.isEmpty()) {
return R.ok();
}
@@ -282,20 +290,30 @@
if (!Cools.isEmpty(powers)) {
List<PowerDto> dtos = JSON.parseArray(powers, PowerDto.class);
for (PowerDto dto : dtos) {
- Resource resource = resourceService.selectOne(new EntityWrapper<Resource>().eq("id", dto.getTwo()).eq("level", 2));
- if (!Cools.isEmpty(resource)) {
- // 鏍¢獙涓婄骇鏉冮檺
- if (leaderId != null) {
- RoleResource roleResource = roleResourceService.selectOne(new EntityWrapper<RoleResource>().eq("role_id", leaderId).eq("resource_id", resource.getId()));
- if (null == roleResource) {
- throw new CoolException(resource.getName().concat("鏃犳硶鎺堟潈缁�").concat(role.getName()));
+ Long resourceId = null;
+ try {
+ resourceId = Long.parseLong(dto.getTwo());
+ } catch (NumberFormatException e) {
+ // 濡傛灉鏃犳硶杞崲涓篖ong锛屽彲鑳芥槸鍔熻兘鏉冮檺锛岃烦杩�
+ }
+ if (resourceId != null) {
+ Resource resource = resourceService.selectOne(new EntityWrapper<Resource>().eq("id", resourceId).eq("level", 2));
+ if (!Cools.isEmpty(resource)) {
+ // 鏍¢獙涓婄骇鏉冮檺
+ if (leaderId != null) {
+ RoleResource leaderRoleResource = roleResourceService.selectOne(new EntityWrapper<RoleResource>().eq("role_id", leaderId).eq("resource_id", resource.getId()));
+ if (null == leaderRoleResource) {
+ throw new CoolException(resource.getName().concat("鏃犳硶鎺堟潈缁�").concat(role.getName()));
+ }
}
+ RoleResource roleResource = new RoleResource();
+ roleResource.setRoleId(roleId);
+ roleResource.setResourceId(resource.getId());
+ roleResourceService.insert(roleResource);
}
- RoleResource roleResource = new RoleResource();
- roleResource.setRoleId(roleId);
- roleResource.setResourceId(resource.getId());
- roleResourceService.insert(roleResource);
- } else {
+ }
+ // 濡傛灉涓嶆槸璧勬簮ID锛屽彲鑳芥槸鍔熻兘鏉冮檺
+ if (resourceId == null) {
Permission permission = permissionService.selectOne(new EntityWrapper<Permission>().eq("action", dto.getTwo()));
if (!Cools.isEmpty(permission)) {
RolePermission rolePermission = new RolePermission();
@@ -304,14 +322,22 @@
rolePermissionService.insert(rolePermission);
}
}
+ // 澶勭悊涓夌骇鑿滃崟
for (String three : dto.getThree()) {
- Resource resource1 = resourceService.selectOne(new EntityWrapper<Resource>().eq("id", three).eq("level", 3));
+ Long threeResourceId = null;
+ try {
+ threeResourceId = Long.parseLong(three);
+ } catch (NumberFormatException e) {
+ // 濡傛灉鏃犳硶杞崲涓篖ong锛岃烦杩�
+ continue;
+ }
+ Resource resource1 = resourceService.selectOne(new EntityWrapper<Resource>().eq("id", threeResourceId).eq("level", 3));
if (!Cools.isEmpty(resource1)) {
// 鏍¢獙涓婄骇鏉冮檺
if (leaderId != null) {
- RoleResource roleResource = roleResourceService.selectOne(new EntityWrapper<RoleResource>().eq("role_id", leaderId).eq("resource_id", resource1.getId()));
- if (null == roleResource) {
- throw new CoolException(resource.getName().concat("鐨�").concat(resource1.getName().concat("鏃犳硶鎺堟潈缁�").concat(role.getName())));
+ RoleResource leaderRoleResource = roleResourceService.selectOne(new EntityWrapper<RoleResource>().eq("role_id", leaderId).eq("resource_id", resource1.getId()));
+ if (null == leaderRoleResource) {
+ throw new CoolException(resource1.getName().concat("鏃犳硶鎺堟潈缁�").concat(role.getName()));
}
}
RoleResource roleResource = new RoleResource();
@@ -340,48 +366,48 @@
return R.ok(resources);
}
- @GetMapping(value = "/system/activation/auth")
- public R activation() {
- if (SystemProperties.SYSTEM_ACTIVATION) {
- String activationCode = SystemProperties.getActivationCode(OSinfo.getOSname().getActivationCodePath());
- String timeStr = AesUtils.decrypt(activationCode, SystemProperties.SALT);
- if (null == timeStr) {
- SystemProperties.SYSTEM_ACTIVATION = Boolean.FALSE;
- return R.error();
- }
- Date exprTime = DateUtils.convert(timeStr, DateUtils.yyyyMMddHHmmss);
- if (new Date().getTime() < exprTime.getTime()) {
- return R.ok().add(DateUtils.convert(exprTime));
- } else {
- SystemProperties.SYSTEM_ACTIVATION = Boolean.FALSE;
- return R.error();
- }
- } else {
- return R.error();
- }
- }
-
- @PostMapping(value = "/system/secret/auth")
- @ManagerAuth
- public R systemSecret(@RequestParam(value = "secret") String secret) {
- if (Cools.isEmpty(secret)) {
- return R.error("璇疯緭鍏ユ縺娲荤爜");
- }
- // 楠岃瘉婵�娲荤爜
- String timeStr = AesUtils.decrypt(secret, SystemProperties.SALT);
- if (null == timeStr) {
- return R.error("婵�娲荤爜閿欒");
- }
- Date exprTime = DateUtils.convert(timeStr, DateUtils.yyyyMMddHHmmss);
- if (new Date().getTime() >= exprTime.getTime()) {
- return R.error("婵�娲荤爜宸插け鏁�");
- }
- boolean result = SystemProperties.saveActivationCode(OSinfo.getOSname().getActivationCodePath(), secret);
- if (!result) {
- return R.error("婵�娲诲け璐�");
- }
- SystemProperties.SYSTEM_ACTIVATION = Boolean.TRUE;
- return R.ok("婵�娲绘垚鍔燂紝鏈夋晥鏈熻嚦" + DateUtils.convert(exprTime));
- }
+// @GetMapping(value = "/system/activation/auth")
+// public R activation() {
+// if (SystemProperties.SYSTEM_ACTIVATION) {
+// String activationCode = SystemProperties.getActivationCode(OSinfo.getOSname().getActivationCodePath());
+// String timeStr = AesUtils.decrypt(activationCode, SystemProperties.SALT);
+// if (null == timeStr) {
+// SystemProperties.SYSTEM_ACTIVATION = Boolean.FALSE;
+// return R.error();
+// }
+// Date exprTime = DateUtils.convert(timeStr, DateUtils.yyyyMMddHHmmss);
+// if (new Date().getTime() < exprTime.getTime()) {
+// return R.ok().add(DateUtils.convert(exprTime));
+// } else {
+// SystemProperties.SYSTEM_ACTIVATION = Boolean.FALSE;
+// return R.error();
+// }
+// } else {
+// return R.error();
+// }
+// }
+//
+// @PostMapping(value = "/system/secret/auth")
+// @ManagerAuth
+// public R systemSecret(@RequestParam(value = "secret") String secret) {
+// if (Cools.isEmpty(secret)) {
+// return R.error("璇疯緭鍏ユ縺娲荤爜");
+// }
+// // 楠岃瘉婵�娲荤爜
+// String timeStr = AesUtils.decrypt(secret, SystemProperties.SALT);
+// if (null == timeStr) {
+// return R.error("婵�娲荤爜閿欒");
+// }
+// Date exprTime = DateUtils.convert(timeStr, DateUtils.yyyyMMddHHmmss);
+// if (new Date().getTime() >= exprTime.getTime()) {
+// return R.error("婵�娲荤爜宸插け鏁�");
+// }
+// boolean result = SystemProperties.saveActivationCode(OSinfo.getOSname().getActivationCodePath(), secret);
+// if (!result) {
+// return R.error("婵�娲诲け璐�");
+// }
+// SystemProperties.SYSTEM_ACTIVATION = Boolean.TRUE;
+// return R.ok("婵�娲绘垚鍔燂紝鏈夋晥鏈熻嚦" + DateUtils.convert(exprTime));
+// }
}
--
Gitblit v1.9.1