Commit 11d1c127 authored by jinliang's avatar jinliang

add proxy structure to globalfield collection

parent feb1eb61
...@@ -44,6 +44,19 @@ public class GlobalFieldController { ...@@ -44,6 +44,19 @@ public class GlobalFieldController {
} }
} }
@GetMapping("/proxy")
public ResultDto queryProxy() {
String logs = "【queryProxy】 ";
try {
return ResponseUtil.success(globalFieldService.queryProxy());
} catch (ClientRequestException e) {
log.warn("{}, ClientRequestException : {}", logs, e.getErrorCode().getReason());
return ResponseUtil.error(e.getErrorCode());
} catch (Exception e) {
log.error("{}, Exception : {}", logs, e.getMessage(), e);
return ResponseUtil.error(e.getMessage());
}
}
/** /**
* 查询公告 * 查询公告
*/ */
......
...@@ -42,4 +42,14 @@ public class GlobalField { ...@@ -42,4 +42,14 @@ public class GlobalField {
* 目前是 0.30 * 目前是 0.30
*/ */
private BigDecimal distributorRate; private BigDecimal distributorRate;
private Proxy proxy;
public Proxy getProxy() {
return proxy;
}
public void setProxy(Proxy proxy) {
this.proxy = proxy;
}
} }
package com.edgec.browserbackend.browser.domain;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.mongodb.core.mapping.Document;
@Getter
@Setter
@Document("Proxy")
public class Proxy {
private String ip;
private String port;
private String username;
private String password;
}
\ No newline at end of file
package com.edgec.browserbackend.browser.service; package com.edgec.browserbackend.browser.service;
import com.edgec.browserbackend.browser.domain.Proxy;
/** /**
* @author xuxin * @author xuxin
...@@ -8,4 +9,6 @@ package com.edgec.browserbackend.browser.service; ...@@ -8,4 +9,6 @@ package com.edgec.browserbackend.browser.service;
public interface GlobalFieldService { public interface GlobalFieldService {
String querySpecialLineState(); String querySpecialLineState();
Proxy queryProxy();
} }
...@@ -4,6 +4,7 @@ import com.edgec.browserbackend.browser.repository.GlobalFieldRepository; ...@@ -4,6 +4,7 @@ import com.edgec.browserbackend.browser.repository.GlobalFieldRepository;
import com.edgec.browserbackend.browser.service.GlobalFieldService; import com.edgec.browserbackend.browser.service.GlobalFieldService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.edgec.browserbackend.browser.domain.Proxy;
/** /**
* @author xuxin * @author xuxin
...@@ -24,4 +25,12 @@ public class GlobalFieldServiceImpl implements GlobalFieldService { ...@@ -24,4 +25,12 @@ public class GlobalFieldServiceImpl implements GlobalFieldService {
} }
return state; return state;
} }
@Override
public Proxy queryProxy() {
Proxy proxy = null;
if (!globalFieldRepository.findAll().isEmpty()) {
proxy = globalFieldRepository.findAll().get(0).getProxy();
}
return proxy;
}
} }
...@@ -35,7 +35,7 @@ public class SpecialLineCheckTask { ...@@ -35,7 +35,7 @@ public class SpecialLineCheckTask {
private GlobalFieldRepository globalFieldRepository; private GlobalFieldRepository globalFieldRepository;
@Scheduled(cron = "0 0/5 * * * ?") //@Scheduled(cron = "0 0/5 * * * ?")
public void healthCheck() { public void healthCheck() {
// 1. 随机获取符合条件的 20 个 ip // 1. 随机获取符合条件的 20 个 ip
List<IpResource> ipResourceList = ipResourceRepository.specialLineCheckTask(); List<IpResource> ipResourceList = ipResourceRepository.specialLineCheckTask();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment