1.供应商角色是PROXY\_SUPPLIER,租赁账户角色编码是PROXY\_ACCOUNT,帮我实现供应商角色和租赁账户后台首页

2\. 给出供应商角色和租赁账户所有权限配置接口的插入sql。
This commit is contained in:
lu7213 committed 2026-10-23 02:31:41 -04:00
1 parent fcff9fa48d
commit dcffc60d80
6 files changed
+146 -2

No files matched your search

@@ -76,7 +76,7 @@ public class RentalController {
}
@PostMapping("/register/{resource}")
@PreAuthorize("@ss.hasPermi('rent:portal:register')")
@PreAuthorize("@ss.hasPermi('rent:portal:register') or @ss.hasPermi('rent:' + #resource + ':create')")
public AjaxResult register(
@PathVariable String resource, @RequestBody Map<String, Object> body) {
return AjaxResult.success(provisioning.create(resource, body, user()));
@@ -155,7 +155,7 @@ public class RentalController {
}
@PostMapping("/account/open")
@PreAuthorize("@ss.hasPermi('rent:portal:register')")
@PreAuthorize("@ss.hasPermi('rent:portal:register') or @ss.hasPermi('rent:account:open')")
public AjaxResult account(@RequestBody Map<String, Object> body) {
return AjaxResult.success(funds.account(user(), input(body, "network", 16)));
}
@@ -0,0 +1,55 @@
package com.ruoyi.system.rental;
import org.junit.Test;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.security.access.prepost.PreAuthorize;
import java.util.Collections;
import java.util.Map;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/** 验证实际入口的权限表达式,防止细分创建权限重新扩大为通用注册权限。 */
public class RentalRolePermissionTest {
@Test
public void supplierCannotCreateMerchantApp() throws Exception {
assertTrue(register("rent:node:create", "node"));
assertTrue(register("rent:wallet:create", "wallet"));
assertFalse(register("rent:node:create", "app"));
assertFalse(register("rent:wallet:create", "app"));
}
@Test
public void merchantCannotCreateSupplierNode() throws Exception {
assertTrue(register("rent:app:create", "app"));
assertFalse(register("rent:app:create", "node"));
assertFalse(register("rent:account:open", "wallet"));
assertTrue(register("rent:portal:register", "app"));
}
private boolean register(String permission, String resource) throws Exception {
String expression = RentalController.class
.getMethod("register", String.class, Map.class)
.getAnnotation(PreAuthorize.class).value();
StandardEvaluationContext context = new StandardEvaluationContext();
context.setVariable("resource", resource);
context.setBeanResolver((evaluationContext, beanName) -> new PermissionProbe(permission));
return Boolean.TRUE.equals(new SpelExpressionParser()
.parseExpression(expression).getValue(context, Boolean.class));
}
/** 仅替代权限查询,不复制控制器表达式;表达式始终读取真实注解。 */
public static class PermissionProbe {
private final String permission;
public PermissionProbe(String permission) {
this.permission = permission;
}
public boolean hasPermi(String requested) {
return Collections.singleton(permission).contains(requested);
}
}
}