From 10fb1b8146cba227783e257c00607e25a8f8d17b Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 4 Jun 2020 22:14:44 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=A2=9EGovVoiceOpenFeignClient,?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8E=9F=E6=9D=A5=E7=9A=84GovVoiceFeignClien?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/feign/GovVoiceFeignClient.java | 39 ------------------- .../fallback/GovVoiceFeignClientFallBack.java | 28 ------------- .../epmet/feign/GovVoiceOpenFeignClient.java | 26 +++++++++---- .../GovVoiceOpenFeignClientFallback.java | 23 ++++++----- .../epmet/controller/ArticleController.java | 5 --- .../epmet/controller/ArticleController.java | 10 +++-- .../service/impl/ArticleServiceImpl.java | 8 +--- 7 files changed, 42 insertions(+), 97 deletions(-) delete mode 100644 epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/feign/GovVoiceFeignClient.java delete mode 100644 epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/feign/fallback/GovVoiceFeignClientFallBack.java rename epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/{ => fallback}/GovVoiceOpenFeignClientFallback.java (71%) diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/feign/GovVoiceFeignClient.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/feign/GovVoiceFeignClient.java deleted file mode 100644 index 6a03cbafbc..0000000000 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/feign/GovVoiceFeignClient.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.epmet.dto.feign; - - -import com.epmet.commons.tools.constant.ServiceConstant; -import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.feign.fallback.GovVoiceFeignClientFallBack; -import com.epmet.dto.form.*; -import com.epmet.dto.result.*; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -import java.util.List; - -/** - * @Author zxc - * @CreateTime 2020/6/2 16:05 - * , url = "localhost:8105" - */ -//@FeignClient(name = ServiceConstant.GOV_VOICE_SERVER, fallback = GovVoiceFeignClientFallBack.class,url = "localhost:8105") -@FeignClient(name = ServiceConstant.GOV_VOICE_SERVER, fallback = GovVoiceFeignClientFallBack.class) -public interface GovVoiceFeignClient { - - /** - * @Description 已发布列表页的标签——居民端 - * @param formDto - * @author zxc - */ - @PostMapping("/gov/voice/tag/resitaglist") - Result> resiTagList(@RequestBody ResiTagListFormDTO formDto); - - /** - * @Description 标签级联查询——居民端 - * @param formDto - * @author zxc - */ - @PostMapping("/gov/voice/tag/tagcascadelist") - Result> tagCascadeList(@RequestBody TagCascadeListFormDTO formDto); -} diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/feign/fallback/GovVoiceFeignClientFallBack.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/feign/fallback/GovVoiceFeignClientFallBack.java deleted file mode 100644 index 9e2c1eebba..0000000000 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/dto/feign/fallback/GovVoiceFeignClientFallBack.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.epmet.dto.feign.fallback; - -import com.epmet.commons.tools.constant.ServiceConstant; -import com.epmet.commons.tools.utils.ModuleUtils; -import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.feign.GovVoiceFeignClient; -import com.epmet.dto.form.*; -import com.epmet.dto.result.*; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * @Author zxc - * @CreateTime 2020/6/2 16:07 - */ -@Component -public class GovVoiceFeignClientFallBack implements GovVoiceFeignClient { - @Override - public Result> resiTagList(ResiTagListFormDTO formDto) { - return ModuleUtils.feignConError(ServiceConstant.GOV_VOICE_SERVER, "resiTagList", formDto); - } - - @Override - public Result> tagCascadeList(TagCascadeListFormDTO formDto) { - return ModuleUtils.feignConError(ServiceConstant.GOV_VOICE_SERVER, "tagCascadeList", formDto); - } -} diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/GovVoiceOpenFeignClient.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/GovVoiceOpenFeignClient.java index eb9cf4c240..3bbc14112f 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/GovVoiceOpenFeignClient.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/GovVoiceOpenFeignClient.java @@ -3,13 +3,9 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.form.ArticlePageFormDTO; -import com.epmet.dto.form.CommonArticleListFormDTO; -import com.epmet.dto.form.ResiArticleDetailFormDTO; -import com.epmet.dto.result.ArticleBannerResultDTO; -import com.epmet.dto.result.ArticleDetailResultDTO; -import com.epmet.dto.result.ArticleLatestResultDTO; -import com.epmet.dto.result.ArticleListResultDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; +import com.epmet.feign.fallback.GovVoiceOpenFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -25,6 +21,22 @@ import java.util.List; @FeignClient(name = ServiceConstant.GOV_VOICE_SERVER, fallback = GovVoiceOpenFeignClientFallback.class) public interface GovVoiceOpenFeignClient { + /** + * @Description 已发布列表页的标签——居民端 + * @param formDto + * @author zxc + */ + @PostMapping("/gov/voice/tag/resitaglist") + Result> resiTagList(@RequestBody ResiTagListFormDTO formDto); + + /** + * @Description 标签级联查询——居民端 + * @param formDto + * @author zxc + */ + @PostMapping("/gov/voice/tag/tagcascadelist") + Result> tagCascadeList(@RequestBody TagCascadeListFormDTO formDto); + /** * @Description 根据网格Id查找置顶文章的相关信息列表 用处:居民端首页轮播 * @param commonArticleListFormDTO :: getGridId :: getNum diff --git a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/GovVoiceOpenFeignClientFallback.java b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/fallback/GovVoiceOpenFeignClientFallback.java similarity index 71% rename from epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/GovVoiceOpenFeignClientFallback.java rename to epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/fallback/GovVoiceOpenFeignClientFallback.java index 16b020b732..9ed332730a 100644 --- a/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/GovVoiceOpenFeignClientFallback.java +++ b/epmet-module/gov-voice/gov-voice-client/src/main/java/com/epmet/feign/fallback/GovVoiceOpenFeignClientFallback.java @@ -1,15 +1,11 @@ -package com.epmet.feign; +package com.epmet.feign.fallback; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.form.ArticlePageFormDTO; -import com.epmet.dto.form.CommonArticleListFormDTO; -import com.epmet.dto.form.ResiArticleDetailFormDTO; -import com.epmet.dto.result.ArticleBannerResultDTO; -import com.epmet.dto.result.ArticleDetailResultDTO; -import com.epmet.dto.result.ArticleLatestResultDTO; -import com.epmet.dto.result.ArticleListResultDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; +import com.epmet.feign.GovVoiceOpenFeignClient; import org.springframework.stereotype.Component; import java.util.List; @@ -21,7 +17,16 @@ import java.util.List; * @date 2020/6/4 16:01 */ @Component -public class GovVoiceOpenFeignClientFallback implements GovVoiceOpenFeignClient{ +public class GovVoiceOpenFeignClientFallback implements GovVoiceOpenFeignClient { + @Override + public Result> resiTagList(ResiTagListFormDTO formDto) { + return ModuleUtils.feignConError(ServiceConstant.GOV_VOICE_SERVER, "resiTagList", formDto); + } + + @Override + public Result> tagCascadeList(TagCascadeListFormDTO formDto) { + return ModuleUtils.feignConError(ServiceConstant.GOV_VOICE_SERVER, "tagCascadeList", formDto); + } @Override public Result> resiTopArticleList(CommonArticleListFormDTO commonArticleListFormDTO) { diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java index fd551fbe25..bb1013913f 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/controller/ArticleController.java @@ -32,11 +32,6 @@ import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.ArticleDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; -import com.epmet.dto.form.ArticlePageFormDTO; -import com.epmet.dto.form.CommonArticleListFormDTO; -import com.epmet.dto.result.ArticleBannerResultDTO; -import com.epmet.dto.result.ArticleLatestResultDTO; -import com.epmet.dto.result.ArticleWithTagsResultDTO; import com.epmet.excel.ArticleExcel; import com.epmet.service.ArticleOperateRecordService; import com.epmet.service.ArticleService; diff --git a/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/controller/ArticleController.java b/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/controller/ArticleController.java index 346549afd2..4db3c1162b 100644 --- a/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/controller/ArticleController.java +++ b/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/controller/ArticleController.java @@ -4,9 +4,13 @@ import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.dto.feign.GovVoiceFeignClient; -import com.epmet.dto.form.*; -import com.epmet.dto.result.*; +import com.epmet.dto.form.ArticlePageFormDTO; +import com.epmet.dto.form.ResiArticleDetailFormDTO; +import com.epmet.dto.form.ResiTagListFormDTO; +import com.epmet.dto.form.TagCascadeListFormDTO; +import com.epmet.dto.result.ArticleDetailResultDTO; +import com.epmet.dto.result.ArticleWithTagsResultDTO; +import com.epmet.dto.result.TagInfoResultDTO; import com.epmet.feign.GovVoiceOpenFeignClient; import com.epmet.service.ArticleService; import org.springframework.beans.factory.annotation.Autowired; diff --git a/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java b/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java index dad9543720..565e6bfda3 100644 --- a/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java +++ b/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java @@ -5,7 +5,6 @@ import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.feign.GovVoiceFeignClient; import com.epmet.dto.form.ArticlePageFormDTO; import com.epmet.dto.form.ResiTagListFormDTO; import com.epmet.dto.form.TagCascadeListFormDTO; @@ -22,7 +21,6 @@ import org.springframework.stereotype.Service; import java.util.Arrays; import java.util.HashSet; import java.util.List; -import java.util.Set; import java.util.stream.Collectors; @@ -33,8 +31,6 @@ import java.util.stream.Collectors; @Service public class ArticleServiceImpl implements ArticleService { - @Autowired - private GovVoiceFeignClient govVoiceFeignClient; @Autowired private GovVoiceOpenFeignClient govVoiceOpenFeignClient; @@ -47,7 +43,7 @@ public class ArticleServiceImpl implements ArticleService { public List resiTagList(TokenDto tokenDto, ResiTagListFormDTO formDto) { // formDto.setCustomerId(tokenDto.getCustomerId()); formDto.setUserId(tokenDto.getUserId()); - return govVoiceFeignClient.resiTagList(formDto).getData(); + return govVoiceOpenFeignClient.resiTagList(formDto).getData(); } /** @@ -58,7 +54,7 @@ public class ArticleServiceImpl implements ArticleService { @Override public List tagCascadeList(TokenDto tokenDto, TagCascadeListFormDTO formDto) { // formDto.setCustomerId(tokenDto.getCustomerId()); - return govVoiceFeignClient.tagCascadeList(formDto).getData(); + return govVoiceOpenFeignClient.tagCascadeList(formDto).getData(); } /** From ca0eb0f7a91bb69a0db18634a25b74e6dce6faef Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 4 Jun 2020 22:15:24 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=96=B0=E5=A2=9EGovVoiceOpenFeignClient,?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8E=9F=E6=9D=A5=E7=9A=84GovVoiceFeignClien?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/controller/ArticleController.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/controller/ArticleController.java b/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/controller/ArticleController.java index 4db3c1162b..2a8bbfd988 100644 --- a/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/controller/ArticleController.java +++ b/epmet-module/resi-voice/resi-voice-server/src/main/java/com/epmet/controller/ArticleController.java @@ -36,7 +36,6 @@ public class ArticleController { * @author zxc */ @PostMapping("taglist") -// @RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_PUBLISHED_LIST) public Result> resiTagList(@LoginUser TokenDto tokenDto, @RequestBody ResiTagListFormDTO formDto){ ValidatorUtils.validateEntity(formDto, ResiTagListFormDTO.ResiTagListForm.class); return new Result>().ok(articleService.resiTagList(tokenDto,formDto)); @@ -48,7 +47,6 @@ public class ArticleController { * @author zxc */ @PostMapping("tagcascadelist") -// @RequirePermission(requirePermission = RequirePermissionEnum.WORK_PARTY_VOICE_PUBLISHED_LIST) public Result> tagCascadeList(@LoginUser TokenDto tokenDto, @RequestBody TagCascadeListFormDTO formDto){ ValidatorUtils.validateEntity(formDto, TagCascadeListFormDTO.TagCascadeList.class); return new Result>().ok(articleService.tagCascadeList(tokenDto,formDto)); From e5acef4585db6d271cc55a58bb4029e8919a4eb5 Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 4 Jun 2020 23:15:04 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=89=AB=E6=8F=8F?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../deploy/docker-compose-dev.yml | 17 ++ .../deploy/docker-compose-test.yml | 17 ++ epmet-openapi/epmet-openapi-scan/pom.xml | 136 +++++++++++++++ .../epmet/openapi/scan/ScanApplication.java | 28 +++ .../openapi/scan/aspect/RequestLogAspect.java | 40 +++++ .../openapi/scan/common/enu/ImgSceneEnum.java | 46 +++++ .../openapi/scan/common/enu/RegionIdEnum.java | 49 ++++++ .../scan/controller/TestController.java | 36 ++++ .../openapi/scan/support/param/ScanParam.java | 37 ++++ .../openapi/scan/support/param/Task.java | 25 +++ .../src/main/resources/bootstrap.yml | 77 ++++++++ .../src/main/resources/logback-spring.xml | 164 ++++++++++++++++++ .../src/test/java/BaseSample.java | 50 ++++++ .../java/ImageAsyncScanRequestSample.java | 95 ++++++++++ .../java/ImageAsyncScanResultsSample.java | 83 +++++++++ .../test/java/ImageSyncScanRequestSample.java | 101 +++++++++++ epmet-openapi/pom.xml | 18 ++ pom.xml | 1 + 18 files changed, 1020 insertions(+) create mode 100644 epmet-openapi/epmet-openapi-scan/deploy/docker-compose-dev.yml create mode 100644 epmet-openapi/epmet-openapi-scan/deploy/docker-compose-test.yml create mode 100644 epmet-openapi/epmet-openapi-scan/pom.xml create mode 100644 epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/ScanApplication.java create mode 100644 epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/aspect/RequestLogAspect.java create mode 100644 epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/enu/ImgSceneEnum.java create mode 100644 epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/enu/RegionIdEnum.java create mode 100644 epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/controller/TestController.java create mode 100644 epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/support/param/ScanParam.java create mode 100644 epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/support/param/Task.java create mode 100644 epmet-openapi/epmet-openapi-scan/src/main/resources/bootstrap.yml create mode 100644 epmet-openapi/epmet-openapi-scan/src/main/resources/logback-spring.xml create mode 100644 epmet-openapi/epmet-openapi-scan/src/test/java/BaseSample.java create mode 100644 epmet-openapi/epmet-openapi-scan/src/test/java/ImageAsyncScanRequestSample.java create mode 100644 epmet-openapi/epmet-openapi-scan/src/test/java/ImageAsyncScanResultsSample.java create mode 100644 epmet-openapi/epmet-openapi-scan/src/test/java/ImageSyncScanRequestSample.java create mode 100644 epmet-openapi/pom.xml diff --git a/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-dev.yml b/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-dev.yml new file mode 100644 index 0000000000..8aed7ac022 --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-dev.yml @@ -0,0 +1,17 @@ +version: "3.7" +services: + epmet-user-server: + container_name: epmet-openapi-scan-dev + image: 192.168.1.130:10080/epmet-cloud-dev/epmet-openapi-scan:0.3.56 + ports: + - "8107:8107" + network_mode: host # 不会创建新的网络 + volumes: + - "/opt/epmet-cloud-logs/dev:/logs" + environment: + RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./app.jar" + deploy: + resources: + limits: + cpus: '0.1' + memory: 300M \ No newline at end of file diff --git a/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-test.yml b/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-test.yml new file mode 100644 index 0000000000..ef6895dc7b --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/deploy/docker-compose-test.yml @@ -0,0 +1,17 @@ +version: "3.7" +services: + epmet-user-server: + container_name: epmet-openapi-scan-test + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-release/epmet-user-scan:0.3.53 + ports: + - "8107:8107" + network_mode: host # 不会创建新的网络 + volumes: + - "/opt/epmet-cloud-logs/test:/logs" + environment: + RUN_INSTRUCT: "java -Xms32m -Xmx200m -jar ./app.jar" + deploy: + resources: + limits: + cpus: '0.1' + memory: 300M \ No newline at end of file diff --git a/epmet-openapi/epmet-openapi-scan/pom.xml b/epmet-openapi/epmet-openapi-scan/pom.xml new file mode 100644 index 0000000000..47462e4a16 --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/pom.xml @@ -0,0 +1,136 @@ + + + + epmet-cloud + com.epmet + 2.0.0 + + 4.0.0 + + epmet-openapi-scan + jar + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-context-support + + + org.springframework.boot + spring-boot-starter-actuator + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + com.epmet + epmet-commons-tools + 2.0.0 + + + + com.aliyun + aliyun-java-sdk-core + 3.5.0 + + + com.aliyun + aliyun-java-sdk-green + 3.5.0 + + + + org.apache.httpcomponents + httpclient + 4.5.2 + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + ${project.basedir}/src/main/java + + + true + ${basedir}/src/main/resources + + + + + + + dev + + true + + + 8107 + dev + + + + 0 + 192.168.1.130 + 6379 + 123456 + + true + 122.152.200.70:8848 + fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b + + + false + + + + + test + + + 8107 + test + + + 0 + r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com + 6379 + EpmEtrEdIs!q@w + + true + 192.168.10.150:8848 + 67e3c350-533e-4d7c-9f8f-faf1b4aa82ae + + + false + + + + + + \ No newline at end of file diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/ScanApplication.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/ScanApplication.java new file mode 100644 index 0000000000..b87a8dc231 --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/ScanApplication.java @@ -0,0 +1,28 @@ +/** + * 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; + +/** + * 管理后台 + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ + +@SpringBootApplication +public class ScanApplication { + + public static void main(String[] args) { + SpringApplication.run(ScanApplication.class, args); + } + +} diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/aspect/RequestLogAspect.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/aspect/RequestLogAspect.java new file mode 100644 index 0000000000..ae6960a52d --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/aspect/RequestLogAspect.java @@ -0,0 +1,40 @@ +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(); + } + +} diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/enu/ImgSceneEnum.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/enu/ImgSceneEnum.java new file mode 100644 index 0000000000..1fcbbba9f0 --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/enu/ImgSceneEnum.java @@ -0,0 +1,46 @@ +package com.epmet.openapi.scan.common.enu; + +import java.util.ArrayList; +import java.util.List; + +/** + * @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 getImgSceneList() { + List 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; + } +} diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/enu/RegionIdEnum.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/enu/RegionIdEnum.java new file mode 100644 index 0000000000..e1dbd5897b --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/common/enu/RegionIdEnum.java @@ -0,0 +1,49 @@ +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; + } +} diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/controller/TestController.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/controller/TestController.java new file mode 100644 index 0000000000..e903a8d0e7 --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/controller/TestController.java @@ -0,0 +1,36 @@ +package com.epmet.openapi.scan.controller; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.utils.Result; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author jianjun liu + * @date 2020-06-04 20:39 + **/ +@RestController +@RequestMapping("test") +public class TestController { + @Value("${aliyun.green.accessKeyId}") + private String accessKeyId; + + @Value("${aliyun.green.accessKeySecret}") + private String accessKeySecret; + + @Value("${aliyun.green.regionId}") + private String regionId; + @GetMapping("api") + public Result page() { + Map map = new HashMap<>(); + map.put(accessKeyId,accessKeyId); + map.put(accessKeySecret,accessKeySecret); + map.put(regionId, regionId); + return new Result().ok(JSON.toJSONString(map)); + } +} diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/support/param/ScanParam.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/support/param/ScanParam.java new file mode 100644 index 0000000000..d589aa33b7 --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/support/param/ScanParam.java @@ -0,0 +1,37 @@ +package com.epmet.openapi.scan.support.param; + +import lombok.Data; + +import java.util.List; + +/** + * 审查参数 + * + * @author jianjun liu + * @date 2020-06-04 21:57 + **/ +@Data +public class ScanParam { + /** + * 场景 必填 + * + * @see com.epmet.openapi.scan.common.enu.ImgSceneEnum; + */ + private List scenes; + + /** + * 要检测的内容列表,必填 + * remark:一组任务列表中的taskId不能相同 + */ + private List tasks; + + /** + * 异步检测结果回调地址,执行异步审查内容时 必填 + */ + private String callback; + + /** + * 随机字符串,该值用于回调通知请求中的签名,使用callback时 必填 + */ + private String seed; +} diff --git a/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/support/param/Task.java b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/support/param/Task.java new file mode 100644 index 0000000000..51f38b1b3b --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/src/main/java/com/epmet/openapi/scan/support/param/Task.java @@ -0,0 +1,25 @@ +package com.epmet.openapi.scan.support.param; + +import lombok.Data; + +/** + * 任务参数 + * + * @author jianjun liu + * @email liujianjun@yunzongnet.com + * @date 2020-06-04 22:13 + **/ +@Data +public class Task { + + /** + * 要检测的数据id 非必填 + * + * */ + private String dataId; + + /** + * 图片url 必填 + */ + private String url; +} diff --git a/epmet-openapi/epmet-openapi-scan/src/main/resources/bootstrap.yml b/epmet-openapi/epmet-openapi-scan/src/main/resources/bootstrap.yml new file mode 100644 index 0000000000..c2cf89a17e --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/src/main/resources/bootstrap.yml @@ -0,0 +1,77 @@ +server: + port: @server.port@ + servlet: + context-path: /epmetscan + +spring: + main: + allow-bean-definition-overriding: true + application: + name: epmet-openapi-scan + #环境 dev|test|prod + profiles: + active: dev + 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 + httpclient: + enabled: true + + +hystrix: + command: + default: + execution: + isolation: + thread: + timeoutInMilliseconds: 60000 #缺省为1000 + +ribbon: + ReadTimeout: 300000 + ConnectTimeout: 300000 + +aliyun: + green: + accessKeyId: 123 + accessKeySecret: 456 + regionId: cn-shanghai \ No newline at end of file diff --git a/epmet-openapi/epmet-openapi-scan/src/main/resources/logback-spring.xml b/epmet-openapi/epmet-openapi-scan/src/main/resources/logback-spring.xml new file mode 100644 index 0000000000..d244b6fa2a --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/src/main/resources/logback-spring.xml @@ -0,0 +1,164 @@ + + + + + + + + + + ${appname} + + + + + + + + + debug + + + ${CONSOLE_LOG_PATTERN} + + UTF-8 + + + + + + + + ${log.path}/debug.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/debug-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + debug + ACCEPT + DENY + + + + + + + ${log.path}/info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + + ${log.path}/info-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + info + ACCEPT + DENY + + + + + + + ${log.path}/warn.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/warn-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + warn + ACCEPT + DENY + + + + + + + ${log.path}/error.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%contextName] [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${log.path}/error-%d{yyyy-MM-dd}.%i.log + + 100MB + + + 15 + + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epmet-openapi/epmet-openapi-scan/src/test/java/BaseSample.java b/epmet-openapi/epmet-openapi-scan/src/test/java/BaseSample.java new file mode 100644 index 0000000000..8c0774030d --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/src/test/java/BaseSample.java @@ -0,0 +1,50 @@ +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; + } + +} diff --git a/epmet-openapi/epmet-openapi-scan/src/test/java/ImageAsyncScanRequestSample.java b/epmet-openapi/epmet-openapi-scan/src/test/java/ImageAsyncScanRequestSample.java new file mode 100644 index 0000000000..acba42e763 --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/src/test/java/ImageAsyncScanRequestSample.java @@ -0,0 +1,95 @@ +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> tasks = new ArrayList>(); + Map task1 = new LinkedHashMap(); + 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(); + } + } +} diff --git a/epmet-openapi/epmet-openapi-scan/src/test/java/ImageAsyncScanResultsSample.java b/epmet-openapi/epmet-openapi-scan/src/test/java/ImageAsyncScanResultsSample.java new file mode 100644 index 0000000000..27e0b6e233 --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/src/test/java/ImageAsyncScanResultsSample.java @@ -0,0 +1,83 @@ +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 taskIds = new ArrayList(); + 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(); + } + } +} diff --git a/epmet-openapi/epmet-openapi-scan/src/test/java/ImageSyncScanRequestSample.java b/epmet-openapi/epmet-openapi-scan/src/test/java/ImageSyncScanRequestSample.java new file mode 100644 index 0000000000..ec418154d9 --- /dev/null +++ b/epmet-openapi/epmet-openapi-scan/src/test/java/ImageSyncScanRequestSample.java @@ -0,0 +1,101 @@ +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> tasks = new ArrayList>(); + Map task = new LinkedHashMap(); + 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(); + } + } +} diff --git a/epmet-openapi/pom.xml b/epmet-openapi/pom.xml new file mode 100644 index 0000000000..47fcd27942 --- /dev/null +++ b/epmet-openapi/pom.xml @@ -0,0 +1,18 @@ + + + + epmet-cloud + com.epmet + 2.0.0 + + 4.0.0 + jar + + epmet-openapi + + epmet-openapi-scan + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 741f491b12..ee379a6b7a 100644 --- a/pom.xml +++ b/pom.xml @@ -27,6 +27,7 @@ epmet-admin epmet-module epmet-user + epmet-openapi From 719951d71b0afb7435212b5d4f95f70e0ffa9371 Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 5 Jun 2020 09:57:08 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ArticleServiceImpl.java | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java index 5219c1de67..b5e4cb2a44 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java @@ -23,9 +23,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; @@ -43,13 +45,14 @@ import com.epmet.dto.feign.GovOrgSelfFeignClient; import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.entity.*; +import com.epmet.feign.EpmetUserClientFeignClient; import com.epmet.feign.EpmetUserSelfFeignClient; import com.epmet.redis.ArticleRedis; import com.epmet.service.ArticleOperateRecordService; import com.epmet.service.ArticlePublishRangeService; import com.epmet.service.ArticleService; -import com.epmet.utils.ModuleConstant; import com.epmet.service.ArticleVisitRecordService; +import com.epmet.utils.ModuleConstant; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.extern.slf4j.Slf4j; @@ -92,6 +95,10 @@ public class ArticleServiceImpl extends BaseServiceImpl loginUserDetails = epmetUserClientFeignClient.getLoginUserDetails(detailsFormDTO); + if (loginUserDetails == null || loginUserDetails.getData() == null){ + log.warn("saveOrUpdateContent getloginUserDetails return null"); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(),EpmetErrorCode.SERVER_ERROR.getMsg()); + } draftEntity = new DraftEntity(); draftEntity.setTitle(fromDTO.getTitle()); draftEntity.setCustomerId(tokenDto.getCustomerId()); draftEntity.setIsTop(DraftConstant.UN_TOP); draftEntity.setStatusFlag(DraftConstant.UNPUBLISH); - draftEntity.setOrgId(""); - draftEntity.setOrgIdPath(""); + draftEntity.setOrgId(loginUserDetails.getData().getAgencyId()); + draftEntity.setOrgIdPath(loginUserDetails.getData().getOrgIdPath()); draftEntity.setGridId(""); - draftEntity.setDepartmentId(""); + draftEntity.setDepartmentId(loginUserDetails.getData().getCustomerId()); draftEntity.setDelFlag(NumConstant.ZERO_STR); - draftDao.insert(draftEntity); } @@ -348,7 +363,7 @@ public class ArticleServiceImpl extends BaseServiceImpl publishRangeEntityList = new ArrayList<>(); List agencyGridNameList = new ArrayList<>(); - ArticleGridResultDTO articleGridResultDTO = agencyGridList(tokenDto); + ArticleGridResultDTO articleGridResultDTO = this.agencyGridList(tokenDto); if (articleGridResultDTO == null) { log.warn("saveDraftAttr userId:{} have not right access publishRange", tokenDto.getUserId()); throw new RenException("参数错误"); @@ -422,6 +437,8 @@ public class ArticleServiceImpl extends BaseServiceImpl