package ink.wgink.properties;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: AccessControl
 * @Description: 访问控制
 * @Author: WangGeng
 * @Date: 2019-06-12 22:01
 * @Version: 1.0
 **/
@Component
@ConfigurationProperties(prefix = "access-control")
public class AccessControlProperties {

    private Boolean rolePermission;
    private List<String> passPaths = new ArrayList<>(0);

    public Boolean getRolePermission() {
        return rolePermission == null ? true: rolePermission;
    }

    public void setRolePermission(Boolean rolePermission) {
        this.rolePermission = rolePermission;
    }

    public List<String> getPassPaths() {
        if (passPaths == null) {
            return new ArrayList<>();
        }
        return passPaths;
    }

    public void setPassPaths(List<String> passPaths) {
        this.passPaths = passPaths;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"rolePermission\":")
                .append(rolePermission);
        sb.append(",\"passPaths\":")
                .append(passPaths);
        sb.append('}');
        return sb.toString();
    }
}
