add black list feign client
This commit is contained in:
parent
7acd522b41
commit
84820f449e
12
cms/pom.xml
12
cms/pom.xml
@ -83,16 +83,8 @@
|
||||
<artifactId>yo-fsesl-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-httpclient</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-jackson</artifactId>
|
||||
<groupId>com.pudonghot.yo</groupId>
|
||||
<artifactId>yo-citic-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -22,9 +22,9 @@ import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.wacai.tigon.service.support.BaseCrudServiceSupport;
|
||||
import com.pudonghot.yo.cms.service.CallingListPreparedService;
|
||||
import com.pudonghot.yo.cms.feign.service.FeignCallingListService;
|
||||
import com.pudonghot.yo.model.dbobject.CallingListPreparedSummary;
|
||||
import static com.pudonghot.yo.model.domain.Campaign.TargetType.QUEUE;
|
||||
import com.pudonghot.yo.citic.feign.service.FeignCiticCallingListService;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
@ -39,7 +39,7 @@ public class CallingListPreparedServiceImpl
|
||||
implements CallingListPreparedService {
|
||||
|
||||
@Autowired
|
||||
private FeignCallingListService callingListService;
|
||||
private FeignCiticCallingListService callingListService;
|
||||
@Value("${yo.campaign.calling-list.fetch-size:24}")
|
||||
private int fetchSize;
|
||||
@Autowired
|
||||
|
@ -48,6 +48,13 @@ yo:
|
||||
feign:
|
||||
base-url: http://stsl.wldmz.cc/stsl-web-partner/call-data/taskdata
|
||||
channel: dx-hzqw
|
||||
citic:
|
||||
feign:
|
||||
base-url: http://stsl.wldmz.cc/stsl-web-partner
|
||||
calling-list: /call-data/taskdata/dx-hzqw
|
||||
black-list: /resource/black-list/verify
|
||||
black-list-batch: /resource/black-list/batch-verify
|
||||
|
||||
# CAS
|
||||
tigon:
|
||||
shiro:
|
||||
|
@ -82,6 +82,11 @@
|
||||
<artifactId>yo-fsesl</artifactId>
|
||||
<version>${yo.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pudonghot.yo</groupId>
|
||||
<artifactId>yo-citic-client</artifactId>
|
||||
<version>${yo.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pudonghot.yo</groupId>
|
||||
<artifactId>yo-fsagent-api</artifactId>
|
||||
|
1
lib/citic-client/README.md
Normal file
1
lib/citic-client/README.md
Normal file
@ -0,0 +1 @@
|
||||
# CITIC Client
|
73
lib/citic-client/pom.xml
Normal file
73
lib/citic-client/pom.xml
Normal file
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>yo-citic-client</artifactId>
|
||||
<name>Yo CITIC Client</name>
|
||||
<description>Yo CITIC Client</description>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.pudonghot.yo</groupId>
|
||||
<artifactId>yo-library</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-httpclient</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-jackson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Test Dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,13 @@
|
||||
package com.pudonghot.yo.citic.feign.config;
|
||||
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import com.pudonghot.yo.citic.feign.service.FeignCiticCallingListService;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
* @date Jun 23, 2021 00:10:22
|
||||
*/
|
||||
@EnableFeignClients(basePackageClasses = FeignCiticCallingListService.class)
|
||||
public class FeignCiticConfiguration {
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.pudonghot.yo.cms.feign.config;
|
||||
package com.pudonghot.yo.citic.feign.config;
|
||||
|
||||
import feign.Retryer;
|
||||
import feign.codec.Decoder;
|
||||
@ -24,7 +24,7 @@ public class FeignClientConfiguration {
|
||||
|
||||
@Bean
|
||||
public RequestInterceptor requestInterceptor() {
|
||||
return reqTpl -> reqTpl.header("x-service-agent", "QINWEI");
|
||||
return reqTpl -> reqTpl.header("x-serv-agent", "QINWEI");
|
||||
}
|
||||
|
||||
@Bean
|
@ -0,0 +1,18 @@
|
||||
package com.pudonghot.yo.citic.feign.request;
|
||||
|
||||
import lombok.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
* @date Jun 23, 2021 00:23:21
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CiticBlackListVerifyFeignReq {
|
||||
@NotBlank
|
||||
private String called;
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.pudonghot.yo.citic.feign.response;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
* @date Jun 23, 2021 00:15:23
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class CiticBlackListBatchVerifyFeignResp {
|
||||
@JsonAlias("retcode")
|
||||
private String code;
|
||||
@JsonAlias("message")
|
||||
private String error;
|
||||
|
||||
private BlackListFeignResp[] data;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public static class BlackListFeignResp {
|
||||
@JsonAlias("inBlackList")
|
||||
private Boolean blacklist;
|
||||
private String phone;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.pudonghot.yo.citic.feign.response;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
* @date Jun 23, 2021 00:15:23
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class CiticBlackListVerifyFeignResp {
|
||||
@JsonAlias("retcode")
|
||||
private String code;
|
||||
@JsonAlias("message")
|
||||
private String error;
|
||||
@JsonAlias("data")
|
||||
private Boolean blacklist;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.pudonghot.yo.cms.feign.response;
|
||||
package com.pudonghot.yo.citic.feign.response;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class RespCallingList {
|
||||
public class CiticCallingListFeignResp {
|
||||
@JsonAlias("retcode")
|
||||
private String code;
|
||||
@JsonAlias("message")
|
@ -0,0 +1,59 @@
|
||||
package com.pudonghot.yo.citic.feign.service;
|
||||
|
||||
import java.util.List;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import com.pudonghot.yo.citic.feign.config.FeignClientConfiguration;
|
||||
import com.pudonghot.yo.citic.feign.request.CiticBlackListVerifyFeignReq;
|
||||
import com.pudonghot.yo.citic.feign.response.CiticBlackListVerifyFeignResp;
|
||||
import com.pudonghot.yo.citic.feign.response.CiticBlackListBatchVerifyFeignResp;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
* @date Jan 07, 2020 14:36:47
|
||||
*/
|
||||
@Validated
|
||||
@FeignClient(url = "${yo.citic.feign.base-url}",
|
||||
name = "FeignCiticBlackList",
|
||||
configuration = FeignClientConfiguration.class)
|
||||
public interface FeignCiticBlackListService {
|
||||
|
||||
/**
|
||||
* batch verify black list
|
||||
*
|
||||
* @param phones phones
|
||||
* @return black list
|
||||
*/
|
||||
@PostMapping("${yo.citic.feign.path.black-list-batch-verify:/resource/black-list/batch-verify}")
|
||||
CiticBlackListBatchVerifyFeignResp batchVerify(
|
||||
@RequestBody
|
||||
@NotEmpty List<String> phones);
|
||||
|
||||
/**
|
||||
* verify black list
|
||||
*
|
||||
* @param req
|
||||
* @return black list
|
||||
*/
|
||||
@PostMapping("${yo.citic.feign.path.black-list-verify:/resource/black-list/verify}")
|
||||
CiticBlackListVerifyFeignResp verify(
|
||||
@Valid
|
||||
@RequestBody
|
||||
@NotNull CiticBlackListVerifyFeignReq req);
|
||||
|
||||
/**
|
||||
* verify black list
|
||||
*
|
||||
* @param phone phone
|
||||
* @return result
|
||||
*/
|
||||
default boolean isBlack(@NotBlank final String phone) {
|
||||
return Boolean.TRUE.equals(verify(new CiticBlackListVerifyFeignReq(phone)).getBlacklist());
|
||||
}
|
||||
}
|
@ -1,19 +1,19 @@
|
||||
package com.pudonghot.yo.cms.feign.service;
|
||||
package com.pudonghot.yo.citic.feign.service;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import com.pudonghot.yo.cms.feign.response.RespCallingList;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import com.pudonghot.yo.cms.feign.config.FeignClientConfiguration;
|
||||
import com.pudonghot.yo.citic.feign.config.FeignClientConfiguration;
|
||||
import com.pudonghot.yo.citic.feign.response.CiticCallingListFeignResp;
|
||||
|
||||
/**
|
||||
* @author Donghuang
|
||||
* @date Jan 07, 2020 14:36:47
|
||||
*/
|
||||
@FeignClient(url = "${yo.campaign.calling-list.feign.base-url}",
|
||||
name = "CallingListFeign",
|
||||
@FeignClient(url = "${yo.citic.feign.base-url}",
|
||||
name = "FeignCiticCallingList",
|
||||
configuration = FeignClientConfiguration.class)
|
||||
public interface FeignCallingListService {
|
||||
public interface FeignCiticCallingListService {
|
||||
|
||||
/**
|
||||
* fetch calling list
|
||||
@ -23,8 +23,8 @@ public interface FeignCallingListService {
|
||||
* @param campaignName campaign name
|
||||
* @return calling list
|
||||
*/
|
||||
@RequestMapping("/${yo.campaign.calling-list.feign.channel}")
|
||||
RespCallingList fetchCallingList(
|
||||
@RequestMapping("/${yo.citic.feign.path.calling-list:/call-data/taskdata/dx-hzqw}")
|
||||
CiticCallingListFeignResp fetchCallingList(
|
||||
@RequestParam("datanum")
|
||||
int numData,
|
||||
@RequestParam("taskid")
|
0
lib/citic-client/src/main/resources/.gitkeep
Normal file
0
lib/citic-client/src/main/resources/.gitkeep
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean class="com.pudonghot.yo.citic.feign.config.FeignCiticConfiguration" />
|
||||
</beans>
|
@ -0,0 +1,16 @@
|
||||
package com.pudonghot.yo.citic.feign;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
/**
|
||||
* @author Donghuang <br>
|
||||
* Aug 21, 2017 16:14
|
||||
*/
|
||||
@Slf4j
|
||||
@SpringBootApplication
|
||||
@ImportResource("classpath*:spring/spring-*.xml")
|
||||
public class TestDriver {
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.pudonghot.yo.citic.feign.service;
|
||||
|
||||
import lombok.val;
|
||||
import org.junit.Test;
|
||||
import java.util.Arrays;
|
||||
import org.junit.runner.RunWith;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.pudonghot.yo.citic.feign.TestDriver;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author Donghuang <br>
|
||||
* Nov 28, 2017 11:01
|
||||
*/
|
||||
@Slf4j
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = TestDriver.class)
|
||||
public class FeignClientTest {
|
||||
|
||||
@Autowired
|
||||
private FeignCiticBlackListService blackListService;
|
||||
@Autowired
|
||||
private FeignCiticCallingListService callingListService;
|
||||
|
||||
@Test
|
||||
public void testBatchVerify() {
|
||||
val resp = blackListService.batchVerify(Arrays.asList("15656232312", "13764268788"));
|
||||
log.info("Resp: [{}]", resp);
|
||||
log.info("Black: [{}]", blackListService.isBlack("15656232312"));
|
||||
log.info("Black: [{}]", blackListService.isBlack("13764268788"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCallingList() {
|
||||
val resp = callingListService.fetchCallingList(100, "5959", "XXX");
|
||||
log.info("Resp: [{}]", resp);
|
||||
}
|
||||
}
|
0
lib/citic-client/src/test/resources/.gitkeep
Normal file
0
lib/citic-client/src/test/resources/.gitkeep
Normal file
13
lib/citic-client/src/test/resources/application.yml
Normal file
13
lib/citic-client/src/test/resources/application.yml
Normal file
@ -0,0 +1,13 @@
|
||||
spring:
|
||||
application:
|
||||
name: yo-citic-client
|
||||
|
||||
yo:
|
||||
citic:
|
||||
feign:
|
||||
# base-url: http://stsl.wldmz.cc/stsl-web-partner
|
||||
base-url: http://e.test.bank.ecitic.com/citiccard/stsl-web-partner
|
||||
path:
|
||||
calling-list: /call-data/taskdata/dx-hzqw
|
||||
black-list-verify: /resource/black-list/verify
|
||||
black-list-batch-verify: /resource/black-list/batch-verify
|
33
lib/citic-client/src/test/resources/log4j2.xml
Normal file
33
lib/citic-client/src/test/resources/log4j2.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Properties>
|
||||
<Property name="log.level">DEBUG</Property>
|
||||
<Property name="log.dir">.logs</Property>
|
||||
<Property name="pattern">%-d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%t][%c{1}] %m%n</Property>
|
||||
</Properties>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%highlight{%-d{yyyy-MM-dd HH:mm:ss,SSS}}{FATAL=magenta, ERROR=magenta, WARN=magenta, INFO=magenta, DEBUG=magenta, TRACE=magenta} %highlight{%-5p}{FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=black, DEBUG=green bold, TRACE=blue} [%t][%highlight{%c{1.}}{FATAL=cyan, ERROR=cyan, WARN=cyan, INFO=cyan, DEBUG=cyan, TRACE=cyan}] %m%n"/>
|
||||
</Console>
|
||||
<RollingFile name="File"
|
||||
fileName="${log.dir}/${project.artifactId}.log"
|
||||
filePattern="${log.dir}/$${date:yyyy-MM}/${project.artifactId}-%d{yyyy-MM-dd}-%i.log">
|
||||
<PatternLayout pattern="${pattern}" />
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<SizeBasedTriggeringPolicy size="16 MB" />
|
||||
</Policies>
|
||||
<DefaultRolloverStrategy max="32" />
|
||||
</RollingFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Logger name="org.springframework" level="${log.level}" additivity="false">
|
||||
<AppenderRef ref="File" />
|
||||
<AppenderRef ref="Console" level="${log.level}" />
|
||||
</Logger>
|
||||
<Root level="${log.level}" additivity="false">
|
||||
<AppenderRef ref="File" level="${log.level}" />
|
||||
<AppenderRef ref="Console" level="${log.level}" />
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<bean class="com.fasterxml.jackson.databind.ObjectMapper" />
|
||||
</beans>
|
@ -37,6 +37,7 @@
|
||||
<module>mybatis-cache</module>
|
||||
<module>shiro-cache</module>
|
||||
<module>http-client</module>
|
||||
<module>citic-client</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
|
Loading…
x
Reference in New Issue
Block a user