You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package com.example.demo.Node;
import lombok.Data;import java.util.HashSet;import java.util.Set;
@Datapublic class RefundApprovalNode { private String nodeName; private Integer level; private Set<String> roles; // 审批所需的角色集合
private Set<Integer> allowedMarketIds; // 允许审批的地区ID集合
private Set<String> allowedMarketNames; // 允许审批的地区名称集合(向后兼容)
private boolean required;
public RefundApprovalNode() { this.roles = new HashSet<>(); this.allowedMarketIds = new HashSet<>(); this.allowedMarketNames = new HashSet<>(); }
public RefundApprovalNode(String nodeName, Integer level, String role, boolean required) { this(); this.nodeName = nodeName; this.level = level; if (role != null) { this.roles.add(role); } this.required = required; }
public RefundApprovalNode(String nodeName, Integer level, Set<String> roles, Set<Integer> allowedMarketIds, boolean required) { this.nodeName = nodeName; this.level = level; this.roles = roles != null ? roles : new HashSet<>(); this.allowedMarketIds = allowedMarketIds != null ? allowedMarketIds : new HashSet<>(); this.allowedMarketNames = new HashSet<>(); this.required = required; } // 构造函数:接受多个角色(数组形式)和地区ID集合
public RefundApprovalNode(String nodeName, Integer level, String[] roles, Set<Integer> allowedMarketIds, boolean required) { this(); this.nodeName = nodeName; this.level = level; if (roles != null) { for (String role : roles) { this.roles.add(role); } } this.allowedMarketIds = allowedMarketIds != null ? allowedMarketIds : new HashSet<>(); this.required = required; }
public void addRole(String role) { if (this.roles == null) { this.roles = new HashSet<>(); } this.roles.add(role); }
public void addMarketId(Integer marketId) { if (this.allowedMarketIds == null) { this.allowedMarketIds = new HashSet<>(); } this.allowedMarketIds.add(marketId); }
public void addMarketName(String marketName) { if (this.allowedMarketNames == null) { this.allowedMarketNames = new HashSet<>(); } this.allowedMarketNames.add(marketName); }
// 检查节点是否对指定地区ID可见
public boolean isMarketAllowed(Integer marketId) { if (allowedMarketIds == null || allowedMarketIds.isEmpty()) { return true; // 没有地区限制,所有地区都可见
} return allowedMarketIds.contains(marketId); }
// 检查节点是否对指定地区名称可见(向后兼容)
public boolean isMarketAllowedByName(String marketName) { if ((allowedMarketNames == null || allowedMarketNames.isEmpty()) && (allowedMarketIds == null || allowedMarketIds.isEmpty())) { return true; // 没有地区限制,所有地区都可见
}
if (allowedMarketNames != null && !allowedMarketNames.isEmpty()) { return allowedMarketNames.contains(marketName); }
return false; }}
|