package com.gk.hotwork.Sms;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Optional;
|
|
import com.gk.hotwork.Sms.Supplier.Abstract.Supplier;
|
import com.gk.hotwork.Sms.Supplier.Ali;
|
import com.gk.hotwork.Sms.Supplier.Jh;
|
import io.swagger.models.auth.In;
|
import org.apache.log4j.Logger;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.PostConstruct;
|
|
@Component("smsServiceConfig")
|
@ConfigurationProperties(prefix = "sms")
|
public class SmsServiceConfig {
|
|
private static final Logger logger = Logger.getLogger(SmsServiceConfig.class);
|
|
@Autowired
|
private Ali ali;
|
@Autowired
|
private Jh jh;
|
|
//开关
|
private boolean enable;
|
//激活
|
private String active;
|
//每日限制条数
|
private Integer limit;
|
|
private List<Supplier> suppliers;
|
|
private Supplier activeSupplier;
|
|
@PostConstruct
|
void initSupplier(){
|
this.suppliers = new ArrayList<>();
|
this.suppliers.add(ali);
|
this.suppliers.add(jh);
|
Optional<Supplier> first = this.suppliers.stream().filter(item -> item.getName().equals(this.active)).findFirst();
|
if (first.isPresent()) {
|
this.activeSupplier = first.get();
|
logger.info("初始化短信配置成功");
|
}else{
|
logger.error("初始化短信配置失败");
|
}
|
}
|
|
|
public boolean isEnable() {
|
return enable;
|
}
|
|
public void setEnable(boolean enable) {
|
this.enable = enable;
|
}
|
|
public List<Supplier> getSuppliers() {
|
return suppliers;
|
}
|
|
public void setSuppliers(List<Supplier> suppliers) {
|
this.suppliers = suppliers;
|
}
|
|
public String getActive() {
|
return active;
|
}
|
|
public Supplier getActiveSupplier() {
|
return activeSupplier;
|
}
|
|
public void setActiveSupplier(Supplier activeSupplier) {
|
this.activeSupplier = activeSupplier;
|
}
|
|
public void setActive(String active) {
|
this.active = active;
|
}
|
|
public Integer getLimit() {
|
return limit;
|
}
|
|
public void setLimit(Integer limit) {
|
this.limit = limit;
|
}
|
}
|