80 changed files with 0 additions and 5007 deletions
@ -1,16 +0,0 @@ |
|||
<?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"> |
|||
<parent> |
|||
<artifactId>epmet-openapi-adv</artifactId> |
|||
<groupId>com.epmet</groupId> |
|||
<version>2.0.0</version> |
|||
<relativePath>../pom.xml</relativePath> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>epmet-openapi-adv-client</artifactId> |
|||
|
|||
|
|||
</project> |
@ -1,11 +0,0 @@ |
|||
FROM java:8 |
|||
|
|||
RUN export LANG="zh_CN.UTF-8" |
|||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime |
|||
RUN echo 'Asia/Shanghai' > /etc/timezone |
|||
|
|||
COPY ./target/*.jar ./epmet-openapi-adv.jar |
|||
|
|||
EXPOSE 8115 |
|||
|
|||
ENTRYPOINT ["sh", "-c", "exec $RUN_INSTRUCT"] |
@ -1,18 +0,0 @@ |
|||
version: "3.7" |
|||
services: |
|||
epmet-openapi-adv-server: |
|||
container_name: epmet-openapi-adv-server-dev |
|||
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-openapi-adv-server:version_placeholder |
|||
ports: |
|||
- "8015:8015" |
|||
network_mode: host # 不会创建新的网络 |
|||
volumes: |
|||
- "/opt/epmet-cloud-logs/dev:/logs" |
|||
environment: |
|||
RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./epmet-openapi-adv.jar" |
|||
restart: "unless-stopped" |
|||
deploy: |
|||
resources: |
|||
limits: |
|||
cpus: '0.1' |
|||
memory: 300M |
@ -1,18 +0,0 @@ |
|||
version: "3.7" |
|||
services: |
|||
epmet-openapi-adv-server: |
|||
container_name: epmet-openapi-adv-server-prod |
|||
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-openapi-adv-server:0.3.3 |
|||
ports: |
|||
- "8015:8015" |
|||
network_mode: host # 不会创建新的网络 |
|||
volumes: |
|||
- "/opt/epmet-cloud-logs/prod:/logs" |
|||
environment: |
|||
RUN_INSTRUCT: "java -Xms256m -Xmx512m -jar ./epmet-openapi-adv.jar" |
|||
restart: "unless-stopped" |
|||
deploy: |
|||
resources: |
|||
limits: |
|||
cpus: '0.1' |
|||
memory: 600M |
@ -1,18 +0,0 @@ |
|||
version: "3.7" |
|||
services: |
|||
epmet-openapi-adv-server: |
|||
container_name: epmet-openapi-adv-server-test |
|||
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-openapi-adv-server:version_placeholder |
|||
ports: |
|||
- "8015:8015" |
|||
network_mode: host # 不会创建新的网络 |
|||
volumes: |
|||
- "/opt/epmet-cloud-logs/test:/logs" |
|||
environment: |
|||
RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./epmet-openapi-adv.jar" |
|||
restart: "unless-stopped" |
|||
deploy: |
|||
resources: |
|||
limits: |
|||
cpus: '0.1' |
|||
memory: 300M |
@ -1,227 +0,0 @@ |
|||
<?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"> |
|||
|
|||
<version>0.3.3</version> |
|||
<parent> |
|||
<artifactId>epmet-openapi-adv</artifactId> |
|||
<groupId>com.epmet</groupId> |
|||
<version>2.0.0</version> |
|||
<relativePath>../pom.xml</relativePath> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>epmet-openapi-adv-server</artifactId> |
|||
|
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>epmet-commons-mybatis</artifactId> |
|||
<version>2.0.0</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-web</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework</groupId> |
|||
<artifactId>spring-context-support</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-actuator</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.alibaba.cloud</groupId> |
|||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.alibaba.cloud</groupId> |
|||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
|||
</dependency> |
|||
<!-- 替换Feign原生httpclient --> |
|||
<dependency> |
|||
<groupId>io.github.openfeign</groupId> |
|||
<artifactId>feign-httpclient</artifactId> |
|||
<version>10.3.0</version> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
<build> |
|||
<finalName>${project.artifactId}</finalName> |
|||
<plugins> |
|||
<plugin> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-maven-plugin</artifactId> |
|||
</plugin> |
|||
<plugin> |
|||
<groupId>org.apache.maven.plugins</groupId> |
|||
<artifactId>maven-surefire-plugin</artifactId> |
|||
<configuration> |
|||
<skipTests>true</skipTests> |
|||
</configuration> |
|||
</plugin> |
|||
</plugins> |
|||
|
|||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory> |
|||
<resources> |
|||
<resource> |
|||
<filtering>true</filtering> |
|||
<directory>${basedir}/src/main/resources</directory> |
|||
</resource> |
|||
</resources> |
|||
</build> |
|||
|
|||
<profiles> |
|||
<profile> |
|||
<id>dev</id> |
|||
<properties> |
|||
<server.port>8115</server.port> |
|||
<spring.profiles.active>dev</spring.profiles.active> |
|||
|
|||
<!-- 数据库配置--> |
|||
<spring.datasource.druid.url> |
|||
<![CDATA[jdbc:mysql://192.168.1.130:3306/epmet_adv?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]> |
|||
</spring.datasource.druid.url> |
|||
<spring.datasource.druid.username>epmet_adv_user</spring.datasource.druid.username> |
|||
<spring.datasource.druid.password>EpmEt-db-UsEr</spring.datasource.druid.password> |
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>192.168.1.130</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>123456</spring.redis.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>192.168.1.130:8848</nacos.server-addr> |
|||
<nacos.discovery.namespace>6ceab336-d004-4acf-89c6-e121d06f4988</nacos.discovery.namespace> |
|||
<nacos.config.namespace></nacos.config.namespace> |
|||
<nacos.config.group></nacos.config.group> |
|||
<nacos.config-enabled>false</nacos.config-enabled> |
|||
<nacos.ip/> |
|||
|
|||
<spring.flyway.enabled>false</spring.flyway.enabled> |
|||
<!--钉钉 机器人地址--> |
|||
<dingTalk.robot.webHook> |
|||
https://oapi.dingtalk.com/robot/send?access_token=90782b119f82a5b6bb8e0f819b6a77bbc2102b53aa2d7d2e24fa10b66d580b1c |
|||
</dingTalk.robot.webHook> |
|||
<dingTalk.robot.secret>SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19 |
|||
</dingTalk.robot.secret> |
|||
</properties> |
|||
</profile> |
|||
<profile> |
|||
<id>local</id> |
|||
<activation> |
|||
<activeByDefault>true</activeByDefault> |
|||
</activation> |
|||
<properties> |
|||
<server.port>8115</server.port> |
|||
<spring.profiles.active>local</spring.profiles.active> |
|||
|
|||
<!-- 数据库配置--> |
|||
<spring.datasource.druid.url> |
|||
<![CDATA[jdbc:mysql://118.190.150.119:47306/epmet_adv?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]> |
|||
</spring.datasource.druid.url> |
|||
<spring.datasource.druid.username>epmet_adv_user</spring.datasource.druid.username> |
|||
<spring.datasource.druid.password>EpmEt-db-UsEr</spring.datasource.druid.password> |
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>118.190.150.119</spring.redis.host> |
|||
<spring.redis.port>47379</spring.redis.port> |
|||
<spring.redis.password>123456</spring.redis.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>false</nacos.register-enabled> |
|||
<nacos.server-addr>192.168.1.130:8848</nacos.server-addr> |
|||
<nacos.discovery.namespace>6ceab336-d004-4acf-89c6-e121d06f4988</nacos.discovery.namespace> |
|||
<nacos.config.namespace></nacos.config.namespace> |
|||
<nacos.config.group></nacos.config.group> |
|||
<nacos.config-enabled>false</nacos.config-enabled> |
|||
<nacos.ip/> |
|||
|
|||
<spring.flyway.enabled>false</spring.flyway.enabled> |
|||
<!--钉钉 机器人地址--> |
|||
<dingTalk.robot.webHook> |
|||
https://oapi.dingtalk.com/robot/send?access_token=90782b119f82a5b6bb8e0f819b6a77bbc2102b53aa2d7d2e24fa10b66d580b1c |
|||
</dingTalk.robot.webHook> |
|||
<dingTalk.robot.secret>SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19 |
|||
</dingTalk.robot.secret> |
|||
<openapi.scan.server.url>https://epmet-dev.elinkservice.cn/api/epmetscan/api</openapi.scan.server.url> |
|||
</properties> |
|||
</profile> |
|||
<profile> |
|||
<id>test</id> |
|||
<!-- <activation> |
|||
<activeByDefault>true</activeByDefault> |
|||
</activation>--> |
|||
<properties> |
|||
<server.port>8115</server.port> |
|||
<spring.profiles.active>test</spring.profiles.active> |
|||
|
|||
<!-- 数据库配置--> |
|||
<spring.datasource.druid.url> |
|||
<![CDATA[jdbc:mysql://rm-m5ef9t617j6o5eup7.mysql.rds.aliyuncs.com:3306/epmet_adv?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]> |
|||
</spring.datasource.druid.url> |
|||
<spring.datasource.druid.username>epmet</spring.datasource.druid.username> |
|||
<spring.datasource.druid.password>elink@833066</spring.datasource.druid.password> |
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>EpmEtrEdIs!q@w</spring.redis.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>192.168.10.150:8848</nacos.server-addr> |
|||
<nacos.discovery.namespace>67e3c350-533e-4d7c-9f8f-faf1b4aa82ae</nacos.discovery.namespace> |
|||
<nacos.config.namespace></nacos.config.namespace> |
|||
<nacos.config.group></nacos.config.group> |
|||
<nacos.config-enabled>false</nacos.config-enabled> |
|||
<nacos.ip/> |
|||
|
|||
<spring.flyway.enabled>true</spring.flyway.enabled> |
|||
<!--测试钉钉 机器人地址--> |
|||
<dingTalk.robot.webHook> |
|||
https://oapi.dingtalk.com/robot/send?access_token=90782b119f82a5b6bb8e0f819b6a77bbc2102b53aa2d7d2e24fa10b66d580b1c |
|||
</dingTalk.robot.webHook> |
|||
<dingTalk.robot.secret>SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19 |
|||
</dingTalk.robot.secret> |
|||
</properties> |
|||
</profile> |
|||
<profile> |
|||
<id>prod</id> |
|||
<properties> |
|||
<server.port>8115</server.port> |
|||
<spring.profiles.active>prod</spring.profiles.active> |
|||
|
|||
<!-- 数据库配置--> |
|||
<spring.datasource.druid.url> |
|||
<![CDATA[jdbc:mysql://rm-m5e3vzs2637224wj9.mysql.rds.aliyuncs.com:3306/epmet_adv?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]> |
|||
</spring.datasource.druid.url> |
|||
<spring.datasource.druid.username>epmet_adv_user</spring.datasource.druid.username> |
|||
<spring.datasource.druid.password>EpmEt-db-UsEr</spring.datasource.druid.password> |
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>r-m5ez3n1j0qc3ykq2ut.redis.rds.aliyuncs.com</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>EpmEtclOUdrEdIs!Q2w</spring.redis.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>192.168.11.180:8848</nacos.server-addr> |
|||
<nacos.discovery.namespace>bd205d23-e696-47be-b995-916313f86e99</nacos.discovery.namespace> |
|||
<nacos.config.namespace></nacos.config.namespace> |
|||
<nacos.config.group></nacos.config.group> |
|||
<nacos.config-enabled>false</nacos.config-enabled> |
|||
<nacos.ip/> |
|||
|
|||
<spring.flyway.enabled>true</spring.flyway.enabled> |
|||
|
|||
<!--生产钉钉 机器人地址--> |
|||
<dingTalk.robot.webHook> |
|||
https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c |
|||
</dingTalk.robot.webHook> |
|||
<dingTalk.robot.secret>SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1 |
|||
</dingTalk.robot.secret> |
|||
</properties> |
|||
</profile> |
|||
</profiles> |
|||
|
|||
</project> |
@ -1,15 +0,0 @@ |
|||
package com.epmet; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
|||
import org.springframework.cloud.openfeign.EnableFeignClients; |
|||
|
|||
@SpringBootApplication |
|||
@EnableDiscoveryClient |
|||
@EnableFeignClients |
|||
public class AdvApplication { |
|||
public static void main(String[] args) { |
|||
SpringApplication.run(AdvApplication.class, args); |
|||
} |
|||
} |
@ -1,40 +0,0 @@ |
|||
package com.epmet.adv.aspect; |
|||
|
|||
import com.epmet.commons.tools.aspect.BaseRequestLogAspect; |
|||
import org.aspectj.lang.ProceedingJoinPoint; |
|||
import org.aspectj.lang.annotation.Around; |
|||
import org.aspectj.lang.annotation.Aspect; |
|||
import org.springframework.core.annotation.Order; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.web.context.request.RequestAttributes; |
|||
import org.springframework.web.context.request.RequestContextHolder; |
|||
import org.springframework.web.context.request.ServletRequestAttributes; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
|
|||
/** |
|||
* 日志/异常处理切面实现,调用父类方法完成日志记录和异常处理。 |
|||
*/ |
|||
@Aspect |
|||
@Component |
|||
@Order(0) |
|||
public class RequestLogAspect extends BaseRequestLogAspect { |
|||
|
|||
@Override |
|||
@Around(value = "execution(* com.epmet.adv.controller.*Controller*.*(..)) ") |
|||
public Object proceed(ProceedingJoinPoint point) throws Throwable { |
|||
return super.proceed(point, getRequest()); |
|||
} |
|||
|
|||
/** |
|||
* 获取Request对象 |
|||
* |
|||
* @return |
|||
*/ |
|||
private HttpServletRequest getRequest() { |
|||
RequestAttributes ra = RequestContextHolder.getRequestAttributes(); |
|||
ServletRequestAttributes sra = (ServletRequestAttributes) ra; |
|||
return sra.getRequest(); |
|||
} |
|||
|
|||
} |
@ -1,26 +0,0 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.epmet.adv.config; |
|||
|
|||
import com.epmet.commons.tools.config.ModuleConfig; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* 模块配置信息 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Service |
|||
public class ModuleConfigImpl implements ModuleConfig { |
|||
@Override |
|||
public String getName() { |
|||
return "adv"; |
|||
} |
|||
} |
@ -1,28 +0,0 @@ |
|||
package com.epmet.adv.controller; |
|||
|
|||
import com.epmet.adv.entity.AdvVedioEntity; |
|||
import com.epmet.adv.service.AdvVedioService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Controller; |
|||
import org.springframework.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.io.IOException; |
|||
|
|||
@Controller |
|||
@RequestMapping("video") |
|||
public class AdvVideoController { |
|||
|
|||
@Autowired |
|||
private AdvVedioService advVedioService; |
|||
|
|||
@GetMapping("company-adv") |
|||
public String toVedio() throws IOException { |
|||
AdvVedioEntity enableAdvVedioEntity = advVedioService.getEnableAdvVedioEntity(); |
|||
String redirectUrl = enableAdvVedioEntity != null ? enableAdvVedioEntity.getPath() : "404"; |
|||
return String.format("redirect:%s", redirectUrl); |
|||
//response.sendRedirect("www.baidu.com");
|
|||
} |
|||
|
|||
} |
@ -1,33 +0,0 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.adv.dao; |
|||
|
|||
import com.epmet.adv.entity.AdvVedioEntity; |
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
/** |
|||
* 宣传视频 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2020-12-30 |
|||
*/ |
|||
@Mapper |
|||
public interface AdvVedioDao extends BaseDao<AdvVedioEntity> { |
|||
AdvVedioEntity getEnableAdvVedioEntity(); |
|||
} |
@ -1,56 +0,0 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.adv.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
|
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 宣传视频 |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2020-12-30 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("adv_vedio") |
|||
public class AdvVedioEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 存储路径 |
|||
*/ |
|||
private String path; |
|||
|
|||
/** |
|||
* 存储类型。aliyun_oss,local |
|||
*/ |
|||
private String storeType; |
|||
|
|||
/** |
|||
* 是否启用 |
|||
*/ |
|||
private Integer enable; |
|||
|
|||
} |
@ -1,7 +0,0 @@ |
|||
package com.epmet.adv.service; |
|||
|
|||
import com.epmet.adv.entity.AdvVedioEntity; |
|||
|
|||
public interface AdvVedioService { |
|||
AdvVedioEntity getEnableAdvVedioEntity(); |
|||
} |
@ -1,18 +0,0 @@ |
|||
package com.epmet.adv.service.impl; |
|||
|
|||
import com.epmet.adv.dao.AdvVedioDao; |
|||
import com.epmet.adv.entity.AdvVedioEntity; |
|||
import com.epmet.adv.service.AdvVedioService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class AdvVedioServiceImpl implements AdvVedioService { |
|||
@Autowired |
|||
private AdvVedioDao advVedioDao; |
|||
|
|||
public AdvVedioEntity getEnableAdvVedioEntity() { |
|||
return advVedioDao.getEnableAdvVedioEntity(); |
|||
} |
|||
|
|||
} |
@ -1,140 +0,0 @@ |
|||
server: |
|||
port: @server.port@ |
|||
version: @version@ |
|||
servlet: |
|||
context-path: /adv |
|||
|
|||
spring: |
|||
main: |
|||
allow-bean-definition-overriding: true |
|||
application: |
|||
name: epmet-openapi-adv-server |
|||
#环境 dev|test|prod |
|||
profiles: |
|||
active: @spring.profiles.active@ |
|||
messages: |
|||
encoding: UTF-8 |
|||
basename: i18n/messages_common |
|||
jackson: |
|||
time-zone: GMT+8 |
|||
date-format: yyyy-MM-dd HH:mm:ss |
|||
redis: |
|||
database: @spring.redis.index@ |
|||
host: @spring.redis.host@ |
|||
port: @spring.redis.port@ |
|||
password: @spring.redis.password@ |
|||
timeout: 30s |
|||
datasource: |
|||
druid: |
|||
#MySQL |
|||
driver-class-name: com.mysql.cj.jdbc.Driver |
|||
url: @spring.datasource.druid.url@ |
|||
username: @spring.datasource.druid.username@ |
|||
password: @spring.datasource.druid.password@ |
|||
initial-size: 10 |
|||
max-active: 100 |
|||
min-idle: 10 |
|||
max-wait: 60000 |
|||
pool-prepared-statements: true |
|||
max-pool-prepared-statement-per-connection-size: 20 |
|||
time-between-eviction-runs-millis: 60000 |
|||
min-evictable-idle-time-millis: 300000 |
|||
#Oracle需要打开注释 |
|||
#validation-query: SELECT 1 FROM DUAL |
|||
test-while-idle: true |
|||
test-on-borrow: false |
|||
test-on-return: false |
|||
filter: |
|||
stat: |
|||
log-slow-sql: true |
|||
slow-sql-millis: 1000 |
|||
merge-sql: false |
|||
wall: |
|||
config: |
|||
multi-statement-allow: true |
|||
# 数据迁移工具flyway |
|||
flyway: |
|||
enabled: @spring.flyway.enabled@ |
|||
locations: classpath:db/migration |
|||
url: @spring.datasource.druid.url@ |
|||
user: @spring.datasource.druid.username@ |
|||
password: @spring.datasource.druid.password@ |
|||
baseline-on-migrate: true |
|||
baseline-version: 0 |
|||
cloud: |
|||
nacos: |
|||
discovery: |
|||
server-addr: @nacos.server-addr@ |
|||
#nacos的命名空间ID,默认是public |
|||
namespace: @nacos.discovery.namespace@ |
|||
#不把自己注册到注册中心的地址 |
|||
register-enabled: @nacos.register-enabled@ |
|||
ip: @nacos.ip@ |
|||
config: |
|||
enabled: @nacos.config-enabled@ |
|||
server-addr: @nacos.server-addr@ |
|||
namespace: @nacos.config.namespace@ |
|||
group: @nacos.config.group@ |
|||
file-extension: yaml |
|||
management: |
|||
endpoints: |
|||
web: |
|||
exposure: |
|||
include: "*" |
|||
endpoint: |
|||
health: |
|||
show-details: ALWAYS |
|||
|
|||
mybatis-plus: |
|||
mapper-locations: classpath:/mapper/**/*.xml |
|||
#实体扫描,多个package用逗号或者分号分隔 |
|||
typeAliasesPackage: com.epmet.entity |
|||
global-config: |
|||
#数据库相关配置 |
|||
db-config: |
|||
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; |
|||
id-type: ID_WORKER |
|||
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" |
|||
field-strategy: NOT_NULL |
|||
#驼峰下划线转换 |
|||
column-underline: true |
|||
banner: false |
|||
#原生配置 |
|||
configuration: |
|||
map-underscore-to-camel-case: true |
|||
cache-enabled: false |
|||
call-setters-on-nulls: true |
|||
jdbc-type-for-null: 'null' |
|||
|
|||
feign: |
|||
hystrix: |
|||
enabled: true |
|||
client: |
|||
config: |
|||
default: |
|||
loggerLevel: BASIC |
|||
okhttp: |
|||
enabled: true |
|||
|
|||
|
|||
hystrix: |
|||
command: |
|||
default: |
|||
execution: |
|||
isolation: |
|||
thread: |
|||
timeoutInMilliseconds: 60000 #缺省为1000 |
|||
|
|||
ribbon: |
|||
ReadTimeout: 300000 |
|||
ConnectTimeout: 300000 |
|||
|
|||
#pageHelper分页插件 |
|||
pagehelper: |
|||
helper-dialect: mysql |
|||
reasonable: false #分页合理化配置,例如输入页码为-1,则自动转化为最小页码1 |
|||
|
|||
dingTalk: |
|||
robot: |
|||
webHook: @dingTalk.robot.webHook@ |
|||
secret: @dingTalk.robot.secret@ |
@ -1,18 +0,0 @@ |
|||
-- create database epmet_adv default character set utf8mb4; |
|||
|
|||
-- CREATE USER epmet_adv_user@'%' IDENTIFIED BY 'EpmEt-db-UsEr'; |
|||
-- GRANT ALL ON `epmet_adv%`.* TO 'epmet_adv_user'@'%'; |
|||
-- flush privileges; |
|||
|
|||
CREATE TABLE `adv_vedio` ( |
|||
`ID` varchar(64) NOT NULL COMMENT 'id' primary key , |
|||
`PATH` varchar(255) NOT NULL COMMENT '存储路径', |
|||
`STORE_TYPE` varchar(30) NOT NULL COMMENT '存储类型。aliyun_oss,local', |
|||
`ENABLE` tinyint(1) NOT NULL COMMENT '是否启用', |
|||
`REVISION` int(11) DEFAULT NULL COMMENT '乐观锁', |
|||
`DEL_FLAG` int(11) unsigned DEFAULT NULL COMMENT '删除标识 0:未删除 1:删除', |
|||
`CREATED_BY` varchar(32) DEFAULT NULL COMMENT '创建者', |
|||
`CREATED_TIME` datetime DEFAULT NULL COMMENT '创建时间', |
|||
`UPDATED_BY` varchar(32) DEFAULT NULL COMMENT '更新者', |
|||
`UPDATED_TIME` datetime DEFAULT NULL COMMENT '更新时间' |
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='宣传视频' |
@ -1,169 +0,0 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<configuration> |
|||
<include resource="org/springframework/boot/logging/logback/base.xml"/> |
|||
|
|||
<property name="log.path" value="logs/adv"/> |
|||
|
|||
<springProperty scope="context" name="appname" source="spring.application.name"/> |
|||
<springProperty scope="context" name="webHook" source="dingTalk.robot.webHook"/> |
|||
<springProperty scope="context" name="secret" source="dingTalk.robot.secret"/> |
|||
|
|||
<!-- 日志上下文名称 --> |
|||
<contextName>${appname}</contextName> |
|||
|
|||
<!-- 彩色日志格式 --> |
|||
<property name="CONSOLE_LOG_PATTERN" |
|||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> |
|||
|
|||
<!--1. 输出到控制台--> |
|||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> |
|||
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息--> |
|||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
|||
<level>debug</level> |
|||
</filter> |
|||
<encoder> |
|||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern> |
|||
<!-- 设置字符集 --> |
|||
<charset>UTF-8</charset> |
|||
</encoder> |
|||
</appender> |
|||
|
|||
<!--2. 输出到文档--> |
|||
<!-- 2.1 level为 DEBUG 日志,时间滚动输出 --> |
|||
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/debug.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<!-- 日志归档 --> |
|||
<fileNamePattern>${log.path}/debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录debug级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>debug</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.2 level为 INFO 日志,时间滚动输出 --> |
|||
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/info.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<!-- 每天日志归档路径以及格式 --> |
|||
<fileNamePattern>${log.path}/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录info级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>info</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.3 level为 WARN 日志,时间滚动输出 --> |
|||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/warn.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<fileNamePattern>${log.path}/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录warn级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>warn</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.4 level为 ERROR 日志,时间滚动输出 --> |
|||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/error.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<fileNamePattern>${log.path}/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录ERROR级别的 发送钉钉短信 --> |
|||
<filter class="com.epmet.commons.tools.filter.LogMsgSendFilter"> |
|||
<level>ERROR</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
<webHook>${webHook}</webHook> |
|||
<secret>${secret}</secret> |
|||
<appName>${appname}</appName> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 开发、测试环境 --> |
|||
<springProfile name="dev,test"> |
|||
<logger name="org.springframework.web" level="INFO"/> |
|||
<logger name="org.springboot.sample" level="INFO"/> |
|||
<logger name="com.epmet.dao" level="INFO"/> |
|||
<logger name="com.epmet.dao" level="DEBUG"/> |
|||
<root level="INFO"> |
|||
<appender-ref ref="DEBUG_FILE"/> |
|||
<appender-ref ref="INFO_FILE"/> |
|||
<appender-ref ref="WARN_FILE"/> |
|||
<appender-ref ref="ERROR_FILE"/> |
|||
</root> |
|||
</springProfile> |
|||
|
|||
<!-- 生产环境 --> |
|||
<springProfile name="prod"> |
|||
<logger name="org.springframework.web" level="INFO"/> |
|||
<logger name="org.springboot.sample" level="INFO"/> |
|||
<logger name="com.epmet.dao" level="INFO"/> |
|||
<root level="INFO"> |
|||
<appender-ref ref="CONSOLE"/> |
|||
<appender-ref ref="DEBUG_FILE"/> |
|||
<appender-ref ref="INFO_FILE"/> |
|||
<appender-ref ref="WARN_FILE"/> |
|||
<appender-ref ref="ERROR_FILE"/> |
|||
</root> |
|||
</springProfile> |
|||
|
|||
</configuration> |
@ -1,35 +0,0 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.epmet.adv.dao.AdvVedioDao"> |
|||
|
|||
<resultMap type="com.epmet.adv.entity.AdvVedioEntity" id="entityMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="path" column="PATH"/> |
|||
<result property="storeType" column="STORE_TYPE"/> |
|||
<result property="enable" column="ENABLE"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
</resultMap> |
|||
|
|||
<select id="getEnableAdvVedioEntity" resultMap="entityMap"> |
|||
select id, |
|||
path, |
|||
store_type, |
|||
enable, |
|||
revision, |
|||
del_flag, |
|||
created_by, |
|||
created_time, |
|||
updated_by, |
|||
updated_time |
|||
from adv_vedio |
|||
where ENABLE = 1 |
|||
limit 1; |
|||
</select> |
|||
|
|||
</mapper> |
@ -1,21 +0,0 @@ |
|||
<?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"> |
|||
<parent> |
|||
<artifactId>epmet-openapi</artifactId> |
|||
<groupId>com.epmet</groupId> |
|||
<version>2.0.0</version> |
|||
</parent> |
|||
<packaging>pom</packaging> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>epmet-openapi-adv</artifactId> |
|||
|
|||
<modules> |
|||
<module>epmet-openapi-adv-client</module> |
|||
<module>epmet-openapi-adv-server</module> |
|||
</modules> |
|||
|
|||
|
|||
</project> |
@ -1,11 +0,0 @@ |
|||
FROM java:8 |
|||
|
|||
RUN export LANG="zh_CN.UTF-8" |
|||
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime |
|||
RUN echo 'Asia/Shanghai' > /etc/timezone |
|||
|
|||
COPY ./target/*.jar ./epmet-openapi-scan.jar |
|||
|
|||
EXPOSE 8107 |
|||
|
|||
ENTRYPOINT ["sh", "-c", "exec $RUN_INSTRUCT"] |
@ -1,18 +0,0 @@ |
|||
version: "3.7" |
|||
services: |
|||
epmet-openapi-scan: |
|||
container_name: epmet-openapi-scan-dev |
|||
image: 192.168.1.130:10080/epmet-cloud-dev/epmet-openapi-scan:version_placeholder |
|||
ports: |
|||
- "8107:8107" |
|||
network_mode: host # 不会创建新的网络 |
|||
volumes: |
|||
- "/opt/epmet-cloud-logs/dev:/logs" |
|||
environment: |
|||
RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./epmet-openapi-scan.jar" |
|||
restart: "unless-stopped" |
|||
deploy: |
|||
resources: |
|||
limits: |
|||
cpus: '0.1' |
|||
memory: 300M |
@ -1,18 +0,0 @@ |
|||
version: "3.7" |
|||
services: |
|||
epmet-openapi-scan: |
|||
container_name: epmet-openapi-scan-prod |
|||
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/epmet-openapi-scan:0.3.24 |
|||
ports: |
|||
- "8107:8107" |
|||
network_mode: host # 不会创建新的网络 |
|||
volumes: |
|||
- "/opt/epmet-cloud-logs/prod:/logs" |
|||
environment: |
|||
RUN_INSTRUCT: "java -Xms256m -Xmx512m -jar ./epmet-openapi-scan.jar" |
|||
restart: "unless-stopped" |
|||
deploy: |
|||
resources: |
|||
limits: |
|||
cpus: '0.1' |
|||
memory: 600M |
@ -1,18 +0,0 @@ |
|||
version: "3.7" |
|||
services: |
|||
epmet-openapi-scan: |
|||
container_name: epmet-openapi-scan-test |
|||
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-openapi-scan:version_placeholder |
|||
ports: |
|||
- "8107:8107" |
|||
network_mode: host # 不会创建新的网络 |
|||
volumes: |
|||
- "/opt/epmet-cloud-logs/test:/logs" |
|||
environment: |
|||
RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./epmet-openapi-scan.jar" |
|||
restart: "unless-stopped" |
|||
deploy: |
|||
resources: |
|||
limits: |
|||
cpus: '0.1' |
|||
memory: 300M |
@ -1,208 +0,0 @@ |
|||
<?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> |
|||
<version>0.3.24</version> |
|||
<artifactId>epmet-openapi-scan</artifactId> |
|||
<packaging>jar</packaging> |
|||
|
|||
<parent> |
|||
<artifactId>epmet-openapi</artifactId> |
|||
<groupId>com.epmet</groupId> |
|||
<version>2.0.0</version> |
|||
</parent> |
|||
<dependencies> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-web</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework</groupId> |
|||
<artifactId>spring-context-support</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-starter-actuator</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.alibaba.cloud</groupId> |
|||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.alibaba.cloud</groupId> |
|||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.epmet</groupId> |
|||
<artifactId>epmet-commons-tools</artifactId> |
|||
<version>2.0.0</version> |
|||
</dependency> |
|||
<!--aliyun green--> |
|||
<dependency> |
|||
<groupId>com.aliyun</groupId> |
|||
<artifactId>aliyun-java-sdk-core</artifactId> |
|||
<version>4.1.1</version> |
|||
</dependency> |
|||
<dependency> |
|||
<groupId>com.aliyun</groupId> |
|||
<artifactId>aliyun-java-sdk-green</artifactId> |
|||
<version>3.5.1</version> |
|||
</dependency> |
|||
<!-- httpclient --> |
|||
<dependency> |
|||
<groupId>org.apache.httpcomponents</groupId> |
|||
<artifactId>httpclient</artifactId> |
|||
<version>4.5.2</version> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
<build> |
|||
<finalName>${project.artifactId}</finalName> |
|||
<plugins> |
|||
<plugin> |
|||
<groupId>org.springframework.boot</groupId> |
|||
<artifactId>spring-boot-maven-plugin</artifactId> |
|||
</plugin> |
|||
<plugin> |
|||
<groupId>org.apache.maven.plugins</groupId> |
|||
<artifactId>maven-surefire-plugin</artifactId> |
|||
<configuration> |
|||
<skipTests>true</skipTests> |
|||
</configuration> |
|||
</plugin> |
|||
</plugins> |
|||
|
|||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory> |
|||
<resources> |
|||
<resource> |
|||
<filtering>true</filtering> |
|||
<directory>${basedir}/src/main/resources</directory> |
|||
</resource> |
|||
</resources> |
|||
</build> |
|||
|
|||
<profiles> |
|||
<profile> |
|||
<id>dev</id> |
|||
<properties> |
|||
<server.port>8107</server.port> |
|||
<spring.profiles.active>dev</spring.profiles.active> |
|||
|
|||
|
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>192.168.1.130</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>123456</spring.redis.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>192.168.1.130:8848</nacos.server-addr> |
|||
<nacos.discovery.namespace>6ceab336-d004-4acf-89c6-e121d06f4988</nacos.discovery.namespace> |
|||
<nacos.config.namespace></nacos.config.namespace> |
|||
<nacos.config.group></nacos.config.group> |
|||
<nacos.config-enabled>false</nacos.config-enabled> |
|||
<nacos.ip/> |
|||
<!--钉钉 机器人地址--> |
|||
<dingTalk.robot.webHook> |
|||
https://oapi.dingtalk.com/robot/send?access_token=90782b119f82a5b6bb8e0f819b6a77bbc2102b53aa2d7d2e24fa10b66d580b1c |
|||
</dingTalk.robot.webHook> |
|||
<dingTalk.robot.secret>SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19 |
|||
</dingTalk.robot.secret> |
|||
</properties> |
|||
</profile> |
|||
<profile> |
|||
<id>local</id> |
|||
<activation> |
|||
<activeByDefault>true</activeByDefault> |
|||
</activation> |
|||
<properties> |
|||
<server.port>8107</server.port> |
|||
<spring.profiles.active>dev</spring.profiles.active> |
|||
|
|||
|
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>192.168.1.130</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>123456</spring.redis.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>false</nacos.register-enabled> |
|||
<nacos.server-addr>192.168.1.130:8848</nacos.server-addr> |
|||
<nacos.discovery.namespace>6ceab336-d004-4acf-89c6-e121d06f4988</nacos.discovery.namespace> |
|||
<nacos.config.namespace></nacos.config.namespace> |
|||
<nacos.config.group></nacos.config.group> |
|||
<nacos.config-enabled>false</nacos.config-enabled> |
|||
<nacos.ip/> |
|||
<!--钉钉 机器人地址--> |
|||
<dingTalk.robot.webHook> |
|||
https://oapi.dingtalk.com/robot/send?access_token=90782b119f82a5b6bb8e0f819b6a77bbc2102b53aa2d7d2e24fa10b66d580b1c |
|||
</dingTalk.robot.webHook> |
|||
<dingTalk.robot.secret>SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19 |
|||
</dingTalk.robot.secret> |
|||
</properties> |
|||
</profile> |
|||
<profile> |
|||
<id>test</id> |
|||
<properties> |
|||
<server.port>8107</server.port> |
|||
<spring.profiles.active>test</spring.profiles.active> |
|||
|
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>EpmEtrEdIs!q@w</spring.redis.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>192.168.10.150:8848</nacos.server-addr> |
|||
<nacos.discovery.namespace>67e3c350-533e-4d7c-9f8f-faf1b4aa82ae</nacos.discovery.namespace> |
|||
<nacos.config.namespace></nacos.config.namespace> |
|||
<nacos.config.group></nacos.config.group> |
|||
<nacos.config-enabled>false</nacos.config-enabled> |
|||
<nacos.ip/> |
|||
<!--测试钉钉 机器人地址--> |
|||
<dingTalk.robot.webHook> |
|||
https://oapi.dingtalk.com/robot/send?access_token=90782b119f82a5b6bb8e0f819b6a77bbc2102b53aa2d7d2e24fa10b66d580b1c |
|||
</dingTalk.robot.webHook> |
|||
<dingTalk.robot.secret>SEC080aac67ff78e79fdaba132aa51e3fb3f6060dec99492feaac82cabf9f8b6a19 |
|||
</dingTalk.robot.secret> |
|||
</properties> |
|||
</profile> |
|||
|
|||
<profile> |
|||
<id>prod</id> |
|||
<!-- <activation> |
|||
<activeByDefault>true</activeByDefault> |
|||
</activation>--> |
|||
<properties> |
|||
<server.port>8107</server.port> |
|||
<spring.profiles.active>prod</spring.profiles.active> |
|||
|
|||
<!-- redis配置 --> |
|||
<spring.redis.index>0</spring.redis.index> |
|||
<spring.redis.host>r-m5ez3n1j0qc3ykq2ut.redis.rds.aliyuncs.com</spring.redis.host> |
|||
<spring.redis.port>6379</spring.redis.port> |
|||
<spring.redis.password>EpmEtclOUdrEdIs!Q2w</spring.redis.password> |
|||
<!-- nacos --> |
|||
<nacos.register-enabled>true</nacos.register-enabled> |
|||
<nacos.server-addr>192.168.11.180:8848</nacos.server-addr> |
|||
<nacos.discovery.namespace>bd205d23-e696-47be-b995-916313f86e99</nacos.discovery.namespace> |
|||
<nacos.config.namespace></nacos.config.namespace> |
|||
<nacos.config.group></nacos.config.group> |
|||
<nacos.config-enabled>false</nacos.config-enabled> |
|||
<nacos.ip/> |
|||
|
|||
|
|||
<!--生产钉钉 机器人地址--> |
|||
<dingTalk.robot.webHook> |
|||
https://oapi.dingtalk.com/robot/send?access_token=a5f66c3374b1642fe2142dbf56d5997e280172d4e8f2b546c9423a68c82ece6c |
|||
</dingTalk.robot.webHook> |
|||
<dingTalk.robot.secret>SEC95f4f40b533ad379ea6a6d1af6dd37029383cfe1b7cd96dfac2678be2c1c3ed1 |
|||
</dingTalk.robot.secret> |
|||
</properties> |
|||
</profile> |
|||
</profiles> |
|||
|
|||
</project> |
@ -1,30 +0,0 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.epmet.openapi.scan; |
|||
|
|||
import org.springframework.boot.SpringApplication; |
|||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
|||
import org.springframework.context.annotation.ComponentScan; |
|||
|
|||
/** |
|||
* 管理后台 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
|
|||
@SpringBootApplication |
|||
@ComponentScan(basePackages = "com.epmet") |
|||
public class ScanApplication { |
|||
|
|||
public static void main(String[] args) { |
|||
SpringApplication.run(ScanApplication.class, args); |
|||
} |
|||
|
|||
} |
@ -1,40 +0,0 @@ |
|||
package com.epmet.openapi.scan.aspect; |
|||
|
|||
import com.epmet.commons.tools.aspect.BaseRequestLogAspect; |
|||
import org.aspectj.lang.ProceedingJoinPoint; |
|||
import org.aspectj.lang.annotation.Around; |
|||
import org.aspectj.lang.annotation.Aspect; |
|||
import org.springframework.core.annotation.Order; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.web.context.request.RequestAttributes; |
|||
import org.springframework.web.context.request.RequestContextHolder; |
|||
import org.springframework.web.context.request.ServletRequestAttributes; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
|
|||
/** |
|||
* 日志/异常处理切面实现,调用父类方法完成日志记录和异常处理。 |
|||
*/ |
|||
@Aspect |
|||
@Component |
|||
@Order(0) |
|||
public class RequestLogAspect extends BaseRequestLogAspect { |
|||
|
|||
@Override |
|||
@Around(value = "execution(* com.epmet.openapi.scan.controller.*Controller*.*(..)) ") |
|||
public Object proceed(ProceedingJoinPoint point) throws Throwable { |
|||
return super.proceed(point, getRequest()); |
|||
} |
|||
|
|||
/** |
|||
* 获取Request对象 |
|||
* |
|||
* @return |
|||
*/ |
|||
private HttpServletRequest getRequest() { |
|||
RequestAttributes ra = RequestContextHolder.getRequestAttributes(); |
|||
ServletRequestAttributes sra = (ServletRequestAttributes) ra; |
|||
return sra.getRequest(); |
|||
} |
|||
|
|||
} |
@ -1,30 +0,0 @@ |
|||
package com.epmet.openapi.scan.common.constant; |
|||
|
|||
/** |
|||
* 系统常量 |
|||
* |
|||
* @author jianjun liu |
|||
* @date 2020-06-05 10:42 |
|||
**/ |
|||
public class SysConstant { |
|||
|
|||
public static final String UTF8 = "utf-8"; |
|||
/** |
|||
* 文本审核最大任务数 |
|||
*/ |
|||
public static final Integer MAX_TASK_SIZE = 100; |
|||
|
|||
/** |
|||
* 图片审核最大任务数 |
|||
*/ |
|||
public static final Integer MAX_SCAN_IMG_TASK_SIZE = 10; |
|||
|
|||
public static final String CODE = "code"; |
|||
public static final String DATA = "data"; |
|||
|
|||
|
|||
/** |
|||
* 任务正在执行中,建议您等待一段时间(例如5s)后再查询结果。 |
|||
*/ |
|||
public static final int PROCESSING=280; |
|||
} |
@ -1,68 +0,0 @@ |
|||
package com.epmet.openapi.scan.common.enu; |
|||
|
|||
import com.epmet.commons.tools.constant.StrConstant; |
|||
|
|||
/** |
|||
* 公共错误码 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2021/1/10 19:43 |
|||
*/ |
|||
public enum CommonErrorCodeEnum { |
|||
OK(200, "请求成功。"), |
|||
PROCESSING(280, "任务正在执行中,建议您等待一段时间(例如5s)后再查询结果。"), |
|||
BAD_REQUEST(400, "请求有误,通常由于请求参数不正确导致,请仔细检查请求参数。"), |
|||
NOT_ALLOWED(401, "请求失败,通常是由于使用了不安全的图片、视频、语音链接地址。"), |
|||
FORBIDDEN(403, "请求访问失败,通常由于您的图片、视频、语音链接无法访问导致,请确认公网是否可访问,并且无防盗链策略。"), |
|||
NOT_FOUND(404, "待检测内容未找到,通常是由于您的图片、视频、语音内容无法下载导致,请确认内容可通过公网访问到。"), |
|||
DOWNLOAD_FAILED(480, "下载失败,请确认待检测内容的大小、分辨率(如果有)在API的限制范围内。"), |
|||
GENERAL_ERROR(500, "一般是服务端临时出错。建议重试,若持续返回该错误码,请通过工单联系我们。"), |
|||
DB_FAILED(580, "数据库操作失败。建议重试,若持续返回该错误码,请通过工单联系我们。"), |
|||
TIMEOUT(581, "超时。建议重试,若持续返回该错误码,请通过工单联系我们。"), |
|||
CACHE_FAILED(585, "缓存出错。建议重试,若持续返回该错误码,请通过工单联系我们。"), |
|||
ALGO_FAILED(586, "算法出错。请通过工单联系我们。"), |
|||
MQ_FAILED(587, "中间件出错。请通过工单联系我们。"), |
|||
EXCEED_QUOTA(588, "请求频率超出配额。默认配额:图片检测50张/秒,视频检测20路/秒,语音检测20路/秒,文本检测100条/秒。如果需要调整配额,请通过工单联系我们。"), |
|||
TOO_LARGE(589, "待检测内容过大,请确保检测的内容在API的限制范围内。建议重试,若持续返回该错误码,请通过工单联系我们。"), |
|||
BAD_FORMAT(590, "待检测内容格式错误,请确保检测的内容在API的限制范围内。"), |
|||
CONNECTION_POOL_FULL(591, "连接池满。请通过工单联系我们。"), |
|||
DOWNLOAD_TIMEOUT(592, "下载超时,下载时间限制为3s,请确保检测的内容大小在API的限制范围内。"), |
|||
EXPIRED(594, "任务过期,如taskId过期。"), |
|||
CATCH_FRAME_FAILED(595, "截帧失败,请通过工单联系我们。"), |
|||
PERMISSION_DENY(596, "账号未授权、账号欠费、账号未开通、账号被禁等原因,具体可以参考返回的msg。"); |
|||
|
|||
|
|||
private Integer code; |
|||
private String desc; |
|||
|
|||
CommonErrorCodeEnum(Integer code, String desc) { |
|||
this.code = code; |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public Integer getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(Integer code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public void setDesc(String desc) { |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public static String getErrorMsg(Integer value) { |
|||
CommonErrorCodeEnum[] codeEnums = values(); |
|||
for (CommonErrorCodeEnum commonErrorCodeEnum : codeEnums) { |
|||
if (commonErrorCodeEnum.getCode().equals(value)) { |
|||
return commonErrorCodeEnum.getDesc(); |
|||
} |
|||
} |
|||
return StrConstant.EPMETY_STR; |
|||
} |
|||
} |
@ -1,47 +0,0 @@ |
|||
package com.epmet.openapi.scan.common.enu; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* desc:图片检测场景 |
|||
* @author jianjun liu |
|||
* @date 2020-06-04 21:39 |
|||
**/ |
|||
public enum ImgSceneEnum { |
|||
PORN("porn", "图片智能鉴黄"), |
|||
TERRORISM("terrorism", "图片暴恐涉政识别"); |
|||
|
|||
private String code; |
|||
private String desc; |
|||
|
|||
ImgSceneEnum(String code, String desc) { |
|||
this.code = code; |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public static List<String> getImgSceneList() { |
|||
List<String> result = new ArrayList<>(); |
|||
ImgSceneEnum[] values = ImgSceneEnum.values(); |
|||
for (ImgSceneEnum v : values) { |
|||
result.add(v.getCode()); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(String code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public void setDesc(String desc) { |
|||
this.desc = desc; |
|||
} |
|||
} |
@ -1,66 +0,0 @@ |
|||
package com.epmet.openapi.scan.common.enu; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 阿里检测结果的分类字典 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/18 14:04 |
|||
*/ |
|||
public enum LabelEnum { |
|||
NORMAL("normal", "正常文本"), |
|||
SPAM("spam", "含垃圾信息"), |
|||
AD("ad", "广告"), |
|||
POLITICS("politics","涉政"), |
|||
TERRORISM("terrorism","暴恐"), |
|||
ABUSE("abuse","辱骂"), |
|||
PORN("porn","色情"), |
|||
FLOOD("flood","灌水"), |
|||
CONTRABAND("contraband","违禁"), |
|||
MEANINGLESS("meaningless","无意义"), |
|||
CUSTOMIZED("customized","自定义"); |
|||
|
|||
private String code; |
|||
private String desc; |
|||
|
|||
LabelEnum(String code, String desc) { |
|||
this.code = code; |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public static List<String> getLabelEnumList() { |
|||
List<String> result = new ArrayList<>(); |
|||
LabelEnum[] values = LabelEnum.values(); |
|||
for (LabelEnum v : values) { |
|||
result.add(v.getCode()); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
public static String getDesc(String code) { |
|||
LabelEnum[] businessModeEnums = values(); |
|||
for (LabelEnum labelEnum : businessModeEnums) { |
|||
if (labelEnum.getCode().equals(code)) { |
|||
return labelEnum.getDesc(); |
|||
} |
|||
} |
|||
return ""; |
|||
} |
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(String code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public void setDesc(String desc) { |
|||
this.desc = desc; |
|||
} |
|||
} |
@ -1,49 +0,0 @@ |
|||
package com.epmet.openapi.scan.common.enu; |
|||
|
|||
/** |
|||
* @author jianjun liu |
|||
* @email liujianjun@yunzongnet.com |
|||
* @date 2020-06-04 21:39 |
|||
**/ |
|||
public enum RegionIdEnum { |
|||
SHANG_HAI("cn-shanghai","green.cn-shanghai.aliyuncs.com"), |
|||
BEI_JING("cn-beijing","green.cn-beijing.aliyuncs.com"), |
|||
AP_SOUTHEAST_1("ap-southeast-1","green.ap-southeast-1.aliyuncs.com"), |
|||
US_WEST_1("us-west-1","green.us-west-1.aliyuncs.com"); |
|||
|
|||
private String regionId; |
|||
private String domain; |
|||
RegionIdEnum(String regionId, String domain){ |
|||
this.regionId = regionId; |
|||
this.domain = domain; |
|||
} |
|||
|
|||
public static String getDoMain(String regionId){ |
|||
if (regionId == null) { |
|||
return SHANG_HAI.getDomain(); |
|||
} |
|||
RegionIdEnum[] values = RegionIdEnum.values(); |
|||
for (RegionIdEnum v : values) { |
|||
if (regionId.equals(v.getDomain())) { |
|||
return v.getDomain(); |
|||
} |
|||
} |
|||
return SHANG_HAI.getDomain(); |
|||
} |
|||
|
|||
public String getRegionId() { |
|||
return regionId; |
|||
} |
|||
|
|||
public void setRegionId(String regionId) { |
|||
this.regionId = regionId; |
|||
} |
|||
|
|||
public String getDomain() { |
|||
return domain; |
|||
} |
|||
|
|||
public void setDomain(String domain) { |
|||
this.domain = domain; |
|||
} |
|||
} |
@ -1,48 +0,0 @@ |
|||
package com.epmet.openapi.scan.common.enu; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* desc:检测建议 |
|||
* @author jianjun liu |
|||
* @date 2020-06-04 21:39 |
|||
**/ |
|||
public enum SuggestionEnum { |
|||
PASS("pass", "正常"), |
|||
REVIEW("review", "需要人工审核"), |
|||
BLOCK("block", "内容违规"); |
|||
|
|||
private String code; |
|||
private String desc; |
|||
|
|||
SuggestionEnum(String code, String desc) { |
|||
this.code = code; |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public static List<String> getImgSceneList() { |
|||
List<String> result = new ArrayList<>(); |
|||
SuggestionEnum[] values = SuggestionEnum.values(); |
|||
for (SuggestionEnum v : values) { |
|||
result.add(v.getCode()); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(String code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public void setDesc(String desc) { |
|||
this.desc = desc; |
|||
} |
|||
} |
@ -1,46 +0,0 @@ |
|||
package com.epmet.openapi.scan.common.enu; |
|||
|
|||
/** |
|||
* @author jianjun liu |
|||
* @date 2020-06-04 21:39 |
|||
**/ |
|||
public enum SysResponseEnum { |
|||
/** |
|||
* |
|||
* 业务代码枚举类 |
|||
* |
|||
* 编码样式:【CCCBBOOXX】 |
|||
* 编码示例说明: |
|||
* CCC 中心编码&业务系统 (110-内容扫描服务中心服务) |
|||
* BB 业务类型(00-默认 ) |
|||
* OO 操作类型(00-默认) |
|||
* XX 具体编码(00-成功,01-失败,02-参数错误,10-异常 99-系统错误) |
|||
* |
|||
*/ |
|||
/*通用枚举 */ |
|||
EXCEPTION(10001,"系统异常"), |
|||
THIRD_PLATFORM_SERVER_ERROR(10002,"第三方检测服务异常,请稍候重试"), |
|||
THIRD_PLATFORM_RESP_STATUS_ERROR(10003,"第三方检测服务响应异常,请稍候重试"), |
|||
THIRD_PLATFORM_RESP_CODE_ERROR(10004,"第三方检测服务检测异常,请稍候重试"), |
|||
|
|||
|
|||
/*审核内容 业务 01*/ |
|||
SCAN_TASK_LIST_PARAM_ERROR(110010001,"任务列表长度超过限制"), |
|||
SCAN_PARAM_ERROR(110010002,"参数格式不正确"), |
|||
; |
|||
|
|||
private Integer code; |
|||
private String msg; |
|||
SysResponseEnum(Integer code, String msg){ |
|||
this.code = code; |
|||
this.msg = msg; |
|||
} |
|||
|
|||
public Integer getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getMsg() { |
|||
return msg; |
|||
} |
|||
} |
@ -1,46 +0,0 @@ |
|||
package com.epmet.openapi.scan.common.enu; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* desc:文本检测场景 |
|||
* @author jianjun liu |
|||
* @date 2020-06-04 21:39 |
|||
**/ |
|||
public enum TextSceneEnum { |
|||
ANTISPAM("antispam", "文本垃圾内容检测"); |
|||
|
|||
private String code; |
|||
private String desc; |
|||
|
|||
TextSceneEnum(String code, String desc) { |
|||
this.code = code; |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public static List<String> getTextSceneList() { |
|||
List<String> result = new ArrayList<>(); |
|||
TextSceneEnum[] values = TextSceneEnum.values(); |
|||
for (TextSceneEnum v : values) { |
|||
result.add(v.getCode()); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(String code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public void setDesc(String desc) { |
|||
this.desc = desc; |
|||
} |
|||
} |
@ -1,50 +0,0 @@ |
|||
package com.epmet.openapi.scan.common.enu; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* desc:视频检测场景 |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/29 13:47 |
|||
**/ |
|||
public enum VideoSceneEnum { |
|||
PORN("porn", "视频智能鉴黄"), |
|||
TERRORISM("terrorism", "视频暴恐涉政"), |
|||
LIVE("live","视频不良场景"), |
|||
LOGO("logo","视频logo"), |
|||
AD("ad","视频图文违规"); |
|||
|
|||
private String code; |
|||
private String desc; |
|||
|
|||
VideoSceneEnum(String code, String desc) { |
|||
this.code = code; |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public static List<String> getVideoSceneList() { |
|||
List<String> result = new ArrayList<>(); |
|||
VideoSceneEnum[] values = VideoSceneEnum.values(); |
|||
for (VideoSceneEnum v : values) { |
|||
result.add(v.getCode()); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(String code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public void setDesc(String desc) { |
|||
this.desc = desc; |
|||
} |
|||
} |
@ -1,47 +0,0 @@ |
|||
package com.epmet.openapi.scan.common.enu; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 语音异步检测场景 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/9 10:12 |
|||
*/ |
|||
public enum VoiceSceneEnum { |
|||
ANTISPAM("antispam", "检测场景,取值:antispam"); |
|||
|
|||
private String code; |
|||
private String desc; |
|||
|
|||
VoiceSceneEnum(String code, String desc) { |
|||
this.code = code; |
|||
this.desc = desc; |
|||
} |
|||
|
|||
public static List<String> getVoiceSceneList() { |
|||
List<String> result = new ArrayList<>(); |
|||
VoiceSceneEnum[] values = VoiceSceneEnum.values(); |
|||
for (VoiceSceneEnum v : values) { |
|||
result.add(v.getCode()); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
public String getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public void setCode(String code) { |
|||
this.code = code; |
|||
} |
|||
|
|||
public String getDesc() { |
|||
return desc; |
|||
} |
|||
|
|||
public void setDesc(String desc) { |
|||
this.desc = desc; |
|||
} |
|||
} |
@ -1,29 +0,0 @@ |
|||
package com.epmet.openapi.scan.common.exception; |
|||
|
|||
import com.epmet.openapi.scan.common.enu.SysResponseEnum; |
|||
|
|||
/** |
|||
* @author jianjun liu |
|||
* @date 2020-06-05 10:31 |
|||
**/ |
|||
public class ExecuteHttpException extends RuntimeException { |
|||
private int code; |
|||
private String msg; |
|||
|
|||
public ExecuteHttpException(String msg) { |
|||
this(SysResponseEnum.EXCEPTION.getCode(), msg); |
|||
} |
|||
|
|||
public ExecuteHttpException(int code, String msg) { |
|||
this.code = code; |
|||
this.msg = msg; |
|||
} |
|||
|
|||
public int getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getMsg() { |
|||
return msg; |
|||
} |
|||
} |
@ -1,38 +0,0 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* <p> |
|||
* https://www.renren.io
|
|||
* <p> |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.epmet.openapi.scan.common.redis; |
|||
|
|||
/** |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
public class RedisKeys { |
|||
|
|||
/** |
|||
* 党群e事通redis前缀 |
|||
*/ |
|||
private static String rootPrefix = "epmet:"; |
|||
|
|||
/** |
|||
* desc:白名单Key |
|||
* @return |
|||
*/ |
|||
public static String getWhiteList () { |
|||
return rootPrefix.concat("openapi:scan:whitelist"); |
|||
} |
|||
|
|||
/** |
|||
* desc: 语音检测任务,异步回调,需要根据taskId获取存储seed的Key |
|||
* @param taskId 提交检测任务API接口返回的taskId eg:1001 |
|||
* @return epmet:openapi:scan:voice:seed:1001 |
|||
*/ |
|||
public static String getVoiceScanSeedKey(String taskId){ |
|||
return rootPrefix.concat("openapi:scan:voice:seed:").concat(taskId); |
|||
} |
|||
} |
@ -1,171 +0,0 @@ |
|||
package com.epmet.openapi.scan.common.util; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang.StringUtils; |
|||
import org.apache.http.HttpStatus; |
|||
import org.apache.http.NameValuePair; |
|||
import org.apache.http.client.config.RequestConfig; |
|||
import org.apache.http.client.entity.UrlEncodedFormEntity; |
|||
import org.apache.http.client.methods.CloseableHttpResponse; |
|||
import org.apache.http.client.methods.HttpGet; |
|||
import org.apache.http.client.methods.HttpPost; |
|||
import org.apache.http.client.methods.HttpRequestBase; |
|||
import org.apache.http.client.utils.URIBuilder; |
|||
import org.apache.http.entity.StringEntity; |
|||
import org.apache.http.impl.client.CloseableHttpClient; |
|||
import org.apache.http.impl.client.HttpClients; |
|||
import org.apache.http.message.BasicNameValuePair; |
|||
import org.apache.http.util.EntityUtils; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.io.IOException; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* desc: http 工具类 |
|||
* date: 2020/6/4 22:27 |
|||
* |
|||
* @author: jianjun liu |
|||
*/ |
|||
@Slf4j |
|||
public class HttpClientManager { |
|||
private static int connectionTimeout = 3000;// 连接超时时间,毫秒
|
|||
private static int soTimeout = 10000;// 读取数据超时时间,毫秒
|
|||
/** |
|||
* HttpClient对象 |
|||
*/ |
|||
private static CloseableHttpClient httpclient = HttpClients.custom().disableAutomaticRetries().build(); |
|||
|
|||
/*** 超时设置 ****/ |
|||
private static RequestConfig requestConfig = RequestConfig.custom() |
|||
.setSocketTimeout(soTimeout) |
|||
.setConnectTimeout(connectionTimeout) |
|||
.build();//设置请求和传输超时时间
|
|||
|
|||
public static HttpClientManager getInstance() { |
|||
return SingleClass.instance; |
|||
} |
|||
|
|||
private static class SingleClass { |
|||
private final static HttpClientManager instance = new HttpClientManager(); |
|||
} |
|||
|
|||
/** |
|||
* desc: 发送json post 请求 |
|||
* param: url,jsonStrParam |
|||
* return: Result<String> |
|||
* date: 2019/2/21 9:12 |
|||
* |
|||
* @author: jianjun liu |
|||
*/ |
|||
public Result<String> sendPost(String url, Map<String, String> paramsMap) { |
|||
|
|||
try { |
|||
HttpPost httppost = new HttpPost(url); |
|||
httppost.setConfig(requestConfig); |
|||
httppost.addHeader("Content-Type", "application/x-www-form-urlencoded charset=utf-8"); |
|||
|
|||
List<NameValuePair> list = new ArrayList<NameValuePair>(); |
|||
for (String key : paramsMap.keySet()) { |
|||
list.add(new BasicNameValuePair(key, String.valueOf(paramsMap.get(key)))); |
|||
} |
|||
UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(list, "utf-8"); |
|||
httppost.setEntity(urlEncodedFormEntity); |
|||
|
|||
return execute(httppost); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
log.error("send exception", e); |
|||
return new Result<String>().error(8000, e.getMessage()); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* desc: 发送json post 请求 |
|||
* param: url,jsonStrParam |
|||
* return: Result<String> |
|||
* date: 2019/2/21 9:12 |
|||
* |
|||
* @author: jianjun liu |
|||
*/ |
|||
public Result<String> sendPostByJSON(String url, String jsonStrParam) { |
|||
|
|||
try { |
|||
HttpPost httppost = new HttpPost(url); |
|||
httppost.setConfig(requestConfig); |
|||
httppost.addHeader("Content-Type", "application/json; charset=utf-8"); |
|||
if (StringUtils.isNotEmpty(jsonStrParam)) { |
|||
StringEntity se = new StringEntity(jsonStrParam, "utf-8"); |
|||
httppost.setEntity(se); |
|||
} |
|||
return execute(httppost); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
log.error("send exception", e); |
|||
return new Result<String>().error(8000, e.getMessage()); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* desc: 发送get请求 |
|||
* param:url, params |
|||
* return: Result<String> |
|||
* date: 2019/2/21 9:16 |
|||
* |
|||
* @author: jianjun liu |
|||
*/ |
|||
public Result<String> sendGet(String url, Map<String, Object> params) { |
|||
|
|||
try { |
|||
URIBuilder builder = new URIBuilder(url); |
|||
if (!CollectionUtils.isEmpty(params)) { |
|||
Set<String> set = params.keySet(); |
|||
for (String key : set) { |
|||
builder.setParameter(key, params.get(key) == null ? "" : String.valueOf(params.get(key))); |
|||
} |
|||
} |
|||
HttpGet httpGet = new HttpGet(builder.build()); |
|||
httpGet.setConfig(requestConfig); |
|||
return execute(httpGet); |
|||
} catch (Exception e) { |
|||
log.error("sendGet exception", e); |
|||
return new Result<String>().error(8000, e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
private Result<String> execute(HttpRequestBase httpMethod) { |
|||
CloseableHttpResponse response = null; |
|||
try { |
|||
response = httpclient.execute(httpMethod); |
|||
log.debug("http send response:{}", JSON.toJSONString(response)); |
|||
if (response != null && response.getStatusLine() != null) { |
|||
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { |
|||
String result = EntityUtils.toString(response.getEntity()); |
|||
return new Result<String>().ok(result); |
|||
} else { |
|||
log.warn("execute http method fail,httpStatus:{0}", response.getStatusLine().getStatusCode()); |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
log.error("execute exception", e); |
|||
} finally { |
|||
httpMethod.releaseConnection(); |
|||
try { |
|||
if (response != null) { |
|||
response.close(); |
|||
} |
|||
} catch (IOException e) { |
|||
} |
|||
} |
|||
return new Result<String>().error(8000, "系统异常"); |
|||
} |
|||
} |
|||
|
|||
|
@ -1,67 +0,0 @@ |
|||
package com.epmet.openapi.scan.common.util; |
|||
|
|||
/** |
|||
* @author jianjun liu |
|||
* @date 2020-06-05 10:03 |
|||
**/ |
|||
|
|||
import com.aliyuncs.DefaultAcsClient; |
|||
import com.aliyuncs.IAcsClient; |
|||
import com.aliyuncs.exceptions.ClientException; |
|||
import com.aliyuncs.profile.DefaultProfile; |
|||
import com.aliyuncs.profile.IClientProfile; |
|||
import com.epmet.openapi.scan.common.enu.RegionIdEnum; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.annotation.PostConstruct; |
|||
|
|||
@Slf4j |
|||
@Component |
|||
public class IAcsClientUtil { |
|||
private static String accessKeyId; |
|||
private static String secret; |
|||
private static String product = "Green"; |
|||
|
|||
private static String regionId; |
|||
private static String endpointName = ""; |
|||
|
|||
private static IClientProfile profile; |
|||
|
|||
|
|||
@PostConstruct |
|||
private void initProFile() { |
|||
profile = DefaultProfile.getProfile(regionId, accessKeyId, secret); |
|||
try { |
|||
DefaultProfile.addEndpoint(endpointName, regionId, product, RegionIdEnum.getDoMain(regionId)); |
|||
} catch (ClientException e) { |
|||
log.error("initProFile exception", e.getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
public static IAcsClient getIAcsClient() { |
|||
return new DefaultAcsClient(profile); |
|||
} |
|||
|
|||
@Value("${aliyun.green.accessKeyId}") |
|||
public void setAccessKeyId(String accessKeyId) { |
|||
IAcsClientUtil.accessKeyId = accessKeyId; |
|||
} |
|||
|
|||
@Value("${aliyun.green.accessKeySecret}") |
|||
public void setSecret(String secret) { |
|||
IAcsClientUtil.secret = secret; |
|||
} |
|||
|
|||
@Value("${aliyun.green.regionId}") |
|||
public void setRegionId(String regionId) { |
|||
IAcsClientUtil.regionId = regionId; |
|||
} |
|||
|
|||
@Value("${aliyun.green.regionId}") |
|||
public void setEndpointName(String endpointName) { |
|||
IAcsClientUtil.endpointName = endpointName; |
|||
} |
|||
} |
@ -1,55 +0,0 @@ |
|||
package com.epmet.openapi.scan.common.util; |
|||
|
|||
import org.apache.commons.lang3.StringUtils; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @author jianjun liu |
|||
* @date 2020-06-05 16:44 |
|||
**/ |
|||
public class MapUtil { |
|||
/** |
|||
* 将url参数转换成map |
|||
* |
|||
* @param param aa=11&bb=22&cc=33 |
|||
* @return |
|||
*/ |
|||
public static Map<String, Object> getUrlParams(String param) { |
|||
Map<String, Object> map = new HashMap<>(0); |
|||
if (StringUtils.isBlank(param)) { |
|||
return map; |
|||
} |
|||
String[] params = param.split("&"); |
|||
for (int i = 0; i < params.length; i++) { |
|||
String[] p = params[i].split("="); |
|||
if (p.length == 2) { |
|||
map.put(p[0], p[1]); |
|||
} |
|||
} |
|||
return map; |
|||
} |
|||
|
|||
/** |
|||
* 将map转换成url |
|||
* |
|||
* @param map |
|||
* @return |
|||
*/ |
|||
public static String getUrlParamsByMap(Map<String, Object> map) { |
|||
if (map == null) { |
|||
return ""; |
|||
} |
|||
StringBuffer sb = new StringBuffer(); |
|||
for (Map.Entry<String, Object> entry : map.entrySet()) { |
|||
sb.append(entry.getKey() + "=" + entry.getValue()); |
|||
sb.append("&"); |
|||
} |
|||
String s = sb.toString(); |
|||
if (s.endsWith("&")) { |
|||
s = StringUtils.substringBeforeLast(s, "&"); |
|||
} |
|||
return s; |
|||
} |
|||
} |
@ -1,26 +0,0 @@ |
|||
/** |
|||
* Copyright (c) 2018 人人开源 All rights reserved. |
|||
* |
|||
* https://www.renren.io
|
|||
* |
|||
* 版权所有,侵权必究! |
|||
*/ |
|||
|
|||
package com.epmet.openapi.scan.config; |
|||
|
|||
import com.epmet.commons.tools.config.ModuleConfig; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
/** |
|||
* 模块配置信息 |
|||
* |
|||
* @author Mark sunlightcs@gmail.com |
|||
* @since 1.0.0 |
|||
*/ |
|||
@Service |
|||
public class ModuleConfigImpl implements ModuleConfig { |
|||
@Override |
|||
public String getName() { |
|||
return "epmetscan"; |
|||
} |
|||
} |
@ -1,31 +0,0 @@ |
|||
package com.epmet.openapi.scan.config; |
|||
|
|||
import com.epmet.openapi.scan.interceptor.ScanApiAuthInterceptor; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
|||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
|||
|
|||
/** |
|||
* @author jianjun liu |
|||
* @email liujianjun@yunzongnet.com |
|||
* @date 2020-06-08 14:30 |
|||
**/ |
|||
|
|||
@Configuration |
|||
public class WebAppConfig implements WebMvcConfigurer{ |
|||
@Autowired |
|||
private ScanApiAuthInterceptor scanApiAuthInterceptor; |
|||
|
|||
// 多个拦截器组成一个拦截器链
|
|||
// addPathPatterns 用于添加拦截规则
|
|||
// excludePathPatterns 用户排除拦截
|
|||
|
|||
@Override |
|||
public void addInterceptors(InterceptorRegistry registry) { |
|||
registry.addInterceptor(scanApiAuthInterceptor)//添加拦截器
|
|||
.addPathPatterns("/**") //拦截所有请求
|
|||
.excludePathPatterns("/opback/**");//对应的不拦截的请求
|
|||
} |
|||
} |
|||
|
@ -1,32 +0,0 @@ |
|||
package com.epmet.openapi.scan.controller; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.openapi.scan.common.redis.RedisKeys; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.data.redis.core.RedisTemplate; |
|||
import org.springframework.data.redis.core.SetOperations; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestParam; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* @author jianjun liu |
|||
* @date 2020-06-04 20:39 |
|||
**/ |
|||
@RestController |
|||
@RequestMapping("opback") |
|||
public class BackDoorController { |
|||
@Autowired |
|||
private RedisTemplate redisTemplate; |
|||
|
|||
@RequestMapping("addWhite") |
|||
public String addWhite(@RequestParam String ip) { |
|||
SetOperations setOperations = redisTemplate.opsForSet(); |
|||
String whiteList = RedisKeys.getWhiteList(); |
|||
Long add = setOperations.add(whiteList, ip); |
|||
Set members = setOperations.members(whiteList); |
|||
return "ip:" + ip + "添加" + (add > 0 ? "成功" : "失败") + ",当前所有列表:" + JSON.toJSONString(members); |
|||
} |
|||
} |
@ -1,116 +0,0 @@ |
|||
package com.epmet.openapi.scan.controller; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.openapi.scan.common.constant.SysConstant; |
|||
import com.epmet.openapi.scan.common.enu.SysResponseEnum; |
|||
import com.epmet.openapi.scan.service.impl.ScanService; |
|||
import com.epmet.openapi.scan.support.param.ImgScanParam; |
|||
import com.epmet.openapi.scan.support.param.TextScanParam; |
|||
import com.epmet.openapi.scan.support.param.VoiceAsyncScanParam; |
|||
import com.epmet.openapi.scan.support.param.video.VideoAsyncScanParam; |
|||
import com.epmet.openapi.scan.support.result.ImgAsyncScanResult; |
|||
import com.epmet.openapi.scan.support.result.SyncScanResult; |
|||
import com.epmet.openapi.scan.support.result.VoiceAsyncScanResult; |
|||
import com.epmet.openapi.scan.support.result.VoiceAsyncScanTaskResult; |
|||
import com.epmet.openapi.scan.support.result.video.VideoAsyncScanTaskResultDTO; |
|||
import com.epmet.openapi.scan.support.result.video.VideoResultDTO; |
|||
import org.apache.commons.collections4.CollectionUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author jianjun liu |
|||
* @email liujianjun@yunzongnet.com |
|||
* @date 2020-06-05 10:39 |
|||
**/ |
|||
@RestController |
|||
@RequestMapping("api") |
|||
public class ScanController { |
|||
|
|||
@Autowired |
|||
private ScanService scanService; |
|||
|
|||
/** |
|||
* desc:图片同步检测接口 |
|||
* |
|||
* @param param |
|||
* @return |
|||
*/ |
|||
@RequestMapping("imgSyncScan") |
|||
public Result<SyncScanResult> ImgSyncScan(@RequestBody ImgScanParam param) { |
|||
ValidatorUtils.validateEntity(param); |
|||
return scanService.sendSyncImgScan(param); |
|||
} |
|||
|
|||
/** |
|||
* desc:文本同步检测接口 |
|||
* |
|||
* @param param |
|||
* @return |
|||
*/ |
|||
@RequestMapping("textSyncScan") |
|||
public Result<SyncScanResult> textSyncScan(@RequestBody TextScanParam param) { |
|||
ValidatorUtils.validateEntity(param); |
|||
return scanService.sendTextScan(param); |
|||
} |
|||
|
|||
//@RequestMapping("imgAsyncScan")
|
|||
public Result<ImgAsyncScanResult> ImgAsyncScan(@RequestBody ImgScanParam param) { |
|||
return null;//scanService.sendASyncImgScan(param);
|
|||
} |
|||
|
|||
|
|||
/** |
|||
* @description 语音异步检测 |
|||
* @Date 2020/12/9 9:14 |
|||
**/ |
|||
@PostMapping("voiceAsyncScan") |
|||
public Result<VoiceAsyncScanTaskResult> voiceAsyncScan(@RequestBody VoiceAsyncScanParam param){ |
|||
ValidatorUtils.validateEntity(param); |
|||
return scanService.sendVoiceAsyncScan(param); |
|||
} |
|||
|
|||
/** |
|||
* @param taskIds 要查询的异步检测任务的taskId列表。数组中的元素个数不超过100个 |
|||
* @author yinzuomei |
|||
* @description 语音异步检测结果查询 |
|||
* @Date 2020/12/9 11:16 |
|||
**/ |
|||
@PostMapping("voiceResults") |
|||
public Result<List<VoiceAsyncScanResult>> voiceResults(@RequestBody List<String> taskIds){ |
|||
return scanService.voiceResults(taskIds); |
|||
} |
|||
|
|||
/** |
|||
* @author yinzuomei |
|||
* @description 视频检测-异步检测 |
|||
**/ |
|||
@PostMapping("videoAsyncScan") |
|||
public Result<VideoAsyncScanTaskResultDTO> videoAsyncScan(@RequestBody VideoAsyncScanParam param) { |
|||
ValidatorUtils.validateEntity(param); |
|||
return scanService.videoAsyncScan(param); |
|||
} |
|||
|
|||
/** |
|||
* @author yinzuomei |
|||
* @description 视频异步检测结果查询接口 |
|||
**/ |
|||
@PostMapping("videoResults") |
|||
public Result<VideoResultDTO> videoResults(@RequestBody List<String> taskIds) { |
|||
if (CollectionUtils.isEmpty(taskIds)) { |
|||
return new Result<>(); |
|||
} |
|||
//检测对象不能为空,且最多支持100个元素
|
|||
if (org.springframework.util.CollectionUtils.isEmpty(taskIds) || taskIds.size() > SysConstant.MAX_TASK_SIZE) { |
|||
return new Result<VideoResultDTO>().error(SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getCode(), |
|||
SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getMsg().concat(SysConstant.MAX_TASK_SIZE.toString())); |
|||
} |
|||
return scanService.videoResults(taskIds); |
|||
} |
|||
} |
@ -1,60 +0,0 @@ |
|||
package com.epmet.openapi.scan.interceptor; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.utils.IpUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.openapi.scan.common.redis.RedisKeys; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.data.redis.core.RedisTemplate; |
|||
import org.springframework.data.redis.core.SetOperations; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.web.servlet.HandlerInterceptor; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.io.IOException; |
|||
import java.io.PrintWriter; |
|||
|
|||
/** |
|||
* @author jianjun liu |
|||
* @date 2020-06-05 16:36 |
|||
**/ |
|||
@Component |
|||
public class ScanApiAuthInterceptor implements HandlerInterceptor { |
|||
private static final Logger log = LoggerFactory.getLogger(ScanApiAuthInterceptor.class); |
|||
@Autowired |
|||
private RedisTemplate redisTemplate; |
|||
|
|||
@Override |
|||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
|||
String ip = IpUtils.getIpAddr(request); |
|||
SetOperations setOperations = redisTemplate.opsForSet(); |
|||
if (!setOperations.isMember(RedisKeys.getWhiteList(), ip)) { |
|||
log.warn("preHandle ip:{} is not in whitelist", ip); |
|||
String result = JSON.toJSONString(new Result<>().error(EpmetErrorCode.ERR401.getCode(), EpmetErrorCode.ERR401.getMsg())); |
|||
responseJson(response, result); |
|||
return false; |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
private void responseJson(HttpServletResponse response, String json) throws Exception { |
|||
PrintWriter writer = null; |
|||
response.setCharacterEncoding("UTF-8"); |
|||
response.setContentType("text/json; charset=utf-8"); |
|||
try { |
|||
writer = response.getWriter(); |
|||
writer.print(json); |
|||
} catch (IOException e) { |
|||
log.error(e.toString()); |
|||
} finally { |
|||
if (writer != null) { |
|||
writer.close(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
@ -1,69 +0,0 @@ |
|||
package com.epmet.openapi.scan.service.impl; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.openapi.scan.support.param.ImgScanParam; |
|||
import com.epmet.openapi.scan.support.param.TextScanParam; |
|||
import com.epmet.openapi.scan.support.param.VoiceAsyncScanParam; |
|||
import com.epmet.openapi.scan.support.param.video.VideoAsyncScanParam; |
|||
import com.epmet.openapi.scan.support.result.SyncScanResult; |
|||
import com.epmet.openapi.scan.support.result.VoiceAsyncScanResult; |
|||
import com.epmet.openapi.scan.support.result.VoiceAsyncScanTaskResult; |
|||
import com.epmet.openapi.scan.support.result.video.VideoAsyncScanTaskResultDTO; |
|||
import com.epmet.openapi.scan.support.result.video.VideoResultDTO; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* desc:内容扫描接口 |
|||
* |
|||
* @author jianjun liu |
|||
* @email liujianjun@yunzongnet.com |
|||
* @date 2020-06-05 13:12 |
|||
**/ |
|||
public interface ScanService { |
|||
/** |
|||
* desc:扫描文本内容 同步 |
|||
* @param textScanParam |
|||
* @return ImgAsyncScanResult |
|||
*/ |
|||
public Result<SyncScanResult> sendTextScan(TextScanParam textScanParam); |
|||
|
|||
|
|||
/** |
|||
* desc:扫描图片内容 同步 |
|||
* @param imgScanParam |
|||
* @return |
|||
*/ |
|||
public Result<SyncScanResult> sendSyncImgScan(ImgScanParam imgScanParam); |
|||
|
|||
/** |
|||
* 语音异步检测 |
|||
* |
|||
* @param param |
|||
* @return com.epmet.openapi.scan.support.result.VoiceAsyncScanTaskResult |
|||
*/ |
|||
Result<VoiceAsyncScanTaskResult> sendVoiceAsyncScan(VoiceAsyncScanParam param); |
|||
|
|||
/** |
|||
* 语音异步检测结果查询 |
|||
* |
|||
* @param taskIds 要查询的异步检测任务的taskId列表。数组中的元素个数不超过100个 |
|||
* @return com.epmet.openapi.scan.support.result.VoiceAsyncScanResult |
|||
*/ |
|||
Result<List<VoiceAsyncScanResult>> voiceResults(List<String> taskIds); |
|||
|
|||
/** |
|||
* desc:视频检测-异步检测 |
|||
* @param videoAsyncScanParam |
|||
* @return 异步检测)返回数据:taskId<=>dataId |
|||
*/ |
|||
Result<VideoAsyncScanTaskResultDTO> videoAsyncScan(VideoAsyncScanParam videoAsyncScanParam); |
|||
|
|||
/** |
|||
* @param taskIds |
|||
* @author yinzuomei |
|||
* @description 视频异步检测结果查询接口 |
|||
* @Date 2020/12/29 16:10 |
|||
**/ |
|||
Result<VideoResultDTO> videoResults(List<String> taskIds); |
|||
} |
@ -1,734 +0,0 @@ |
|||
package com.epmet.openapi.scan.service.impl; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.aliyuncs.AcsRequest; |
|||
import com.aliyuncs.green.model.v20180509.*; |
|||
import com.aliyuncs.http.FormatType; |
|||
import com.aliyuncs.http.HttpResponse; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.aliyuncs.http.MethodType; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.openapi.scan.common.constant.SysConstant; |
|||
import com.epmet.openapi.scan.common.enu.*; |
|||
import com.epmet.openapi.scan.common.exception.ExecuteHttpException; |
|||
import com.epmet.openapi.scan.common.redis.RedisKeys; |
|||
import com.epmet.openapi.scan.common.util.IAcsClientUtil; |
|||
import com.epmet.openapi.scan.support.param.*; |
|||
import com.epmet.openapi.scan.support.param.video.VideoAsyncScanParam; |
|||
import com.epmet.openapi.scan.support.param.video.VideoAsyncScanTask; |
|||
import com.epmet.openapi.scan.support.result.*; |
|||
import com.epmet.openapi.scan.support.result.video.*; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.collections4.ListUtils; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.apache.http.HttpStatus; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.data.redis.core.RedisTemplate; |
|||
import org.springframework.data.redis.core.ValueOperations; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.io.UnsupportedEncodingException; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.UUID; |
|||
|
|||
/** |
|||
* @author jianjun liu |
|||
* @email liujianjun@yunzongnet.com |
|||
* @date 2020-06-05 13:16 |
|||
**/ |
|||
@Slf4j |
|||
@Service |
|||
public class ScanServiceImpl implements ScanService { |
|||
@Value("${aliyun.green.regionId}") |
|||
private String regionId; |
|||
@Value("${aliyun.green.bizType}") |
|||
private String bizType; |
|||
@Autowired |
|||
private RedisTemplate redisTemplate; |
|||
@Override |
|||
public Result<SyncScanResult> sendTextScan(TextScanParam textScanParam) { |
|||
//默认参数
|
|||
// 鉴黄 暴恐涉政
|
|||
textScanParam.setScenes(TextSceneEnum.getTextSceneList()); |
|||
textScanParam.setBizType(bizType); |
|||
|
|||
List<TextTask> textTasks = textScanParam.getTasks(); |
|||
if (CollectionUtils.isEmpty(textTasks) || textTasks.size() > SysConstant.MAX_TASK_SIZE) { |
|||
return new Result<SyncScanResult>().error(SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getMsg().concat(SysConstant.MAX_TASK_SIZE.toString())); |
|||
} |
|||
|
|||
TextScanRequest textScanRequest = getTextScanRequest(); |
|||
|
|||
try { |
|||
textScanRequest.setHttpContent(JSON.toJSONString(textScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON); |
|||
} catch (UnsupportedEncodingException e) { |
|||
log.error("sendTextScan parse param exception", e); |
|||
return new Result<SyncScanResult>().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg()); |
|||
} |
|||
|
|||
try { |
|||
SyncScanResult textScanResult = executeSyncText(textScanRequest); |
|||
return new Result<SyncScanResult>().ok(textScanResult); |
|||
} catch (ExecuteHttpException e) { |
|||
log.error("sendTextScan execute Exception", e); |
|||
return new Result<SyncScanResult>().error(e.getCode(), e.getMsg()); |
|||
} |
|||
} |
|||
|
|||
private TextScanRequest getTextScanRequest() { |
|||
TextScanRequest textScanRequest = new TextScanRequest(); |
|||
textScanRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式
|
|||
textScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法
|
|||
textScanRequest.setEncoding(SysConstant.UTF8); |
|||
textScanRequest.setRegionId(regionId); |
|||
textScanRequest.setConnectTimeout(3000); |
|||
textScanRequest.setReadTimeout(6000); |
|||
return textScanRequest; |
|||
} |
|||
|
|||
@Override |
|||
public Result<SyncScanResult> sendSyncImgScan(ImgScanParam imgScanParam) { |
|||
//默认参数
|
|||
// 鉴黄 暴恐涉政
|
|||
imgScanParam.setScenes(ImgSceneEnum.getImgSceneList()); |
|||
imgScanParam.setBizType(bizType); |
|||
|
|||
List<ImgTask> imgTasks = imgScanParam.getTasks(); |
|||
if (CollectionUtils.isEmpty(imgTasks) || imgTasks.size() > SysConstant.MAX_TASK_SIZE) { |
|||
return new Result<SyncScanResult>().error(SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getMsg().concat(SysConstant.MAX_TASK_SIZE.toString())); |
|||
} |
|||
if (imgTasks.size() <= SysConstant.MAX_SCAN_IMG_TASK_SIZE) { |
|||
return doScanImg(imgScanParam); |
|||
} |
|||
log.info("sendSyncImgScan tasks size:{} over 10", imgTasks.size()); |
|||
List<List<ImgTask>> partition = ListUtils.partition(imgTasks, SysConstant.MAX_SCAN_IMG_TASK_SIZE); |
|||
SyncScanResult finalResult = new SyncScanResult(); |
|||
for (List<ImgTask> tasks : partition) { |
|||
ImgScanParam scanParam = new ImgScanParam(); |
|||
scanParam.setBizType(imgScanParam.getBizType()); |
|||
scanParam.setScenes(imgScanParam.getScenes()); |
|||
scanParam.setTasks(tasks); |
|||
scanParam.setCallback(imgScanParam.getCallback()); |
|||
scanParam.setSeed(imgScanParam.getSeed()); |
|||
Result<SyncScanResult> partResult = doScanImg(scanParam); |
|||
try { |
|||
Thread.sleep(5L); |
|||
} catch (InterruptedException e) { |
|||
log.error("sendSyncImgScan InterruptedException"); |
|||
} |
|||
if (partResult.success()) { |
|||
SyncScanResult data = partResult.getData(); |
|||
finalResult.getSuccessDataIds().addAll(data.getSuccessDataIds()); |
|||
finalResult.getFailDataIds().addAll(data.getFailDataIds()); |
|||
finalResult.getDetails().addAll(data.getDetails()); |
|||
} else { |
|||
return partResult; |
|||
} |
|||
} |
|||
return new Result<SyncScanResult>().ok(finalResult); |
|||
|
|||
|
|||
} |
|||
|
|||
private Result<SyncScanResult> doScanImg(ImgScanParam imgScanParam) { |
|||
ImageSyncScanRequest imageSyncScanRequest = getImgScanRequest(); |
|||
try { |
|||
imageSyncScanRequest.setHttpContent(JSON.toJSONString(imgScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON); |
|||
} catch (UnsupportedEncodingException e) { |
|||
log.error("sendSyncImgScan parse param exception", e); |
|||
return new Result<SyncScanResult>().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg()); |
|||
} |
|||
|
|||
try { |
|||
SyncScanResult scanResult = executeSyncImg(imageSyncScanRequest); |
|||
return new Result<SyncScanResult>().ok(scanResult); |
|||
} catch (ExecuteHttpException e) { |
|||
log.error("sendImgScan execute exception,param:{},fail msg:{}", JSON.toJSONString(imgScanParam), e.getMsg()); |
|||
return new Result<SyncScanResult>().error(e.getCode(), e.getMsg()); |
|||
} |
|||
} |
|||
|
|||
private ImageSyncScanRequest getImgScanRequest() { |
|||
ImageSyncScanRequest imageSyncScanRequest = new ImageSyncScanRequest(); |
|||
imageSyncScanRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式
|
|||
imageSyncScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法
|
|||
imageSyncScanRequest.setEncoding(SysConstant.UTF8); |
|||
imageSyncScanRequest.setRegionId(regionId); |
|||
imageSyncScanRequest.setConnectTimeout(3000); |
|||
imageSyncScanRequest.setReadTimeout(6000); |
|||
return imageSyncScanRequest; |
|||
} |
|||
|
|||
public SyncScanResult executeSyncText(AcsRequest<?> textScanRequest) { |
|||
SyncScanResult result = new SyncScanResult(); |
|||
try { |
|||
HttpResponse httpResponse = IAcsClientUtil.getIAcsClient().doAction(textScanRequest); |
|||
|
|||
if (httpResponse.isSuccess()) { |
|||
JSONObject scrResponse = JSON.parseObject(new String(httpResponse.getHttpContent(), SysConstant.UTF8)); |
|||
if (HttpStatus.SC_OK == scrResponse.getInteger(SysConstant.CODE)) { |
|||
//任务 列表
|
|||
List<ScanTaskResult> scanTaskResults = scrResponse.getJSONArray(SysConstant.DATA).toJavaList(ScanTaskResult.class); |
|||
for (ScanTaskResult taskResult : scanTaskResults) { |
|||
result.getDetails().add(taskResult); |
|||
//又根据场景不同
|
|||
if (HttpStatus.SC_OK != taskResult.getCode()) { |
|||
if (!result.getFailDataIds().contains(taskResult.getDataId())) { |
|||
result.getFailDataIds().add(taskResult.getDataId()); |
|||
log.warn("executeSyncText task process fail:code:{},result:{}", taskResult.getCode(), JSON.toJSONString(taskResult)); |
|||
} |
|||
continue; |
|||
} |
|||
//如果是多个场景 则为对个 BaseScanResult
|
|||
List<SceneDetailResult> sceneResults = taskResult.getResults(); |
|||
//是文本检测 目前就一种场景
|
|||
boolean isSuccess = true; |
|||
for (SceneDetailResult sceneResult : sceneResults) { |
|||
String suggestion = sceneResult.getSuggestion(); |
|||
if (SuggestionEnum.BLOCK.getCode().equals(suggestion)) { |
|||
isSuccess = false; |
|||
break; |
|||
} |
|||
} |
|||
if (isSuccess) { |
|||
result.getSuccessDataIds().add(taskResult.getDataId()); |
|||
} else { |
|||
log.warn("executeSyncText dataId:{} block:{}", taskResult.getDataId(), JSON.toJSONString(taskResult.getResults())); |
|||
result.getFailDataIds().add(taskResult.getDataId()); |
|||
} |
|||
} |
|||
return result; |
|||
} else { |
|||
log.warn("executeSyncText response not success. code:{}", scrResponse.getInteger(SysConstant.CODE)); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_RESP_CODE_ERROR.getCode(), SysResponseEnum.THIRD_PLATFORM_RESP_CODE_ERROR.getMsg() + ",status:" + httpResponse.getStatus()); |
|||
} |
|||
} else { |
|||
log.warn("executeSyncText response status is not success. httpResponse:{}", JSON.toJSONString(httpResponse)); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_RESP_STATUS_ERROR.getCode(), SysResponseEnum.THIRD_PLATFORM_RESP_STATUS_ERROR.getMsg() + ",status:" + httpResponse.getStatus()); |
|||
} |
|||
} catch (Exception e) { |
|||
log.error("executeSyncText exception IAcsClientUtil do action exception", e); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_SERVER_ERROR.getCode(), SysResponseEnum.THIRD_PLATFORM_SERVER_ERROR.getMsg()); |
|||
} |
|||
} |
|||
|
|||
private SyncScanResult executeSyncImg(AcsRequest<?> request) { |
|||
SyncScanResult result = new SyncScanResult(); |
|||
try { |
|||
HttpResponse httpResponse = IAcsClientUtil.getIAcsClient().doAction(request); |
|||
if (httpResponse.isSuccess()) { |
|||
JSONObject scrResponse = JSON.parseObject(new String(httpResponse.getHttpContent(), SysConstant.UTF8)); |
|||
if (HttpStatus.SC_OK == scrResponse.getInteger(SysConstant.CODE)) { |
|||
JSONArray taskResults = scrResponse.getJSONArray(SysConstant.DATA); |
|||
List<ScanTaskResult> scanTaskResults = taskResults.toJavaList(ScanTaskResult.class); |
|||
for (ScanTaskResult taskResult : scanTaskResults) { |
|||
result.getDetails().add(taskResult); |
|||
if (HttpStatus.SC_OK != taskResult.getCode()) { |
|||
if (!result.getFailDataIds().contains(taskResult.getDataId())) { |
|||
result.getFailDataIds().add(taskResult.getDataId()); |
|||
log.warn("executeSyncImg detect not success. code:{},result:{}", taskResult.getCode(), JSON.toJSONString(taskResult)); |
|||
} |
|||
continue; |
|||
} |
|||
//如果是多个场景 则为对个 BaseScanResult
|
|||
List<SceneDetailResult> sceneResults = taskResult.getResults(); |
|||
|
|||
boolean isSuccess = true; |
|||
for (SceneDetailResult sceneResult : sceneResults) { |
|||
String suggestion = sceneResult.getSuggestion(); |
|||
if (SuggestionEnum.BLOCK.getCode().equals(suggestion)) { |
|||
isSuccess = false; |
|||
break; |
|||
} |
|||
} |
|||
if (isSuccess) { |
|||
result.getSuccessDataIds().add(taskResult.getDataId()); |
|||
} else { |
|||
log.warn("executeSyncImg dataId:{} block:{}", taskResult.getDataId(), JSON.toJSONString(taskResult.getResults())); |
|||
result.getFailDataIds().add(taskResult.getDataId()); |
|||
} |
|||
} |
|||
return result; |
|||
} else { |
|||
log.warn("executeSyncImg detect not success. code:{}", scrResponse.getInteger(SysConstant.CODE)); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_RESP_CODE_ERROR.getCode(), SysResponseEnum.THIRD_PLATFORM_RESP_CODE_ERROR.getMsg() + ",status:" + httpResponse.getStatus()); |
|||
} |
|||
} else { |
|||
log.warn("executeSyncImg response status is not success. httpResponse:{}", JSON.toJSONString(httpResponse)); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_RESP_STATUS_ERROR.getCode(), SysResponseEnum.THIRD_PLATFORM_RESP_STATUS_ERROR.getMsg() + ",status:" + httpResponse.getStatus()); |
|||
} |
|||
} catch (Exception e) { |
|||
log.error("executeSyncImg exception IAcsClientUtil do action exception", e); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_SERVER_ERROR.getCode(), SysResponseEnum.THIRD_PLATFORM_SERVER_ERROR.getMsg()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @author yinzuomei |
|||
* @description 语音异步检测 |
|||
* @Date 2020/12/9 10:02 |
|||
*/ |
|||
@Override |
|||
public Result<VoiceAsyncScanTaskResult> sendVoiceAsyncScan(VoiceAsyncScanParam voiceAsyncScanParam) { |
|||
//检测对象不能为空,且最多支持100个元素
|
|||
List<VoiceTask> voiceTasks = voiceAsyncScanParam.getTasks(); |
|||
if (CollectionUtils.isEmpty(voiceTasks) || voiceTasks.size() > SysConstant.MAX_TASK_SIZE) { |
|||
return new Result<VoiceAsyncScanTaskResult>().error(SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getCode(), |
|||
SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getMsg().concat(SysConstant.MAX_TASK_SIZE.toString())); |
|||
} |
|||
|
|||
//默认参数
|
|||
voiceAsyncScanParam.setScenes(VoiceSceneEnum.getVoiceSceneList()); |
|||
voiceAsyncScanParam.setBizType(bizType); |
|||
// 如果是语音流检测,则修改为true。现在默认为音频文件检测false
|
|||
voiceAsyncScanParam.setLive(false); |
|||
voiceAsyncScanParam.setSeed(UUID.randomUUID().toString().replace("-", "")); |
|||
|
|||
VoiceAsyncScanRequest voiceAsyncScanRequest=getVoiceAsyncScanRequest(); |
|||
|
|||
try { |
|||
voiceAsyncScanRequest.setHttpContent(JSON.toJSONString(voiceAsyncScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON); |
|||
} catch (UnsupportedEncodingException e) { |
|||
log.error("sendVoiceAsyncScan parse param exception", e); |
|||
return new Result<VoiceAsyncScanTaskResult>().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg()); |
|||
} |
|||
log.info("语音异步检测入参:"+JSON.toJSONString(voiceAsyncScanParam,true)); |
|||
List<VoiceAsyncScanTaskDataDTO> taskList; |
|||
try { |
|||
taskList = executeSyncVoice(voiceAsyncScanRequest); |
|||
log.info("语音异步检测返参taskList:"+JSON.toJSONString(taskList,true)); |
|||
} catch (ExecuteHttpException e) { |
|||
log.error("sendVoiceAsyncScan execute Exception", e); |
|||
return new Result<VoiceAsyncScanTaskResult>().error(e.getCode(), e.getMsg()); |
|||
} |
|||
//成功返回
|
|||
VoiceAsyncScanTaskResult resultDto=new VoiceAsyncScanTaskResult(); |
|||
resultDto.setSeed(voiceAsyncScanParam.getSeed()); |
|||
List<VoiceAsyncScanTaskDataDTO> successList = new ArrayList<>(); |
|||
List<VoiceAsyncScanTaskDataDTO> failedList = new ArrayList<>(); |
|||
taskList.forEach(taskDetail -> { |
|||
if (HttpStatus.SC_OK == taskDetail.getCode()) { |
|||
successList.add(taskDetail); |
|||
} else { |
|||
failedList.add(taskDetail); |
|||
} |
|||
}); |
|||
resultDto.setSuccessTasks(successList); |
|||
resultDto.setFailTasks(failedList); |
|||
resultDto.setAllSuccess(resultDto.isAllSuccess()); |
|||
if (StringUtils.isNotBlank(voiceAsyncScanParam.getCallback())) { |
|||
// 存储seed和 任务id、dataId的关系 用于回调鉴权
|
|||
log.info("need to save seed and taskId、dataId的关系"); |
|||
ValueOperations valueOperations=redisTemplate.opsForValue(); |
|||
taskList.forEach(task -> { |
|||
String seedKey = RedisKeys.getVoiceScanSeedKey(task.getTaskId()); |
|||
valueOperations.set(seedKey,voiceAsyncScanParam.getSeed()); |
|||
}); |
|||
} |
|||
return new Result<VoiceAsyncScanTaskResult>().ok(resultDto); |
|||
} |
|||
|
|||
/** |
|||
* @param |
|||
* @author yinzuomei |
|||
* @description 构造语音异步检测请求对象 |
|||
* @Date 2020/12/9 10:44 |
|||
**/ |
|||
private VoiceAsyncScanRequest getVoiceAsyncScanRequest() { |
|||
VoiceAsyncScanRequest voiceAsyncScanRequest = new VoiceAsyncScanRequest(); |
|||
// 指定api返回格式
|
|||
voiceAsyncScanRequest.setAcceptFormat(FormatType.JSON); |
|||
// 指定请求方法
|
|||
voiceAsyncScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); |
|||
voiceAsyncScanRequest.setEncoding(SysConstant.UTF8); |
|||
voiceAsyncScanRequest.setRegionId(regionId); |
|||
voiceAsyncScanRequest.setConnectTimeout(3000); |
|||
voiceAsyncScanRequest.setReadTimeout(6000); |
|||
return voiceAsyncScanRequest; |
|||
} |
|||
|
|||
/** |
|||
* @param voiceAsyncScanRequest |
|||
* @author yinzuomei |
|||
* @description 解析返参 |
|||
* @Date 2020/12/9 10:44 |
|||
**/ |
|||
private List<VoiceAsyncScanTaskDataDTO> executeSyncVoice(AcsRequest<?> voiceAsyncScanRequest) { |
|||
try { |
|||
HttpResponse httpResponse = IAcsClientUtil.getIAcsClient().doAction(voiceAsyncScanRequest); |
|||
|
|||
if (httpResponse.isSuccess()) { |
|||
|
|||
JSONObject scrResponse = JSON.parseObject(new String(httpResponse.getHttpContent(), "UTF-8")); |
|||
//后面注释掉此日志
|
|||
log.info("VoiceAsyncScanRequest原生接口返参:" + JSON.toJSONString(scrResponse, true)); |
|||
|
|||
if (HttpStatus.SC_OK == scrResponse.getInteger(SysConstant.CODE)) { |
|||
|
|||
//获取data列表
|
|||
JSONArray dataResults = scrResponse.getJSONArray(SysConstant.DATA); |
|||
List<VoiceAsyncScanTaskDataDTO> resultList = dataResults.toJavaList(VoiceAsyncScanTaskDataDTO.class); |
|||
//成功返回
|
|||
return resultList; |
|||
|
|||
} else { |
|||
|
|||
log.warn("executeSyncVoice detect not success. code:{}", scrResponse.getInteger(SysConstant.CODE)); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_RESP_CODE_ERROR.getCode(), |
|||
SysResponseEnum.THIRD_PLATFORM_RESP_CODE_ERROR.getMsg() + ",status:" + httpResponse.getStatus()); |
|||
} |
|||
|
|||
} else { |
|||
log.warn("executeSyncVoice response status is not success. httpResponse:{}", JSON.toJSONString(httpResponse)); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_RESP_STATUS_ERROR.getCode(), |
|||
SysResponseEnum.THIRD_PLATFORM_RESP_STATUS_ERROR.getMsg() + ",status:" + httpResponse.getStatus()); |
|||
} |
|||
|
|||
} catch (Exception e) { |
|||
log.error("executeSyncVoice exception IAcsClientUtil do action exception", e); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_SERVER_ERROR.getCode(), SysResponseEnum.THIRD_PLATFORM_SERVER_ERROR.getMsg()); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* @param taskIds 要查询的异步检测任务的taskId列表。数组中的元素个数不超过100个 |
|||
* @author yinzuomei |
|||
* @description 语音异步检测结果查询 |
|||
* @Date 2020/12/9 11:17 |
|||
**/ |
|||
@Override |
|||
public Result<List<VoiceAsyncScanResult>> voiceResults(List<String> taskIds) { |
|||
//检测对象不能为空,且最多支持100个元素
|
|||
if (CollectionUtils.isEmpty(taskIds) || taskIds.size() > SysConstant.MAX_TASK_SIZE) { |
|||
return new Result<List<VoiceAsyncScanResult>>().error(SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getCode(), |
|||
SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getMsg().concat(SysConstant.MAX_TASK_SIZE.toString())); |
|||
} |
|||
|
|||
VoiceAsyncScanResultsRequest request=getVoiceAsyncScanResultsRequest(); |
|||
try { |
|||
request.setHttpContent(JSON.toJSONString(taskIds).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON); |
|||
} catch (UnsupportedEncodingException e) { |
|||
log.error("voiceResults parse param exception", e); |
|||
return new Result<List<VoiceAsyncScanResult>>().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg()); |
|||
} |
|||
|
|||
// log.info("语音异步检测结果查询入参:"+JSON.toJSONString(taskIds,true));
|
|||
|
|||
try { |
|||
HttpResponse httpResponse = IAcsClientUtil.getIAcsClient().doAction(request); |
|||
if (httpResponse.isSuccess()) { |
|||
|
|||
JSONObject scrResponse=JSON.parseObject(new String(httpResponse.getHttpContent(), "UTF-8")); |
|||
//后面注释掉此返参
|
|||
log.info("VoiceAsyncScanResultsRequest原生接口返参:"+JSON.toJSONString(scrResponse, true)); |
|||
if (HttpStatus.SC_OK == scrResponse.getInteger(SysConstant.CODE)) { |
|||
//获取data列表
|
|||
JSONArray dataResults = scrResponse.getJSONArray(SysConstant.DATA); |
|||
List<VoiceAsyncScanResult> resultList = dataResults.toJavaList(VoiceAsyncScanResult.class); |
|||
List<VoiceAsyncScanResult> resultData=processVoiceAsyncScanResult(resultList); |
|||
//成功返回
|
|||
return new Result<List<VoiceAsyncScanResult>>().ok(resultData); |
|||
|
|||
}else{ |
|||
|
|||
log.warn("voiceResults detect not success. code:{}", scrResponse.getInteger(SysConstant.CODE)); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_RESP_CODE_ERROR.getCode(), |
|||
SysResponseEnum.THIRD_PLATFORM_RESP_CODE_ERROR.getMsg() + ",status:" + httpResponse.getStatus()); |
|||
} |
|||
|
|||
} else { |
|||
log.warn("语音异步检测结果查询预警 getVoiceAsyncScanResult response status is not success. httpResponse:{}", JSON.toJSONString(httpResponse)); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_RESP_STATUS_ERROR.getCode(), |
|||
SysResponseEnum.THIRD_PLATFORM_RESP_STATUS_ERROR.getMsg() + ",status:" + httpResponse.getStatus()); |
|||
} |
|||
} catch (Exception e) { |
|||
log.error("voiceResults exception IAcsClientUtil do action exception", e); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_SERVER_ERROR.getCode(), SysResponseEnum.THIRD_PLATFORM_SERVER_ERROR.getMsg()); |
|||
} |
|||
|
|||
} |
|||
|
|||
private List<VoiceAsyncScanResult> processVoiceAsyncScanResult(List<VoiceAsyncScanResult> resultList) { |
|||
List<VoiceAsyncScanResult> list = new ArrayList<>(); |
|||
for (VoiceAsyncScanResult voiceAsyncScanResult : resultList) { |
|||
if (SysConstant.PROCESSING == voiceAsyncScanResult.getCode()) { |
|||
//280:表示处理中,需要继续轮询
|
|||
continue; |
|||
} |
|||
VoiceAsyncScanResult dto = ConvertUtils.sourceToTarget(voiceAsyncScanResult, VoiceAsyncScanResult.class); |
|||
if (HttpStatus.SC_OK == voiceAsyncScanResult.getCode()) { |
|||
if (!CollectionUtils.isEmpty(voiceAsyncScanResult.getResults()) && voiceAsyncScanResult.getResults().size() > NumConstant.ZERO) { |
|||
//目前只有一个检测场景,所以只判断返回来的第一个场景
|
|||
VoiceAsyncScanResultDTO voiceAsyncScanResultDTO = voiceAsyncScanResult.getResults().get(NumConstant.ZERO); |
|||
if (null != voiceAsyncScanResultDTO) { |
|||
dto.setLabel(voiceAsyncScanResultDTO.getLabel()); |
|||
dto.setLabelDesc(LabelEnum.getDesc(voiceAsyncScanResultDTO.getLabel())); |
|||
dto.setSuggestion(voiceAsyncScanResultDTO.getSuggestion()); |
|||
} |
|||
} |
|||
} else if(HttpStatus.SC_NOT_FOUND == voiceAsyncScanResult.getCode()) { |
|||
dto.setSuggestion(SuggestionEnum.REVIEW.getCode()); |
|||
dto.setLabel(NumConstant.EMPTY_STR); |
|||
dto.setLabelDesc("智能检测任务失败,结果已失效," + SuggestionEnum.REVIEW.getDesc()); |
|||
}else{ |
|||
//其他:表示任务失败
|
|||
dto.setSuggestion(SuggestionEnum.REVIEW.getCode()); |
|||
dto.setLabel(NumConstant.EMPTY_STR); |
|||
dto.setLabelDesc("智能检测任务失败," + SuggestionEnum.REVIEW.getDesc()); |
|||
} |
|||
list.add(dto); |
|||
} |
|||
return list; |
|||
} |
|||
|
|||
private VoiceAsyncScanResultsRequest getVoiceAsyncScanResultsRequest(){ |
|||
VoiceAsyncScanResultsRequest getResultsRequest = new VoiceAsyncScanResultsRequest(); |
|||
// 指定API返回格式。
|
|||
getResultsRequest.setAcceptFormat(FormatType.JSON); |
|||
// 指定请求方法。
|
|||
getResultsRequest.setMethod(com.aliyuncs.http.MethodType.POST); |
|||
getResultsRequest.setEncoding(SysConstant.UTF8); |
|||
getResultsRequest.setRegionId(regionId); |
|||
/** |
|||
* 请务必设置超时时间。 |
|||
*/ |
|||
getResultsRequest.setConnectTimeout(3000); |
|||
getResultsRequest.setReadTimeout(6000); |
|||
return getResultsRequest; |
|||
} |
|||
|
|||
/** |
|||
* desc:视频检测-异步检测 |
|||
* |
|||
* @param videoAsyncScanParam |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public Result<VideoAsyncScanTaskResultDTO> videoAsyncScan(VideoAsyncScanParam videoAsyncScanParam) { |
|||
//一次至多提交100个检测对象
|
|||
List<VideoAsyncScanTask> videoTasks = videoAsyncScanParam.getTasks(); |
|||
if (CollectionUtils.isEmpty(videoTasks) || videoTasks.size() > SysConstant.MAX_TASK_SIZE) { |
|||
return new Result<VideoAsyncScanTaskResultDTO>().error(SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_TASK_LIST_PARAM_ERROR.getMsg().concat(SysConstant.MAX_TASK_SIZE.toString())); |
|||
} |
|||
//默认参数赋值
|
|||
videoAsyncScanParam.setScenes(VideoSceneEnum.getVideoSceneList()); |
|||
videoAsyncScanParam.setBizType(bizType); |
|||
videoAsyncScanParam.setAudioScenes(VoiceSceneEnum.getVoiceSceneList()); |
|||
videoAsyncScanParam.setSeed(UUID.randomUUID().toString().replace("-", "")); |
|||
//API文档没写限制多少最大多少,应该与图片一致
|
|||
if (videoTasks.size() <= SysConstant.MAX_SCAN_IMG_TASK_SIZE) { |
|||
return doScanVideo(videoAsyncScanParam); |
|||
} |
|||
log.info("videoAsyncScan tasks size:{} over 10", videoTasks.size()); |
|||
//分组调用,一次提交10个
|
|||
List<List<VideoAsyncScanTask>> partition = ListUtils.partition(videoTasks, SysConstant.MAX_SCAN_IMG_TASK_SIZE); |
|||
VideoAsyncScanTaskResultDTO finalResult = new VideoAsyncScanTaskResultDTO(); |
|||
for (List<VideoAsyncScanTask> tasks : partition) { |
|||
VideoAsyncScanParam videParam = new VideoAsyncScanParam(); |
|||
videParam.setBizType(videoAsyncScanParam.getBizType()); |
|||
videParam.setScenes(videoAsyncScanParam.getScenes()); |
|||
videParam.setTasks(tasks); |
|||
videParam.setCallback(videoAsyncScanParam.getCallback()); |
|||
videParam.setSeed(videoAsyncScanParam.getSeed()); |
|||
videParam.setAudioScenes(videoAsyncScanParam.getAudioScenes()); |
|||
Result<VideoAsyncScanTaskResultDTO> partResult = doScanVideo(videParam); |
|||
try { |
|||
Thread.sleep(5L); |
|||
} catch (InterruptedException e) { |
|||
log.error("videoAsyncScan InterruptedException"); |
|||
} |
|||
if (partResult.success()) { |
|||
VideoAsyncScanTaskResultDTO data = partResult.getData(); |
|||
finalResult.setSeed(data.getSeed()); |
|||
finalResult.getSuccessTasks().addAll(data.getSuccessTasks()); |
|||
finalResult.getFailTasks().addAll(data.getFailTasks()); |
|||
} else { |
|||
return partResult; |
|||
} |
|||
} |
|||
return new Result<VideoAsyncScanTaskResultDTO>().ok(finalResult); |
|||
} |
|||
|
|||
private Result<VideoAsyncScanTaskResultDTO> doScanVideo(VideoAsyncScanParam videoAsyncScanParam) { |
|||
VideoAsyncScanRequest videoAsyncScanRequest = getVideoAsyncScanRequest(); |
|||
try { |
|||
videoAsyncScanRequest.setHttpContent(JSON.toJSONString(videoAsyncScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON); |
|||
} catch (UnsupportedEncodingException e) { |
|||
log.error("doScanVideo parse param exception", e); |
|||
return new Result<VideoAsyncScanTaskResultDTO>().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg()); |
|||
} |
|||
|
|||
try { |
|||
VideoAsyncScanTaskResultDTO scanResult = executeAsyncVideo(videoAsyncScanRequest); |
|||
scanResult.setSeed(videoAsyncScanParam.getSeed()); |
|||
return new Result<VideoAsyncScanTaskResultDTO>().ok(scanResult); |
|||
} catch (ExecuteHttpException e) { |
|||
log.error("doScanVideo execute exception,param:{},fail msg:{}", JSON.toJSONString(videoAsyncScanParam), e.getMsg()); |
|||
return new Result<VideoAsyncScanTaskResultDTO>().error(e.getCode(), e.getMsg()); |
|||
} |
|||
} |
|||
|
|||
private VideoAsyncScanRequest getVideoAsyncScanRequest() { |
|||
VideoAsyncScanRequest videoAsyncScanRequest = new VideoAsyncScanRequest(); |
|||
videoAsyncScanRequest.setAcceptFormat(FormatType.JSON); // 指定API返回格式。
|
|||
videoAsyncScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法。
|
|||
/** |
|||
* 请务必设置超时时间。 |
|||
*/ |
|||
videoAsyncScanRequest.setConnectTimeout(3000); |
|||
videoAsyncScanRequest.setReadTimeout(6000); |
|||
return videoAsyncScanRequest; |
|||
} |
|||
|
|||
private VideoAsyncScanTaskResultDTO executeAsyncVideo(VideoAsyncScanRequest videoAsyncScanRequest) { |
|||
try { |
|||
HttpResponse httpResponse = IAcsClientUtil.getIAcsClient().doAction(videoAsyncScanRequest); |
|||
if (httpResponse.isSuccess()) { |
|||
JSONObject scrResponse = JSON.parseObject(new String(httpResponse.getHttpContent(), "UTF-8")); |
|||
if (HttpStatus.SC_OK == scrResponse.getInteger(SysConstant.CODE)) { |
|||
//获取data列表
|
|||
JSONArray dataResults = scrResponse.getJSONArray(SysConstant.DATA); |
|||
List<VideoAsyncScanTaskDataDTO> dataList = dataResults.toJavaList(VideoAsyncScanTaskDataDTO.class); |
|||
VideoAsyncScanTaskResultDTO result=new VideoAsyncScanTaskResultDTO(); |
|||
dataList.forEach(data->{ |
|||
if (HttpStatus.SC_OK == data.getCode()) { |
|||
result.getSuccessTasks().add(data); |
|||
} else { |
|||
result.getFailTasks().add(data); |
|||
} |
|||
}); |
|||
return result; |
|||
} else { |
|||
log.warn("executeAsyncVideo detect not success. code:{}", scrResponse.getInteger(SysConstant.CODE)); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_RESP_CODE_ERROR.getCode(), |
|||
SysResponseEnum.THIRD_PLATFORM_RESP_CODE_ERROR.getMsg() + ",status:" + httpResponse.getStatus()); |
|||
} |
|||
} else { |
|||
log.warn("executeAsyncVideo response status is not success. httpResponse:{}", JSON.toJSONString(httpResponse)); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_RESP_STATUS_ERROR.getCode(), |
|||
SysResponseEnum.THIRD_PLATFORM_RESP_STATUS_ERROR.getMsg() + ",status:" + httpResponse.getStatus()); |
|||
} |
|||
} catch (Exception e) { |
|||
log.error("executeAsyncVideo exception IAcsClientUtil do action exception", e); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_SERVER_ERROR.getCode(), SysResponseEnum.THIRD_PLATFORM_SERVER_ERROR.getMsg()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @param taskIds |
|||
* @author yinzuomei |
|||
* @description 视频异步检测结果查询接口 |
|||
* @Date 2020/12/29 16:10 |
|||
**/ |
|||
@Override |
|||
public Result<VideoResultDTO> videoResults(List<String> taskIds) { |
|||
VideoAsyncScanResultsRequest videoAsyncScanResultsRequest = new VideoAsyncScanResultsRequest(); |
|||
videoAsyncScanResultsRequest.setAcceptFormat(FormatType.JSON); |
|||
videoAsyncScanResultsRequest.setMethod(com.aliyuncs.http.MethodType.POST); |
|||
videoAsyncScanResultsRequest.setConnectTimeout(3000); |
|||
videoAsyncScanResultsRequest.setReadTimeout(6000); |
|||
try { |
|||
videoAsyncScanResultsRequest.setHttpContent(JSON.toJSONString(taskIds).getBytes("UTF-8"), "UTF-8", FormatType.JSON); |
|||
} catch (UnsupportedEncodingException e) { |
|||
log.error("videoResults parse param exception", e); |
|||
return new Result<VideoResultDTO>().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg()); |
|||
} |
|||
try { |
|||
HttpResponse httpResponse = IAcsClientUtil.getIAcsClient().doAction(videoAsyncScanResultsRequest); |
|||
if (httpResponse.isSuccess()) { |
|||
JSONObject responseObject = JSON.parseObject(new String(httpResponse.getHttpContent(), "UTF-8")); |
|||
log.info("查询视频检测结果返参"+JSON.toJSONString(responseObject)); |
|||
if (HttpStatus.SC_OK == responseObject.getInteger(SysConstant.CODE)) { |
|||
//获取data列表
|
|||
JSONArray dataResults = responseObject.getJSONArray(SysConstant.DATA); |
|||
List<VideoScanOriginalResultDTO> resultList = dataResults.toJavaList(VideoScanOriginalResultDTO.class); |
|||
//解析数据
|
|||
VideoResultDTO resultDTO = processVideoResults(resultList); |
|||
//成功返回
|
|||
return new Result<VideoResultDTO>().ok(resultDTO); |
|||
} else { |
|||
log.warn("查询视频检测结果,接口返回code=" + responseObject.getInteger(SysConstant.CODE)); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_RESP_CODE_ERROR.getCode(), |
|||
SysResponseEnum.THIRD_PLATFORM_RESP_CODE_ERROR.getMsg() + ",status:" + httpResponse.getStatus()); |
|||
} |
|||
} else { |
|||
log.warn("查询视频检测结果,API返回失败"); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_RESP_STATUS_ERROR.getCode(), |
|||
SysResponseEnum.THIRD_PLATFORM_RESP_STATUS_ERROR.getMsg() + ",status:" + httpResponse.getStatus()); |
|||
} |
|||
} catch (Exception e) { |
|||
log.error("videoResults exception ", e); |
|||
throw new ExecuteHttpException(SysResponseEnum.THIRD_PLATFORM_SERVER_ERROR.getCode(), SysResponseEnum.THIRD_PLATFORM_SERVER_ERROR.getMsg()); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @author yinzuomei |
|||
* @description |
|||
**/ |
|||
private VideoResultDTO processVideoResults(List<VideoScanOriginalResultDTO> resultList) { |
|||
VideoResultDTO videoResultDTO = new VideoResultDTO(); |
|||
resultList.forEach(result -> { |
|||
result.setCodeDesc(CommonErrorCodeEnum.getErrorMsg(result.getCode())); |
|||
if (result.getCode().equals(CommonErrorCodeEnum.PROCESSING.getCode())) { |
|||
//任务正在检测中,继续轮询
|
|||
} else if (result.getCode().equals(CommonErrorCodeEnum.OK.getCode())) { |
|||
//成功=>分析结果
|
|||
boolean videoPassFlag = getVideoFlag(result.getResults()); |
|||
boolean voicePassFlag = getVoiceFlag(result.getAudioScanResults()); |
|||
if (videoPassFlag && voicePassFlag) { |
|||
videoResultDTO.getPassDataIds().add(result.getDataId()); |
|||
videoResultDTO.getPassTaskIds().add(result.getTaskId()); |
|||
} else { |
|||
videoResultDTO.getNoPassDataIds().add(result.getDataId()); |
|||
videoResultDTO.getNoPassTaskIds().add(result.getTaskId()); |
|||
} |
|||
} else { |
|||
//检测结果走丢了.... (*^▽^*) 默认失败
|
|||
videoResultDTO.getNoPassDataIds().add(result.getDataId()); |
|||
videoResultDTO.getNoPassTaskIds().add(result.getTaskId()); |
|||
} |
|||
}); |
|||
videoResultDTO.setDetails(resultList); |
|||
return videoResultDTO; |
|||
} |
|||
|
|||
/** |
|||
* @return boolean |
|||
* @author yinzuomei |
|||
* @description 视频检测结果判断 |
|||
**/ |
|||
private boolean getVideoFlag(List<VideoScanOriginDetail> results) { |
|||
for(VideoScanOriginDetail videoRes:results){ |
|||
if (!SuggestionEnum.PASS.getCode().equals(videoRes.getSuggestion())) { |
|||
return false; |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* @return boolean true:内容通过; 建议为内容违规或者需要人工审核的统一视为不通过,返回false |
|||
* @author yinzuomei |
|||
* @description 返回视频语音检测结果 |
|||
**/ |
|||
private boolean getVoiceFlag(List<VoiceAsyncScanResultDTO> audioScanResults) { |
|||
if (CollectionUtils.isEmpty(audioScanResults)) { |
|||
return true; |
|||
} |
|||
for(VoiceAsyncScanResultDTO m:audioScanResults){ |
|||
//人工审核或者内容违规,统一视为不通过
|
|||
if (!SuggestionEnum.PASS.getCode().equals(m.getSuggestion())) { |
|||
return false; |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
} |
@ -1,48 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.param; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.Valid; |
|||
import javax.validation.constraints.NotEmpty; |
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 审查参数 |
|||
* |
|||
* @author jianjun liu |
|||
* @date 2020-06-04 21:57 |
|||
**/ |
|||
@Data |
|||
public class ImgScanParam implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 958801658335909745L; |
|||
/** |
|||
* 业务类型 |
|||
*/ |
|||
private String bizType; |
|||
/** |
|||
* 场景 必填 |
|||
* |
|||
* @see com.epmet.openapi.scan.common.enu.ImgSceneEnum; |
|||
*/ |
|||
private List<String> scenes; |
|||
|
|||
/** |
|||
* 要检测的内容列表,必填 |
|||
* remark:一组任务列表中的taskId不能相同 |
|||
*/ |
|||
@Valid |
|||
@NotEmpty(message = "任务列表不能为空") |
|||
private List<ImgTask> tasks; |
|||
|
|||
/** |
|||
* 异步检测结果回调地址,执行异步审查内容时 必填 |
|||
*/ |
|||
private String callback; |
|||
|
|||
/** |
|||
* 随机字符串,该值用于回调通知请求中的签名,使用callback时 必填 |
|||
*/ |
|||
private String seed; |
|||
} |
@ -1,31 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.param; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 任务参数 |
|||
* |
|||
* @author jianjun liu |
|||
* @email liujianjun@yunzongnet.com |
|||
* @date 2020-06-04 22:13 |
|||
**/ |
|||
@Data |
|||
public class ImgTask implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -747206284930578105L; |
|||
/** |
|||
* 要检测的数据id 非必填 |
|||
* |
|||
* */ |
|||
@NotBlank(message = "dataId不能为空") |
|||
private String dataId; |
|||
|
|||
/** |
|||
* 图片url 必填 |
|||
*/ |
|||
@NotBlank(message = "图片URL不能为空") |
|||
private String url; |
|||
} |
@ -1,48 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.param; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.Valid; |
|||
import javax.validation.constraints.NotEmpty; |
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 文本审查参数 |
|||
* |
|||
* @author jianjun liu |
|||
* @date 2020-06-05 11:17 |
|||
**/ |
|||
@Data |
|||
public class TextScanParam implements Serializable { |
|||
private static final long serialVersionUID = -3568903097975113166L; |
|||
|
|||
/** |
|||
* 业务类型 |
|||
*/ |
|||
private String bizType; |
|||
/** |
|||
* 场景 必填 |
|||
* |
|||
* @see com.epmet.openapi.scan.common.enu.ImgSceneEnum; |
|||
*/ |
|||
private List<String> scenes; |
|||
|
|||
/** |
|||
* 要检测的内容列表,必填 |
|||
* remark:一组任务列表中的taskId不能相同 |
|||
*/ |
|||
@Valid |
|||
@NotEmpty(message = "任务列表不能为空") |
|||
private List<TextTask> tasks; |
|||
|
|||
/** |
|||
* 异步检测结果回调地址,执行异步审查内容时 必填 |
|||
*/ |
|||
private String callback; |
|||
|
|||
/** |
|||
* 随机字符串,该值用于回调通知请求中的签名,使用callback时 必填 |
|||
*/ |
|||
private String seed; |
|||
} |
@ -1,33 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.param; |
|||
|
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 任务参数 |
|||
* |
|||
* @author jianjun liu |
|||
* @email liujianjun@yunzongnet.com |
|||
* @date 2020-06-04 22:13 |
|||
**/ |
|||
@Data |
|||
public class TextTask implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 6957195274696018630L; |
|||
/** |
|||
* 要检测的数据id 非必填 |
|||
* |
|||
* */ |
|||
@NotBlank(message = "dataId不能为空") |
|||
private String dataId; |
|||
|
|||
/** |
|||
* 文本内容 必填 最多不能超过10000 |
|||
*/ |
|||
@NotBlank(message = "待检测文本不能为空") |
|||
@Length(max = 10000,message = "待检测文本最大为10000") |
|||
private String content; |
|||
} |
@ -1,68 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.param; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.Valid; |
|||
import javax.validation.constraints.NotEmpty; |
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 音频审查 入参 |
|||
* 参考文档:https://help.aliyun.com/document_detail/89630.html?spm=a2c4g.11186623.2.12.51a32dbfW6AdqV#reference-bcf-3nk-z2b
|
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/9 9:07 |
|||
*/ |
|||
@Data |
|||
public class VoiceAsyncScanParam implements Serializable { |
|||
private static final long serialVersionUID = 3408043673247901184L; |
|||
|
|||
/** |
|||
* 是否开启回调 |
|||
*/ |
|||
private Boolean openCallBack; |
|||
|
|||
/** |
|||
* 不必填 |
|||
* 该字段用于标识您的业务场景。您可以通过内容安全控制台创建业务场景(具体操作,请参见自定义机审标准),或者提交工单联系我们帮助您创建业务场景。 |
|||
*/ |
|||
private String bizType; |
|||
|
|||
/** |
|||
* 必填 |
|||
* 检测场景,取值:antispam。 |
|||
*/ |
|||
private List<String> scenes; |
|||
|
|||
/** |
|||
* 不必填 |
|||
* 是否为语音流(例如直播流)检测。取值: |
|||
* true:表示语音流检测。 |
|||
* false(默认):表示音频文件检测。 |
|||
*/ |
|||
private Boolean live; |
|||
|
|||
/** |
|||
* 不必填 |
|||
* 是否为近线检测模式。 取值: |
|||
* true:表示近线检测模式。近线检测模式下,您提交的任务不保证能够实时处理,但是可以排队并在24小时内开始检测。 |
|||
* false(默认):表示实时检测模式。对于超过了并发路数限制的检测请求会直接拒绝。 |
|||
* 说明 该参数仅适用于音频文件检测,不适用于语音流检测。 |
|||
*/ |
|||
private Boolean offline; |
|||
|
|||
/** |
|||
* 异步检测结果回调地址,执行异步审查内容时 必填 |
|||
*/ |
|||
private String callback; |
|||
|
|||
/** |
|||
* 随机字符串,该值用于回调通知请求中的签名,使用callback时 必填 |
|||
*/ |
|||
private String seed; |
|||
|
|||
@Valid |
|||
@NotEmpty(message = "任务列表不能为空") |
|||
private List<VoiceTask> tasks; |
|||
|
|||
} |
@ -1,31 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.param; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 语音异步检测 对象 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/9 10:16 |
|||
*/ |
|||
@Data |
|||
public class VoiceTask implements Serializable { |
|||
/** |
|||
* 不必填 |
|||
* 要检测的数据id 非必填 |
|||
* 检测对象对应的数据ID。 |
|||
* 由大小写英文字母、数字、下划线(_)、短划线(-)、英文句号(.)组成,不超过128个字符,可以用于唯一标识您的业务数据。 |
|||
* */ |
|||
@NotBlank(message = "dataId不能为空") |
|||
private String dataId; |
|||
|
|||
/** |
|||
* 必填 |
|||
* 需要检测的音频文件或语音流的下载地址。 |
|||
*/ |
|||
@NotBlank(message = "音频URL不能为空") |
|||
private String url; |
|||
} |
@ -1,76 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.param.video; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotEmpty; |
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 视频审核-异步检测入参DTO |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
*/ |
|||
@Data |
|||
public class VideoAsyncScanParam implements Serializable { |
|||
private static final long serialVersionUID = -7635290200099445362L; |
|||
|
|||
/** |
|||
* 是否开启回调 |
|||
*/ |
|||
private Boolean openCallBack; |
|||
|
|||
/** |
|||
* 不必填 |
|||
* 该字段用于标识您的业务场景。您可以通过内容安全控制台创建业务场景(具体操作,请参见自定义机审标准),或者提交工单联系我们帮助您创建业务场景。 |
|||
*/ |
|||
private String bizType; |
|||
|
|||
/** |
|||
* 不必填 |
|||
* 是否为语音流(例如直播流)检测。取值: |
|||
* true:表示语音流检测。 |
|||
* false(默认):表示音频文件检测。 |
|||
*/ |
|||
private Boolean live; |
|||
|
|||
/** |
|||
* 不必填 |
|||
* 是否为近线检测模式。 取值: |
|||
* true:表示近线检测模式。近线检测模式下,您提交的任务不保证能够实时处理,但是可以排队并在24小时内开始检测。 |
|||
* false(默认):表示实时检测模式。对于超过了并发路数限制的检测请求会直接拒绝。 |
|||
* 说明 该参数仅适用于音频文件检测,不适用于语音流检测。 |
|||
*/ |
|||
private Boolean offline; |
|||
|
|||
/** |
|||
* 必填 |
|||
* 指定视频检测场景。取值: |
|||
* porn:视频智能鉴黄 |
|||
* terrorism:视频暴恐涉政 |
|||
* live:视频不良场景 |
|||
* logo:视频logo |
|||
* ad:视频图文违规 |
|||
*/ |
|||
private List<String> scenes; |
|||
|
|||
/** |
|||
* 不必填 |
|||
* 指定视频语音检测场景,唯一取值:antispam,表示语音反垃圾。不传入该参数时仅检测视频图像内容;如果传入该参数,则在检测视频中图像的同时,对视频中语音进行检测。 |
|||
* 说明 如果需要检测视频语音,则不支持通过上传视频截帧序列的方式(即在task中传入frames)进行检测,您必须传入视频或视频流的URL地址(即在task中传入url)进行检测。 |
|||
*/ |
|||
private List<String> audioScenes; |
|||
|
|||
/** |
|||
* 异步检测结果回调地址,执行异步审查内容时 必填 |
|||
*/ |
|||
private String callback; |
|||
|
|||
/** |
|||
* 随机字符串,该值用于回调通知请求中的签名,使用callback时 必填 |
|||
*/ |
|||
private String seed; |
|||
|
|||
@NotEmpty(message = "检测对象不能为空") |
|||
private List<VideoAsyncScanTask> tasks; |
|||
} |
@ -1,30 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.param.video; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 视频审核-异步检测入参-检测对象 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
*/ |
|||
@Data |
|||
public class VideoAsyncScanTask implements Serializable { |
|||
/** |
|||
* 建议必填 |
|||
* 要检测的数据id 非必填 |
|||
* 检测对象对应的数据ID。 |
|||
* 由大小写英文字母、数字、下划线(_)、短划线(-)、英文句号(.)组成,不超过128个字符,可以用于唯一标识您的业务数据。 |
|||
* */ |
|||
@NotBlank(message = "dataId不能为空") |
|||
private String dataId; |
|||
|
|||
/** |
|||
* 必填 |
|||
* 待检测视频的URL。该字段不能和frames同时为空,也不能和frames同时有值。 |
|||
*/ |
|||
@NotBlank(message = "音频URL不能为空") |
|||
private String url; |
|||
} |
@ -1,24 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 检测结果 |
|||
* |
|||
* @author jianjun liu |
|||
* @email liujianjun@yunzongnet.com |
|||
* @date 2020-06-05 10:52 |
|||
**/ |
|||
@Data |
|||
public class ImgAsyncScanResult { |
|||
/** |
|||
* 执行成功的任务Id集合 |
|||
*/ |
|||
private List<String> successTaskIds; |
|||
/** |
|||
* 执行失败的任务Id集合 |
|||
*/ |
|||
private List<String> failTaskIds; |
|||
} |
@ -1,28 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* desc:文本检测返回结果 |
|||
* @author jianjun liu |
|||
* @email liujianjun@yunzongnet.com |
|||
* @date 2020-06-05 14:24 |
|||
**/ |
|||
@Data |
|||
public class ScanTaskResult implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -7905091710384256911L; |
|||
private Integer code; |
|||
|
|||
|
|||
private String msg; |
|||
|
|||
|
|||
private String dataId; |
|||
|
|||
|
|||
private List<SceneDetailResult> results; |
|||
} |
@ -1,31 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* desc:场景扫描结果 |
|||
* @author jianjun liu |
|||
* @date 2020-06-05 14:24 |
|||
**/ |
|||
@Data |
|||
public class SceneDetailResult { |
|||
/** |
|||
* 结果为该分类的概率 |
|||
*/ |
|||
private Double rate; |
|||
|
|||
/** |
|||
* 建议用户执行的操作 |
|||
*/ |
|||
private String suggestion; |
|||
|
|||
/** |
|||
* 场景 |
|||
*/ |
|||
private String scene; |
|||
|
|||
/** |
|||
* 标签 |
|||
*/ |
|||
private String label; |
|||
} |
@ -1,42 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 检测结果 |
|||
* |
|||
* @author jianjun liu |
|||
* @date 2020-06-05 10:52 |
|||
**/ |
|||
@Data |
|||
public class SyncScanResult implements Serializable { |
|||
/** |
|||
* 执行成功的任务Id集合 |
|||
*/ |
|||
private List<String> successDataIds = new ArrayList<>(); |
|||
/** |
|||
* 执行失败的任务Id集合 |
|||
*/ |
|||
private List<String> failDataIds = new ArrayList<>(); |
|||
|
|||
/** |
|||
* desc:检测详情 |
|||
*/ |
|||
private List<ScanTaskResult> details = new ArrayList<>(); |
|||
|
|||
/** |
|||
* 本地是否全部通过 |
|||
*/ |
|||
private boolean isAllPass; |
|||
|
|||
public boolean isAllPass() { |
|||
if (failDataIds.isEmpty() && !successDataIds.isEmpty()) { |
|||
return true; |
|||
} |
|||
return isAllPass; |
|||
} |
|||
} |
@ -1,47 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 语音异步检测结果查询结果返参 -data-result-detail详情 |
|||
* 语音对应的文本详情。每一句文本对应一个元素,包含一个或者多个元素。关于每个元素的结构描述 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/9 11:11 |
|||
*/ |
|||
@Data |
|||
public class VoiceAsyncScanDetailDTO implements Serializable { |
|||
private static final long serialVersionUID = -2664219492371705160L; |
|||
/** |
|||
* 句子开始的时间,单位:秒。 |
|||
*/ |
|||
private Integer startTime; |
|||
|
|||
/** |
|||
* 句子结束的时间,单位:秒。 |
|||
*/ |
|||
private Integer endTime; |
|||
|
|||
/** |
|||
* 语音转换成文本的结果。 |
|||
*/ |
|||
private String text; |
|||
|
|||
/** |
|||
* 检测结果的分类。取值: |
|||
* normal:正常文本 |
|||
* spam:含垃圾信息 |
|||
* ad:广告 |
|||
* politics:涉政 |
|||
* terrorism:暴恐 |
|||
* abuse:辱骂 |
|||
* porn:色情 |
|||
* flood:灌水 |
|||
* contraband:违禁 |
|||
* meaningless:无意义 |
|||
* customized:自定义(例如命中自定义关键词) |
|||
*/ |
|||
private String label; |
|||
} |
@ -1,89 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.result; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 语音异步检测结果查询结果返参 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/9 10:56 |
|||
*/ |
|||
@Data |
|||
public class VoiceAsyncScanResult implements Serializable { |
|||
private static final long serialVersionUID = 8702129292884498023L; |
|||
|
|||
/** |
|||
* 检测对象对应的数据ID。 |
|||
*/ |
|||
private String dataId; |
|||
|
|||
/** |
|||
* 检测任务的ID |
|||
*/ |
|||
private String taskId; |
|||
|
|||
/** |
|||
* 检测结果的分类。取值: |
|||
* normal:正常文本 |
|||
* spam:含垃圾信息 |
|||
* ad:广告 |
|||
* politics:涉政 |
|||
* terrorism:暴恐 |
|||
* abuse:辱骂 |
|||
* porn:色情 |
|||
* flood:灌水 |
|||
* contraband:违禁 |
|||
* meaningless:无意义 |
|||
* customized:自定义(例如命中自定义关键词) |
|||
*/ |
|||
private String label; |
|||
|
|||
/** |
|||
* labelDesc是对label的说明,包含两种特殊说明: |
|||
* (1)如果检测任务失败labelDesc:智能检测任务失败,结果已失效,需要人工审核 |
|||
* (2)如果检测结果失效labelDesc:智能检测任务失败,需要人工审核 |
|||
*/ |
|||
private String labelDesc; |
|||
|
|||
/** |
|||
* 建议您执行的后续操作。取值: |
|||
* pass:结果正常,无需进行其余操作。 |
|||
* review:结果不确定,需要进行人工审核。 |
|||
* block:结果违规,建议直接删除或者限制公开。 |
|||
*/ |
|||
private String suggestion; |
|||
|
|||
|
|||
/** |
|||
* 错误码,和HTTP状态码一致。 |
|||
* 200:表示检测成功。 |
|||
* 280:表示处理中,需要继续轮询。 |
|||
* 其他:表示任务失败。 |
|||
* 更多信息,请参见公共错误码。 |
|||
*/ |
|||
@JsonIgnore |
|||
private Integer code; |
|||
/** |
|||
* 错误描述信息。 |
|||
*/ |
|||
@JsonIgnore |
|||
private String msg; |
|||
|
|||
/** |
|||
* 暂时没用,所以返回忽略 |
|||
*/ |
|||
@JsonIgnore |
|||
private String url; |
|||
|
|||
/** |
|||
* 检测成功(code=200)时,返回的检测结果。该结果包含一个或多个元素,每个元素是个结构体,对应一个场景。关于每个元素的结构描述,请参见result。 |
|||
* 暂时不展示审核结果明细 |
|||
*/ |
|||
@JsonIgnore |
|||
private List<VoiceAsyncScanResultDTO> results; |
|||
|
|||
} |
@ -1,57 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 语音异步检测结果查询结果返参 -data-result详情 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/9 11:07 |
|||
*/ |
|||
@Data |
|||
public class VoiceAsyncScanResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 4602226363259983753L; |
|||
/** |
|||
* 检测场景,和调用请求中的场景对应。取值:antispam。 |
|||
*/ |
|||
private String scene; |
|||
|
|||
/** |
|||
* 检测结果的分类。取值: |
|||
* normal:正常文本 |
|||
* spam:含垃圾信息 |
|||
* ad:广告 |
|||
* politics:涉政 |
|||
* terrorism:暴恐 |
|||
* abuse:辱骂 |
|||
* porn:色情 |
|||
* flood:灌水 |
|||
* contraband:违禁 |
|||
* meaningless:无意义 |
|||
* customized:自定义(例如命中自定义关键词) |
|||
*/ |
|||
private String label; |
|||
|
|||
/** |
|||
* 建议您执行的后续操作。取值: |
|||
* pass:结果正常,无需进行其余操作。 |
|||
* review:结果不确定,需要进行人工审核。 |
|||
* block:结果违规,建议直接删除或者限制公开。 |
|||
*/ |
|||
private String suggestion; |
|||
|
|||
/** |
|||
* 置信度分数,取值范围:0(表示置信度最低)~100(表示置信度最高)。 |
|||
* 如果suggestion为pass,则置信度越高,表示内容正常的可能性越高;如果suggestion为review或block,则置信度越高,表示内容违规的可能性越高。 |
|||
* 注意 该值仅作为参考,强烈建议您不要在业务中使用。建议您参考suggestion和label(或者部分接口返回的sublabel)结果用于内容违规判定。 |
|||
*/ |
|||
private Float rate; |
|||
|
|||
/** |
|||
* 语音对应的文本详情。每一句文本对应一个元素,包含一个或者多个元素。关于每个元素的结构描述, |
|||
*/ |
|||
private List<VoiceAsyncScanDetailDTO> details; |
|||
} |
@ -1,40 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.result; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 语音异步检测,返回检测对象列表 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/9 16:38 |
|||
*/ |
|||
@Data |
|||
public class VoiceAsyncScanTaskDataDTO implements Serializable { |
|||
/** |
|||
* 错误码,和HTTP状态码一致。 |
|||
* 更多信息,请参见公共错误码。 |
|||
*/ |
|||
private Integer code; |
|||
/** |
|||
* 错误描述信息。 |
|||
*/ |
|||
private String msg; |
|||
/** |
|||
* 检测对象对应的数据ID。 |
|||
*/ |
|||
private String dataId; |
|||
|
|||
/** |
|||
* 检测任务的ID |
|||
*/ |
|||
private String taskId; |
|||
|
|||
/** |
|||
* 暂时没用,所以返回忽略 |
|||
*/ |
|||
@JsonIgnore |
|||
private String url; |
|||
} |
@ -1,46 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 语音异步检测,返参 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/9 9:23 |
|||
*/ |
|||
@Data |
|||
public class VoiceAsyncScanTaskResult implements Serializable { |
|||
private static final long serialVersionUID = 8702129292884498023L; |
|||
/** |
|||
* 随机字符串,该值用于回调通知请求中的签名。 |
|||
*/ |
|||
private String seed; |
|||
|
|||
/** |
|||
* 提交成功的失败对象 |
|||
*/ |
|||
private List<VoiceAsyncScanTaskDataDTO> successTasks=new ArrayList<>(); |
|||
|
|||
/** |
|||
* 提交失败的检测对象 |
|||
*/ |
|||
private List<VoiceAsyncScanTaskDataDTO> failTasks=new ArrayList<>(); |
|||
|
|||
/** |
|||
* 是否全部提交成功 |
|||
*/ |
|||
private boolean isAllSuccess; |
|||
|
|||
public boolean isAllSuccess() { |
|||
if (failTasks.isEmpty() && !successTasks.isEmpty()) { |
|||
return true; |
|||
} |
|||
return isAllSuccess; |
|||
} |
|||
|
|||
|
|||
} |
@ -1,41 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.result.video; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 视频审核-异步检测任务提交返参详情 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/29 13:42 |
|||
*/ |
|||
@Data |
|||
public class VideoAsyncScanTaskDataDTO implements Serializable { |
|||
private static final long serialVersionUID = 8430710131685814181L; |
|||
/** |
|||
* 错误码,和HTTP状态码一致。 |
|||
* 更多信息,请参见公共错误码。 |
|||
*/ |
|||
private Integer code; |
|||
/** |
|||
* 错误描述信息。 |
|||
*/ |
|||
private String msg; |
|||
/** |
|||
* 检测对象对应的数据ID。 |
|||
*/ |
|||
private String dataId; |
|||
|
|||
/** |
|||
* 检测任务的ID |
|||
*/ |
|||
private String taskId; |
|||
|
|||
/** |
|||
* 暂时没用,所以返回忽略 |
|||
*/ |
|||
@JsonIgnore |
|||
private String url; |
|||
} |
@ -1,45 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.result.video; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 视频审核-异步检测任务提交返参 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/29 13:38 |
|||
*/ |
|||
@Data |
|||
public class VideoAsyncScanTaskResultDTO implements Serializable { |
|||
private static final long serialVersionUID = -467990806428860191L; |
|||
|
|||
/** |
|||
* 随机字符串,该值用于回调通知请求中的签名。 |
|||
*/ |
|||
private String seed; |
|||
|
|||
/** |
|||
* 提交成功的失败对象 |
|||
*/ |
|||
private List<VideoAsyncScanTaskDataDTO> successTasks=new ArrayList<>(); |
|||
|
|||
/** |
|||
* 提交失败的检测对象 |
|||
*/ |
|||
private List<VideoAsyncScanTaskDataDTO> failTasks=new ArrayList<>(); |
|||
|
|||
/** |
|||
* 是否全部提交成功 |
|||
*/ |
|||
private Boolean isAllSuccess; |
|||
|
|||
public boolean isAllSuccess() { |
|||
if (failTasks.isEmpty() && !successTasks.isEmpty()) { |
|||
return true; |
|||
} |
|||
return isAllSuccess; |
|||
} |
|||
} |
@ -1,48 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.result.video; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 视频异步检测结果查询接口返参 |
|||
* 正在检测中的不返回,调用方继续轮询查询结果 |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/29 15:37 |
|||
*/ |
|||
@Data |
|||
public class VideoResultDTO implements Serializable { |
|||
private static final long serialVersionUID = -3451342817149956488L; |
|||
|
|||
/** |
|||
* 执行成功的任务Id集合 |
|||
* code=200,且所有语音+视频所有场景返回结果都为pass时则为成功 |
|||
*/ |
|||
private List<String> passDataIds = new ArrayList<>(); |
|||
/** |
|||
* 执行失败的任务Id集合 |
|||
*/ |
|||
private List<String> noPassDataIds = new ArrayList<>(); |
|||
|
|||
private List<String> passTaskIds = new ArrayList<>(); |
|||
private List<String> noPassTaskIds = new ArrayList<>(); |
|||
|
|||
/** |
|||
* desc:阿里内容审核API返回结果详情 |
|||
*/ |
|||
private List<VideoScanOriginalResultDTO> details = new ArrayList<>(); |
|||
|
|||
/** |
|||
* 本地是否全部通过 |
|||
*/ |
|||
private Boolean isAllPass; |
|||
|
|||
public boolean isAllPass() { |
|||
if (noPassTaskIds.isEmpty() && !passTaskIds.isEmpty()) { |
|||
return true; |
|||
} |
|||
return isAllPass; |
|||
} |
|||
} |
@ -1,53 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.result.video; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 视频异步检测结果查询接口原生返参-视频检测结果 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/29 16:39 |
|||
*/ |
|||
@Data |
|||
public class VideoScanOriginDetail implements Serializable { |
|||
private static final long serialVersionUID = 5547706236158849091L; |
|||
/** |
|||
* 视频检测场景,和调用请求中的场景对应。取值: |
|||
* porn:视频智能鉴黄 |
|||
* terrorism:视频暴恐涉政 |
|||
* live:视频不良场景 |
|||
* logo:视频logo |
|||
* ad:视频图文违规 |
|||
*/ |
|||
private String scene; |
|||
|
|||
/** |
|||
* 视频检测结果的分类。不同检测场景的结果分类不同,具体如下: |
|||
* 视频智能鉴黄(porn)结果分类: |
|||
* normal:正常 |
|||
* porn:色情 |
|||
* 视频暴恐涉政(terrorism)结果分类: |
|||
* normal:正常 |
|||
* terrorism:暴恐涉政 |
|||
* 视频不良场景(live)结果分类: |
|||
* normal:正常 |
|||
* live:包含不良场景 |
|||
* 视频logo(logo)结果分类: |
|||
* normal:正常 |
|||
* logo:包含logo |
|||
* 视频图文违规(ad)结果分类: |
|||
* normal:正常 |
|||
* ad:包含广告或文字违规信息 |
|||
*/ |
|||
private String label; |
|||
|
|||
/** |
|||
* 建议您执行的后续操作。取值: |
|||
* pass:结果正常,无需进行其余操作。 |
|||
* review:结果不确定,需要进行人工审核。 |
|||
* block:结果违规,建议直接删除或者限制公开。 |
|||
*/ |
|||
private String suggestion; |
|||
} |
@ -1,51 +0,0 @@ |
|||
package com.epmet.openapi.scan.support.result.video; |
|||
|
|||
import com.epmet.openapi.scan.support.result.VoiceAsyncScanResultDTO; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 视频异步检测结果查询接口原生返参 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/29 15:48 |
|||
*/ |
|||
@Data |
|||
public class VideoScanOriginalResultDTO implements Serializable { |
|||
private static final long serialVersionUID = -1565008507757551616L; |
|||
|
|||
/** |
|||
* 错误码,和HTTP状态码一致。 |
|||
* 更多信息,请参见公共错误码。 |
|||
*/ |
|||
private Integer code; |
|||
|
|||
private String codeDesc; |
|||
|
|||
/** |
|||
* 错误描述信息。 |
|||
*/ |
|||
private String msg; |
|||
/** |
|||
* 检测对象对应的数据ID。 |
|||
*/ |
|||
private String dataId; |
|||
|
|||
/** |
|||
* 检测任务的ID |
|||
*/ |
|||
private String taskId; |
|||
|
|||
/** |
|||
* 返回结果,调用成功时(code=200),返回结果中包含一个或多个元素。每个元素是个结构体,具体结构描述,请参见result。 |
|||
* 说明 视频流检测场景中,code返回280表示在检测中,返回200表示检测完成。在检测中状态时,检测结果中包含从开始检测到当前时间的检测到结果。 |
|||
*/ |
|||
private List<VideoScanOriginDetail> results; |
|||
|
|||
/** |
|||
* 视频语音检测结果。具体结构描述,请参见audioScanResult。 |
|||
*/ |
|||
private List<VoiceAsyncScanResultDTO> audioScanResults; |
|||
} |
@ -1,91 +0,0 @@ |
|||
server: |
|||
port: @server.port@ |
|||
version: @version@ |
|||
servlet: |
|||
context-path: /epmetscan |
|||
|
|||
spring: |
|||
main: |
|||
allow-bean-definition-overriding: true |
|||
application: |
|||
name: epmet-openapi-scan |
|||
#环境 dev|test|prod |
|||
profiles: |
|||
active: @spring.profiles.active@ |
|||
messages: |
|||
encoding: UTF-8 |
|||
basename: i18n/messages_common |
|||
jackson: |
|||
time-zone: GMT+8 |
|||
date-format: yyyy-MM-dd HH:mm:ss |
|||
redis: |
|||
database: @spring.redis.index@ |
|||
host: @spring.redis.host@ |
|||
port: @spring.redis.port@ |
|||
password: @spring.redis.password@ |
|||
timeout: 30s |
|||
cloud: |
|||
nacos: |
|||
discovery: |
|||
server-addr: @nacos.server-addr@ |
|||
#nacos的命名空间ID,默认是public |
|||
namespace: @nacos.discovery.namespace@ |
|||
#不把自己注册到注册中心的地址 |
|||
register-enabled: @nacos.register-enabled@ |
|||
ip: @nacos.ip@ |
|||
config: |
|||
enabled: @nacos.config-enabled@ |
|||
server-addr: @nacos.server-addr@ |
|||
namespace: @nacos.config.namespace@ |
|||
group: @nacos.config.group@ |
|||
file-extension: yaml |
|||
management: |
|||
endpoints: |
|||
web: |
|||
exposure: |
|||
include: "*" |
|||
endpoint: |
|||
health: |
|||
show-details: ALWAYS |
|||
|
|||
feign: |
|||
hystrix: |
|||
enabled: true |
|||
client: |
|||
config: |
|||
default: |
|||
loggerLevel: BASIC |
|||
okhttp: |
|||
enabled: true |
|||
|
|||
|
|||
hystrix: |
|||
command: |
|||
default: |
|||
execution: |
|||
isolation: |
|||
thread: |
|||
timeoutInMilliseconds: 60000 #缺省为1000 |
|||
|
|||
ribbon: |
|||
ReadTimeout: 300000 |
|||
ConnectTimeout: 300000 |
|||
|
|||
aliyun: |
|||
green: |
|||
accessKeyId: LTAI4G6Fv6uTzQbpsayATHq4 |
|||
accessKeySecret: QevMw1RYCwQUG3RSMPq1J6EAfmSblo |
|||
regionId: cn-shanghai |
|||
bizType: epmet_img_text |
|||
|
|||
dingTalk: |
|||
robot: |
|||
webHook: @dingTalk.robot.webHook@ |
|||
secret: @dingTalk.robot.secret@ |
|||
|
|||
# 停机选项 |
|||
shutdown: |
|||
graceful: |
|||
enable: true #是否开启优雅停机 |
|||
waitTimeSecs: 30 # 优雅停机等待时间,超过30秒,发出告警 |
|||
|
@ -1,169 +0,0 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<configuration> |
|||
<include resource="org/springframework/boot/logging/logback/base.xml"/> |
|||
|
|||
<property name="log.path" value="logs/epmet/openapi/scan"/> |
|||
|
|||
<springProperty scope="context" name="appname" source="spring.application.name"/> |
|||
<springProperty scope="context" name="webHook" source="dingTalk.robot.webHook"/> |
|||
<springProperty scope="context" name="secret" source="dingTalk.robot.secret"/> |
|||
|
|||
<!-- 日志上下文名称 --> |
|||
<contextName>${appname}</contextName> |
|||
|
|||
<!-- 彩色日志格式 --> |
|||
<property name="CONSOLE_LOG_PATTERN" |
|||
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> |
|||
|
|||
<!--1. 输出到控制台--> |
|||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> |
|||
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息--> |
|||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
|||
<level>debug</level> |
|||
</filter> |
|||
<encoder> |
|||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern> |
|||
<!-- 设置字符集 --> |
|||
<charset>UTF-8</charset> |
|||
</encoder> |
|||
</appender> |
|||
|
|||
<!--2. 输出到文档--> |
|||
<!-- 2.1 level为 DEBUG 日志,时间滚动输出 --> |
|||
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/debug.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<!-- 日志归档 --> |
|||
<fileNamePattern>${log.path}/debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录debug级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>debug</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.2 level为 INFO 日志,时间滚动输出 --> |
|||
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/info.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<!-- 每天日志归档路径以及格式 --> |
|||
<fileNamePattern>${log.path}/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录info级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>info</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.3 level为 WARN 日志,时间滚动输出 --> |
|||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/warn.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<fileNamePattern>${log.path}/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录warn级别的 --> |
|||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
|||
<level>warn</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 2.4 level为 ERROR 日志,时间滚动输出 --> |
|||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
|||
<!-- 正在记录的日志文档的路径及文档名 --> |
|||
<file>${log.path}/error.log</file> |
|||
<!--日志文档输出格式--> |
|||
<encoder> |
|||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n</pattern> |
|||
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
|||
</encoder> |
|||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
|||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
|||
<fileNamePattern>${log.path}/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
|||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
|||
<maxFileSize>100MB</maxFileSize> |
|||
</timeBasedFileNamingAndTriggeringPolicy> |
|||
<!--日志文档保留天数--> |
|||
<maxHistory>15</maxHistory> |
|||
</rollingPolicy> |
|||
<!-- 此日志文档只记录ERROR级别的 发送钉钉短信 --> |
|||
<filter class="com.epmet.commons.tools.filter.LogMsgSendFilter"> |
|||
<level>ERROR</level> |
|||
<onMatch>ACCEPT</onMatch> |
|||
<onMismatch>DENY</onMismatch> |
|||
<webHook>${webHook}</webHook> |
|||
<secret>${secret}</secret> |
|||
<appName>${appname}</appName> |
|||
</filter> |
|||
</appender> |
|||
|
|||
<!-- 开发、测试环境 --> |
|||
<springProfile name="dev,test"> |
|||
<logger name="org.springframework.web" level="INFO"/> |
|||
<logger name="org.springboot.sample" level="INFO"/> |
|||
<logger name="com.epmet.dao" level="INFO"/> |
|||
<logger name="com.epmet.dao" level="DEBUG"/> |
|||
<root level="INFO"> |
|||
<appender-ref ref="DEBUG_FILE"/> |
|||
<appender-ref ref="INFO_FILE"/> |
|||
<appender-ref ref="WARN_FILE"/> |
|||
<appender-ref ref="ERROR_FILE"/> |
|||
</root> |
|||
</springProfile> |
|||
|
|||
<!-- 生产环境 --> |
|||
<springProfile name="prod"> |
|||
<logger name="org.springframework.web" level="INFO"/> |
|||
<logger name="org.springboot.sample" level="INFO"/> |
|||
<logger name="com.epmet.dao" level="INFO"/> |
|||
<root level="INFO"> |
|||
<appender-ref ref="CONSOLE"/> |
|||
<appender-ref ref="DEBUG_FILE"/> |
|||
<appender-ref ref="INFO_FILE"/> |
|||
<appender-ref ref="WARN_FILE"/> |
|||
<appender-ref ref="ERROR_FILE"/> |
|||
</root> |
|||
</springProfile> |
|||
|
|||
</configuration> |
@ -1,7 +0,0 @@ |
|||
#访问openApi 需要向redis中 添加白名单 |
|||
sadd epmet:openapi:scan:whitelist "客户端ip地址" |
|||
#eg: |
|||
sadd epmet:openapi:scan:whitelist "\"192.168.1.1\"" |
|||
|
|||
#del |
|||
srem 'epmet:openapi:scan:whitelist' "\"116.179.32.197\"" "\"27.219.156.47\"" |
@ -1,50 +0,0 @@ |
|||
import java.io.IOException; |
|||
import java.util.Properties; |
|||
|
|||
/** |
|||
* Created by liuhai.lh on 17/01/12. |
|||
*/ |
|||
public class BaseSample { |
|||
|
|||
protected static String accessKeyId = "123"; |
|||
protected static String accessKeySecret = "456"; |
|||
|
|||
protected static String regionId = "cn-shanghai"; |
|||
|
|||
static { |
|||
Properties properties = new Properties(); |
|||
|
|||
try { |
|||
properties.load(BaseSample.class.getResourceAsStream("bootstrap.yml")); |
|||
accessKeyId = properties.getProperty("aliyun.green.accessKeyId"); |
|||
accessKeySecret = properties.getProperty("aliyun.green.accessKeySecret"); |
|||
regionId = properties.getProperty("aliyun.green.url"); |
|||
} catch(IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
} |
|||
protected static String getDomain(){ |
|||
if("cn-shanghai".equals(regionId)){ |
|||
return "green.cn-shanghai.aliyuncs.com"; |
|||
} |
|||
|
|||
if ("cn-beijing".equals(regionId)) { |
|||
return "green.cn-beijing.aliyuncs.com"; |
|||
} |
|||
|
|||
if ("ap-southeast-1".equals(regionId)) { |
|||
return "green.ap-southeast-1.aliyuncs.com"; |
|||
} |
|||
|
|||
if ("us-west-1".equals(regionId)) { |
|||
return "green.us-west-1.aliyuncs.com"; |
|||
} |
|||
|
|||
return "green.cn-shanghai.aliyuncs.com"; |
|||
} |
|||
protected static String getEndPointName(){ |
|||
return regionId; |
|||
} |
|||
|
|||
} |
@ -1,95 +0,0 @@ |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.aliyuncs.DefaultAcsClient; |
|||
import com.aliyuncs.IAcsClient; |
|||
import com.aliyuncs.exceptions.ClientException; |
|||
import com.aliyuncs.exceptions.ServerException; |
|||
import com.aliyuncs.green.model.v20180509.ImageAsyncScanRequest; |
|||
import com.aliyuncs.http.FormatType; |
|||
import com.aliyuncs.http.HttpResponse; |
|||
import com.aliyuncs.profile.DefaultProfile; |
|||
import com.aliyuncs.profile.IClientProfile; |
|||
import com.epmet.openapi.scan.common.enu.RegionIdEnum; |
|||
|
|||
import java.util.*; |
|||
|
|||
/** |
|||
* Created by liuhai.lh on 2017/2/17. |
|||
* 图片异步检测接口 |
|||
* @author liuhai.lh |
|||
* @date 2017/02/17 |
|||
*/ |
|||
public class ImageAsyncScanRequestSample extends BaseSample{ |
|||
|
|||
public static void main(String[] args) throws Exception { |
|||
//请替换成你自己的accessKeyId、accessKeySecret
|
|||
IClientProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret); |
|||
DefaultProfile.addEndpoint(getEndPointName(), regionId, "Green", RegionIdEnum.getDoMain(regionId)); |
|||
IAcsClient client = new DefaultAcsClient(profile); |
|||
|
|||
ImageAsyncScanRequest imageAsyncScanRequest = new ImageAsyncScanRequest(); |
|||
imageAsyncScanRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式
|
|||
imageAsyncScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法
|
|||
imageAsyncScanRequest.setEncoding("utf-8"); |
|||
imageAsyncScanRequest.setRegionId(regionId); |
|||
|
|||
|
|||
List<Map<String, Object>> tasks = new ArrayList<Map<String, Object>>(); |
|||
Map<String, Object> task1 = new LinkedHashMap<String, Object>(); |
|||
task1.put("dataId", UUID.randomUUID().toString()); |
|||
task1.put("url", "https://img.alicdn.com/tfs/TB1Xk_qvwmTBuNjy1XbXXaMrVXa-550-407.jpg"); |
|||
task1.put("time", new Date()); |
|||
|
|||
tasks.add(task1); |
|||
JSONObject data = new JSONObject(); |
|||
/** |
|||
* porn: 色情 |
|||
* terrorism: 暴恐 |
|||
* qrcode: 二维码 |
|||
* ad: 图片广告 |
|||
* ocr: 文字识别 |
|||
*/ |
|||
data.put("scenes", Arrays.asList("porn", "ocr", "qrcode", "sface")); |
|||
data.put("tasks", tasks); |
|||
|
|||
imageAsyncScanRequest.setHttpContent(data.toJSONString().getBytes("UTF-8"), "UTF-8", FormatType.JSON); |
|||
|
|||
/** |
|||
* 请务必设置超时时间 |
|||
*/ |
|||
imageAsyncScanRequest.setConnectTimeout(3000); |
|||
imageAsyncScanRequest.setReadTimeout(6000); |
|||
|
|||
try { |
|||
HttpResponse httpResponse = client.doAction(imageAsyncScanRequest); |
|||
|
|||
if(httpResponse.isSuccess()){ |
|||
JSONObject scrResponse = JSON.parseObject(new String(httpResponse.getHttpContent(), "UTF-8")); |
|||
System.out.println(JSON.toJSONString(scrResponse, true)); |
|||
if (200 == scrResponse.getInteger("code")) { |
|||
JSONArray taskResults = scrResponse.getJSONArray("data"); |
|||
for (Object taskResult : taskResults) { |
|||
if(200 == ((JSONObject)taskResult).getInteger("code")){ |
|||
String taskId = ((JSONObject)taskResult).getString("taskId"); |
|||
// 将taskId 保存下来,间隔一段时间来轮询结果, 参照ImageAsyncScanResultsRequest
|
|||
System.out.println("args = [" + taskId + "]"); |
|||
}else{ |
|||
System.out.println("task process fail:" + ((JSONObject)taskResult).getInteger("code")); |
|||
} |
|||
} |
|||
} else { |
|||
System.out.println("detect not success. code:" + scrResponse.getInteger("code")); |
|||
} |
|||
}else{ |
|||
System.out.println("response not success. status:" + httpResponse.getStatus()); |
|||
} |
|||
} catch (ServerException e) { |
|||
e.printStackTrace(); |
|||
} catch (ClientException e) { |
|||
e.printStackTrace(); |
|||
} catch (Exception e){ |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
@ -1,83 +0,0 @@ |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.aliyuncs.DefaultAcsClient; |
|||
import com.aliyuncs.IAcsClient; |
|||
import com.aliyuncs.exceptions.ClientException; |
|||
import com.aliyuncs.exceptions.ServerException; |
|||
import com.aliyuncs.green.model.v20180509.ImageAsyncScanResultsRequest; |
|||
import com.aliyuncs.http.FormatType; |
|||
import com.aliyuncs.http.HttpResponse; |
|||
import com.aliyuncs.profile.DefaultProfile; |
|||
import com.aliyuncs.profile.IClientProfile; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* Created by liuhai.lh on 2017/2/17. |
|||
* 获取图片异步检测结果接口 |
|||
* @author liuhai.lh |
|||
* @date 2017/02/17 |
|||
*/ |
|||
public class ImageAsyncScanResultsSample extends BaseSample{ |
|||
|
|||
public static void main(String[] args) throws Exception { |
|||
//请替换成你自己的accessKeyId、accessKeySecret
|
|||
IClientProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret); |
|||
DefaultProfile.addEndpoint(getEndPointName(), regionId, "Green", getDomain()); |
|||
IAcsClient client = new DefaultAcsClient(profile); |
|||
|
|||
ImageAsyncScanResultsRequest imageAsyncScanResultsRequest = new ImageAsyncScanResultsRequest(); |
|||
imageAsyncScanResultsRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式
|
|||
imageAsyncScanResultsRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法
|
|||
imageAsyncScanResultsRequest.setEncoding("utf-8"); |
|||
imageAsyncScanResultsRequest.setRegionId(regionId); |
|||
|
|||
|
|||
List<String> taskIds = new ArrayList<String>(); |
|||
taskIds.add("img1hdP5Wn0QC@7wW0n$VX0R@-1p3mnZ"); |
|||
imageAsyncScanResultsRequest.setHttpContent(JSON.toJSONString(taskIds).getBytes("UTF-8"), "UTF-8", FormatType.JSON); |
|||
|
|||
/** |
|||
* 请务必设置超时时间 |
|||
*/ |
|||
imageAsyncScanResultsRequest.setConnectTimeout(3000); |
|||
imageAsyncScanResultsRequest.setReadTimeout(6000); |
|||
|
|||
try { |
|||
HttpResponse httpResponse = client.doAction(imageAsyncScanResultsRequest); |
|||
|
|||
if(httpResponse.isSuccess()){ |
|||
JSONObject scrResponse = JSON.parseObject(new String(httpResponse.getHttpContent(), "UTF-8")); |
|||
System.out.println(JSON.toJSONString(scrResponse, true)); |
|||
if (200 == scrResponse.getInteger("code")) { |
|||
JSONArray taskResults = scrResponse.getJSONArray("data"); |
|||
for (Object taskResult : taskResults) { |
|||
if(200 == ((JSONObject)taskResult).getInteger("code")){ |
|||
JSONArray sceneResults = ((JSONObject)taskResult).getJSONArray("results"); |
|||
for (Object sceneResult : sceneResults) { |
|||
String scene = ((JSONObject)sceneResult).getString("scene"); |
|||
String suggestion = ((JSONObject)sceneResult).getString("suggestion"); |
|||
//根据scene和suggetion做相关的处理
|
|||
//do something
|
|||
} |
|||
}else{ |
|||
System.out.println("task process fail:" + ((JSONObject)taskResult).getInteger("code")); |
|||
} |
|||
} |
|||
} else { |
|||
System.out.println("detect not success. code:" + scrResponse.getInteger("code")); |
|||
} |
|||
}else{ |
|||
System.out.println("response not success. status:" + httpResponse.getStatus()); |
|||
} |
|||
} catch (ServerException e) { |
|||
e.printStackTrace(); |
|||
} catch (ClientException e) { |
|||
e.printStackTrace(); |
|||
} catch (Exception e){ |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
@ -1,101 +0,0 @@ |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.aliyuncs.DefaultAcsClient; |
|||
import com.aliyuncs.IAcsClient; |
|||
import com.aliyuncs.exceptions.ClientException; |
|||
import com.aliyuncs.exceptions.ServerException; |
|||
import com.aliyuncs.green.model.v20180509.ImageSyncScanRequest; |
|||
import com.aliyuncs.http.FormatType; |
|||
import com.aliyuncs.http.HttpResponse; |
|||
import com.aliyuncs.profile.DefaultProfile; |
|||
import com.aliyuncs.profile.IClientProfile; |
|||
|
|||
import java.util.*; |
|||
|
|||
/** |
|||
* Created by liuhai.lh on 2017/2/17. |
|||
* 图片同步检测接口 |
|||
* @author liuhai.lh |
|||
* @date 2017/02/17 |
|||
*/ |
|||
public class ImageSyncScanRequestSample extends BaseSample { |
|||
|
|||
|
|||
public static void main(String[] args) throws Exception { |
|||
//请替换成你自己的accessKeyId、accessKeySecret
|
|||
IClientProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret); |
|||
DefaultProfile.addEndpoint(getEndPointName(), regionId, "Green", getDomain()); |
|||
IAcsClient client = new DefaultAcsClient(profile); |
|||
|
|||
ImageSyncScanRequest imageSyncScanRequest = new ImageSyncScanRequest(); |
|||
imageSyncScanRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式
|
|||
imageSyncScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法
|
|||
imageSyncScanRequest.setEncoding("utf-8"); |
|||
imageSyncScanRequest.setRegionId(regionId); |
|||
|
|||
|
|||
List<Map<String, Object>> tasks = new ArrayList<Map<String, Object>>(); |
|||
Map<String, Object> task = new LinkedHashMap<String, Object>(); |
|||
task.put("dataId", UUID.randomUUID().toString()); |
|||
task.put("url", "http://f.hiphotos.baidu.com/image/pic/item/aa18972bd40735fa13899ac392510fb30f24084b.jpg"); |
|||
task.put("time", new Date()); |
|||
|
|||
tasks.add(task); |
|||
JSONObject data = new JSONObject(); |
|||
/** |
|||
* porn: 色情 |
|||
* terrorism: 暴恐 |
|||
* qrcode: 二维码 |
|||
* ad: 图片广告 |
|||
* ocr: 文字识别 |
|||
*/ |
|||
data.put("scenes", Arrays.asList("porn","terrorism")); |
|||
data.put("tasks", tasks); |
|||
|
|||
imageSyncScanRequest.setHttpContent(data.toJSONString().getBytes("UTF-8"), "UTF-8", FormatType.JSON); |
|||
|
|||
/** |
|||
* 请务必设置超时时间 |
|||
*/ |
|||
imageSyncScanRequest.setConnectTimeout(3000); |
|||
imageSyncScanRequest.setReadTimeout(10000); |
|||
|
|||
try { |
|||
HttpResponse httpResponse = client.doAction(imageSyncScanRequest); |
|||
|
|||
if (httpResponse.isSuccess()) { |
|||
JSONObject scrResponse = JSON.parseObject(new String(httpResponse.getHttpContent(), "UTF-8")); |
|||
System.out.println(JSON.toJSONString(scrResponse, true)); |
|||
if (200 == scrResponse.getInteger("code")) { |
|||
JSONArray taskResults = scrResponse.getJSONArray("data"); |
|||
for (Object taskResult : taskResults) { |
|||
if(200 == ((JSONObject)taskResult).getInteger("code")){ |
|||
JSONArray sceneResults = ((JSONObject)taskResult).getJSONArray("results"); |
|||
for (Object sceneResult : sceneResults) { |
|||
String scene = ((JSONObject)sceneResult).getString("scene"); |
|||
String suggestion = ((JSONObject)sceneResult).getString("suggestion"); |
|||
//根据scene和suggetion做相关的处理
|
|||
//do something
|
|||
System.out.println("args = [" + scene + "]"); |
|||
System.out.println("args = [" + suggestion + "]"); |
|||
} |
|||
}else{ |
|||
System.out.println("task process fail:" + ((JSONObject)taskResult).getInteger("code")); |
|||
} |
|||
} |
|||
} else { |
|||
System.out.println("detect not success. code:" + scrResponse.getInteger("code")); |
|||
} |
|||
} else { |
|||
System.out.println("response not success. status:" + httpResponse.getStatus()); |
|||
} |
|||
} catch (ServerException e) { |
|||
e.printStackTrace(); |
|||
} catch (ClientException e) { |
|||
e.printStackTrace(); |
|||
} catch (Exception e){ |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
@ -1,90 +0,0 @@ |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.aliyuncs.DefaultAcsClient; |
|||
import com.aliyuncs.IAcsClient; |
|||
import com.aliyuncs.green.model.v20180509.VoiceAsyncScanRequest; |
|||
import com.aliyuncs.http.FormatType; |
|||
import com.aliyuncs.http.HttpResponse; |
|||
import com.aliyuncs.profile.DefaultProfile; |
|||
import com.aliyuncs.profile.IClientProfile; |
|||
|
|||
import java.util.*; |
|||
|
|||
/** |
|||
* 提交语音异步检测任务 demo |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/8 21:51 |
|||
*/ |
|||
public class VoiceAsyncScanRequestSample extends BaseSample { |
|||
|
|||
|
|||
|
|||
public static void main(String[] args) throws Exception { |
|||
|
|||
//请替换成您自己的AccessKey ID、AccessKey Secret。
|
|||
IClientProfile profile = DefaultProfile.getProfile("cn-shanghai", |
|||
"LTAI4G6Fv6uTzQbpsayATHq4", //您自己的AccessKey ID
|
|||
"QevMw1RYCwQUG3RSMPq1J6EAfmSblo");//您自己的AccessKey Secret
|
|||
final IAcsClient client = new DefaultAcsClient(profile); |
|||
|
|||
VoiceAsyncScanRequest asyncScanRequest = new VoiceAsyncScanRequest(); //class different vs common
|
|||
asyncScanRequest.setAcceptFormat(FormatType.JSON); // 指定API返回格式。
|
|||
asyncScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法。
|
|||
asyncScanRequest.setRegionId("cn-shanghai"); |
|||
asyncScanRequest.setConnectTimeout(3000); |
|||
asyncScanRequest.setReadTimeout(6000); |
|||
|
|||
List<Map<String, Object>> tasks = new ArrayList<Map<String, Object>>(); |
|||
Map<String, Object> task1 = new LinkedHashMap<String, Object>(); |
|||
// 请将下面的地址修改为要检测的语音文件的地址。
|
|||
task1.put("dataId","voice1"); |
|||
task1.put("url", "https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/20201208/6480bd6be9f14a458162218cea84dfa5.aac"); |
|||
|
|||
Map<String, Object> task2 = new LinkedHashMap<String, Object>(); |
|||
task2.put("dataId","voice2"); |
|||
task2.put("url", "https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/test/20201208/b566d94fd7114ffb9a203e80c22ebb96.aac"); |
|||
|
|||
tasks.add(task1); |
|||
tasks.add(task2); |
|||
|
|||
JSONObject data = new JSONObject(); |
|||
|
|||
System.out.println("==========Task count:" + tasks.size()); |
|||
data.put("scenes", Arrays.asList("antispam")); |
|||
data.put("tasks", tasks); |
|||
// 如果是语音流检测,则修改为true。
|
|||
data.put("live", false); |
|||
asyncScanRequest.setHttpContent(data.toJSONString().getBytes("UTF-8"), "UTF-8", FormatType.JSON); |
|||
System.out.println("接口入参:"+JSON.toJSONString(data, true)); |
|||
|
|||
try { |
|||
HttpResponse httpResponse = client.doAction(asyncScanRequest); |
|||
|
|||
if (httpResponse.isSuccess()) { |
|||
JSONObject scrResponse = JSON.parseObject(new String(httpResponse.getHttpContent(), "UTF-8")); |
|||
System.out.println("接口返参:"+JSON.toJSONString(scrResponse, true)); |
|||
if (200 == scrResponse.getInteger("code")) { |
|||
JSONArray taskResults = scrResponse.getJSONArray("data"); |
|||
for (Object taskResult : taskResults) { |
|||
Integer code = ((JSONObject) taskResult).getInteger("code"); |
|||
if (200 == code) { |
|||
final String taskId = ((JSONObject) taskResult).getString("taskId"); |
|||
System.out.println("submit async task success, taskId = [" + taskId + "]"); |
|||
} else { |
|||
System.out.println("task process fail: " + code); |
|||
} |
|||
} |
|||
} else { |
|||
System.out.println("detect not success. code: " + scrResponse.getInteger("code")); |
|||
} |
|||
} else { |
|||
System.out.println("response not success. status: " + httpResponse.getStatus()); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
} |
|||
} |
@ -1,113 +0,0 @@ |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.aliyuncs.DefaultAcsClient; |
|||
import com.aliyuncs.IAcsClient; |
|||
import com.aliyuncs.green.model.v20180509.VoiceAsyncScanResultsRequest; |
|||
import com.aliyuncs.http.FormatType; |
|||
import com.aliyuncs.http.HttpResponse; |
|||
import com.aliyuncs.profile.DefaultProfile; |
|||
import com.aliyuncs.profile.IClientProfile; |
|||
|
|||
import java.util.*; |
|||
|
|||
/** |
|||
* 查询异步语音检测结果。 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/12/8 22:08 |
|||
*/ |
|||
public class VoiceAsyncScanResultsRequestSample extends BaseSample { |
|||
|
|||
|
|||
public static void main(String[] args) throws Exception { |
|||
// 请替换成您自己的AccessKey ID、AccessKey Secret。
|
|||
IClientProfile profile = DefaultProfile |
|||
.getProfile("cn-shanghai", |
|||
"LTAI4G6Fv6uTzQbpsayATHq4", |
|||
"QevMw1RYCwQUG3RSMPq1J6EAfmSblo"); |
|||
final IAcsClient client = new DefaultAcsClient(profile); |
|||
//提交语音异步检测任务后返回的taskId
|
|||
pollingScanResult(client, Arrays.asList("vc_f_7WZZ01BCH0q6ZnM3g1OKGG-1tAaZ7", "vc_f_6AKaBxy4HdG5bruQ0JwweV-1tAaJi")); |
|||
// pollingScanResult(client, "vc_f_6AKaBxy4HdG5bruQ0JwweV-1tAaJi");
|
|||
} |
|||
|
|||
public static void pollingScanResult(IAcsClient client, List<String> taskIdList) throws InterruptedException { |
|||
int failCount = 0; |
|||
boolean stop = false; |
|||
do { |
|||
// 设置每10秒查询一次。
|
|||
Thread.sleep(10 * 1000); |
|||
JSONObject scanResult = getScanResult(client, taskIdList); |
|||
System.out.println("接口完整返参:"+JSON.toJSONString(scanResult, true)); |
|||
if (scanResult == null || 200 != scanResult.getInteger("code")) { |
|||
failCount++; |
|||
System.out.println("请求失败,get result fail, failCount=" + failCount); |
|||
if (scanResult != null) { |
|||
System.out.println("请求失败,错误信息errorMsg:" + scanResult.getString("msg")); |
|||
} |
|||
if (failCount > 20) { |
|||
break; |
|||
} |
|||
continue; |
|||
} |
|||
|
|||
JSONArray taskResults = scanResult.getJSONArray("data"); |
|||
if (taskResults.isEmpty()) { |
|||
System.out.println("请求成功,but data is empty"); |
|||
break; |
|||
} |
|||
System.out.println("data.size=" + taskResults.size()); |
|||
for (Object taskResult : taskResults) { |
|||
JSONObject result = (JSONObject) taskResult; |
|||
Integer code = result.getInteger("code"); |
|||
String taskId = result.getString("taskId"); |
|||
if (280 == code) { |
|||
System.out.println("taskId=" + taskId + ": processing status: " + result.getString("msg")); |
|||
} else if (200 == code) { |
|||
System.out.println("taskId=" + taskId + "请求成功,返参:" + JSON.toJSONString(taskResult, true)); |
|||
stop = true; |
|||
} else { |
|||
System.out.println("taskId=" + taskId + "请求失败,返参:" + JSON.toJSONString(taskResult, true)); |
|||
stop = true; |
|||
} |
|||
} |
|||
} while (!stop); |
|||
} |
|||
|
|||
private static JSONObject getScanResult(IAcsClient client, List<String> taskIdList) { |
|||
VoiceAsyncScanResultsRequest getResultsRequest = new VoiceAsyncScanResultsRequest(); |
|||
getResultsRequest.setAcceptFormat(FormatType.JSON); // 指定API返回格式。
|
|||
getResultsRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法。
|
|||
getResultsRequest.setEncoding("utf-8"); |
|||
getResultsRequest.setRegionId("cn-shanghai"); |
|||
|
|||
|
|||
List<Map<String, Object>> tasks = new ArrayList<Map<String, Object>>(); |
|||
for (String taskId : taskIdList) { |
|||
Map<String, Object> task1 = new LinkedHashMap<String, Object>(); |
|||
task1.put("taskId", taskId); |
|||
tasks.add(task1); |
|||
} |
|||
|
|||
/** |
|||
* 请务必设置超时时间。 |
|||
*/ |
|||
getResultsRequest.setConnectTimeout(3000); |
|||
getResultsRequest.setReadTimeout(6000); |
|||
|
|||
try { |
|||
getResultsRequest.setHttpContent(JSON.toJSONString(tasks).getBytes("UTF-8"), "UTF-8", FormatType.JSON); |
|||
|
|||
HttpResponse httpResponse = client.doAction(getResultsRequest); |
|||
if (httpResponse.isSuccess()) { |
|||
return JSON.parseObject(new String(httpResponse.getHttpContent(), "UTF-8")); |
|||
} else { |
|||
System.out.println("response not success. status: " + httpResponse.getStatus()); |
|||
} |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
} |
@ -1,19 +0,0 @@ |
|||
<?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"> |
|||
<parent> |
|||
<artifactId>epmet-cloud</artifactId> |
|||
<groupId>com.epmet</groupId> |
|||
<version>2.0.0</version> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
<packaging>pom</packaging> |
|||
|
|||
<artifactId>epmet-openapi</artifactId> |
|||
<modules> |
|||
<module>epmet-openapi-scan</module> |
|||
<module>epmet-openapi-adv</module> |
|||
</modules> |
|||
|
|||
</project> |
Loading…
Reference in new issue