...
|
...
|
@@ -8,6 +8,7 @@ import com.monitor.model.response.BaseResponse; |
|
|
import com.monitor.model.response.PageResponse;
|
|
|
import com.monitor.mysql.mapper.SMSLogsMapper;
|
|
|
import com.monitor.other.sms.service.SmsLogService;
|
|
|
import org.apache.zookeeper.data.Stat;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -31,6 +32,7 @@ public class SmsLogServiceImpl implements SmsLogService { |
|
|
|
|
|
private String ZK_PATH = "/yh/config/";
|
|
|
private String smsSendSwitch="ops.sendsms.open";
|
|
|
private String smsSendVoiceSwitch="ops.sendvoicesms.open";
|
|
|
|
|
|
public BaseResponse setSmsTurnOnOff(String key){
|
|
|
BaseResponse res=null;
|
...
|
...
|
@@ -39,8 +41,13 @@ public class SmsLogServiceImpl implements SmsLogService { |
|
|
if("off".equals(key)){
|
|
|
value="false";
|
|
|
}
|
|
|
zkClient.getCuratorFramework().setData().forPath(ZK_PATH + smsSendSwitch,"false".getBytes("UTF-8"));
|
|
|
res= new BaseResponse(200,"ok");
|
|
|
Stat stat=zkClient.getCuratorFramework().checkExists().forPath(ZK_PATH + smsSendSwitch);
|
|
|
// Stat 就是对zonde所有属性的一个映射, stat=null表示节点不存在!
|
|
|
if(stat==null){
|
|
|
zkClient.getCuratorFramework().create().forPath(ZK_PATH + smsSendSwitch);
|
|
|
}
|
|
|
zkClient.getCuratorFramework().setData().forPath(ZK_PATH + smsSendSwitch,value.getBytes("UTF-8"));
|
|
|
res= new BaseResponse(200,"sms send is "+value);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("set ZK_PATH smsSendSwitch error",e);
|
|
|
res=new BaseResponse("set zk data error");
|
...
|
...
|
@@ -48,6 +55,27 @@ public class SmsLogServiceImpl implements SmsLogService { |
|
|
return res;
|
|
|
}
|
|
|
|
|
|
public BaseResponse setVoiceSmsTurnOnOff(String key){
|
|
|
BaseResponse res=null;
|
|
|
try{
|
|
|
String value="true";
|
|
|
if("off".equals(key)){
|
|
|
value="false";
|
|
|
}
|
|
|
Stat stat=zkClient.getCuratorFramework().checkExists().forPath(ZK_PATH + smsSendVoiceSwitch);
|
|
|
// Stat 就是对zonde所有属性的一个映射, stat=null表示节点不存在!
|
|
|
if(stat==null){
|
|
|
zkClient.getCuratorFramework().create().forPath(ZK_PATH + smsSendVoiceSwitch);
|
|
|
}
|
|
|
zkClient.getCuratorFramework().setData().forPath(ZK_PATH + smsSendVoiceSwitch,value.getBytes("UTF-8"));
|
|
|
res= new BaseResponse(200,"sms voice send is "+value);
|
|
|
} catch (Exception e) {
|
|
|
logger.error("set ZK_PATH smsVoiceSendSwitch error",e);
|
|
|
res=new BaseResponse("set zk data error");
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
public PageResponse<SMSLogs> getSmsLogs(PageRequest req){
|
|
|
// 组装分页对象
|
|
|
PageBean page = PageBean.initPageInfo(req.getCurrentPage(),
|
...
|
...
|
|