轻松聘AI开发
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.
 
 
 

33 lines
1.3 KiB

package com.mydreamjob.salarycalculator;
import jakarta.annotation.PostConstruct;
import java.util.LinkedHashMap;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/** 发布白名单为空时失败关闭;enabled/dataLevel 不表示政策已核验。 */
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "app.salary-publication")
public class SalaryPolicyPublicationProperties {
private Map<String, String> approvedPolicies = new LinkedHashMap<>();
@PostConstruct
void validate() {
if (approvedPolicies == null || approvedPolicies.entrySet().stream().anyMatch(entry ->
entry.getKey() == null || !entry.getKey().matches("[0-9]{6}")
|| entry.getValue() == null || entry.getValue().isBlank()
|| !entry.getValue().equals(entry.getValue().trim()))) {
throw new IllegalStateException("invalid salary publication allowlist");
}
}
public boolean isPublished(String cityCode, String policyVersion) {
return cityCode != null && policyVersion != null && approvedPolicies != null
&& policyVersion.equals(approvedPolicies.get(cityCode));
}
}