From 1adf59bd4dc1f881e0a97365c350daf99c43f6ad Mon Sep 17 00:00:00 2001
From: qyx <565485304@qq.com>
Date: Fri, 21 Jan 2022 16:01:01 +0800
Subject: [PATCH] =?UTF-8?q?[=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD](master):?=
=?UTF-8?q?=20=E5=88=9D=E5=A7=8B=E5=8C=96=E9=A1=B9=E7=9B=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
提交巨量回调代码
---
.gitignore | 33 ++
.jpb/jpb-settings.xml | 14 +
README.md | 4 +
pom.xml | 87 ++++
.../adcallback/AdCallbackApplication.java | 23 ++
.../api/callback/JuliangAuthCallbackAPI.java | 43 ++
.../JuliangMobileMonitorCallbackAPI.java | 125 ++++++
.../adcallback/api/common/CommonResponse.java | 134 ++++++
.../adcallback/api/common/ResponseCode.java | 48 +++
.../api/constants/RequestDetailConstant.java | 11 +
.../api/constants/RequestInfoConstant.java | 32 ++
.../AdOriginalityManageController.java | 74 ++++
.../api/controller/BaseController.java | 11 +
.../FeiyuSourceManageController.java | 23 ++
.../JuliangMobileMonitorController.java | 61 +++
.../api/controller/TokenManageController.java | 49 +++
...JuliangMobileMonitorCallbackRequestVO.java | 40 ++
.../common/constant/JuliangConstant.java | 35 ++
.../adcallback/common/pojo/JlBackdataDTO.java | 36 ++
.../pojo/convert/JlBackdataConvert.java | 41 ++
.../common/request/JuliangRequestHeader.java | 48 +++
.../common/request/JuliangRequestParam.java | 26 ++
.../adcallback/common/util/FileUtil.java | 382 ++++++++++++++++++
.../adcallback/config/AuditingConfig.java | 15 +
.../config/DefaultAuditorAwareImpl.java | 15 +
.../config/SpringMVCConfiguration.java | 25 ++
.../TbJlBackdataEntityRepository.java | 18 +
.../repository/TbJlTokenEntityRepository.java | 7 +
.../repository/entity/TbJlBackdataEntity.java | 104 +++++
.../repository/entity/TbJlTokenEntity.java | 62 +++
.../service/AdOriginalityManageService.java | 14 +
.../service/FeiyuSourceManageService.java | 4 +
.../service/JuliangMobileMonitorService.java | 13 +
.../service/TokenManageService.java | 36 ++
.../impl/AdOriginalityManageServiceImpl.java | 38 ++
.../impl/FeiyuSourceManageServiceImpl.java | 8 +
.../impl/JuliangMobileMonitorServiceImpl.java | 88 ++++
.../service/impl/TokenManageServiceImpl.java | 122 ++++++
.../FixedTimeAutoRefreshJuliangTokenTask.java | 50 +++
src/main/resources/application-dev.yml | 47 +++
src/main/resources/application-online.yml | 45 +++
src/main/resources/application-prod.yml | 45 +++
src/main/resources/application.yml | 55 +++
src/main/resources/logback.xml | 83 ++++
.../AdCallbackApplicationTests.java | 13 +
45 files changed, 2287 insertions(+)
create mode 100644 .gitignore
create mode 100644 .jpb/jpb-settings.xml
create mode 100644 README.md
create mode 100644 pom.xml
create mode 100644 src/main/java/com/baiyee/adcallback/AdCallbackApplication.java
create mode 100644 src/main/java/com/baiyee/adcallback/api/callback/JuliangAuthCallbackAPI.java
create mode 100644 src/main/java/com/baiyee/adcallback/api/callback/JuliangMobileMonitorCallbackAPI.java
create mode 100644 src/main/java/com/baiyee/adcallback/api/common/CommonResponse.java
create mode 100644 src/main/java/com/baiyee/adcallback/api/common/ResponseCode.java
create mode 100644 src/main/java/com/baiyee/adcallback/api/constants/RequestDetailConstant.java
create mode 100644 src/main/java/com/baiyee/adcallback/api/constants/RequestInfoConstant.java
create mode 100644 src/main/java/com/baiyee/adcallback/api/controller/AdOriginalityManageController.java
create mode 100644 src/main/java/com/baiyee/adcallback/api/controller/BaseController.java
create mode 100644 src/main/java/com/baiyee/adcallback/api/controller/FeiyuSourceManageController.java
create mode 100644 src/main/java/com/baiyee/adcallback/api/controller/JuliangMobileMonitorController.java
create mode 100644 src/main/java/com/baiyee/adcallback/api/controller/TokenManageController.java
create mode 100644 src/main/java/com/baiyee/adcallback/api/vo/JuliangMobileMonitorCallbackRequestVO.java
create mode 100644 src/main/java/com/baiyee/adcallback/common/constant/JuliangConstant.java
create mode 100644 src/main/java/com/baiyee/adcallback/common/pojo/JlBackdataDTO.java
create mode 100644 src/main/java/com/baiyee/adcallback/common/pojo/convert/JlBackdataConvert.java
create mode 100644 src/main/java/com/baiyee/adcallback/common/request/JuliangRequestHeader.java
create mode 100644 src/main/java/com/baiyee/adcallback/common/request/JuliangRequestParam.java
create mode 100644 src/main/java/com/baiyee/adcallback/common/util/FileUtil.java
create mode 100644 src/main/java/com/baiyee/adcallback/config/AuditingConfig.java
create mode 100644 src/main/java/com/baiyee/adcallback/config/DefaultAuditorAwareImpl.java
create mode 100644 src/main/java/com/baiyee/adcallback/config/SpringMVCConfiguration.java
create mode 100644 src/main/java/com/baiyee/adcallback/repository/TbJlBackdataEntityRepository.java
create mode 100644 src/main/java/com/baiyee/adcallback/repository/TbJlTokenEntityRepository.java
create mode 100644 src/main/java/com/baiyee/adcallback/repository/entity/TbJlBackdataEntity.java
create mode 100644 src/main/java/com/baiyee/adcallback/repository/entity/TbJlTokenEntity.java
create mode 100644 src/main/java/com/baiyee/adcallback/service/AdOriginalityManageService.java
create mode 100644 src/main/java/com/baiyee/adcallback/service/FeiyuSourceManageService.java
create mode 100644 src/main/java/com/baiyee/adcallback/service/JuliangMobileMonitorService.java
create mode 100644 src/main/java/com/baiyee/adcallback/service/TokenManageService.java
create mode 100644 src/main/java/com/baiyee/adcallback/service/impl/AdOriginalityManageServiceImpl.java
create mode 100644 src/main/java/com/baiyee/adcallback/service/impl/FeiyuSourceManageServiceImpl.java
create mode 100644 src/main/java/com/baiyee/adcallback/service/impl/JuliangMobileMonitorServiceImpl.java
create mode 100644 src/main/java/com/baiyee/adcallback/service/impl/TokenManageServiceImpl.java
create mode 100644 src/main/java/com/baiyee/adcallback/task/FixedTimeAutoRefreshJuliangTokenTask.java
create mode 100644 src/main/resources/application-dev.yml
create mode 100644 src/main/resources/application-online.yml
create mode 100644 src/main/resources/application-prod.yml
create mode 100644 src/main/resources/application.yml
create mode 100644 src/main/resources/logback.xml
create mode 100644 src/test/java/com/baiyee/adcallback/AdCallbackApplicationTests.java
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..549e00a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
diff --git a/.jpb/jpb-settings.xml b/.jpb/jpb-settings.xml
new file mode 100644
index 0000000..988ee6a
--- /dev/null
+++ b/.jpb/jpb-settings.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..e06c60c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,4 @@
+## 百度广告投放平台检测 - 百度营销
+ https://dev2.baidu.com/content?sceneType=0&pageId=101214&nodeId=662&subhead=
+## 广电通 - 腾讯广告
+ https://developers.e.qq.com/docs/guide/conversion/new_version/dianjijiance
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..5217d2d
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,87 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.3.2.RELEASE
+
+
+ com.baiyee
+ ad-callback
+ 0.0.1-SNAPSHOT
+ ad-callback
+ ad-callback
+
+ 1.8
+ true
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+ cn.hutool
+ hutool-all
+ 5.7.16
+
+
+
+
+ com.alibaba
+ druid-spring-boot-starter
+ 1.1.22
+
+
+
+
+ mysql
+ mysql-connector-java
+ runtime
+
+
+
+ org.apache.poi
+ poi-ooxml
+ 5.1.0
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ ${maven.test.skip}
+ ${maven.test.failure.ignore}
+
+
+
+
+
+
diff --git a/src/main/java/com/baiyee/adcallback/AdCallbackApplication.java b/src/main/java/com/baiyee/adcallback/AdCallbackApplication.java
new file mode 100644
index 0000000..1a869d0
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/AdCallbackApplication.java
@@ -0,0 +1,23 @@
+package com.baiyee.adcallback;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+/**
+ * 广告回调程序
+ *
+ * @author q
+ * @date 2022/01/05
+ */
+@SpringBootApplication
+// 开启定时任务功能
+@EnableScheduling
+public class AdCallbackApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(AdCallbackApplication.class, args);
+ }
+
+}
diff --git a/src/main/java/com/baiyee/adcallback/api/callback/JuliangAuthCallbackAPI.java b/src/main/java/com/baiyee/adcallback/api/callback/JuliangAuthCallbackAPI.java
new file mode 100644
index 0000000..41c176f
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/api/callback/JuliangAuthCallbackAPI.java
@@ -0,0 +1,43 @@
+package com.baiyee.adcallback.api.callback;
+
+import com.baiyee.adcallback.service.TokenManageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * juliang身份验证回调api
+ *
+ * @author q
+ * @date 2022/01/05
+ */
+@RestController
+@RequestMapping(value = ("/jl"))
+public class JuliangAuthCallbackAPI {
+
+ @Autowired
+ private TokenManageService tokenManageService;
+
+ @RequestMapping(value = "/callback")
+ public void julaingAuthCallbackReqUrl(HttpServletRequest request){
+ // 授权链接的回调地址
+ // 需要与callback address相同**,否则会报错
+ System.out.println(request.getParameter("redirect"));
+ // 授权成功后,开发者通回调地址获取的授权码auth code,可用于获取 Access Token。
+ // 注意auth_code有效时间为10分钟,且只可使用一次
+ System.out.println(request.getParameter("auth_code"));
+ // 这里是一个自定义的字段
+ // state=your_custom_params&
+ // 用于拼装授权URL时传递自定义信息,授权成功回调时会原样带回。
+ // 常见应用:比如将广告主账号作为自定义参数,回调时以区分授权码对应的广告主。
+ System.out.println(request.getParameter("state"));
+
+
+ }
+
+// https://xx.tuoz.net/login?redirect=%2Fdashboard%3Fstate%3Dyour_custom_params&auth_code=3819efd33fcaba807c0f65ac252b5b58495e5223
+
+
+}
diff --git a/src/main/java/com/baiyee/adcallback/api/callback/JuliangMobileMonitorCallbackAPI.java b/src/main/java/com/baiyee/adcallback/api/callback/JuliangMobileMonitorCallbackAPI.java
new file mode 100644
index 0000000..c785f27
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/api/callback/JuliangMobileMonitorCallbackAPI.java
@@ -0,0 +1,125 @@
+package com.baiyee.adcallback.api.callback;
+
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baiyee.adcallback.api.common.CommonResponse;
+import com.baiyee.adcallback.api.common.ResponseCode;
+import com.baiyee.adcallback.api.vo.JuliangMobileMonitorCallbackRequestVO;
+import com.baiyee.adcallback.common.pojo.JlBackdataDTO;
+import com.baiyee.adcallback.common.pojo.convert.JlBackdataConvert;
+import com.baiyee.adcallback.service.AdOriginalityManageService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import static com.baiyee.adcallback.common.constant.JuliangConstant.IMEI_TAG;
+
+/**
+ * juliang移动监控回调的api
+ *
+ * @author q
+ * @date 2022/01/06
+ * @see
+ */
+@RestController
+@RequestMapping(value = ("/jl"))
+@Slf4j
+public class JuliangMobileMonitorCallbackAPI {
+
+
+
+ private final AdOriginalityManageService adOriginalityManageService;
+
+ public JuliangMobileMonitorCallbackAPI(AdOriginalityManageService adOriginalityManageService) {
+ this.adOriginalityManageService = adOriginalityManageService;
+ }
+
+
+ /**
+ * julaing身份验证回调url请求
+ *
+ * 1. 首先需要广告主在计划上填写监测链接
+ * exp: https://mybest.custom.com/click/?aid=__AID__&cid=__CID__&callback_url=__CALLBACK_URL__
+ *
+ * ps. 其中下划线的部分,就是我们替换后的真实广告信息(非 ASC 字符,进行了 url encode)
+ * ps. 在头条客户端中,用户真实产生了广告点击的时候,我们会把相应的字段换成真实的广告信息,发送给广告主。
+ * ps. 为了获得更高的安全性,推荐您使用HTTPS通道
+ * ps. 支持HTTP GET方法发送请求,这种方式下请求参数需要包含在请求的URL中
+ *
+ * 2. 我们采用的配置为
+ * 平台配置 exp: &__AID__&__AIDNAME__&__ADVERTISERID__&__CID__&__CTYPE__&__CSITE__&__IMEI__&__IDFA__&__OAID__&__OS__&__MAC__&__MAC1__&__IP__&__GEO__&__TS__&__CALLBACKURL__&__MODEL__&__CAID12__
+ * 测试 exp: aid=1645988237525045&aidname=testaidname1&advertiserid=1631857582073864&cid=1650703686054530&ctype=2&csite=33013&imei=0c2bd03c39f19845bf54ea0abafae70e&idfa=4FCFEFA1-096D-4176-B352-1870ED6DB777&oaid=97e7ef3f-e5f2-d0b8-ccfc-f79bbeaf4841&os=0&mac=df97bc5021e14256e141b2f036df5a3c&mac1=4d0433eb614f5d5ad409a65395426cbe&ip=61.158.146.195&geo=35.7x122.4x100.0&ts=1575194434000&callbackurl=https://ad.toutiao.com/track/activate/?callback=EJiw267wvfQCGKf2g74ZIPD89-vIATAMOAFCIjIwMTkxMTI3MTQxMTEzMDEwMDI2MDc3MjE1MTUwNTczNTBIAQ==&os=0&muid=db94e6a60a9c6661e3e03a7d301c25b6&model=iPhone12%2c2&caid12=f949f306494646edfee1f939698e1fb1
+ *
+ */
+ @RequestMapping(value = "/monitor")
+ public CommonResponse julaingMonitorUrlCallbackReqUrl(
+ @RequestParam(value = "aid", defaultValue = "") String aid,
+ @RequestParam(value = "aidname", defaultValue = "") String aidName,
+ @RequestParam(value = "advertiserid", defaultValue = "") String advertiserId,
+ @RequestParam(value = "cid", defaultValue = "") Long cid,
+ @RequestParam(value = "ctype", defaultValue = "") Integer ctype,
+ @RequestParam(value = "csite", defaultValue = "") Integer csite,
+ @RequestParam(value = "imei", defaultValue = "") String imei,
+ @RequestParam(value = "idfa", defaultValue = "") String idfa,
+ @RequestParam(value = "oaid", defaultValue = "") String oaid,
+ @RequestParam(value = "os", defaultValue = "") Integer os,
+ @RequestParam(value = "mac", defaultValue = "") String mac,
+ @RequestParam(value = "mac1", defaultValue = "") String mac1,
+ @RequestParam(value = "ip", defaultValue = "") String ip,
+ @RequestParam(value = "geo", defaultValue = "") String geo,
+ @RequestParam(value = "TIMESTAMP", defaultValue = "") Long ts,
+ @RequestParam(value = "callback_url", defaultValue = "") String callbackUrl,
+ @RequestParam(value = "model", defaultValue = "") String model,
+ @RequestParam(value = "caid1", defaultValue = "") String caid12
+
+ ) {
+ JuliangMobileMonitorCallbackRequestVO vo = new JuliangMobileMonitorCallbackRequestVO(
+ aid,aidName,advertiserId,cid,ctype,csite,imei,idfa,oaid,os,mac,mac1,ip,geo,ts,callbackUrl,model,caid12
+ );
+
+
+ if (ObjectUtil.isNull(vo)) {
+ return CommonResponse.createByErrorMessage(ResponseCode.EMPTY_ARGUMENT.getDesc());
+ }
+ // 请求过滤规则,过滤掉不用的数据
+ if (preRuleForReq(vo)){
+ log.error("================================= [not right imei data ,{} ] =================================",vo);
+ return CommonResponse.createBySuccess();
+ }
+
+ log.info("================================= [one request comming, JuliangMobileMonitorCallbackAPI|julaingMonitorUrlCallbackReqUrl, vo is {} ] =================================", vo);
+
+
+ JlBackdataDTO jlBackdataDTO = new JlBackdataDTO();
+ JlBackdataConvert.voCovertToDTO(vo, jlBackdataDTO);
+
+ adOriginalityManageService.handleMonitorUrlCallbackDataThenSave();
+
+ return CommonResponse.createBySuccess();
+ }
+
+ /**
+ * 之前的规则要求
+ *
+ * @return boolean
+ */
+ private boolean preRuleForReq(JuliangMobileMonitorCallbackRequestVO vo) {
+
+ String imei = vo.getImei();
+ if (StrUtil.isBlank(imei)){
+ return Boolean.TRUE;
+ }
+
+ if (StrUtil.isNotBlank(imei) && StrUtil.equalsIgnoreCase(IMEI_TAG,imei)){
+ return Boolean.TRUE;
+ }
+ return Boolean.FALSE;
+
+ }
+
+// https://xx.tuoz.net/login?redirect=%2Fdashboard%3Fstate%3Dyour_custom_params&auth_code=3819efd33fcaba807c0f65ac252b5b58495e5223
+
+
+
+}
diff --git a/src/main/java/com/baiyee/adcallback/api/common/CommonResponse.java b/src/main/java/com/baiyee/adcallback/api/common/CommonResponse.java
new file mode 100644
index 0000000..00c0a1a
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/api/common/CommonResponse.java
@@ -0,0 +1,134 @@
+package com.baiyee.adcallback.api.common;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+
+/**
+ *
+ * JsonInclude.Include.NON_EMPTY 属性为 空("") 或者为 NULL 都不序列化,则返回的json是没有这个字段的。这样对移动端会更省流量
+ *
+ * @param 返回的对象实体
+ * @author q
+ */
+@JsonSerialize
+@Getter
+@JsonInclude(JsonInclude.Include.NON_EMPTY)
+@NoArgsConstructor
+public class CommonResponse implements Serializable {
+
+ /**
+ * 成功还是失败的状态标识 0,成功 1,失败
+ */
+ private int status;
+
+ /**
+ * 返回信息
+ */
+ private String msg;
+
+ /**
+ * 返回的结果数据
+ */
+ private T data;
+
+
+ /*
+ * 封装所有的构造器为私有的
+ */
+
+ private CommonResponse(int status) {
+ this.status = status;
+ }
+
+ private CommonResponse(int status, T data) { // ps: 当调用T为String类型时候,会默认调用下面的ServerResponse(int status, String msg)类型的构造器
+ this.status = status;
+ this.data = data;
+ }
+
+ private CommonResponse(int status, String msg, T data) {
+ this.status = status;
+ this.msg = msg;
+ this.data = data;
+ }
+
+ private CommonResponse(int status, String msg) {
+ this.status = status;
+ this.msg = msg;
+ }
+
+
+ /*
+ * 对外开放调用的静态方法,用来调用私有构造器,来返回成功结果给前台
+ */
+
+ /**
+ * @return 返回成功码和默认的成功信息
+ */
+ public static CommonResponse createBySuccess() {
+ return new CommonResponse(ResponseCode.SUCCESS.getCode(),ResponseCode.SUCCESS.getDesc());
+ }
+
+ /**
+ *
+ * @param msg 定义的成功信息
+ * @return 返回成功码和成功信息
+ */
+ public static CommonResponse createBySuccessMessage(String msg) {
+ return new CommonResponse(ResponseCode.SUCCESS.getCode(), msg);
+ }
+
+ /**
+ *
+ * @param data 传入实体
+ * @return 返回成功码和数据
+ */
+ public static CommonResponse createBySuccess(T data) {
+ return new CommonResponse(ResponseCode.SUCCESS.getCode(), data);
+ }
+
+ /**
+ *
+ * @param msg 传入信息
+ * @param data 传入实体
+ * @return 返回成功码和成功信息和数据
+ */
+ public static CommonResponse createBySuccess(String msg, T data) {
+ return new CommonResponse(ResponseCode.SUCCESS.getCode(), msg, data);
+ }
+
+ /*
+ 对外开放调用的静态方法,用来调用私有构造器,来返回失败结果给前台
+ */
+
+ /**
+ *
+ * @return 返回错误码和默认的错误
+ */
+ public static CommonResponse createByError(){
+ return new CommonResponse(ResponseCode.ERROR.getCode(),ResponseCode.ERROR.getDesc());
+ }
+
+ /**
+ *
+ * @param errorMessage 定义的错误信息
+ * @return 返回错误码和错误信息(传入)
+ */
+ public static CommonResponse createByErrorMessage(String errorMessage){
+ return new CommonResponse(ResponseCode.ERROR.getCode(),errorMessage);
+ }
+
+ /**
+ *
+ * @param errorCode 错误码
+ * @param errorMessage 错误信息
+ * @return 返回错误码(传入)和错误信息(传入)
+ */
+ public static CommonResponse createByErrorCodeMessage(int errorCode,String errorMessage){
+ return new CommonResponse(errorCode,errorMessage);
+ }
+}
diff --git a/src/main/java/com/baiyee/adcallback/api/common/ResponseCode.java b/src/main/java/com/baiyee/adcallback/api/common/ResponseCode.java
new file mode 100644
index 0000000..e90870c
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/api/common/ResponseCode.java
@@ -0,0 +1,48 @@
+package com.baiyee.adcallback.api.common;
+
+/**
+ * Description: 自定义Response响应返回体 -> 这边采用的是
+ * @author q
+ */
+public enum ResponseCode {
+
+ /**
+ * 成功
+ */
+ SUCCESS(0,"SUCCESS"),
+ /**
+ * 失败
+ */
+ ERROR(1,"ERROR"),
+
+
+ /*
+ * 请求参数校验
+ */
+ ILLEGAL_ARGUMENT(1,"请求参数格式错误"),
+ EMPTY_ARGUMENT(1,"请求参数为空"),
+
+ /*
+ * 请求结果性的错误
+ */
+ NO_REASON_ERROR(1,"未知异常错误发生"),
+ SYSTEM_ERROR(1,"系统异常"),
+ DECRYPT_ERROR(1,"解密错误,请联系相关人员");
+
+ private final int code;
+ private final String desc;
+
+ ResponseCode(int code, String desc){
+ this.code = code;
+ this.desc = desc;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public String getDesc() {
+ return desc;
+ }
+
+}
diff --git a/src/main/java/com/baiyee/adcallback/api/constants/RequestDetailConstant.java b/src/main/java/com/baiyee/adcallback/api/constants/RequestDetailConstant.java
new file mode 100644
index 0000000..34e39db
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/api/constants/RequestDetailConstant.java
@@ -0,0 +1,11 @@
+package com.baiyee.adcallback.api.constants;
+
+/**
+ * 详细的请求参数验证 - 错误信息
+ */
+public class RequestDetailConstant {
+
+ public static final String REQUEST_ADDR_EMPTY = "请求的地址为空";
+
+ public static final String REQUEST_PARAMS_EMPTY = "请求参数为空";
+}
diff --git a/src/main/java/com/baiyee/adcallback/api/constants/RequestInfoConstant.java b/src/main/java/com/baiyee/adcallback/api/constants/RequestInfoConstant.java
new file mode 100644
index 0000000..1beb40d
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/api/constants/RequestInfoConstant.java
@@ -0,0 +1,32 @@
+package com.baiyee.adcallback.api.constants;
+
+/**
+ * 请求信息常量类
+ */
+public class RequestInfoConstant {
+
+ /**
+ * 客户端请求地址标识名称
+ */
+ public static final String CUSTOMER_IP_ADDR_KEY = "customer_ip_addr_key";
+
+ /**
+ * 正式环境对应服务器绑定的域名
+ */
+ public static final String PROD_SERVER_HOST = "http://bc.tuoz.net/";
+
+ /**
+ * 本地开发路径 - 应用于本地服务器
+ */
+ public static final String DEV_SERVER_HOST = "http://localhost:6666/";
+
+ /**
+ * Http请求调用失败 重试次数
+ */
+ public static final int RETRY_COUNT = 3;
+
+ /**
+ * 默认的超时时长 默认是2000ms
+ */
+ public static final int DEFAULT_TIMEOUT_NUMBER = 20000;
+}
diff --git a/src/main/java/com/baiyee/adcallback/api/controller/AdOriginalityManageController.java b/src/main/java/com/baiyee/adcallback/api/controller/AdOriginalityManageController.java
new file mode 100644
index 0000000..cb251d6
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/api/controller/AdOriginalityManageController.java
@@ -0,0 +1,74 @@
+package com.baiyee.adcallback.api.controller;
+
+import com.baiyee.adcallback.api.common.CommonResponse;
+
+/**
+ * 广告创意管理控制器
+ *
+ * API doc
+ * @see 创意Api
+ *
+ * @author q
+ * @date 2022/01/05
+ */
+public class AdOriginalityManageController {
+
+
+ /**
+ * 获取的创意列表
+ *
+ * @see
+ *
+ * @return {@link CommonResponse}
+ */
+ public CommonResponse getListOfOriginality(){
+ return CommonResponse.createBySuccess();
+
+ }
+
+
+ /**
+ * 创建广告创意
+ *
+ * @see
+ *
+ * @return {@link CommonResponse}
+ */
+ public CommonResponse createOriginality(){
+ return CommonResponse.createBySuccess();
+ }
+
+ /**
+ * 创意的细节
+ *
+ * @see
+ *
+ * @return {@link CommonResponse}
+ */
+ public CommonResponse detailsOfOriginality(){
+ return CommonResponse.createBySuccess();
+ }
+
+
+ /**
+ * 编辑创意
+ *
+ * @see
+ *
+ * @return {@link CommonResponse}
+ */
+ public CommonResponse editOriginality(){
+ return CommonResponse.createBySuccess();
+ }
+
+ /**
+ * 更新创意状态
+ *
+ * @return {@link CommonResponse}
+ */
+ public CommonResponse updateOriginalityState(){
+ return CommonResponse.createBySuccess();
+ }
+
+
+}
diff --git a/src/main/java/com/baiyee/adcallback/api/controller/BaseController.java b/src/main/java/com/baiyee/adcallback/api/controller/BaseController.java
new file mode 100644
index 0000000..41154c3
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/api/controller/BaseController.java
@@ -0,0 +1,11 @@
+package com.baiyee.adcallback.api.controller;
+
+/**
+ * 基本控制器
+ *
+ * @author q
+ * @date 2022/01/05
+ */
+public class BaseController {
+
+}
diff --git a/src/main/java/com/baiyee/adcallback/api/controller/FeiyuSourceManageController.java b/src/main/java/com/baiyee/adcallback/api/controller/FeiyuSourceManageController.java
new file mode 100644
index 0000000..c67d46a
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/api/controller/FeiyuSourceManageController.java
@@ -0,0 +1,23 @@
+package com.baiyee.adcallback.api.controller;
+
+
+import com.baiyee.adcallback.api.common.CommonResponse;
+
+/**
+ * 飞鱼 源管理控制器
+ *
+ * @author q
+ * @date 2022/01/05
+ */
+public class FeiyuSourceManageController {
+
+ /**
+ * 得到飞鱼线索列表
+ *
+ * @return {@link CommonResponse}
+ */
+ public CommonResponse getListOfFeiyuSource(){
+ return CommonResponse.createBySuccess();
+ }
+
+}
diff --git a/src/main/java/com/baiyee/adcallback/api/controller/JuliangMobileMonitorController.java b/src/main/java/com/baiyee/adcallback/api/controller/JuliangMobileMonitorController.java
new file mode 100644
index 0000000..6b3ee29
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/api/controller/JuliangMobileMonitorController.java
@@ -0,0 +1,61 @@
+package com.baiyee.adcallback.api.controller;
+
+import com.baiyee.adcallback.api.common.CommonResponse;
+import com.baiyee.adcallback.service.JuliangMobileMonitorService;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+import java.time.LocalDate;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * juliang移动监控控制器
+ *
+ * @author q
+ * @date 2022/01/10
+ */
+@RestController
+@RequestMapping("/jl")
+public class JuliangMobileMonitorController {
+
+
+ private final JuliangMobileMonitorService juliangMobileMonitorService;
+
+ public JuliangMobileMonitorController(JuliangMobileMonitorService juliangMobileMonitorService) {
+ this.juliangMobileMonitorService = juliangMobileMonitorService;
+ }
+
+
+ /**
+ * 得到形式db imei列表
+ *
+ * @return {@link CommonResponse}
+ */
+ @GetMapping("/getimei")
+ public CommonResponse getImeiListFormDB() {
+
+ List result = juliangMobileMonitorService.queryByImeiAdvancedMode();
+
+ return CommonResponse.createBySuccess(result);
+ }
+
+
+ /**
+ * imei下载到文件
+ *
+ * @param date 日期 格式 yyyy-MM-dd
+ * @param response 响应
+ */
+ @GetMapping("/download")
+ public void downloadImeiToFile(@RequestParam(value = "startDate") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")Date startDate,
+ @RequestParam(value = "endDate") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")Date endDate,
+ HttpServletResponse response){
+
+ juliangMobileMonitorService.downloadImeiFile(response, startDate, endDate);
+ }
+}
diff --git a/src/main/java/com/baiyee/adcallback/api/controller/TokenManageController.java b/src/main/java/com/baiyee/adcallback/api/controller/TokenManageController.java
new file mode 100644
index 0000000..6972062
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/api/controller/TokenManageController.java
@@ -0,0 +1,49 @@
+package com.baiyee.adcallback.api.controller;
+
+import com.baiyee.adcallback.api.common.CommonResponse;
+import com.baiyee.adcallback.service.TokenManageService;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 令牌管理控制器
+ *
+ * @author q
+ * @date 2022/01/05
+ */
+@RestController(value = "/token")
+public class TokenManageController {
+
+ private final TokenManageService tokenManageService;
+
+ public TokenManageController(TokenManageService tokenManageService) {
+ this.tokenManageService = tokenManageService;
+ }
+
+ /**
+ * 获取访问令牌 - 这里
+ *
+ * @see
+ *
+ * @return {@link CommonResponse}
+ */
+ @PostMapping(value = "/get")
+ public CommonResponse getAccessToken(){
+ tokenManageService.getAccessToken();
+ return CommonResponse.createBySuccess();
+ }
+
+ /**
+ * 刷新令牌 - 类似于手动刷新接口 - 配合后台的过期时间内的规定频率的刷新
+ *
+ * @return {@link CommonResponse}
+ */
+ @PostMapping(value = "/refresh")
+ public CommonResponse refreshToken(){
+ tokenManageService.refreshToken();
+ return CommonResponse.createBySuccess();
+ }
+
+
+
+}
diff --git a/src/main/java/com/baiyee/adcallback/api/vo/JuliangMobileMonitorCallbackRequestVO.java b/src/main/java/com/baiyee/adcallback/api/vo/JuliangMobileMonitorCallbackRequestVO.java
new file mode 100644
index 0000000..72d0b7b
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/api/vo/JuliangMobileMonitorCallbackRequestVO.java
@@ -0,0 +1,40 @@
+package com.baiyee.adcallback.api.vo;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * juliang移动监控调请求 vo
+ *
+ * @author q
+ * @date 2022/01/07
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class JuliangMobileMonitorCallbackRequestVO implements Serializable {
+
+
+ private String aid;
+ private String aidName;
+ private String advertiserId;
+ private Long cid;
+ private Integer ctype;
+ private Integer csite;
+ private String imei;
+ private String idfa;
+ private String oaid;
+ private Integer os;
+ private String mac;
+ private String mac1;
+ private String ip;
+ private String geo;
+ private Long ts;
+ private String callbackUrl;
+ private String model;
+ private String caid12;
+}
diff --git a/src/main/java/com/baiyee/adcallback/common/constant/JuliangConstant.java b/src/main/java/com/baiyee/adcallback/common/constant/JuliangConstant.java
new file mode 100644
index 0000000..b505fa7
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/common/constant/JuliangConstant.java
@@ -0,0 +1,35 @@
+package com.baiyee.adcallback.common.constant;
+
+/**
+ * juliang常数
+ *
+ * @author q
+ * @date 2022/01/05
+ */
+public class JuliangConstant {
+
+ /**
+ * 回调地址
+ */
+ public static final String BACK_URL = "http://cb.tuoz.net";
+
+
+ /**
+ * 获取Access Token 的 url
+ */
+ public static final String GET_ACCESS_TOKEN_URL = "https://ad.oceanengine.com/open_api/oauth2/access_token/";
+
+ /**
+ * 刷新Access Token 的 url
+ */
+ public static final String REFRESH_ACCESS_TOKEN_URL = "https://ad.oceanengine.com/open_api/oauth2/refresh_token/";
+
+ /**
+ * 获取已授权账户 - 这个接口的详细信息关联与 Token 表的 advertiser_ids 字段
+ */
+ public static final String ADVERTISER_LIST_URL = "https://ad.oceanengine.com/open_api/oauth2/advertiser/get/";
+
+ public static final String IMEI_TAG = "__IMEI__";
+
+
+}
diff --git a/src/main/java/com/baiyee/adcallback/common/pojo/JlBackdataDTO.java b/src/main/java/com/baiyee/adcallback/common/pojo/JlBackdataDTO.java
new file mode 100644
index 0000000..e695c50
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/common/pojo/JlBackdataDTO.java
@@ -0,0 +1,36 @@
+package com.baiyee.adcallback.common.pojo;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baiyee.adcallback.api.vo.JuliangMobileMonitorCallbackRequestVO;
+import com.baiyee.adcallback.repository.entity.TbJlBackdataEntity;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class JlBackdataDTO implements Serializable {
+
+ private String aid;
+ private String aidName;
+ private String advertiserId;
+ private Long cid;
+ private Integer ctype;
+ private Integer csite;
+ private String imei;
+ private String idfa;
+ private String oaid;
+ private Integer os;
+ private String mac;
+ private String mac1;
+ private String ip;
+ private String geo;
+ private Long ts;
+ private String callbackUrl;
+ private String model;
+ private String caid12;
+
+}
diff --git a/src/main/java/com/baiyee/adcallback/common/pojo/convert/JlBackdataConvert.java b/src/main/java/com/baiyee/adcallback/common/pojo/convert/JlBackdataConvert.java
new file mode 100644
index 0000000..119a35e
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/common/pojo/convert/JlBackdataConvert.java
@@ -0,0 +1,41 @@
+package com.baiyee.adcallback.common.pojo.convert;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baiyee.adcallback.api.vo.JuliangMobileMonitorCallbackRequestVO;
+import com.baiyee.adcallback.common.pojo.JlBackdataDTO;
+import com.baiyee.adcallback.repository.entity.TbJlBackdataEntity;
+
+public class JlBackdataConvert {
+
+ /**
+ * 私有化构造
+ */
+ private JlBackdataConvert(){}
+
+ private static final ThreadLocal context = new ThreadLocal<>();
+
+ /**
+ * vo 转换为 dto -> 存放在当前线程上下文中
+ *
+ * @param vo 对象
+ */
+ public static void voCovertToDTO(JuliangMobileMonitorCallbackRequestVO vo, JlBackdataDTO dto) {
+ BeanUtil.copyProperties(vo, dto, true);
+ context.set(dto);
+ }
+
+ /**
+ * 转换为实体
+ *
+ * @return {@link TbJlBackdataEntity}
+ */
+ public static TbJlBackdataEntity covertToEntity(TbJlBackdataEntity entity) {
+ JlBackdataDTO jlBackdataDTO = context.get();
+ if (ObjectUtil.isNotNull(jlBackdataDTO)){
+ BeanUtil.copyProperties(jlBackdataDTO, entity, true);
+ }
+ context.remove();
+ return entity;
+ }
+}
diff --git a/src/main/java/com/baiyee/adcallback/common/request/JuliangRequestHeader.java b/src/main/java/com/baiyee/adcallback/common/request/JuliangRequestHeader.java
new file mode 100644
index 0000000..9484b44
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/common/request/JuliangRequestHeader.java
@@ -0,0 +1,48 @@
+package com.baiyee.adcallback.common.request;
+
+
+import lombok.Getter;
+import lombok.Setter;
+import org.springframework.beans.factory.annotation.Value;
+
+/**
+ * 巨量请求头常数
+ *
+ * @author q
+ * @date 2022/01/05
+ */
+public class JuliangRequestHeader {
+
+
+ /**
+ * 请求消息类型 content-type
+ */
+ public static final String CONTEN_TTYPE = "application/json";
+
+ public static final String X_Debug_Mode_NAME = "X-Debug-Mode";
+
+ /**
+ * 允许值:1(开启);Debugger模式仅适用于接口测试使用(不适合线上生产环境),
+ * 目前频控限制为20次/分钟,
+ * 建议在遇到调用接口报错后,在header中传入此段,以获取错误help message。
+ */
+
+ public static String X_DEBUGMODE_VALUE;
+
+ public static String getXDebugModeValue(){
+ return X_DEBUGMODE_VALUE;
+ }
+
+ @Value("${x-debug.mode}")
+ public void setXDebugmodeValue(String xDebugmodeValue) {
+ JuliangRequestHeader.X_DEBUGMODE_VALUE = xDebugmodeValue;
+ }
+
+ /**
+ * 授权access-token,获取方法见接口文档【获取Access-Token】
+ * @see
+ */
+ @Setter
+ @Getter
+ public String accessToken;
+}
diff --git a/src/main/java/com/baiyee/adcallback/common/request/JuliangRequestParam.java b/src/main/java/com/baiyee/adcallback/common/request/JuliangRequestParam.java
new file mode 100644
index 0000000..f26a2f9
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/common/request/JuliangRequestParam.java
@@ -0,0 +1,26 @@
+package com.baiyee.adcallback.common.request;
+
+/**
+ * juliang请求参数
+ *
+ * @author q
+ * @date 2022/01/05
+ */
+public class JuliangRequestParam {
+
+ /**
+ * 开发者申请的应用APP_ID,可通过“应用管理”界面查看
+ */
+ public static final String APPID = "1720560676257815";
+
+ /**
+ * 开发者应用的私钥Secret,可通过“应用管理”界面查看(确保填入secret与app_id对应以免报错!)
+ * 这个可以进行重置
+ */
+ public static final String SECRET = "343e2d0e55713607bdd34da957603f66f578ebe5";
+
+ /**
+ * 授权类型 - 1
+ */
+ public static final String GRANT_TYPE_AUTH_CODE = "auth_code";
+}
diff --git a/src/main/java/com/baiyee/adcallback/common/util/FileUtil.java b/src/main/java/com/baiyee/adcallback/common/util/FileUtil.java
new file mode 100644
index 0000000..19b4253
--- /dev/null
+++ b/src/main/java/com/baiyee/adcallback/common/util/FileUtil.java
@@ -0,0 +1,382 @@
+/*
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.baiyee.adcallback.common.util;
+
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.RandomUtil;
+import cn.hutool.poi.excel.BigExcelWriter;
+import cn.hutool.poi.excel.ExcelUtil;
+import org.apache.tomcat.util.http.fileupload.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.security.MessageDigest;
+import java.text.DecimalFormat;
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * File工具类,扩展 hutool 工具包
+ *
+ * @author Zheng Jie
+ * @date 2018-12-27
+ */
+public class FileUtil extends cn.hutool.core.io.FileUtil {
+ private static final Logger log = LoggerFactory.getLogger(FileUtil.class);
+ /**
+ * 系统临时目录
+ *
+ * windows 包含路径分割符,但Linux 不包含,
+ * 在windows \\==\ 前提下,
+ * 为安全起见 同意拼装 路径分割符,
+ *
+ * java.io.tmpdir
+ * windows : C:\Users/xxx\AppData\Local\Temp\
+ * linux: /temp
+ *
+ */
+ public static final String SYS_TEM_DIR = System.getProperty("java.io.tmpdir") + File.separator;
+ /**
+ * 定义GB的计算常量
+ */
+ private static final int GB = 1024 * 1024 * 1024;
+ /**
+ * 定义MB的计算常量
+ */
+ private static final int MB = 1024 * 1024;
+ /**
+ * 定义KB的计算常量
+ */
+ private static final int KB = 1024;
+
+
+ /**
+ * 默认的生成文件前缀
+ */
+ private static final String PRE_FILE = "out_task_";
+
+ /**
+ * 字段分隔符 (目前用于随机文件名中,...) [后续使用范围进行自行补充]
+ */
+ private static final String SEPARATOR = "_";
+
+ /**
+ * 随机字符串的长度 (目前用于随机文件名中,...) [后续使用范围进行自行补充]
+ */
+ private static final int RANDOM_STRING_LENGTH = 6;
+
+ /**
+ * 格式化小数
+ */
+ private static final DecimalFormat DF = new DecimalFormat("0.00");
+
+ /**
+ * MultipartFile转File
+ */
+ public static File toFile(MultipartFile multipartFile) {
+ // 获取文件名
+ String fileName = multipartFile.getOriginalFilename();
+ // 获取文件后缀
+ String prefix = "." + getExtensionName(fileName);
+ File file = null;
+ try {
+ // 用uuid作为文件名,防止生成的临时文件重复
+ file = File.createTempFile(IdUtil.simpleUUID(), prefix);
+ // MultipartFile to File
+ multipartFile.transferTo(file);
+ } catch (IOException e) {
+ log.error(e.getMessage(), e);
+ }
+ return file;
+ }
+
+ /**
+ * 获取文件扩展名,不带 .
+ */
+ public static String getExtensionName(String filename) {
+ if ((filename != null) && (filename.length() > 0)) {
+ int dot = filename.lastIndexOf('.');
+ if ((dot > -1) && (dot < (filename.length() - 1))) {
+ return filename.substring(dot + 1);
+ }
+ }
+ return filename;
+ }
+
+ /**
+ * Java文件操作 获取不带扩展名的文件名
+ */
+ public static String getFileNameNoEx(String filename) {
+ if ((filename != null) && (filename.length() > 0)) {
+ int dot = filename.lastIndexOf('.');
+ if ((dot > -1) && (dot < (filename.length()))) {
+ return filename.substring(0, dot);
+ }
+ }
+ return filename;
+ }
+
+ /**
+ * 文件大小转换
+ */
+ public static String getSize(long size) {
+ String resultSize;
+ if (size / GB >= 1) {
+ //如果当前Byte的值大于等于1GB
+ resultSize = DF.format(size / (float) GB) + "GB ";
+ } else if (size / MB >= 1) {
+ //如果当前Byte的值大于等于1MB
+ resultSize = DF.format(size / (float) MB) + "MB ";
+ } else if (size / KB >= 1) {
+ //如果当前Byte的值大于等于1KB
+ resultSize = DF.format(size / (float) KB) + "KB ";
+ } else {
+ resultSize = size + "B ";
+ }
+ return resultSize;
+ }
+
+ /**
+ * inputStream 转 File
+ */
+ static File inputStreamToFile(InputStream ins, String name) throws Exception {
+ File file = new File(SYS_TEM_DIR + name);
+ if (file.exists()) {
+ return file;
+ }
+ OutputStream os = new FileOutputStream(file);
+ int bytesRead;
+ int len = 8192;
+ byte[] buffer = new byte[len];
+ while ((bytesRead = ins.read(buffer, 0, len)) != -1) {
+ os.write(buffer, 0, bytesRead);
+ }
+ os.close();
+ ins.close();
+ return file;
+ }
+
+ /**
+ * 将文件名解析成文件的上传路径
+ */
+ public static File upload(MultipartFile file, String filePath) {
+ Date date = new Date();
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMddhhmmssS");
+ String name = getFileNameNoEx(file.getOriginalFilename());
+ String suffix = getExtensionName(file.getOriginalFilename());
+ String nowStr = "-" + format.format(date);
+ try {
+ String fileName = name + nowStr + "." + suffix;
+ String path = filePath + fileName;
+ // getCanonicalFile 可解析正确各种路径
+ File dest = new File(path).getCanonicalFile();
+ // 检测是否存在目录
+ if (!dest.getParentFile().exists()) {
+ if (!dest.getParentFile().mkdirs()) {
+ System.out.println("was not successful.");
+ }
+ }
+ // 文件写入
+ file.transferTo(dest);
+ return dest;
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+ return null;
+ }
+
+ /**
+ * 导出excel
+ */
+ public static void downloadExcel(List