Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-execute-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 3220cd3d
authored
Oct 18, 2023
by
周海宝
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'v1.0.1' into 'master'
V1.0.1 See merge request
!1
2 parents
551d255d
b68ea798
Show whitespace changes
Inline
Side-by-side
Showing
106 changed files
with
6026 additions
and
94 deletions
platform-execute-api/pom.xml
platform-execute-api/src/main/java/cn/com/glsx/execute/api/ShortUrlFeignClient.java
platform-execute-api/src/main/java/cn/com/glsx/execute/api/dubbo/ShortUrlApi.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/entity/shortutl/ShortUrlAccessEventRecordDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/entity/shortutl/ShortUrlCompressCodeDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/entity/shortutl/ShortUrlDomainConfigDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/entity/shortutl/ShortUrlMappingDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/entity/shortutl/SopEventDelaySendLogDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/AppKeyEnum.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/CacheEnums.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/ExceptionEnum.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/LockEnums.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/rop/MethodEnum.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/rop/ModelBaseUrlEnum.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/shorturl/RedirectType.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/shorturl/TransformStatus.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/mapper/ShortUrlAccessEventRecordMapper.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/mapper/ShortUrlCompressCodeMapper.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/mapper/ShortUrlDomainConfigMapper.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/mapper/ShortUrlMappingMapper.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/mapper/SopEventDelaySendLogMapper.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetCustomerDetailRequestDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetCustomerDetailResponseDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetRobotListRequestDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetRobotListResponseDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiImportCallJobCustomerRequestDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiImportCallJobCustomerResponseDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/oneVone/BatchMessagingContentDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/oneVone/BatchMessagingCreateRopRequestDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/oneVone/BatchMessagingCrowConditionDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/oneVone/LabelRequestDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/rop/RopResponseDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/shorturl/GenerateUrlRequest.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/shorturl/GenerateUrlResponse.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/sms/SmsResponseDTO.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/wechat/GetUserInfoRequest.java
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/wechat/GetUserInfoResponse.java
platform-execute-api/src/test/resources/generatorConfig.xml
platform-execute/pom.xml
platform-execute/src/main/java/cn/com/glsx/execute/common/constant/Constants.java
platform-execute/src/main/java/cn/com/glsx/execute/common/constant/DBConstants.java
platform-execute/src/main/java/cn/com/glsx/execute/common/constant/SmsConstants.java
platform-execute/src/main/java/cn/com/glsx/execute/common/constant/shorturl/CompressCodeStatus.java
platform-execute/src/main/java/cn/com/glsx/execute/common/constant/shorturl/DomainStatus.java
platform-execute/src/main/java/cn/com/glsx/execute/common/constant/shorturl/UrlMapStatus.java
platform-execute/src/main/java/cn/com/glsx/execute/common/exception/ChainFilterErrorException.java
platform-execute/src/main/java/cn/com/glsx/execute/common/exception/LockException.java
platform-execute/src/main/java/cn/com/glsx/execute/common/lock/DistributedLock.java
platform-execute/src/main/java/cn/com/glsx/execute/common/lock/DistributedLockFactory.java
platform-execute/src/main/java/cn/com/glsx/execute/common/lock/RedissonDistributedLock.java
platform-execute/src/main/java/cn/com/glsx/execute/config/DubboConfig.java
platform-execute/src/main/java/cn/com/glsx/execute/config/RabbitMQConfig.java
platform-execute/src/main/java/cn/com/glsx/execute/config/RedissonBloomFilterConfig.java
platform-execute/src/main/java/cn/com/glsx/execute/config/WebConfig.java
platform-execute/src/main/java/cn/com/glsx/execute/filter/AccessFilter.java
platform-execute/src/main/java/cn/com/glsx/execute/filter/AccessFilterChain.java
platform-execute/src/main/java/cn/com/glsx/execute/filter/AccessFilterChainFactory.java
platform-execute/src/main/java/cn/com/glsx/execute/filter/BaseNamingAccessFilter.java
platform-execute/src/main/java/cn/com/glsx/execute/filter/DefaultAccessFilterChain.java
platform-execute/src/main/java/cn/com/glsx/execute/filter/FilterChainNode.java
platform-execute/src/main/java/cn/com/glsx/execute/filter/TransformContext.java
platform-execute/src/main/java/cn/com/glsx/execute/filter/shorturl/AccessUrlEventProcessFilter.java
platform-execute/src/main/java/cn/com/glsx/execute/filter/shorturl/CacheCheckFilter.java
platform-execute/src/main/java/cn/com/glsx/execute/filter/shorturl/ExtractRequestParamFilter.java
platform-execute/src/main/java/cn/com/glsx/execute/filter/shorturl/RedirectOrForwardLocationFilter.java
platform-execute/src/main/java/cn/com/glsx/execute/filter/shorturl/RedirectUrlFilter.java
platform-execute/src/main/java/cn/com/glsx/execute/filter/shorturl/SopEventProcessFilter.java
platform-execute/src/main/java/cn/com/glsx/execute/filter/shorturl/UrlTransformFilter.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/LoginController.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/controller/buryingPoint/BuryingPointController.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/controller/shorturl/ShortUrlController.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/controller/shorturl/UrlMapController.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/converter/rop/RopRequestConveter.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/converter/rop/RopResponseConveter.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/rabbitmq/consumer/DirectReceiver.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/rabbitmq/produce/MsgProducer.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/rabbitmq/produce/RabbitConfig.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/request/shorturl/GenerateShortUrlRequest.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/service/proxy/AiOutboundCallService.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/service/proxy/BatchMessageService.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/service/proxy/SendMessageService.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/service/proxy/WechatUserInfoService.java
platform-execute/src/main/java/cn/com/glsx/execute/modules/service/shorturl/ShortUrlService.java
platform-execute/src/main/java/cn/com/glsx/execute/utils/CacheUtil.java
platform-execute/src/main/java/cn/com/glsx/execute/utils/HashUtil.java
platform-execute/src/main/java/cn/com/glsx/execute/utils/IpUtils.java
platform-execute/src/main/java/cn/com/glsx/execute/utils/JacksonUtils.java
platform-execute/src/main/java/cn/com/glsx/execute/utils/MD5.java
platform-execute/src/main/java/cn/com/glsx/execute/utils/RopHttpUtil.java
platform-execute/src/main/java/cn/com/glsx/execute/utils/RopUtils.java
platform-execute/src/main/java/cn/com/glsx/execute/utils/UrlUtil.java
platform-execute/src/main/resources/bootstrap.properties
platform-execute/src/main/resources/mapper/ShortUrlAccessEventRecordMapper.xml
platform-execute/src/main/resources/mapper/ShortUrlCompressCodeMapper.xml
platform-execute/src/main/resources/mapper/ShortUrlDomainConfigMapper.xml
platform-execute/src/main/resources/mapper/ShortUrlMappingMapper.xml
platform-execute/src/main/resources/mapper/SopEventDelaySendLogMapper.xml
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/BaseTest.java
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/TestApplication.java
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/Utils/RopHttpUtilTest.java
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/Utils/SendMessageServiceTest.java
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/aioutboundcall/AiOutboundCallTest.java
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/oneVone/BatchMessageServiceTest.java
platform-execute/src/test/resources/generatorConfig.xml
platform-execute/target/generated-sources/annotations/cn/com/glsx/execute/modules/converter/UserConverterImpl.java
pom.xml
platform-execute-api/pom.xml
View file @
3220cd3
...
@@ -12,6 +12,11 @@
...
@@ -12,6 +12,11 @@
<description>
Microservice Scaffolding Api Base on Spring Cloud
</description>
<description>
Microservice Scaffolding Api Base on Spring Cloud
</description>
<dependencies>
<dependencies>
<dependency>
<groupId>
cn.com.glsx.entmicro
</groupId>
<artifactId>
rpc-scrm-entmicro-api
</artifactId>
<version>
3.20.0-SNAPSHOT
</version>
</dependency>
<!-- mybatis -->
<!-- mybatis -->
<dependency>
<dependency>
<groupId>
com.glsx
</groupId>
<groupId>
com.glsx
</groupId>
...
@@ -22,6 +27,22 @@
...
@@ -22,6 +27,22 @@
<groupId>
com.glsx
</groupId>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-admin-feign
</artifactId>
<artifactId>
rest-admin-feign
</artifactId>
</dependency>
</dependency>
<dependency>
<groupId>
com.glsx
</groupId>
<artifactId>
rest-admin-swagger3
</artifactId>
</dependency>
</dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.mybatis.generator
</groupId>
<artifactId>
mybatis-generator-maven-plugin
</artifactId>
<configuration>
<skip>
true
</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
</project>
platform-execute-api/src/main/java/cn/com/glsx/execute/api/ShortUrlFeignClient.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
api
;
import
cn.com.glsx.execute.modules.model.UserDTO
;
import
com.glsx.plat.core.web.Result
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
* @Description 短链feign
* @author chizw
* @create 2023/9/27 16:04
* @version ver.1.0.0
*/
@FeignClient
(
name
=
"rest-admin"
,
contextId
=
"shorturl"
,
path
=
"/api/user/"
,
decode404
=
true
)
public
interface
ShortUrlFeignClient
{
@GetMapping
(
"/shorturl/generate"
)
String
generateUrl
(
@RequestParam
String
message
);
}
platform-execute-api/src/main/java/cn/com/glsx/execute/api/dubbo/ShortUrlApi.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
api
.
dubbo
;
import
cn.com.glsx.entmicro.model.request.wechatcloudcontrol.batchmessaging.BatchMessagingRpcRequest
;
import
cn.com.glsx.execute.modules.model.shorturl.GenerateUrlResponse
;
import
cn.com.glsx.framework.core.annotation.*
;
import
cn.com.glsx.framework.core.beans.rpc.RpcResponse
;
/**
* @author chizw
* @version ver.1.0.0
* @Description
* @create 2023/9/26 20:42
*/
@ApiService
(
value
=
"短链服务"
,
version
=
"1.0.0"
,
protocol
=
ApiService
.
ProtocolEnum
.
dubbo
,
type
=
ApiService
.
ApiTypeEnum
.
DUBBO
,
alias
=
"ShortUrlApi"
,
owner
=
"chizw"
)
public
interface
ShortUrlApi
{
@ApiMethod
(
"短链生成"
)
@ApiResponse
(
"生成结果"
)
@ApiParams
({
@ApiParam
(
name
=
"BatchMessagingRpcRequest"
,
notes
=
"短链生成"
,
dataType
=
ApiParam
.
DataTypeEnum
.
OBJECT
,
required
=
true
)})
RpcResponse
<
GenerateUrlResponse
>
generateUrl
(
BatchMessagingRpcRequest
rpcRequest
);
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/entity/shortutl/ShortUrlAccessEventRecordDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
entity
.
shortutl
;
import
lombok.Data
;
import
lombok.ToString
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
@Table
(
name
=
"short_url_access_event_record"
)
public
class
ShortUrlAccessEventRecordDTO
implements
Serializable
{
/**
* 主键
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
/**
* 唯一身份标识,SHA-1(客户端IP-UA)
*/
@Column
(
name
=
"unique_identity"
)
private
String
uniqueIdentity
;
/**
* 客户端IP
*/
@Column
(
name
=
"client_ip"
)
private
String
clientIp
;
/**
* 短链URL
*/
@Column
(
name
=
"short_url"
)
private
String
shortUrl
;
/**
* 长链URL
*/
@Column
(
name
=
"long_url"
)
private
String
longUrl
;
/**
* 短链摘要
*/
@Column
(
name
=
"short_url_digest"
)
private
String
shortUrlDigest
;
/**
* 长链摘要
*/
@Column
(
name
=
"long_url_digest"
)
private
String
longUrlDigest
;
/**
* 压缩码
*/
@Column
(
name
=
"compress_code"
)
private
String
compressCode
;
/**
* 记录时间戳
*/
@Column
(
name
=
"record_time"
)
private
Date
recordTime
;
/**
* UA
*/
@Column
(
name
=
"user_agent"
)
private
String
userAgent
;
/**
* cookie
*/
@Column
(
name
=
"cookie_value"
)
private
String
cookieValue
;
/**
* URL参数
*/
@Column
(
name
=
"query_param"
)
private
String
queryParam
;
/**
* 省份
*/
private
String
province
;
/**
* 城市
*/
private
String
city
;
/**
* 手机型号
*/
@Column
(
name
=
"phone_type"
)
private
String
phoneType
;
/**
* 浏览器类型
*/
@Column
(
name
=
"browser_type"
)
private
String
browserType
;
/**
* 浏览器版本号
*/
@Column
(
name
=
"browser_version"
)
private
String
browserVersion
;
/**
* 操作系统型号
*/
@Column
(
name
=
"os_type"
)
private
String
osType
;
/**
* 设备型号
*/
@Column
(
name
=
"device_type"
)
private
String
deviceType
;
/**
* 操作系统版本号
*/
@Column
(
name
=
"os_version"
)
private
String
osVersion
;
/**
* 转换状态,1:转换成功,2:转换失败,3:重定向成功,4:重定向失败
*/
@Column
(
name
=
"transform_status"
)
private
Integer
transformStatus
;
/**
* 是否删除:0=正常,-1=删除
*/
@Column
(
name
=
"del_flag"
)
private
Byte
delFlag
;
/**
* 创建人
*/
@Column
(
name
=
"created_by"
)
private
Integer
createdBy
;
/**
* 创建时间
*/
@Column
(
name
=
"created_time"
)
private
Date
createdTime
;
/**
* 更新人
*/
@Column
(
name
=
"updated_by"
)
private
Integer
updatedBy
;
/**
* 更新时间
*/
@Column
(
name
=
"updated_time"
)
private
Date
updatedTime
;
private
static
final
long
serialVersionUID
=
1L
;
}
\ No newline at end of file
\ No newline at end of file
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/entity/shortutl/ShortUrlCompressCodeDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
entity
.
shortutl
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
@Table
(
name
=
"short_url_compress_code"
)
public
class
ShortUrlCompressCodeDTO
implements
Serializable
{
/**
* 主键
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
/**
* 压缩码
*/
@Column
(
name
=
"compress_code"
)
private
String
compressCode
;
/**
* 压缩码状态,1:未使用,2:已使用,3:已失效
*/
@Column
(
name
=
"code_status"
)
private
Integer
codeStatus
;
/**
* 序列(盐)
*/
@Column
(
name
=
"sequence_value"
)
private
String
sequenceValue
;
/**
* 策略,sequence或者hash
*/
private
String
strategy
;
/**
* 是否删除:0=正常,-1=删除
*/
@Column
(
name
=
"del_flag"
)
private
Byte
delFlag
;
/**
* 创建人
*/
@Column
(
name
=
"created_by"
)
private
Integer
createdBy
;
/**
* 创建时间
*/
@Column
(
name
=
"created_time"
)
private
Date
createdTime
;
/**
* 更新人
*/
@Column
(
name
=
"updated_by"
)
private
Integer
updatedBy
;
/**
* 更新时间
*/
@Column
(
name
=
"updated_time"
)
private
Date
updatedTime
;
private
static
final
long
serialVersionUID
=
1L
;
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
getClass
().
getSimpleName
());
sb
.
append
(
" ["
);
sb
.
append
(
"Hash = "
).
append
(
hashCode
());
sb
.
append
(
", id="
).
append
(
id
);
sb
.
append
(
", compressCode="
).
append
(
compressCode
);
sb
.
append
(
", codeStatus="
).
append
(
codeStatus
);
sb
.
append
(
", sequenceValue="
).
append
(
sequenceValue
);
sb
.
append
(
", strategy="
).
append
(
strategy
);
sb
.
append
(
", delFlag="
).
append
(
delFlag
);
sb
.
append
(
", createdBy="
).
append
(
createdBy
);
sb
.
append
(
", createdTime="
).
append
(
createdTime
);
sb
.
append
(
", updatedBy="
).
append
(
updatedBy
);
sb
.
append
(
", updatedTime="
).
append
(
updatedTime
);
sb
.
append
(
", serialVersionUID="
).
append
(
serialVersionUID
);
sb
.
append
(
"]"
);
return
sb
.
toString
();
}
}
\ No newline at end of file
\ No newline at end of file
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/entity/shortutl/ShortUrlDomainConfigDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
entity
.
shortutl
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
@Table
(
name
=
"short_url_domain_config"
)
public
class
ShortUrlDomainConfigDTO
implements
Serializable
{
/**
* 主键
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
/**
* 域名
*/
@Column
(
name
=
"domain_value"
)
private
String
domainValue
;
/**
* 协议,https或者http
*/
private
String
protocol
;
/**
* 域名状态,1:正常,2:已失效
*/
@Column
(
name
=
"domain_status"
)
private
Byte
domainStatus
;
/**
* 优先级,正序排序
*/
@Column
(
name
=
"level"
)
private
Integer
level
;
/**
* 是否删除:0=正常,-1=删除
*/
@Column
(
name
=
"del_flag"
)
private
Byte
delFlag
;
/**
* 创建人
*/
@Column
(
name
=
"created_by"
)
private
Integer
createdBy
;
/**
* 创建时间
*/
@Column
(
name
=
"created_time"
)
private
Date
createdTime
;
/**
* 更新人
*/
@Column
(
name
=
"updated_by"
)
private
Integer
updatedBy
;
/**
* 更新时间
*/
@Column
(
name
=
"updated_time"
)
private
Date
updatedTime
;
/**
* 重定向类型 1.直接重定向 2.通过授权页面
*/
@Column
(
name
=
"redirect_type"
)
private
Integer
redirectType
;
private
static
final
long
serialVersionUID
=
1L
;
}
\ No newline at end of file
\ No newline at end of file
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/entity/shortutl/ShortUrlMappingDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
entity
.
shortutl
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
@Table
(
name
=
"short_url_mapping"
)
public
class
ShortUrlMappingDTO
implements
Serializable
{
/**
* 主键
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
/**
* 短链URL
*/
@Column
(
name
=
"short_url"
)
private
String
shortUrl
;
/**
* 长链URL
*/
@Column
(
name
=
"long_url"
)
private
String
longUrl
;
/**
* 短链摘要
*/
@Column
(
name
=
"short_url_digest"
)
private
String
shortUrlDigest
;
/**
* 长链摘要
*/
@Column
(
name
=
"long_url_digest"
)
private
String
longUrlDigest
;
/**
* 压缩码
*/
@Column
(
name
=
"compress_code"
)
private
String
compressCode
;
/**
* 描述
*/
private
String
description
;
/**
* URL状态,1:正常,2:已失效
*/
@Column
(
name
=
"url_status"
)
private
Integer
urlStatus
;
/**
* 是否删除:0=正常,-1=删除
*/
@Column
(
name
=
"del_flag"
)
private
Byte
delFlag
;
/**
* 创建人
*/
@Column
(
name
=
"created_by"
)
private
Integer
createdBy
;
/**
* 创建时间
*/
@Column
(
name
=
"created_time"
)
private
Date
createdTime
;
/**
* 更新人
*/
@Column
(
name
=
"updated_by"
)
private
Integer
updatedBy
;
/**
* 更新时间
*/
@Column
(
name
=
"updated_time"
)
private
Date
updatedTime
;
/**
* 长链参数
*/
@Column
(
name
=
"url_param"
)
private
String
urlParam
;
/**
* 重定向前转发至页面
*/
@Column
(
name
=
"b4_redirect_page"
)
private
String
b4RedirectPage
;
/**
* 生成长链时添加时间戳
*/
@Column
(
name
=
"add_timestamp"
)
private
Boolean
addTimestamp
;
private
static
final
long
serialVersionUID
=
1L
;
}
\ No newline at end of file
\ No newline at end of file
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/entity/shortutl/SopEventDelaySendLogDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
entity
.
shortutl
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.Date
;
@Data
@Table
(
name
=
"sop_event_delay_send_log"
)
public
class
SopEventDelaySendLogDTO
implements
Serializable
{
/**
* 主键
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
/**
* 事件类型 1.短链
*/
@Column
(
name
=
"event_type"
)
private
Integer
eventType
;
/**
* 是否删除:0=正常,-1=删除
*/
@Column
(
name
=
"del_flag"
)
private
Byte
delFlag
;
/**
* 创建人
*/
@Column
(
name
=
"created_by"
)
private
Integer
createdBy
;
/**
* 创建时间
*/
@Column
(
name
=
"created_time"
)
private
Date
createdTime
;
/**
* 更新人
*/
@Column
(
name
=
"updated_by"
)
private
Integer
updatedBy
;
/**
* 更新时间
*/
@Column
(
name
=
"updated_time"
)
private
Date
updatedTime
;
/**
* 事件内容
*/
@Column
(
name
=
"event_content"
)
private
String
eventContent
;
/**
* 发送状态
*/
@Column
(
name
=
"send_status"
)
private
String
sendStatus
;
private
static
final
long
serialVersionUID
=
1L
;
}
\ No newline at end of file
\ No newline at end of file
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/AppKeyEnum.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* @Author yelq
* @Version 1.0
* @Description: 密钥对枚举
* @Date 2023/9/7 15:15
*/
@Getter
@AllArgsConstructor
public
enum
AppKeyEnum
{
// 客户服务
ROP_SCRM_ENTMICRO
(
"rop-scrm-entmicro"
,
"48e5e13229b82c1b4e6e8c96151f0637"
,
"c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b"
),
// 营销服务
ROP_SCRM_MARKETING
(
"rop-scrm-marketing"
,
"48e5e13229b82c1b4e6e8c96151f0637"
,
"c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b"
),
;
/**
* 服务名
*/
private
final
String
ropServiceName
;
private
final
String
appKey
;
private
final
String
secret
;
public
static
AppKeyEnum
getByRopServiceName
(
String
ropName
){
for
(
AppKeyEnum
value
:
AppKeyEnum
.
values
())
{
if
(
value
.
getRopServiceName
().
equals
(
ropName
)){
return
value
;
}
}
return
null
;
}
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/CacheEnums.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
enums
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
/**
* @Description 缓存工具
* @author chizw
* @create 2023/9/18 16:08
* @version ver.1.0.0
*/
@RequiredArgsConstructor
@Getter
public
enum
CacheEnums
{
BLACK_LIST_IP
(
"execute:black_list_ip"
,
"黑名单ip"
,
0L
,
10000L
),
IP_ACCESS_COUNT
(
"execute:ip_access_count"
,
"ip访问次数"
,
0L
,
10000L
),
IP_INVALID_ACCESS_COUNT
(
"execute:ip_invalid_access_count"
,
"ip无效访问次数"
,
0L
,
10000L
),
SHORT_URL_MAP_CACHE
(
"execute:short_url_map_cache"
,
"短链映射缓存"
,
0L
,
10000L
),
;
private
final
String
key
;
private
final
String
desc
;
private
final
long
waitTime
;
private
final
long
releaseTime
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/ExceptionEnum.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
enums
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
/**
* @author chizw
* @version ver.1.0.0
* @Description 异常枚举
* @create 2023/9/19 14:43
*/
@RequiredArgsConstructor
@Getter
public
enum
ExceptionEnum
{
/* 通用状态码 成功与失败 */
SUCCESS
(
1
,
"ok"
),
FAILED
(-
1
,
"操作失败"
),
/* 参数错误 101 - 199 */
PARAM_IS_INVALID
(
101
,
"参数无效"
),
PARAM_IS_BLANK
(
102
,
"参数为空"
),
/* 用户错误 201 - 299 */
USER_NOT_LOGIN
(
201
,
"未登录"
),
USER_NOT_EXIST
(
202
,
"用户不存在"
),
USER_LOGIN_ERROR
(
203
,
"登陆失败,账号或者密码有误"
),
NOT_PERMISSION
(
204
,
"无权限访问"
),
/* 业务错误 301 - 399 */
DATA_NOT_FOUND
(
301
,
"没有数据"
),
/* 系统错误 401 - 499 */
DB_EXCEPTION
(
401
,
"数据库操作异常"
),
;
private
final
Integer
code
;
private
final
String
msg
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/LockEnums.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
enums
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
/**
* @author thorwable
* @description 分布式锁KEY
* @since 2020/6/15 20:02
*/
/**
* @Description 锁key值枚举
* @author chizw
* @create 2023/9/15 14:10
* @version ver.1.0.0
*/
@RequiredArgsConstructor
@Getter
public
enum
LockEnums
{
/**
* 创建短链映射场景
*/
CREATE_URL_MAP
(
"execute:url:map:create"
,
"创建URL映射"
,
0L
,
10000L
),
/**
* 编辑短链映射场景
*/
EDIT_URL_MAP
(
"execute:url:map:edit"
,
"修改URL映射"
,
0L
,
10000L
),
/**
* 访问统计任务
*/
VISITOR_STATS_TASK
(
"execute:visitor:stats:task"
,
"访问统计任务"
,
0L
,
10000L
),
;
private
final
String
key
;
private
final
String
desc
;
private
final
long
waitTime
;
private
final
long
releaseTime
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/rop/MethodEnum.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
enums
.
rop
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* @Author yelq
* @Version 1.0
* @Description: rop框架的方法地址
* @Date 2023/9/11 11:58
*/
@Getter
@AllArgsConstructor
public
enum
MethodEnum
{
ROBOT_LIST
(
"marketing.api.ai.outbound.call.getRobotList"
,
"获取机器人列表"
),
INVOKE_AI_CALL
(
"marketing.api.ai.outbound.call.invokeAICall"
,
"执行AI外呼"
),
CUSTOMER_CALL_DETAIL
(
"marketing.api.ai.outbound.call.customer.detail"
,
"客户通话详情"
),
BATCH_MESSAGE_CREATE
(
"entmicro.api.wechatcloudcontrol.nosession.batchmessaging.create"
,
"企微高级群发任务创建"
),
WECHAT_USERINFO_BY_UNIONID
(
"scrm.api.wechat.auth.userProfile.getUserInfo.byUnionId"
,
"获取的用户信息"
),
;
private
String
method
;
private
String
describe
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/rop/ModelBaseUrlEnum.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
enums
.
rop
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* @Author yelq
* @Version 1.0
* @Description: rop框架的方法地址
* @Date 2023/9/11 11:58
*/
@Getter
@AllArgsConstructor
public
enum
ModelBaseUrlEnum
{
ROP_SCRM_MARKETING
(
"http.request.base.url.rop.scrm.marketing"
,
"营销模块"
),
ROP_SCRM_ENTMICRO
(
"http.request.base.url.rop.scrm.entmicro"
,
"客群模块"
),
ROP_SCRM_WECHAT
(
"http.request.base.url.rop.scrm.wechat"
,
"微信模块"
),
;
private
String
baseUrlConfig
;
private
String
modelName
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/shorturl/RedirectType.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
enums
.
shorturl
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
/**
* @Description 重定向类型
* @author chizw
* @create 2023/9/19 11:02
* @version ver.1.0.0
*/
@Getter
@RequiredArgsConstructor
public
enum
RedirectType
{
DIRECT
(
1
,
"直接重定向"
),
THROUGH_AUTH_PAGE
(
2
,
"通过授权页面"
),
;
private
final
Integer
value
;
private
final
String
desc
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/enums/shorturl/TransformStatus.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
enums
.
shorturl
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
/**
* @Description 短链转换状态
* @author chizw
* @create 2023/9/19 11:02
* @version ver.1.0.0
*/
@Getter
@RequiredArgsConstructor
public
enum
TransformStatus
{
TRANSFORM_SUCCESS
(
1
,
"转换成功"
),
TRANSFORM_FAIL
(
2
,
"转换失败"
),
REDIRECTION_SUCCESS
(
3
,
"重定向成功"
),
REDIRECTION_FAIL
(
4
,
"重定向失败"
),
AUTH_PAGE_SUCCESS
(
5
,
"授权页面跳转成功"
),
AUTH_PAGE_FAIL
(
6
,
"授权页面跳转失败"
),
;
private
final
Integer
value
;
private
final
String
desc
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/mapper/ShortUrlAccessEventRecordMapper.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
mapper
;
import
cn.com.glsx.execute.modules.entity.shortutl.ShortUrlAccessEventRecordDTO
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
ShortUrlAccessEventRecordMapper
extends
CommonBaseMapper
<
ShortUrlAccessEventRecordDTO
>
{
}
\ No newline at end of file
\ No newline at end of file
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/mapper/ShortUrlCompressCodeMapper.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
mapper
;
import
cn.com.glsx.execute.modules.entity.shortutl.ShortUrlCompressCodeDTO
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
ShortUrlCompressCodeMapper
extends
CommonBaseMapper
<
ShortUrlCompressCodeDTO
>
{
}
\ No newline at end of file
\ No newline at end of file
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/mapper/ShortUrlDomainConfigMapper.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
mapper
;
import
cn.com.glsx.execute.modules.entity.shortutl.ShortUrlDomainConfigDTO
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
ShortUrlDomainConfigMapper
extends
CommonBaseMapper
<
ShortUrlDomainConfigDTO
>
{
}
\ No newline at end of file
\ No newline at end of file
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/mapper/ShortUrlMappingMapper.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
mapper
;
import
cn.com.glsx.execute.modules.entity.shortutl.ShortUrlMappingDTO
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
ShortUrlMappingMapper
extends
CommonBaseMapper
<
ShortUrlMappingDTO
>
{
}
\ No newline at end of file
\ No newline at end of file
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/mapper/SopEventDelaySendLogMapper.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
mapper
;
import
cn.com.glsx.execute.modules.entity.shortutl.SopEventDelaySendLogDTO
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
SopEventDelaySendLogMapper
extends
CommonBaseMapper
<
SopEventDelaySendLogDTO
>
{
}
\ No newline at end of file
\ No newline at end of file
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetCustomerDetailRequestDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
aioutboundcall
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.ToString
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.io.Serializable
;
/**
* @Description
* @author chizw
* @create 2023/7/5 10:32
* @version ver.1.0.0
*/
@JsonSerialize
()
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
(
includeFieldNames
=
true
,
callSuper
=
true
)
public
class
ByaiGetCustomerDetailRequestDTO
implements
Serializable
{
/**
* 导入客户id
*/
@JsonProperty
(
"importCustomerId"
)
@Schema
(
name
=
"importCustomerId"
,
description
=
"导入客户id"
)
private
Integer
importCustomerId
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetCustomerDetailResponseDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
aioutboundcall
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
lombok.ToString
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
/**
* @Description
* @author chizw
* @create 2023/7/5 10:32
* @version ver.1.0.0
*/
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@JsonSerialize
(
include
=
JsonSerialize
.
Inclusion
.
NON_NULL
)
@Data
@ToString
(
includeFieldNames
=
true
,
callSuper
=
true
)
public
class
ByaiGetCustomerDetailResponseDTO
implements
Serializable
{
/**
* 通话时长
*/
@JsonProperty
(
"duration"
)
@Schema
(
name
=
"duration"
,
description
=
"通话时长"
)
private
Long
duration
;
/**
* 录音地址
*/
@JsonProperty
(
"luyinOssUrl"
)
@Schema
(
name
=
"luyinOssUrl"
,
description
=
"录音地址"
)
private
String
luyinOssUrl
;
/**
* 通话日志
*/
@JsonProperty
(
"phoneLogs"
)
@Schema
(
name
=
"phoneLogs"
,
description
=
"通话日志"
)
private
List
<
PhoneLogVO
>
phoneLogs
;
@Data
public
static
class
PhoneLogVO
implements
Serializable
{
/**
* 是否是ai无法应答的问题,1-是,0-否
*/
@JsonProperty
(
"aiUnknown"
)
@Schema
(
name
=
"aiUnknown"
,
description
=
"是否是ai无法应答的问题,1-是,0-否"
)
private
Long
aiUnknown
;
/**
* 通话id
*/
@JsonProperty
(
"callInstanceId"
)
@Schema
(
name
=
"callInstanceId"
,
description
=
"通话id"
)
private
Long
callInstanceId
;
/**
* 说话内容
*/
@JsonProperty
(
"content"
)
@Schema
(
name
=
"content"
,
description
=
"说话内容"
)
private
String
content
;
/**
* 说话的结束时间
*/
@JsonProperty
(
"endTime"
)
@Schema
(
name
=
"endTime"
,
description
=
"说话的结束时间"
)
private
Date
endTime
;
/**
* 说话人,ME: 客户 AI: 机器人
*/
@JsonProperty
(
"speaker"
)
@Schema
(
name
=
"speaker"
,
description
=
"说话人,ME: 客户 AI: 机器人"
)
private
String
speaker
;
/**
* 说话的开始时间
*/
@JsonProperty
(
"startTime"
)
@Schema
(
name
=
"startTime"
,
description
=
"说话的开始时间"
)
private
Date
startTime
;
}
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetRobotListRequestDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
aioutboundcall
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.ToString
;
import
java.io.Serializable
;
/**
* @Description 百应话术列表请求
* @author chizw
* @create 2023/7/5 10:32
* @version ver.1.0.0
*/
@JsonSerialize
()
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
(
includeFieldNames
=
true
,
callSuper
=
true
)
public
class
ByaiGetRobotListRequestDTO
implements
Serializable
{
/**
* 商户号
*/
@JsonProperty
(
"merchantId"
)
@Schema
(
name
=
"merchantId"
,
description
=
"商户号"
,
example
=
"0"
)
private
Integer
merchantId
;
/**
* 公司Id
*/
@JsonProperty
(
"companyId"
)
@Schema
(
name
=
"companyId"
,
description
=
"公司Id"
,
example
=
"1"
)
private
Long
companyId
;
/**
* 话术状态 0:所有话术,1:已上线话术,2:查询发布过(含已上线和上线后重新修改)的话术 ;默认为0
*/
@JsonProperty
(
"robotStatus"
)
@Schema
(
name
=
"robotStatus"
,
description
=
"话术状态 0:所有话术,1:已上线话术,2:查询发布过(含已上线和上线后重新修改)的话术 ;默认为0"
,
example
=
"0"
)
private
Long
robotStatus
;
/**
* 查询百应所有话术
*/
@JsonProperty
(
"selectAll"
)
@Schema
(
name
=
"selectAll"
,
description
=
"查询百应所有话术"
)
private
Boolean
selectAll
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiGetRobotListResponseDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
aioutboundcall
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
lombok.ToString
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* @author chizw
* @version ver.1.0.0
* @Description 百应话术列表返回
* @create 2023/7/5 10:32
*/
@Data
@ToString
(
includeFieldNames
=
true
,
callSuper
=
true
)
public
class
ByaiGetRobotListResponseDTO
implements
Serializable
{
/**
* 公司的机器人话术列表
*/
@Schema
(
name
=
"list"
,
description
=
"公司的机器人话术列表"
)
private
List
<
RobotVO
>
list
;
/**
* 公司的机器人话术列表
*/
@Data
public
static
class
RobotVO
implements
Serializable
{
/**
* 机器人ID
*/
@Schema
(
name
=
"robotDefId"
,
description
=
"机器人ID"
,
example
=
"1"
)
private
Long
robotDefId
;
/**
* 机器人名称
*/
@Schema
(
name
=
"robotName"
,
description
=
"机器人名称"
,
example
=
"测试"
)
private
String
robotName
;
/**
* 一级行业名
*/
@Schema
(
name
=
"industryOneName"
,
description
=
"一级行业名"
,
example
=
"房产"
)
private
String
industryOneName
;
/**
* 二级行业名
*/
@Schema
(
name
=
"industryTwoName"
,
description
=
"二级行业名"
,
example
=
"卖房"
)
private
String
industryTwoName
;
/**
* 话术状态 0:待发布 1:待审核 2:待录音 3:待上线 4:审核不通过 5:已上线
*/
@Schema
(
name
=
"robotStatus"
,
description
=
"话术状态 0:待发布 1:待审核 2:待录音 3:待上线 4:审核不通过 5:已上线"
,
example
=
"0"
)
private
Long
robotStatus
;
/**
* 发布时间
*/
@Schema
(
name
=
"deployTime"
,
description
=
"发布时间"
,
example
=
"2022-02-22 17:04:18"
)
private
String
deployTime
;
}
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiImportCallJobCustomerRequestDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
aioutboundcall
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.ToString
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author chizw
* @version ver.1.0.0
* @Description 百应导入客户请求
* @create 2023/7/5 10:32
*/
@JsonSerialize
()
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
(
includeFieldNames
=
true
,
callSuper
=
true
)
public
class
ByaiImportCallJobCustomerRequestDTO
implements
Serializable
{
/**
* 商户号
*/
@JsonProperty
(
"merchantId"
)
@Schema
(
name
=
"merchantId"
,
description
=
"商户号"
)
private
Integer
merchantId
;
/**
* 话术状态 0:所有话术,1:已上线话术,2:查询发布过(含已上线和上线后重新修改)的话术 ;默认为0
*/
@JsonProperty
(
"callJobId"
)
@Schema
(
name
=
"callJobId"
,
description
=
"话术状态 0:所有话术,1:已上线话术,2:查询发布过(含已上线和上线后重新修改)的话术 ;默认为0"
)
private
Long
callJobId
;
/**
* 公司Id
*/
@JsonProperty
(
"companyId"
)
@Schema
(
name
=
"companyId"
,
description
=
"公司Id"
,
example
=
"30123"
)
private
Long
companyId
;
/**
* 用户信息字段,其中phone为必传,name可不传,properties字段在话术中有变量时为必传字段;
* 如果需自定义参数也可以通过properties入参;变量可通过“查询话术变量”接口查询;
* 如果使用了SDK中AES方式加密数据,需要入参encryptionProp、encryptionPhone为true
*/
@JsonProperty
(
"customerInfoVOList"
)
@Schema
(
name
=
"customerInfoVOList"
,
required
=
true
,
description
=
"话术状态 0:所有话术,1:已上线话术,2:查询发布过(含已上线和上线后重新修改)的话术 ;默认为0"
)
private
List
<
CustomerInfoVO
>
customerInfoVOList
;
@Data
public
static
class
CustomerInfoVO
implements
Serializable
{
/**
* 客户名称
*/
@JsonProperty
(
"name"
)
@Schema
(
name
=
"name"
,
description
=
"客户名称"
,
example
=
"赵四"
,
required
=
true
)
private
String
name
;
/**
* 客户电话
*/
@JsonProperty
(
"phone"
)
@Schema
(
name
=
"phone"
,
description
=
"客户电话"
,
example
=
"13900008888"
,
required
=
true
)
private
String
phone
;
/**
* 客户自定义额外信息
*/
@JsonProperty
(
"properties"
)
@Schema
(
name
=
"properties"
,
description
=
"客户自定义额外信息"
,
example
=
"{\"客户名称\":\"赵四\",\"联系方式\":\"13700000731\"}"
)
private
Map
<
String
,
String
>
properties
;
}
/**
* 手机号码加密,默认false;仅在使用sdk加密(AES)时需要传,并需传入 true
*/
@JsonProperty
(
"encryptionPhone"
)
@Schema
(
name
=
"encryptionPhone"
,
description
=
"手机号码加密,默认false;仅在使用sdk加密(AES)时需要传,并需传入 true"
,
example
=
"false"
)
private
Boolean
encryptionPhone
;
/**
* 客户属性加密,默认false;仅在使用sdk加密(AES)时需要传,并需传入 true
*/
@JsonProperty
(
"encryptionProp"
)
@Schema
(
name
=
"encryptionProp"
,
description
=
"客户属性加密,默认false;仅在使用sdk加密(AES)时需要传,并需传入 true"
,
example
=
"false"
)
private
Boolean
encryptionProp
;
/**
* 同一个任务中是否支持重复导入手机号,默认false
*/
@JsonProperty
(
"permitrepeatnum"
)
@Schema
(
name
=
"permitrepeatnum"
,
description
=
"同一个任务中是否支持重复导入手机号,默认false"
,
example
=
"true"
)
private
Boolean
permitrepeatnum
;
/**
* 任务类型, 1-定时,2-手动;当选择定时任务时,startDate为必传
*/
@JsonProperty
(
"callJobType"
)
@Schema
(
name
=
"callJobType"
,
description
=
"任务类型, 1-定时,2-手动;当选择定时任务时,startDate为必传"
,
example
=
"true"
)
private
Long
callJobType
;
/**
* 任务开始日期(定时任务必填)格式2019-08-08 精确到天
*/
@JsonProperty
(
"startDate"
)
@Schema
(
name
=
"startDate"
,
description
=
"任务开始日期(定时任务必填)格式2019-08-08 精确到天"
,
example
=
"2019-08-08"
)
private
String
startDate
;
/**
* 自定义多时段
*/
@JsonProperty
(
"workingTimeRuleList"
)
@Schema
(
name
=
"workingTimeRuleList"
,
description
=
"自定义多时段"
,
example
=
"[{\"timeRanges\":[{\"startTime\":\"09:00\",\"endTime\":\"20:00\"}],\"weeks\":[1,2]}]"
)
private
List
<
JobWorkingTimeRuleDetailVO
>
workingTimeRuleList
;
@Data
public
static
class
JobWorkingTimeRuleDetailVO
implements
Serializable
{
/**
* timeRanges
*/
@JsonProperty
(
"timeRanges"
)
@Schema
(
name
=
"timeRanges"
,
description
=
"timeRanges"
)
private
List
<
TimeRangeVO
>
timeRanges
;
/**
* weeks
*/
@JsonProperty
(
"weeks"
)
@Schema
(
name
=
"weeks"
,
description
=
"weeks"
)
private
List
<
Integer
>
weeks
;
@Data
public
static
class
TimeRangeVO
implements
Serializable
{
/**
* 开始时间
*/
@JsonProperty
(
"startTime"
)
@Schema
(
name
=
"startTime"
,
description
=
"开始时间"
)
private
String
startTime
;
/**
* 结束时间
*/
@JsonProperty
(
"endTime"
)
@Schema
(
name
=
"endTime"
,
description
=
"结束时间"
)
private
String
endTime
;
}
}
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/aioutboundcall/ByaiImportCallJobCustomerResponseDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
aioutboundcall
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
lombok.ToString
;
import
java.io.Serializable
;
/**
* @Description 百应导入客户返回
* @author chizw
* @create 2023/7/5 10:32
* @version ver.1.0.0
*/
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
@JsonSerialize
(
include
=
JsonSerialize
.
Inclusion
.
NON_NULL
)
@Data
@ToString
(
includeFieldNames
=
true
,
callSuper
=
true
)
public
class
ByaiImportCallJobCustomerResponseDTO
implements
Serializable
{
/**
* 导入结果
*/
@JsonProperty
(
"success"
)
@Schema
(
name
=
"success"
,
description
=
"导入结果"
)
private
Boolean
success
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/oneVone/BatchMessagingContentDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
oneVone
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @Description 群发内容请求参数
* @author chizw
* @create 2022/9/16 17:44
* @version ver.1.0.0
*/
@Data
public
class
BatchMessagingContentDTO
implements
Serializable
{
@Schema
(
description
=
"素材类型(1文本,2图片,3视频,4链接,5小程序,6附件,7活动)"
,
name
=
"attType"
)
private
Integer
attType
;
@Schema
(
description
=
"素材内容,例:"
+
"\n文本:hello群发"
+
"\n图片:https://wx.glsx.com.cn/upload/biz/2c808549-447b-4193-b1da-e81f88a2cf47.png"
+
"\n视频:https://wx.glsx.com.cn/upload/biz/59983d6c-4e19-438c-bad5-46d3f911c3bb.mp4"
+
"\n链接:{\"picurl\":\"https://wx.glsx.com.cn/upload/biz/c8289241-0522-48a5-954a-4e581e895844.png\",\"title\":\"测试群发海报\",\"url\":\"http://scrm.test.glsx.com.cn/scrm-wx-merchant-activity/#/crowdfunding?id=705&merchantId=44210895&sharedTime=1666683990067\"}"
+
"\n小程序:{\"path\":\"页面\",\"thumb_url\":\"小图标url\",\"appId\":\"appId\",\"title\":\"标题\",\"pic_url\":\"图片url\",\"wx_id\":\"小程序原始ID,gh_xxx\",\"desc\":\"描述\"}"
+
"\n附件:{\"fileName\":\"测试文件\",\"url\":\"https://wx.glsx.com.cn/upload/biz/4f42a81f-dff8-4b1a-822e-9c65b5c27e85.pdf\"}"
+
"\n活动:{\"marketingId\":1,\"marketingType\":3,\"marketingName\":\"招商银行信用卡\",\"marketingContent\":{\"equityName\":\"招商银行信用卡\",\"effectivedDay\":365,\"effectiveType\":2,\"freeDay\":30,\"selectType\":\"card\"}}"
,
name
=
"attContent"
)
private
String
attContent
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/oneVone/BatchMessagingCreateRopRequestDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
oneVone
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
/**
* @Description 企微高级群发创建请求参数
* @author chizw
* @create 2022/9/16 17:36
* @version ver.1.0.0
*/
@Data
public
class
BatchMessagingCreateRopRequestDTO
implements
Serializable
{
@Schema
(
description
=
"群发名称"
,
name
=
"msgName"
,
required
=
false
)
private
String
msgName
;
@Schema
(
description
=
"群发门店id"
,
name
=
"msgMerchantId"
,
required
=
true
)
private
Integer
msgMerchantId
;
@Schema
(
description
=
"群发门店名称"
,
name
=
"msgMerchantName"
,
required
=
false
)
private
String
msgMerchantName
;
@Schema
(
description
=
"客户类型 1=标签筛选 2=人群筛选 3=指定id类型(默认)"
,
name
=
"customerType"
,
required
=
false
)
private
Integer
customerType
;
@Schema
(
description
=
"1-组之间并集,2-组之间交集,customerType=1|2 时不能为空"
,
name
=
"combineType"
)
private
Integer
combineType
;
@Schema
(
description
=
"标签条件,customerType=1 时不能为空"
,
name
=
"labelList"
)
private
List
<
LabelRequestDTO
>
labelList
;
@Schema
(
description
=
"人群条件,customerType=2 时不能为空"
,
name
=
"crowdList"
)
private
List
<
BatchMessagingCrowConditionDTO
>
crowdList
;
@Schema
(
description
=
"群发内容,不能为空"
,
name
=
"contentList"
,
required
=
true
)
private
List
<
BatchMessagingContentDTO
>
contentList
;
@Schema
(
description
=
"员工id,customerType=3 时使用"
,
name
=
"staffIdList"
)
private
List
<
Integer
>
staffIdList
;
@Schema
(
description
=
"客户id,customerType=3 时使用"
,
name
=
"customerIdList"
)
private
List
<
Integer
>
customerIdList
;
@Schema
(
description
=
"员工云控id,customerType=3 时使用"
,
name
=
"staffCloudIdList"
)
private
List
<
String
>
staffCloudIdList
;
@Schema
(
description
=
"客户或客户群云控id,customerType=3|4 时使用"
,
name
=
"customerCloudIdList"
)
private
List
<
String
>
customerCloudIdList
;
@Schema
(
description
=
"发送状态 1=立即发送(默认),2=定时发送"
,
name
=
"sendType"
)
private
Integer
sendType
;
@DateTimeFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@Schema
(
description
=
"定时发送时间,sendType=2 时使用,为空或小于当前时间时为立即发送"
,
name
=
"sendTime"
)
private
Date
sendTime
;
@Schema
(
description
=
"是否异步处理 true=异步处理 false=实时处理(默认)"
,
name
=
"asyncProcess"
)
private
Boolean
asyncProcess
;
/**
* 创建者
*/
private
Integer
createdBy
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/oneVone/BatchMessagingCrowConditionDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
oneVone
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @Description 群发人群条件请求参数
* @author chizw
* @create 2022/9/16 18:00
* @version ver.1.0.0
*/
@Data
public
class
BatchMessagingCrowConditionDTO
implements
Serializable
{
@Schema
(
description
=
"人群id"
,
name
=
"crowdId"
)
private
Integer
crowdId
;
@Schema
(
description
=
"人群名称"
,
name
=
"crowdName"
)
private
String
crowdName
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/oneVone/LabelRequestDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
oneVone
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
/**
* @author yelq
* @version 1.2.0
* @description: 标签请求对象
* @createTime 2022年2月18日
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
public
class
LabelRequestDTO
implements
Serializable
{
@Schema
(
description
=
"标签组id"
,
name
=
"groupId"
)
private
Integer
groupId
;
@Schema
(
description
=
"标签组名称"
,
name
=
"groupName"
)
private
String
groupName
;
@Schema
(
description
=
"标签组类型"
,
name
=
"groupType"
)
private
String
groupType
;
@Schema
(
description
=
"标签id"
,
name
=
"labelId"
)
private
Integer
labelId
;
@Schema
(
description
=
"标签名称"
,
name
=
"labelName"
)
private
String
labelName
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/rop/RopResponseDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
rop
;
import
lombok.Data
;
/**
* @Author yelq
* @Version 1.0
* @Description:
* @Date 2023/9/7 17:02
*/
@Data
public
class
RopResponseDTO
<
T
>
{
private
String
code
;
private
String
errId
;
private
String
message
;
private
T
data
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/shorturl/GenerateUrlRequest.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
shorturl
;
import
lombok.*
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
/**
* @Description 创建长短链映射请求
* @author chizw
* @create 2023/9/26 20:49
* @version ver.1.0.0
*/
@Data
public
class
GenerateUrlRequest
implements
Serializable
{
/**
* 要生成的短链接地址
*/
@NotNull
private
String
url
;
private
String
requestId
;
private
String
description
;
private
String
b4RedirectPage
;
private
Boolean
isThroughAuth
;
private
Boolean
addTimestamp
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/shorturl/GenerateUrlResponse.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
shorturl
;
import
lombok.*
;
import
java.io.Serializable
;
/**
* @Description 创建长短链映射请求
* @author chizw
* @create 2023/9/26 20:49
* @version ver.1.0.0
*/
@RequiredArgsConstructor
@Data
@ToString
@Builder
public
class
GenerateUrlResponse
implements
Serializable
{
/**
* 请求标识
*/
private
final
String
requestId
;
/**
* 短链
*/
private
final
String
shortUrl
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/sms/SmsResponseDTO.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
sms
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
lombok.ToString
;
/**
* @Author yelq
* @Version 1.0
* @Description:
* @Date 2023/9/7 17:53
*/
@ToString
@Data
public
class
SmsResponseDTO
{
@Schema
(
name
=
"code"
,
title
=
"响应码"
,
example
=
"0"
,
description
=
"响应码"
)
private
String
code
;
@Schema
(
name
=
"message"
,
title
=
"响应描述"
,
example
=
"0"
,
description
=
"响应描述"
)
private
String
message
;
@Schema
(
name
=
"datas"
,
title
=
"返回对象"
,
example
=
""
,
description
=
"响应主体"
)
private
Object
datas
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/wechat/GetUserInfoRequest.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
wechat
;
import
lombok.Data
;
import
lombok.ToString
;
import
javax.validation.constraints.NotNull
;
/**
* @author huangch
* @version V1.0
* @Title: GetAccessTokenRequest
* @Description:
* @Company: Didihu.com.cn
* @Date 2022/6/29 17:41
*/
@Data
@ToString
public
class
GetUserInfoRequest
{
@NotNull
private
String
openId
;
@NotNull
private
String
unionId
;
}
platform-execute-api/src/main/java/cn/com/glsx/execute/modules/model/wechat/GetUserInfoResponse.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
model
.
wechat
;
import
lombok.Data
;
import
lombok.ToString
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.Date
;
/**
*
* @Title WechatUserInfo
* @Description:
* @author Suro
* @date 2021/7/21 15:08
* @version V1.0
* @Company:didihu.com.cn
**/
@Data
@ToString
public
class
GetUserInfoResponse
implements
Serializable
{
/**
* 主键
*/
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Integer
id
;
/**
* 账号ID
*/
@Column
(
name
=
"account_id"
)
private
Integer
accountId
;
/**
* 昵称
*/
@Column
(
name
=
"nick_name"
)
private
String
nickName
;
/**
* 手机号
*/
private
String
phone
;
/**
* 性别(1:男性,2:女性,0:未知 )
*/
private
Integer
sex
;
/**
* 头像
*/
@Column
(
name
=
"head_img_url"
)
private
String
headImgUrl
;
/**
* 国家
*/
private
String
country
;
/**
* 省份
*/
private
String
province
;
/**
* 城市
*/
private
String
city
;
/**
* 地址
*/
private
String
address
;
/**
* 关注时间
*/
@Column
(
name
=
"subscribe_time"
)
private
String
subscribeTime
;
/**
* 是否登录(Y:已登录;N:未登录)
*/
@Column
(
name
=
"is_login"
)
private
String
isLogin
;
/**
* 微信openId
*/
@Column
(
name
=
"open_id"
)
private
String
openId
;
/**
* 微信账户unionId
*/
@Column
(
name
=
"union_id"
)
private
String
unionId
;
/**
* 授权方应用ID
*/
private
String
appid
;
/**
* 创建人
*/
@Column
(
name
=
"created_by"
)
private
String
createdBy
;
/**
* 创建时间
*/
@Column
(
name
=
"created_date"
)
private
Date
createdDate
;
/**
* 修改人
*/
@Column
(
name
=
"updated_by"
)
private
String
updatedBy
;
/**
* 修改时间
*/
@Column
(
name
=
"updated_date"
)
private
Date
updatedDate
;
/**
* 删除标示(D:已删除;N:未删除)
*/
@Column
(
name
=
"deleted_flag"
)
private
String
deletedFlag
;
}
\ No newline at end of file
\ No newline at end of file
platform-execute-api/src/test/resources/generatorConfig.xml
0 → 100644
View file @
3220cd3
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE generatorConfiguration PUBLIC
"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<!-- 配置生成器 -->
<generatorConfiguration>
<!--classPathEntry:数据库的JDBC驱动,换成你自己的驱动位置 可选 -->
<!-- <classPathEntry location="F://jdbc//mysql-connector-java-8.0.18.jar"/>-->
<!-- 一个数据库一个context -->
<context
id=
"DB2Tables"
targetRuntime=
"Mybatis3"
>
<!-- 自动识别数据库关键字,默认false,如果设置为true,根据SqlReservedWords中定义的关键字列表;一般保留默认值,遇到数据库关键字(Java关键字),使用columnOverride覆盖 -->
<property
name=
"autoDelimitKeywords"
value=
"true"
/>
<!-- 生成的Java文件的编码 -->
<property
name=
"javaFileEncoding"
value=
"utf-8"
/>
<!-- beginningDelimiter和endingDelimiter:指明数据库的用于标记数据库对象名的符号,比如ORACLE就是双引号,MYSQL默认是`反引号; -->
<property
name=
"beginningDelimiter"
value=
"`"
/>
<property
name=
"endingDelimiter"
value=
"`"
/>
<!-- 格式化java代码 -->
<property
name=
"javaFormatter"
value=
"org.mybatis.generator.api.dom.DefaultJavaFormatter"
/>
<!-- 格式化XML代码 -->
<property
name=
"xmlFormatter"
value=
"org.mybatis.generator.api.dom.DefaultXmlFormatter"
/>
<plugin
type=
"org.mybatis.generator.plugins.SerializablePlugin"
/>
<plugin
type=
"org.mybatis.generator.plugins.ToStringPlugin"
/>
<!-- 配置 tk.mybatis 插件 -->
<!-- <plugin type="tk.mybatis.mapper.generator.MapperPlugin">-->
<!-- <property name="mappers" value="com.glsx.plat.mybatis.mapper.CommonBaseMapper"/>-->
<!-- </plugin>-->
<plugin
type=
"tk.mybatis.mapper.generator.MapperPlugin"
>
<property
name=
"mappers"
value=
"com.glsx.plat.mybatis.mapper.CommonBaseMapper"
/>
<property
name=
"caseSensitive"
value=
"true"
/>
<property
name=
"useActualColumnNames"
value=
"true"
/>
<!--<property name="beginningDelimiter" value="`"/>-->
<!--<property name="endingDelimiter" value="`"/>-->
</plugin>
<!--配置生成注释信息,最多配置一个 -->
<commentGenerator>
<!-- 阻止生成注释包含时间戳 默认为false -->
<property
name=
"suppressDate"
value=
"true"
/>
<!-- 注释是否添加数据库表的备注信息 默认为false -->
<property
name=
"addRemarkComments"
value=
"true"
/>
</commentGenerator>
<!-- jdbc连接-->
<!-- <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"-->
<!-- connectionURL="jdbc:mysql://192.168.0.39:3306/seata_storage?serverTimeZone=Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false"-->
<!-- userId="root"-->
<!-- password="123456">-->
<!-- <!–防止生成其他库同名表–>-->
<!-- <property name="nullCatalogMeansCurrent" value="true"/>-->
<!-- </jdbcConnection>-->
<jdbcConnection
driverClass=
"com.mysql.jdbc.Driver"
connectionURL=
"jdbc:mysql://192.168.3.222:3308/platform_process_dev?characterEncoding=utf8"
userId=
"user_zhouhb"
password=
"WoWP7N1u"
/>
<!-- 类型转换 -->
<javaTypeResolver>
<!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->
<property
name=
"forceBigDecimals"
value=
"false"
/>
</javaTypeResolver>
<!-- 生成实体类地址 -->
<!-- <javaModelGenerator targetPackage="cn.com.payu.modules.entity" targetProject="src/main/java">-->
<!-- <!– 是否让schema作为包的后缀 –>-->
<!-- <property name="enableSubPackages" value="true"/>-->
<!-- <!– 从数据库返回的值去掉前后空格 –>-->
<!-- <property name="trimStrings" value="true"/>-->
<!-- </javaModelGenerator>-->
<javaModelGenerator
targetPackage=
"cn.com.glsx.execute.modules.entity.shortutl"
targetProject=
"D:\projects\sop\platform-execute-server\platform-execute-api\src\main\java"
>
<property
name=
"enableSubPackages"
value=
"true"
/>
<property
name=
"trimStrings"
value=
"true"
/>
</javaModelGenerator>
<!-- 生成mapper.xml文件存放地址 -->
<sqlMapGenerator
targetPackage=
"mapper"
targetProject=
"src/main/resources"
>
<property
name=
"enableSubPackages"
value=
"true"
/>
</sqlMapGenerator>
<!-- 生成接口dao type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象 type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象 type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<!-- <javaClientGenerator targetPackage="cn.com.payu.modules.mapper" targetProject="src/main/java" type="XMLMAPPER">-->
<!-- <property name="enableSubPackages" value="false"/>-->
<!-- </javaClientGenerator>-->
<javaClientGenerator
targetPackage=
"cn.com.glsx.execute.modules.mapper"
targetProject=
"D:\projects\sop\platform-execute-server\platform-execute-api\src\main\java"
type=
"XMLMAPPER"
>
<property
name=
"enableSubPackages"
value=
"true"
/>
</javaClientGenerator>
<!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 -->
<!-- <table tableName="t_storage" domainObjectName="Storage" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" -->
<!-- selectByExampleQueryId="false"/>-->
<table
tableName=
"short_url_compress_code"
domainObjectName=
"ShortUrlCompressCodeDTO"
enableSelectByExample=
"false"
enableCountByExample=
"false"
enableDeleteByExample=
"false"
enableUpdateByExample=
"false"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
<table
tableName=
"short_url_domain_config"
domainObjectName=
"ShortUrlDomainConfigDTO"
enableSelectByExample=
"false"
enableCountByExample=
"false"
enableDeleteByExample=
"false"
enableUpdateByExample=
"false"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
<table
tableName=
"short_url_jump_event_record"
domainObjectName=
"ShortUrlJumpEventRecordDTO"
enableSelectByExample=
"false"
enableCountByExample=
"false"
enableDeleteByExample=
"false"
enableUpdateByExample=
"false"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
<table
tableName=
"short_url_mapping"
domainObjectName=
"ShortUrlMappingDTO"
enableSelectByExample=
"false"
enableCountByExample=
"false"
enableDeleteByExample=
"false"
enableUpdateByExample=
"false"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
\ No newline at end of file
platform-execute/pom.xml
View file @
3220cd3
...
@@ -11,7 +11,43 @@
...
@@ -11,7 +11,43 @@
<artifactId>
platform-execute
</artifactId>
<artifactId>
platform-execute
</artifactId>
<properties>
<redisson.version>
3.20.0
</redisson.version>
<distribute.version>
2.2.0-SNAPSHOT
</distribute.version>
<ttl.version>
2.14.2
</ttl.version>
<jackson.version>
2.15.1
</jackson.version>
</properties>
<dependencies>
<dependencies>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
<version>
${jackson.version}
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
transmittable-thread-local
</artifactId>
<version>
${ttl.version}
</version>
</dependency>
<dependency>
<groupId>
org.oreframework
</groupId>
<artifactId>
ore-distribute-lock
</artifactId>
<version>
${distribute.version}
</version>
</dependency>
<dependency>
<groupId>
org.redisson
</groupId>
<artifactId>
redisson
</artifactId>
<version>
${redisson.version}
</version>
</dependency>
<dependency>
<groupId>
commons-validator
</groupId>
<artifactId>
commons-validator
</artifactId>
<version>
1.7
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-webflux
</artifactId>
</dependency>
<!-- 运行环境上下文 -->
<!-- 运行环境上下文 -->
<dependency>
<dependency>
<groupId>
com.glsx
</groupId>
<groupId>
com.glsx
</groupId>
...
@@ -35,9 +71,19 @@
...
@@ -35,9 +71,19 @@
<!-- local api -->
<!-- local api -->
<dependency>
<dependency>
<groupId>
cn.com.glsx
</groupId>
<groupId>
cn.com.glsx
</groupId>
<artifactId>
rpc-scrm-wechat-api
</artifactId>
<version>
3.15.0-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
cn.com.glsx
</groupId>
<artifactId>
platform-execute-api
</artifactId>
<artifactId>
platform-execute-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<version>
1.0-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<groupId>
cn.com.glsx
</groupId>
<artifactId>
platform-cdp-api
</artifactId>
<version>
1.0-SNAPSHOT
</version>
</dependency>
<!-- rest api -->
<!-- rest api -->
<dependency>
<dependency>
<groupId>
com.glsx
</groupId>
<groupId>
com.glsx
</groupId>
...
@@ -50,6 +96,29 @@
...
@@ -50,6 +96,29 @@
<artifactId>
rpc-scrm-proxy-api
</artifactId>
<artifactId>
rpc-scrm-proxy-api
</artifactId>
<version>
3.7.0-SNAPSHOT
</version>
<version>
3.7.0-SNAPSHOT
</version>
</dependency>
</dependency>
<!--rabbitmq-->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-amqp
</artifactId>
<version>
2.6.0
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<dependency>
<groupId>
de.codecentric
</groupId>
<artifactId>
spring-boot-admin-starter-client
</artifactId>
<version>
3.0.2
</version>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
1.18.26
</version>
<scope>
provided
</scope>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
platform-execute/src/main/java/cn/com/glsx/execute/common/constant/Constants.java
View file @
3220cd3
...
@@ -13,4 +13,17 @@ public final class Constants extends BasicConstants {
...
@@ -13,4 +13,17 @@ public final class Constants extends BasicConstants {
public
final
static
String
SERVER_NAME
=
"glsx_rest_admin"
;
public
final
static
String
SERVER_NAME
=
"glsx_rest_admin"
;
public
static
final
String
HTTPS_PROTOCOL
=
"https"
;
public
static
final
String
HTTP_PROTOCOL
=
"http"
;
/**
* 数据标记 删除
*/
public
static
final
byte
DEL_FLAG
=
-
1
;
/**
* 数据标记 正常
*/
public
static
final
byte
NORMAL_FLAG
=
0
;
}
}
platform-execute/src/main/java/cn/com/glsx/execute/common/constant/DBConstants.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
common
.
constant
;
import
lombok.Data
;
/**
* @Description 数据库常量
* @author chizw
* @create 2023/9/19 16:21
* @version ver.1.0.0
*/
@Data
public
final
class
DBConstants
{
private
DBConstants
()
{
throw
new
IllegalStateException
(
"Utility class"
);
}
public
static
final
String
DEL_FLAG
=
"delFlag"
;
public
static
final
class
ShortUrl
{
private
ShortUrl
()
{
throw
new
IllegalStateException
(
"Utility class"
);
}
public
static
final
String
COMPRESS_CODE
=
"compressCode"
;
}
}
platform-execute/src/main/java/cn/com/glsx/execute/common/constant/SmsConstants.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
common
.
constant
;
import
com.glsx.plat.core.constant.BasicConstants
;
/**
* 〈一句话功能简述〉<br>
* 短信公共常量类
*
* @author yelq
* @since 1.0.0
*/
public
final
class
SmsConstants
extends
BasicConstants
{
/**
* 营销类短信来源(此来源需要去短信管理平台创建)
*/
public
static
final
String
SMS_SOURCE
=
"platform-execute-sms"
;
/**
* 短信类型
*/
public
static
final
String
SMS_TYPE
=
"1"
;
}
platform-execute/src/main/java/cn/com/glsx/execute/common/constant/shorturl/CompressCodeStatus.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
common
.
constant
.
shorturl
;
import
lombok.Data
;
/**
* @Description 压缩码状态
* @author chizw
* @create 2023/9/15 10:31
* @version ver.1.0.0
*/
@Data
public
class
CompressCodeStatus
{
private
CompressCodeStatus
()
{
throw
new
IllegalStateException
(
"Utility class"
);
}
public
static
final
int
AVAILABLE
=
1
;
public
static
final
int
USED
=
2
;
public
static
final
int
INVALID
=
3
;
}
platform-execute/src/main/java/cn/com/glsx/execute/common/constant/shorturl/DomainStatus.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
common
.
constant
.
shorturl
;
/**
* @Description 域名状态
* @author chizw
* @create 2023/9/14 17:15
* @version ver.1.0.0
*/
public
final
class
DomainStatus
{
private
DomainStatus
()
{
throw
new
IllegalStateException
(
"Utility class"
);
}
public
static
final
int
NORMAL
=
1
;
public
static
final
int
EXPIRED
=
2
;
}
platform-execute/src/main/java/cn/com/glsx/execute/common/constant/shorturl/UrlMapStatus.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
common
.
constant
.
shorturl
;
import
lombok.Data
;
/**
* @Description 短链映射状态
* @author chizw
* @create 2023/9/15 9:39
* @version ver.1.0.0
*/
@Data
public
class
UrlMapStatus
{
private
UrlMapStatus
()
{
throw
new
IllegalStateException
(
"Utility class"
);
}
/**
* 可用状态
*/
public
static
final
int
AVAILABLE
=
1
;
/**
* 非法状态
*/
public
static
final
int
INVALID
=
2
;
}
platform-execute/src/main/java/cn/com/glsx/execute/common/exception/ChainFilterErrorException.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
common
.
exception
;
/**
* @Description 需要重定向的异常
* @author chizw
* @create 2023/10/10 16:57
* @version ver.1.0.0
*/
public
class
ChainFilterErrorException
extends
RuntimeException
{
public
ChainFilterErrorException
(
String
message
)
{
super
(
message
);
}
public
ChainFilterErrorException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
public
ChainFilterErrorException
(
Throwable
cause
)
{
super
(
cause
);
}
@Override
public
synchronized
Throwable
fillInStackTrace
()
{
return
this
;
}
}
platform-execute/src/main/java/cn/com/glsx/execute/common/exception/LockException.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
common
.
exception
;
/**
* @Description 锁异常
* @author chizw
* @create 2023/9/15 13:44
* @version ver.1.0.0
*/
public
class
LockException
extends
RuntimeException
{
public
LockException
(
String
message
)
{
super
(
message
);
}
public
LockException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
public
LockException
(
Throwable
cause
)
{
super
(
cause
);
}
}
platform-execute/src/main/java/cn/com/glsx/execute/common/lock/DistributedLock.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
common
.
lock
;
import
java.util.concurrent.TimeUnit
;
/**
* @Description 分布式锁
* @author chizw
* @create 2023/9/15 14:00
* @version ver.1.0.0
*/
public
interface
DistributedLock
{
/**
* 阻塞加锁
*
* @param leaseTime leaseTime
* @param unit unit
*/
void
lock
(
long
leaseTime
,
TimeUnit
unit
);
/**
* 尝试加锁
*
* @param waitTime waitTime
* @param leaseTime leaseTime
* @param unit unit
* @return boolean
*/
boolean
tryLock
(
long
waitTime
,
long
leaseTime
,
TimeUnit
unit
);
/**
* 解锁
*/
void
unlock
();
/**
* 是否锁定
*
* @return boolean
*/
boolean
isLock
();
/**
* 当前线程是否持有锁
*
* @return boolean
*/
boolean
isHeldByCurrentThread
();
}
platform-execute/src/main/java/cn/com/glsx/execute/common/lock/DistributedLockFactory.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
common
.
lock
;
import
lombok.RequiredArgsConstructor
;
import
org.redisson.api.RedissonClient
;
/**
* @Description redis工厂
* @author chizw
* @create 2023/9/15 13:54
* @version ver.1.0.0
*/
//@Component
@RequiredArgsConstructor
public
class
DistributedLockFactory
{
private
static
final
String
DISTRIBUTED_LOCK_PATH_PREFIX
=
"dl:"
;
private
final
RedissonClient
redissonClient
;
/**
* 提供分布式锁
*
* @param lockKey lockKey
* @return DistributedLock
*/
public
DistributedLock
provideDistributedLock
(
String
lockKey
)
{
String
lockPath
=
DISTRIBUTED_LOCK_PATH_PREFIX
+
lockKey
;
return
new
RedissonDistributedLock
(
redissonClient
,
lockPath
);
}
}
platform-execute/src/main/java/cn/com/glsx/execute/common/lock/RedissonDistributedLock.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
common
.
lock
;
import
cn.com.glsx.execute.common.exception.LockException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.redisson.api.RLock
;
import
org.redisson.api.RedissonClient
;
import
java.util.concurrent.TimeUnit
;
/**
* @Description Redisson分布式锁
* @author chizw
* @create 2023/9/15 13:54
* @version ver.1.0.0
*/
@Slf4j
class
RedissonDistributedLock
implements
DistributedLock
{
private
final
RedissonClient
redissonClient
;
private
final
String
lockPath
;
private
final
RLock
internalLock
;
RedissonDistributedLock
(
RedissonClient
redissonClient
,
String
lockPath
)
{
this
.
redissonClient
=
redissonClient
;
this
.
lockPath
=
lockPath
;
this
.
internalLock
=
initInternalLock
();
}
private
RLock
initInternalLock
()
{
return
redissonClient
.
getLock
(
lockPath
);
}
@Override
public
boolean
isLock
()
{
return
internalLock
.
isLocked
();
}
@Override
public
boolean
isHeldByCurrentThread
()
{
return
internalLock
.
isHeldByCurrentThread
();
}
@Override
public
void
lock
(
long
leaseTime
,
TimeUnit
unit
)
{
internalLock
.
lock
(
leaseTime
,
unit
);
}
@Override
public
boolean
tryLock
(
long
waitTime
,
long
leaseTime
,
TimeUnit
unit
)
{
try
{
return
internalLock
.
tryLock
(
waitTime
,
leaseTime
,
unit
);
}
catch
(
InterruptedException
e
)
{
Thread
.
currentThread
().
interrupt
();
throw
new
LockException
(
String
.
format
(
"Acquire lock fail by thread interrupted,path:%s"
,
lockPath
),
e
);
}
}
@Override
public
void
unlock
()
{
try
{
internalLock
.
unlock
();
}
catch
(
IllegalMonitorStateException
ex
)
{
log
.
warn
(
"Unlock path:{} error for thread status change in concurrency"
,
lockPath
,
ex
);
}
}
}
platform-execute/src/main/java/cn/com/glsx/execute/config/DubboConfig.java
0 → 100644
View file @
3220cd3
/*
package cn.com.glsx.execute.config;
import cn.com.glsx.execute.api.dubbo.ShortUrlApi;
import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
*/
/**
* @author deployer name
* @version V1.0
* @Title: DubboConfig.java
* @Description: Dubbo服务注册配置
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2018
*//*
@Configuration
public class DubboConfig {
@Lazy
@Autowired
private ReferenceBuilderFactory factory;
@Bean
public ShortUrlApi ShortUrlApi() {
return factory.builder(ShortUrlApi.class)*/
/*.url("dubbo://localhost:22883")*//*
.check(false).timeout(30000).version("1.0.0").build();
}
}
*/
platform-execute/src/main/java/cn/com/glsx/execute/config/RabbitMQConfig.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
config
;
import
org.springframework.amqp.core.Binding
;
import
org.springframework.amqp.core.BindingBuilder
;
import
org.springframework.amqp.core.Queue
;
import
org.springframework.amqp.core.TopicExchange
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.HashMap
;
@Configuration
public
class
RabbitMQConfig
{
public
static
final
String
DATA_REPORT_QUEUE_NAME
=
"dataReport_queue"
;
public
static
final
String
DATA_REPORT_EXCHANGE_NAME
=
"dataReport_exchange"
;
public
static
final
String
DATA_REPORT_TOPIC
=
"dataReport.#"
;
public
static
final
String
DATA_DELAY_EXCHANGE_NAME
=
"dataDelay_exchange"
;
public
static
final
String
DATA_DELAY_TOPIC
=
"dataDelay.#"
;
public
static
final
String
DATA_DEAD_TOPIC
=
"dataDead.#"
;
public
static
final
String
DATA_REPORT_DEAD_QUEUE_NAME
=
"dataReport_dead_queue"
;
public
static
final
String
DATA_DELAY_QUEUE_NAME
=
"dataDelay_queue"
;
@Bean
(
name
=
"dataReportQueue"
)
public
Queue
dataReportQueue
(){
return
new
Queue
(
DATA_REPORT_QUEUE_NAME
,
true
);
}
@Bean
(
name
=
"dataDelayQueue"
)
public
Queue
dataDelayQueue
(){
return
new
Queue
(
DATA_DELAY_QUEUE_NAME
,
true
);
}
@Bean
(
name
=
"dataReportDeadQueue"
)
public
Queue
dataReportDeadQueue
(){
HashMap
<
String
,
Object
>
arguments
=
new
HashMap
<>();
arguments
.
put
(
"x-dead-letter-exchange"
,
DATA_DELAY_EXCHANGE_NAME
);
arguments
.
put
(
"x-dead-letter-routing-key"
,
DATA_DELAY_TOPIC
);
return
new
Queue
(
DATA_REPORT_DEAD_QUEUE_NAME
,
true
,
false
,
false
,
arguments
);
}
@Bean
(
name
=
"dataReportTopicExchange"
)
public
TopicExchange
dataReportTopicExchange
(){
return
new
TopicExchange
(
DATA_REPORT_EXCHANGE_NAME
);
}
@Bean
(
name
=
"dataDelayTopicExchange"
)
public
TopicExchange
dataDelayTopicExchange
(){
return
new
TopicExchange
(
DATA_DELAY_EXCHANGE_NAME
);
}
@Bean
public
Binding
bindingDataReport
(
@Qualifier
(
"dataReportQueue"
)
Queue
dataReportQueue
,
@Qualifier
(
"dataReportTopicExchange"
)
TopicExchange
dataReportTopicExchange
){
return
BindingBuilder
.
bind
(
dataReportQueue
).
to
(
dataReportTopicExchange
).
with
(
DATA_REPORT_TOPIC
);
}
@Bean
public
Binding
bindingDataDead
(
@Qualifier
(
"dataReportDeadQueue"
)
Queue
dataReportDeadQueue
,
@Qualifier
(
"dataDelayTopicExchange"
)
TopicExchange
dataDelayTopicExchange
){
return
BindingBuilder
.
bind
(
dataReportDeadQueue
).
to
(
dataDelayTopicExchange
).
with
(
DATA_DEAD_TOPIC
);
}
@Bean
public
Binding
bindingDataDelay
(
@Qualifier
(
"dataDelayQueue"
)
Queue
dataDelayQueue
,
@Qualifier
(
"dataDelayTopicExchange"
)
TopicExchange
dataDelayTopicExchange
){
return
BindingBuilder
.
bind
(
dataDelayQueue
).
to
(
dataDelayTopicExchange
).
with
(
DATA_DELAY_TOPIC
);
}
}
platform-execute/src/main/java/cn/com/glsx/execute/config/RedissonBloomFilterConfig.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
config
;
import
com.glsx.plat.common.utils.StringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.redisson.Redisson
;
import
org.redisson.api.RBloomFilter
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.config.Config
;
import
org.redisson.config.SingleServerConfig
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
javax.annotation.PostConstruct
;
@Slf4j
@Configuration
public
class
RedissonBloomFilterConfig
{
@Value
(
"${spring.redis.host}"
)
private
String
address
;
@Value
(
"${spring.redis.port}"
)
private
String
port
;
@Value
(
"${spring.redis.password}"
)
private
String
password
;
@Bean
(
destroyMethod
=
"shutdown"
)
public
RedissonClient
redissonClient
()
{
Config
config
=
new
Config
();
SingleServerConfig
serverConfig
=
config
.
useSingleServer
().
setAddress
(
"redis://"
+
address
+
":"
+
port
);
if
(
StringUtils
.
isNotEmpty
(
password
))
serverConfig
.
setPassword
(
password
);
return
Redisson
.
create
(
config
);
}
@Bean
(
"executeBloomFilter"
)
public
RBloomFilter
<
String
>
bloomFilter
(
@Autowired
RedissonClient
redissonClient
)
{
RBloomFilter
<
String
>
bloomFilter
=
redissonClient
.
getBloomFilter
(
"executeBloomFilter"
);
// 设置布隆过滤器的预期误报率和初始容量
bloomFilter
.
tryInit
(
100000000L
,
0.01
);
return
bloomFilter
;
}
}
platform-execute/src/main/java/cn/com/glsx/execute/config/WebConfig.java
View file @
3220cd3
...
@@ -65,6 +65,10 @@ public class WebConfig implements WebMvcConfigurer {
...
@@ -65,6 +65,10 @@ public class WebConfig implements WebMvcConfigurer {
.
excludePathPatterns
(
"/login"
)
.
excludePathPatterns
(
"/login"
)
.
excludePathPatterns
(
"/actuator/**"
)
.
excludePathPatterns
(
"/actuator/**"
)
.
excludePathPatterns
(
"/api/**"
)
.
excludePathPatterns
(
"/api/**"
)
.
excludePathPatterns
(
"/sop/**"
)
.
excludePathPatterns
(
"/shorturl/**"
)
.
excludePathPatterns
(
"/u/**"
)
.
excludePathPatterns
(
"/r/**"
)
.
excludePathPatterns
(
uploadProperties
.
getFilepath
())
.
excludePathPatterns
(
uploadProperties
.
getFilepath
())
.
excludePathPatterns
(
"/swagger-resources/**"
,
"/swagger-ui/**"
,
"/v3/**"
,
"/doc.html"
);
.
excludePathPatterns
(
"/swagger-resources/**"
,
"/swagger-ui/**"
,
"/v3/**"
,
"/doc.html"
);
registry
.
addInterceptor
(
logInterceptor
).
addPathPatterns
(
"/**"
);
registry
.
addInterceptor
(
logInterceptor
).
addPathPatterns
(
"/**"
);
...
...
platform-execute/src/main/java/cn/com/glsx/execute/filter/AccessFilter.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
filter
;
/**
* @Description
* @author chizw
* @create 2023/9/19 19:51
* @version ver.1.0.0
*/
public
interface
AccessFilter
{
/**
* 顺序系数
*
* @return int
*/
default
int
order
()
{
return
1
;
}
/**
* 获取拦截器类名
*
* @return
*/
default
String
getClassName
()
{
return
"AccessFilter"
;
}
/**
* 初始化钩子方法
*
* @param context context
*/
default
void
init
(
TransformContext
context
)
{
}
/**
* 执行过滤
*
* @param chain chain
* @param context context
*/
void
doFilter
(
AccessFilterChain
chain
,
TransformContext
context
);
}
platform-execute/src/main/java/cn/com/glsx/execute/filter/AccessFilterChain.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
filter
;
/**
* @Description
* @author chizw
* @create 2023/9/19 19:51
* @version ver.1.0.0
*/
public
interface
AccessFilterChain
{
void
doFilter
(
TransformContext
context
);
void
release
();
}
platform-execute/src/main/java/cn/com/glsx/execute/filter/AccessFilterChainFactory.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
filter
;
import
cn.com.glsx.execute.filter.shorturl.RedirectUrlFilter
;
import
com.google.common.collect.Lists
;
import
lombok.Getter
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.BeanFactory
;
import
org.springframework.beans.factory.BeanFactoryAware
;
import
org.springframework.beans.factory.ListableBeanFactory
;
import
org.springframework.stereotype.Component
;
import
java.lang.annotation.Annotation
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map
;
/**
* @Description
* @author chizw
* @create 2023/9/19 19:51
* @version ver.1.0.0
*/
@Component
public
class
AccessFilterChainFactory
implements
BeanFactoryAware
{
private
ListableBeanFactory
beanFactory
;
@SuppressWarnings
(
"NullableProblems"
)
@Override
public
void
setBeanFactory
(
BeanFactory
beanFactory
)
throws
BeansException
{
this
.
beanFactory
=
(
ListableBeanFactory
)
beanFactory
;
}
/**
* 创建TransformFilter链
*/
public
AccessFilterChain
buildTransformFilterChain
(
TransformContext
context
,
Class
<?
extends
Annotation
>
annotationType
)
{
List
<
TransformFilterInstance
>
instances
=
Lists
.
newArrayList
();
if
(
annotationType
==
null
)
{
Map
<
String
,
AccessFilter
>
filters
=
beanFactory
.
getBeansOfType
(
AccessFilter
.
class
);
filters
.
forEach
((
k
,
v
)
->
instances
.
add
(
new
TransformFilterInstance
(
v
,
v
.
order
(),
k
)));
}
else
{
String
[]
names
=
beanFactory
.
getBeanNamesForAnnotation
(
annotationType
);
for
(
String
name
:
names
)
{
AccessFilter
filter
=
beanFactory
.
getBean
(
name
,
AccessFilter
.
class
);
instances
.
add
(
new
TransformFilterInstance
(
filter
,
filter
.
order
(),
name
));
}
// instances.sort(Comparator.comparingInt(instance -> instance.getFilter().getClass().getAnnotation(annotationType).order()));
}
// 排序,order小的在前,大的在后
instances
.
sort
(
Comparator
.
comparingInt
(
TransformFilterInstance:
:
getOrder
));
DefaultAccessFilterChain
filterChain
=
new
DefaultAccessFilterChain
();
// 二次封装,添加名称为beanName,并且初始化
instances
.
forEach
(
instance
->
{
AccessFilter
filter
=
instance
.
getFilter
();
BaseNamingAccessFilter
baseNamingTransformFilter
=
new
BaseNamingAccessFilter
(
filter
)
{
@Override
public
String
filterName
()
{
return
instance
.
getFilterName
();
}
};
filterChain
.
addTransformFilter
(
baseNamingTransformFilter
);
baseNamingTransformFilter
.
init
(
context
);
});
return
filterChain
;
}
public
AccessFilterChain
buildTransformFilterChain
(
TransformContext
context
)
{
return
buildTransformFilterChain
(
context
,
null
);
}
/**
* 转换过滤器实例
*/
@RequiredArgsConstructor
@Getter
private
static
class
TransformFilterInstance
{
private
final
AccessFilter
filter
;
private
final
int
order
;
private
final
String
filterName
;
}
}
platform-execute/src/main/java/cn/com/glsx/execute/filter/BaseNamingAccessFilter.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
filter
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.concurrent.TimeUnit
;
/**
* @Description 抽象命名过滤器
* @author chizw
* @create 2023/10/10 16:55
* @version ver.1.0.0
*/
@Slf4j
@RequiredArgsConstructor
public
abstract
class
BaseNamingAccessFilter
implements
AccessFilter
{
private
final
AccessFilter
delegate
;
/**
* 定义过滤器名称
*
* @return String
*/
public
abstract
String
filterName
();
@Override
public
int
order
()
{
return
delegate
.
order
();
}
@Override
public
String
getClassName
()
{
return
delegate
.
getClass
().
getSimpleName
();
}
@Override
public
void
init
(
TransformContext
context
)
{
delegate
.
init
(
context
);
}
@Override
public
void
doFilter
(
AccessFilterChain
chain
,
TransformContext
context
)
{
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"Entry TransformFilter {}..."
,
filterName
());
}
long
start
=
System
.
nanoTime
();
try
{
log
.
info
(
"{}拦截器开始执行,上下文信息:{}"
,
this
.
getClassName
(),
context
);
delegate
.
doFilter
(
chain
,
context
);
}
finally
{
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"Exit TransformFilter {},execution cost {} ms..."
,
filterName
(),
TimeUnit
.
NANOSECONDS
.
toMillis
(
System
.
nanoTime
()
-
start
));
}
}
}
}
platform-execute/src/main/java/cn/com/glsx/execute/filter/DefaultAccessFilterChain.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
filter
;
import
lombok.extern.slf4j.Slf4j
;
import
org.redisson.api.RBloomFilter
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
/**
* @Description
* @author chizw
* @create 2023/9/19 20:42
* @version ver.1.0.0
*/
@Slf4j
public
class
DefaultAccessFilterChain
implements
AccessFilterChain
{
private
int
pos
=
0
;
private
int
n
=
0
;
private
AccessFilter
[]
filters
=
new
AccessFilter
[
0
];
@Override
public
void
doFilter
(
TransformContext
context
)
{
if
(
this
.
pos
<
this
.
n
)
{
AccessFilter
transformFilter
=
this
.
filters
[
this
.
pos
++];
transformFilter
.
doFilter
(
this
,
context
);
}
}
public
void
addTransformFilter
(
AccessFilter
filter
)
{
AccessFilter
[]
newFilters
=
this
.
filters
;
for
(
AccessFilter
newFilter
:
newFilters
)
{
if
(
newFilter
==
filter
)
{
return
;
}
}
// 扩容
if
(
this
.
n
==
this
.
filters
.
length
)
{
newFilters
=
new
AccessFilter
[
this
.
n
+
10
];
System
.
arraycopy
(
this
.
filters
,
0
,
newFilters
,
0
,
this
.
n
);
this
.
filters
=
newFilters
;
}
this
.
filters
[
this
.
n
++]
=
filter
;
}
@Override
public
void
release
()
{
for
(
int
i
=
0
;
i
<
this
.
n
;
++
i
)
{
this
.
filters
[
i
]
=
null
;
}
this
.
pos
=
0
;
this
.
n
=
0
;
}
}
platform-execute/src/main/java/cn/com/glsx/execute/filter/FilterChainNode.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
filter
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
/**
* @Description
* @author chizw
* @create 2023/9/20 11:23
* @version ver.1.0.0
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
ElementType
.
TYPE
})
public
@interface
FilterChainNode
{
int
order
()
default
1
;
}
platform-execute/src/main/java/cn/com/glsx/execute/filter/TransformContext.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
filter
;
import
cn.com.glsx.execute.modules.enums.shorturl.RedirectType
;
import
cn.com.glsx.execute.modules.enums.shorturl.TransformStatus
;
import
com.alibaba.ttl.TransmittableThreadLocal
;
import
com.google.common.collect.Maps
;
import
lombok.Data
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Map
;
import
java.util.Objects
;
/**
* @Description
* @author chizw
* @create 2023/9/18 22:05
* @version ver.1.0.0
*/
@Data
public
class
TransformContext
{
public
static
final
String
PARAM_CLIENT_ID_KEY
=
"CLIENT_ID"
;
public
static
final
String
PARAM_UA_KEY
=
"UA"
;
public
static
final
String
PARAM_COOKIE_KEY
=
"COOKIE"
;
public
static
final
String
PARAM_SHORT_URL_KEY
=
"SL"
;
public
static
final
String
PARAM_LONG_URL_KEY
=
"LL"
;
public
static
final
String
PARAM_TARGET_LONG_URL_KEY
=
"RLL"
;
public
static
final
String
PARAM_REMOTE_HOST_NAME_KEY
=
"RHN"
;
public
static
final
String
PARAM_QUERY_STRING_KEY
=
"QS"
;
public
static
final
String
PARAM_REQUEST_URL_KEY
=
"URL"
;
public
static
final
String
PARAM_PROTOCOL_KEY
=
"PROTOCOL"
;
public
static
final
String
PARAM_PORT_KEY
=
"PORT"
;
public
static
final
String
PARAM_URL_PARAM_KEY
=
"UP"
;
public
static
final
String
PARAM_SERVER_WEB_EXCHANGE_KEY
=
"__SWE__"
;
private
HttpServletRequest
request
;
private
HttpServletResponse
response
;
final
ThreadLocal
<
Runnable
>
redirectAction
=
new
TransmittableThreadLocal
<>();
private
String
compressCode
;
private
TransformStatus
transformStatus
;
private
Map
<
String
,
String
>
headers
=
Maps
.
newHashMap
();
private
Map
<
String
,
Object
>
params
=
Maps
.
newHashMap
();
private
String
location
;
private
RedirectType
redirectType
;
public
void
setTransformStatus
(
TransformStatus
transformStatus
)
{
this
.
transformStatus
=
transformStatus
;
}
public
Integer
getTransformStatusValue
()
{
return
transformStatus
.
getValue
();
}
public
void
addHeader
(
String
key
,
String
value
)
{
headers
.
putIfAbsent
(
key
,
value
);
}
public
void
setHeader
(
String
key
,
String
value
)
{
headers
.
put
(
key
,
value
);
}
public
String
getHeader
(
String
key
)
{
return
headers
.
get
(
key
);
}
public
void
releaseHeaders
()
{
headers
=
null
;
}
public
void
addParam
(
String
key
,
Object
value
)
{
params
.
putIfAbsent
(
key
,
value
);
}
public
void
setParam
(
String
key
,
Object
value
)
{
params
.
put
(
key
,
value
);
}
@SuppressWarnings
(
"unchecked"
)
public
<
T
>
T
getParam
(
String
key
)
{
return
(
T
)
params
.
get
(
key
);
}
public
void
setRedirectAction
(
Runnable
redirectAction
)
{
this
.
redirectAction
.
set
(
redirectAction
);
}
public
Runnable
getRedirectAction
()
{
Runnable
redirectAction
=
this
.
redirectAction
.
get
();
return
Objects
.
nonNull
(
redirectAction
)
?
redirectAction
:
()
->
{};
}
public
void
release
()
{
headers
=
null
;
params
=
null
;
}
}
platform-execute/src/main/java/cn/com/glsx/execute/filter/shorturl/AccessUrlEventProcessFilter.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
filter
.
shorturl
;
import
cn.com.glsx.execute.filter.AccessFilter
;
import
cn.com.glsx.execute.filter.AccessFilterChain
;
import
cn.com.glsx.execute.filter.TransformContext
;
import
cn.com.glsx.execute.modules.entity.shortutl.ShortUrlAccessEventRecordDTO
;
import
cn.com.glsx.execute.modules.rabbitmq.produce.MsgProducer
;
import
cn.com.glsx.execute.modules.service.shorturl.ShortUrlService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.config.ConfigurableBeanFactory
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Date
;
/**
* @Description 访问url事件处理拦截器
* @author chizw
* @create 2023/9/23 14:25
* @version ver.1.0.0
*/
@Slf4j
@Scope
(
scopeName
=
ConfigurableBeanFactory
.
SCOPE_PROTOTYPE
)
@Component
@RedirectUrlFilter
public
class
AccessUrlEventProcessFilter
implements
AccessFilter
{
@Resource
private
ShortUrlService
shortUrlService
;
@Resource
private
MsgProducer
msgProducer
;
@Override
public
int
order
()
{
return
5
;
}
@Override
public
String
getClassName
()
{
return
"AccessUrlEventProcessFilter"
;
}
@Override
public
void
init
(
TransformContext
context
)
{
}
@Override
public
void
doFilter
(
AccessFilterChain
chain
,
TransformContext
context
)
{
//短链事件
try
{
ShortUrlAccessEventRecordDTO
event
=
new
ShortUrlAccessEventRecordDTO
();
event
.
setClientIp
(
context
.
getParam
(
TransformContext
.
PARAM_CLIENT_ID_KEY
));
event
.
setCreatedTime
(
new
Date
());
event
.
setCompressCode
(
context
.
getCompressCode
());
event
.
setUserAgent
(
context
.
getParam
(
TransformContext
.
PARAM_UA_KEY
));
event
.
setCookieValue
(
context
.
getParam
(
TransformContext
.
PARAM_COOKIE_KEY
));
event
.
setShortUrl
(
context
.
getParam
(
TransformContext
.
PARAM_SHORT_URL_KEY
));
event
.
setLongUrl
(
context
.
getParam
(
TransformContext
.
PARAM_TARGET_LONG_URL_KEY
));
event
.
setTransformStatus
(
context
.
getTransformStatusValue
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"{} error:{}"
,
this
.
getClassName
(),
e
.
getMessage
(),
e
);
}
finally
{
}
chain
.
doFilter
(
context
);
}
}
platform-execute/src/main/java/cn/com/glsx/execute/filter/shorturl/CacheCheckFilter.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
filter
.
shorturl
;
import
cn.com.glsx.execute.filter.AccessFilter
;
import
cn.com.glsx.execute.filter.AccessFilterChain
;
import
cn.com.glsx.execute.filter.TransformContext
;
import
cn.com.glsx.execute.modules.rabbitmq.produce.MsgProducer
;
import
cn.com.glsx.execute.modules.service.shorturl.ShortUrlService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.redisson.api.RBloomFilter
;
import
org.springframework.beans.factory.config.ConfigurableBeanFactory
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
/**
* @Description 缓存检查拦截器
* @author chizw
* @create 2023/9/23 14:20
* @version ver.1.0.0
*/
@Slf4j
@Scope
(
scopeName
=
ConfigurableBeanFactory
.
SCOPE_PROTOTYPE
)
@Component
@RedirectUrlFilter
public
class
CacheCheckFilter
implements
AccessFilter
{
@Resource
private
RBloomFilter
<
String
>
rBloomFilter
;
@Resource
private
ShortUrlService
shortUrlService
;
@Resource
private
MsgProducer
msgProducer
;
@Override
public
int
order
()
{
return
2
;
}
@Override
public
String
getClassName
()
{
return
"CacheCheckFilter"
;
}
@Override
public
void
init
(
TransformContext
context
)
{
}
@Override
public
void
doFilter
(
AccessFilterChain
chain
,
TransformContext
context
)
{
// 校验
try
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"{} error:{}"
,
this
.
getClassName
(),
e
.
getMessage
(),
e
);
}
finally
{
}
chain
.
doFilter
(
context
);
}
@PostConstruct
public
void
initializeBloomFilter
()
{
rBloomFilter
.
add
(
"qqq"
);
log
.
info
(
"qqq========{}"
,
rBloomFilter
.
contains
(
"qqq"
));
log
.
info
(
"xxx========{}"
,
rBloomFilter
.
contains
(
"xxx"
));
log
.
info
(
"BloomFilter init success"
);
}
}
platform-execute/src/main/java/cn/com/glsx/execute/filter/shorturl/ExtractRequestParamFilter.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
filter
.
shorturl
;
import
cn.com.glsx.execute.filter.AccessFilter
;
import
cn.com.glsx.execute.filter.AccessFilterChain
;
import
cn.com.glsx.execute.filter.TransformContext
;
import
cn.com.glsx.execute.modules.rabbitmq.produce.MsgProducer
;
import
cn.com.glsx.execute.modules.service.shorturl.ShortUrlService
;
import
cn.com.glsx.execute.utils.IpUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.config.ConfigurableBeanFactory
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
/**
* @Description 提取请求拦截器
* @author chizw
* @create 2023/9/23 14:19
* @version ver.1.0.0
*/
@Slf4j
@Scope
(
scopeName
=
ConfigurableBeanFactory
.
SCOPE_PROTOTYPE
)
@Component
@RedirectUrlFilter
public
class
ExtractRequestParamFilter
implements
AccessFilter
{
@Resource
private
ShortUrlService
shortUrlService
;
@Resource
private
MsgProducer
msgProducer
;
private
static
final
String
UA_KEY
=
"User-Agent"
;
private
static
final
String
COOKIE_KEY
=
"Cookie"
;
@Override
public
int
order
()
{
return
1
;
}
@Override
public
String
getClassName
()
{
return
"ExtractRequestParamFilter"
;
}
@Override
public
void
init
(
TransformContext
context
)
{
}
@Override
public
void
doFilter
(
AccessFilterChain
chain
,
TransformContext
context
)
{
// 封装
try
{
String
ua
=
context
.
getHeader
(
UA_KEY
);
String
cookie
=
context
.
getHeader
(
COOKIE_KEY
);
context
.
setParam
(
TransformContext
.
PARAM_UA_KEY
,
ua
);
context
.
setParam
(
TransformContext
.
PARAM_COOKIE_KEY
,
cookie
);
String
clientHostName
=
context
.
getParam
(
TransformContext
.
PARAM_REMOTE_HOST_NAME_KEY
);
context
.
setParam
(
TransformContext
.
PARAM_CLIENT_ID_KEY
,
IpUtils
.
X
.
extractClientIp
(
context
.
getHeaders
(),
clientHostName
));
HttpServletRequest
request
=
context
.
getRequest
();
context
.
setParam
(
TransformContext
.
PARAM_REQUEST_URL_KEY
,
request
.
getRequestURL
());
context
.
setParam
(
TransformContext
.
PARAM_QUERY_STRING_KEY
,
request
.
getQueryString
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"{} error:{}"
,
this
.
getClassName
(),
e
.
getMessage
(),
e
);
}
finally
{
context
.
releaseHeaders
();
}
chain
.
doFilter
(
context
);
}
}
platform-execute/src/main/java/cn/com/glsx/execute/filter/shorturl/RedirectOrForwardLocationFilter.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
filter
.
shorturl
;
import
cn.com.glsx.execute.filter.AccessFilter
;
import
cn.com.glsx.execute.filter.AccessFilterChain
;
import
cn.com.glsx.execute.filter.TransformContext
;
import
cn.com.glsx.execute.modules.enums.shorturl.TransformStatus
;
import
cn.com.glsx.execute.modules.service.shorturl.ShortUrlService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.config.ConfigurableBeanFactory
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
static
org
.
springframework
.
web
.
cors
.
CorsConfiguration
.
ALL
;
/**
* @Description 重定向或转发位置拦截器
* @author chizw
* @create 2023/9/23 14:22
* @version ver.1.0.0
*/
@Slf4j
@Scope
(
scopeName
=
ConfigurableBeanFactory
.
SCOPE_PROTOTYPE
)
@Component
@RedirectUrlFilter
public
class
RedirectOrForwardLocationFilter
implements
AccessFilter
{
@Resource
private
ShortUrlService
shortUrlService
;
@Override
public
int
order
()
{
return
4
;
}
@Override
public
String
getClassName
()
{
return
"RedirectOrForwardLocationFilter"
;
}
@Override
public
void
init
(
TransformContext
context
)
{
}
@Override
public
void
doFilter
(
AccessFilterChain
chain
,
TransformContext
context
)
{
// 转换成功,进行重定向
try
{
if
(
TransformStatus
.
TRANSFORM_SUCCESS
==
context
.
getTransformStatus
())
{
String
location
=
context
.
getLocation
();
if
(
StringUtils
.
isNotBlank
(
location
))
{
Runnable
redirectAction
=
buildRedirectAction
(
context
.
getResponse
(),
location
);
context
.
setRedirectAction
(
redirectAction
);
context
.
setParam
(
TransformContext
.
PARAM_TARGET_LONG_URL_KEY
,
location
);
context
.
setTransformStatus
(
TransformStatus
.
REDIRECTION_SUCCESS
);
}
else
{
context
.
setTransformStatus
(
TransformStatus
.
REDIRECTION_FAIL
);
log
.
warn
(
"重定向到长链接失败,长链值为空,压缩码:{}"
,
context
.
getCompressCode
());
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"{} error:{}"
,
this
.
getClassName
(),
e
.
getMessage
(),
e
);
context
.
setTransformStatus
(
TransformStatus
.
REDIRECTION_FAIL
);
}
finally
{
}
chain
.
doFilter
(
context
);
}
public
Runnable
buildRedirectAction
(
HttpServletResponse
response
,
String
url
)
{
return
()
->
{
response
.
setStatus
(
HttpStatus
.
FOUND
.
value
());
response
.
setHeader
(
HttpHeaders
.
LOCATION
,
url
);
response
.
setHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_ORIGIN
,
ALL
);
response
.
setHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_HEADERS
,
ALL
);
response
.
setHeader
(
HttpHeaders
.
ACCESS_CONTROL_ALLOW_CREDENTIALS
,
Boolean
.
TRUE
.
toString
());
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setContentType
(
"text/html;charset=UTF-8"
);
};
}
}
platform-execute/src/main/java/cn/com/glsx/execute/filter/shorturl/RedirectUrlFilter.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
filter
.
shorturl
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
/**
* @Description
* @author chizw
* @create 2023/9/19 21:59
* @version ver.1.0.0
*/
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
ElementType
.
TYPE
})
public
@interface
RedirectUrlFilter
{
String
param
()
default
""
;
int
order
()
default
1
;
}
platform-execute/src/main/java/cn/com/glsx/execute/filter/shorturl/SopEventProcessFilter.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
filter
.
shorturl
;
import
cn.com.glsx.execute.filter.AccessFilter
;
import
cn.com.glsx.execute.filter.AccessFilterChain
;
import
cn.com.glsx.execute.filter.TransformContext
;
import
cn.com.glsx.execute.modules.rabbitmq.produce.MsgProducer
;
import
cn.com.glsx.execute.modules.service.proxy.WechatUserInfoService
;
import
cn.com.glsx.execute.modules.service.shorturl.ShortUrlService
;
import
cn.com.glsx.execute.utils.UrlUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.plat.common.utils.StringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.config.ConfigurableBeanFactory
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
* @author chizw
* @version ver.1.0.0
* @Description 访问url事件处理拦截器
* @create 2023/9/23 14:25
*/
@Slf4j
@Scope
(
scopeName
=
ConfigurableBeanFactory
.
SCOPE_PROTOTYPE
)
@Component
@RedirectUrlFilter
public
class
SopEventProcessFilter
implements
AccessFilter
{
@Resource
private
ShortUrlService
shortUrlService
;
@Resource
private
WechatUserInfoService
wechatUserInfoService
;
@Resource
private
MsgProducer
msgProducer
;
@Override
public
int
order
()
{
return
6
;
}
@Override
public
String
getClassName
()
{
return
"SopEventProcessFilter"
;
}
@Override
public
void
init
(
TransformContext
context
)
{
}
@Override
public
void
doFilter
(
AccessFilterChain
chain
,
TransformContext
context
)
{
//sop事件
try
{
String
urlParam
=
context
.
getParam
(
TransformContext
.
PARAM_URL_PARAM_KEY
);
String
queryString
=
context
.
getParam
(
TransformContext
.
PARAM_QUERY_STRING_KEY
);
Map
<
String
,
String
>
extra
=
UrlUtil
.
convertUrlParamsToMap
(
urlParam
,
queryString
);
String
unionId
=
extra
.
get
(
"unionId"
);
if
(
StringUtils
.
isNotEmpty
(
unionId
))
{
List
<
Map
<
String
,
Object
>>
mapList
=
new
ArrayList
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"org_id"
,
extra
.
get
(
"merchantId"
));
map
.
put
(
"add_way"
,
"SHORT_LINK"
);
map
.
put
(
"wechat_union_id"
,
unionId
);
map
.
put
(
"event_time"
,
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
new
Date
()));
map
.
put
(
"event_type"
,
"READ_URL"
);
map
.
put
(
"system_source"
,
"Others"
);
map
.
put
(
"platform"
,
"Others"
);
map
.
put
(
"user_agent"
,
JSON
.
toJSONString
(
context
.
getParam
(
TransformContext
.
PARAM_UA_KEY
)));
map
.
put
(
"device_type"
,
null
);
map
.
put
(
"os"
,
null
);
map
.
put
(
"ip"
,
context
.
getParam
(
TransformContext
.
PARAM_CLIENT_ID_KEY
));
map
.
put
(
"gps"
,
null
);
map
.
put
(
"extra"
,
JSON
.
toJSONString
(
extra
));
String
phone
=
shortUrlService
.
getAppPhoneByUnionId
(
unionId
);
if
(
StringUtils
.
isNotEmpty
(
phone
))
{
map
.
put
(
"customer_phone"
,
phone
);
mapList
.
add
(
map
);
log
.
info
(
"sop event mq message send:{}"
,
JSON
.
toJSONString
(
mapList
));
msgProducer
.
customerEventSend
(
mapList
);
}
else
{
mapList
.
add
(
map
);
msgProducer
.
sendDelayedMessage
(
JSON
.
toJSONString
(
mapList
),
1000
*
60
*
30
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"{} error:{}"
,
this
.
getClassName
(),
e
.
getMessage
(),
e
);
}
finally
{
}
chain
.
doFilter
(
context
);
}
}
platform-execute/src/main/java/cn/com/glsx/execute/filter/shorturl/UrlTransformFilter.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
filter
.
shorturl
;
import
cn.com.glsx.execute.common.exception.ChainFilterErrorException
;
import
cn.com.glsx.execute.filter.AccessFilter
;
import
cn.com.glsx.execute.filter.AccessFilterChain
;
import
cn.com.glsx.execute.filter.TransformContext
;
import
cn.com.glsx.execute.modules.entity.shortutl.ShortUrlDomainConfigDTO
;
import
cn.com.glsx.execute.modules.entity.shortutl.ShortUrlMappingDTO
;
import
cn.com.glsx.execute.modules.enums.shorturl.RedirectType
;
import
cn.com.glsx.execute.modules.enums.shorturl.TransformStatus
;
import
cn.com.glsx.execute.modules.service.shorturl.ShortUrlService
;
import
cn.com.glsx.execute.utils.UrlUtil
;
import
com.glsx.plat.common.utils.StringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.config.ConfigurableBeanFactory
;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Date
;
/**
* @author chizw
* @version ver.1.0.0
* @Description 短链转换拦截器
* @create 2023/9/23 14:21
*/
@Slf4j
@Scope
(
scopeName
=
ConfigurableBeanFactory
.
SCOPE_PROTOTYPE
)
@Component
@RedirectUrlFilter
public
class
UrlTransformFilter
implements
AccessFilter
{
@Resource
private
ShortUrlService
shortUrlService
;
@Resource
private
Environment
environment
;
// private String b4RedirectPage;
private
String
protocol
;
private
String
domainValue
;
@Override
public
int
order
()
{
return
3
;
}
@Override
public
String
getClassName
()
{
return
"UrlTransformFilter"
;
}
@Override
public
void
init
(
TransformContext
context
)
{
ShortUrlDomainConfigDTO
domain
=
shortUrlService
.
selectDomain
(
RedirectType
.
DIRECT
);
if
(
domain
!=
null
)
{
protocol
=
domain
.
getProtocol
();
domainValue
=
domain
.
getDomainValue
();
}
}
@Override
public
void
doFilter
(
AccessFilterChain
chain
,
TransformContext
context
)
{
try
{
context
.
setTransformStatus
(
TransformStatus
.
TRANSFORM_FAIL
);
String
compressCode
=
context
.
getCompressCode
();
RedirectType
redirectType
=
context
.
getRedirectType
();
ShortUrlMappingDTO
mappingDTO
=
shortUrlService
.
selectUrlMapByCompressCode
(
compressCode
);
if
(
mappingDTO
==
null
)
{
// 标记ip无效访问一次
log
.
warn
(
"压缩码[{}]不存在或异常,终止TransformFilterChain执行,并且重定向到404页面......"
,
compressCode
);
throw
new
ChainFilterErrorException
(
String
.
format
(
"[c:%s]"
,
compressCode
));
}
String
urlParam
=
mappingDTO
.
getUrlParam
();
String
longUrl
=
mappingDTO
.
getLongUrl
();
context
.
setParam
(
TransformContext
.
PARAM_URL_PARAM_KEY
,
urlParam
);
context
.
setParam
(
TransformContext
.
PARAM_SHORT_URL_KEY
,
mappingDTO
.
getShortUrl
());
context
.
setParam
(
TransformContext
.
PARAM_LONG_URL_KEY
,
mappingDTO
.
getLongUrl
());
String
b4RedirectPage
=
mappingDTO
.
getB4RedirectPage
();
Boolean
addTimestamp
=
mappingDTO
.
getAddTimestamp
();
if
(
redirectType
.
equals
(
RedirectType
.
THROUGH_AUTH_PAGE
)
&&
StringUtils
.
isNotEmpty
(
b4RedirectPage
))
{
longUrl
=
b4RedirectPage
+
"?url="
+
UrlUtil
.
splicingUrl
(
protocol
,
domainValue
,
context
.
getCompressCode
());
}
else
{
if
(
StringUtils
.
isNotEmpty
(
urlParam
))
{
longUrl
=
String
.
format
(
"%s?%s&%s"
,
longUrl
,
context
.
getParam
(
TransformContext
.
PARAM_QUERY_STRING_KEY
),
urlParam
);
}
if
(
addTimestamp
!=
null
&&
addTimestamp
)
{
longUrl
=
String
.
format
(
"%s%stimestamp=%s"
,
longUrl
,
(
longUrl
.
contains
(
"?"
)
?
"?"
:
"&"
),
new
Date
().
getTime
());
}
}
context
.
setLocation
(
longUrl
);
context
.
setTransformStatus
(
TransformStatus
.
TRANSFORM_SUCCESS
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"{} error:{}"
,
this
.
getClassName
(),
e
.
getMessage
(),
e
);
}
finally
{
}
chain
.
doFilter
(
context
);
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/LoginController.java
View file @
3220cd3
...
@@ -43,5 +43,4 @@ public class LoginController {
...
@@ -43,5 +43,4 @@ public class LoginController {
rtnMap
.
put
(
"user"
,
user
);
rtnMap
.
put
(
"user"
,
user
);
return
R
.
ok
().
data
(
rtnMap
);
return
R
.
ok
().
data
(
rtnMap
);
}
}
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/controller/buryingPoint/BuryingPointController.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
controller
.
buryingPoint
;
import
cn.com.glsx.execute.modules.rabbitmq.produce.MsgProducer
;
import
cn.com.glsx.execute.modules.rabbitmq.produce.RabbitConfig
;
import
com.glsx.plat.core.annotation.ResponseResultBody
;
import
com.glsx.plat.core.web.R
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
@Slf4j
@Tag
(
name
=
"业务埋点"
)
@RestController
@RequestMapping
(
value
=
"/sop/api/buryingPoint"
)
@ResponseResultBody
public
class
BuryingPointController
{
@Autowired
private
MsgProducer
msgProducer
;
@Operation
(
description
=
"业务埋点上报"
)
@PostMapping
(
"/report"
)
public
R
report
(
@RequestBody
String
buryingPoint
)
{
try
{
log
.
info
(
"platform-execute业务埋点接收:{}"
,
buryingPoint
);
msgProducer
.
topicSend
(
RabbitConfig
.
DATA_REPORT_EXCHANGE_NAME
,
RabbitConfig
.
DATA_REPORT_TOPIC
,
buryingPoint
);
return
R
.
ok
();
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
RuntimeException
(
e
);
}
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/controller/shorturl/ShortUrlController.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
controller
.
shorturl
;
import
cn.com.glsx.execute.modules.model.shorturl.GenerateUrlRequest
;
import
cn.com.glsx.execute.modules.service.shorturl.ShortUrlService
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.redisson.api.RBloomFilter
;
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
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
import
javax.validation.Valid
;
/**
* @author chizw
* @version ver.1.0.0
* @Description 短链controller
* @create 2023/9/14 16:51
*/
@Slf4j
@Tag
(
name
=
"短链服务"
)
@RestController
@RequiredArgsConstructor
@RequestMapping
(
value
=
"/sop/api/shorturl"
)
public
class
ShortUrlController
{
@Resource
private
ShortUrlService
shortUrlService
;
@PostMapping
(
path
=
"/generate"
)
public
String
generate
(
@RequestBody
@Valid
GenerateUrlRequest
request
)
{
return
shortUrlService
.
generate
(
request
);
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/controller/shorturl/UrlMapController.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
controller
.
shorturl
;
import
cn.com.glsx.execute.filter.TransformContext
;
import
cn.com.glsx.execute.modules.enums.shorturl.RedirectType
;
import
cn.com.glsx.execute.modules.service.shorturl.ShortUrlService
;
import
cn.com.glsx.execute.utils.UrlUtil
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.server.reactive.ServerHttpResponse
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.server.ServerWebExchange
;
import
reactor.core.publisher.Mono
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.util.Enumeration
;
@Slf4j
@Tag
(
name
=
"短链映射"
)
@RestController
@RequiredArgsConstructor
@RequestMapping
(
value
=
"/sop/api"
)
public
class
UrlMapController
{
@Resource
private
ShortUrlService
shortUrlService
;
@GetMapping
(
path
=
"/r/{compressionCode}"
)
@ResponseStatus
(
HttpStatus
.
FOUND
)
public
Mono
<
Void
>
redirect
(
@PathVariable
(
name
=
"compressionCode"
)
String
compressCode
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
TransformContext
context
=
buildContext
(
request
,
response
);
context
.
setCompressCode
(
compressCode
);
context
.
setRedirectType
(
RedirectType
.
DIRECT
);
shortUrlService
.
processFilterChain
(
context
);
return
Mono
.
fromRunnable
(
context
.
getRedirectAction
());
}
@GetMapping
(
path
=
"/u/{compressionCode}"
)
@ResponseStatus
(
HttpStatus
.
FOUND
)
public
Mono
<
Void
>
redirectAuthPage
(
@PathVariable
(
name
=
"compressionCode"
)
String
compressCode
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
TransformContext
context
=
buildContext
(
request
,
response
);
context
.
setCompressCode
(
compressCode
);
context
.
setRedirectType
(
RedirectType
.
THROUGH_AUTH_PAGE
);
shortUrlService
.
processFilterChain
(
context
);
return
Mono
.
fromRunnable
(
context
.
getRedirectAction
());
}
private
TransformContext
buildContext
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
TransformContext
context
=
new
TransformContext
();
context
.
setRequest
(
request
);
context
.
setResponse
(
response
);
context
.
setParam
(
TransformContext
.
PARAM_REMOTE_HOST_NAME_KEY
,
request
.
getRemoteHost
());
Enumeration
<
String
>
headerNames
=
request
.
getHeaderNames
();
while
(
headerNames
.
hasMoreElements
())
{
String
element
=
headerNames
.
nextElement
();
String
headerValue
=
request
.
getHeader
(
element
);
context
.
setHeader
(
element
,
headerValue
);
}
return
context
;
}
/************************************************ test *****************************************************/
@GetMapping
(
path
=
"/u2/{compressCode}"
)
@ResponseStatus
(
HttpStatus
.
SEE_OTHER
)
public
void
redirectTest
(
@PathVariable
(
name
=
"compressCode"
)
String
compressCode
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
request
.
setCharacterEncoding
(
"UTF-8"
);
TransformContext
context
=
new
TransformContext
();
context
.
setCompressCode
(
compressCode
);
context
.
setRequest
(
request
);
context
.
setResponse
(
response
);
context
.
setParam
(
TransformContext
.
PARAM_REMOTE_HOST_NAME_KEY
,
request
.
getRemoteHost
());
Enumeration
<
String
>
headerNames
=
request
.
getHeaderNames
();
while
(
headerNames
.
hasMoreElements
())
{
String
element
=
headerNames
.
nextElement
();
String
headerValue
=
request
.
getHeader
(
element
);
context
.
setHeader
(
element
,
headerValue
);
}
StringBuilder
builder
=
new
StringBuilder
();
Enumeration
<
String
>
parameterNames
=
request
.
getParameterNames
();
while
(
parameterNames
.
hasMoreElements
())
{
String
element
=
parameterNames
.
nextElement
();
String
parameter
=
request
.
getParameter
(
element
);
builder
.
append
(
"&"
).
append
(
element
).
append
(
"="
).
append
(
parameter
);
// builder.append("&").append(element).append("=").append(URLEncoder.encode(parameter, StandardCharsets.UTF_8.toString()));
}
log
.
info
(
"parameterNames:{}"
,
parameterNames
);
log
.
info
(
"builder:{}"
,
builder
);
log
.
info
(
"getRequestURL:{}"
,
request
.
getRequestURL
());
log
.
info
(
"getRemoteHost:{}"
,
request
.
getRemoteHost
());
log
.
info
(
"getRemoteAddr:{}"
,
request
.
getRemoteAddr
());
log
.
info
(
"getPathInfo:{}"
,
request
.
getPathInfo
());
log
.
info
(
"getRemotePort:{}"
,
request
.
getRemotePort
());
log
.
info
(
"getLocalAddr:{}"
,
request
.
getLocalAddr
());
log
.
info
(
"getLocalName:{}"
,
request
.
getLocalName
());
log
.
info
(
"getParameterMap:{}"
,
request
.
getParameterMap
());
log
.
info
(
"getProtocol:{}"
,
request
.
getProtocol
());
log
.
info
(
"getMethod:{}"
,
request
.
getMethod
());
log
.
info
(
"getQueryString:{}"
,
request
.
getQueryString
());
log
.
info
(
"getQueryString22:{}"
,
UrlUtil
.
decodeUrlParam
(
request
.
getQueryString
()));
String
location
=
"https://www.baidu.com/s?wdd=%E6%80%8E%E4%B9%88%E7%9F%A5%E9%81%93%E8%87%AA%E5%B7%B1%E6%98%AF%E4%B8%8D%E6%98%AF%E7%8C%AA&"
+
request
.
getQueryString
();
log
.
info
(
"location:{}"
,
location
);
context
.
setLocation
(
location
);
shortUrlService
.
process
(
context
);
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setContentType
(
"text/html;charset=UTF-8"
);
response
.
sendRedirect
(
context
.
getLocation
());
}
@GetMapping
(
path
=
"/aaa/{compressionCode}"
)
@ResponseStatus
(
HttpStatus
.
FOUND
)
public
Mono
<
Void
>
dispatch
(
@PathVariable
(
name
=
"compressionCode"
)
String
compressionCode
,
ServerWebExchange
exchange
)
{
log
.
info
(
"start:{}"
,
compressionCode
);
ServerHttpResponse
response
=
exchange
.
getResponse
();
//重定向到登录页面
response
.
setStatusCode
(
HttpStatus
.
SEE_OTHER
);
// 错误码
response
.
getHeaders
().
set
(
HttpHeaders
.
LOCATION
,
"http://www.baidu.com"
);
return
response
.
setComplete
();
}
@GetMapping
(
path
=
"/bbb/{compressionCode}"
)
@ResponseStatus
(
HttpStatus
.
FOUND
)
public
Mono
<
Void
>
dispatch3
(
@PathVariable
(
name
=
"compressionCode"
)
String
compressionCode
,
ServerWebExchange
exchange
)
{
log
.
info
(
"start:{}"
,
compressionCode
);
ServerHttpResponse
response
=
exchange
.
getResponse
();
String
location
=
"http://www.baidu.com"
;
return
response
.
setComplete
().
then
(
Mono
.
fromRunnable
(()
->
{
HttpHeaders
headers
=
new
HttpHeaders
();
try
{
headers
.
setLocation
(
new
URI
(
location
));
}
catch
(
URISyntaxException
e
)
{
e
.
printStackTrace
();
}
response
.
getHeaders
().
addAll
(
headers
);
response
.
setStatusCode
(
HttpStatus
.
SEE_OTHER
);
}));
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/converter/rop/RopRequestConveter.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
converter
.
rop
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.ByaiGetCustomerDetailRequestDTO
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.ByaiGetRobotListRequestDTO
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.ByaiImportCallJobCustomerRequestDTO
;
import
cn.com.glsx.execute.modules.model.oneVone.BatchMessagingContentDTO
;
import
cn.com.glsx.execute.modules.model.oneVone.BatchMessagingCreateRopRequestDTO
;
import
cn.com.glsx.execute.modules.model.oneVone.BatchMessagingCrowConditionDTO
;
import
cn.com.glsx.execute.modules.model.oneVone.LabelRequestDTO
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
java.lang.reflect.Field
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
/**
* @Author yelq
* @Version 1.0
* @Description: rop框架请求转化
* @Date 2023/9/11 11:44
*/
public
class
RopRequestConveter
{
/**
* 1v1群发
*
* @param requestDTO
* @return
*/
public
static
MultiValueMap
<
String
,
String
>
toMultiValueMap
(
BatchMessagingCreateRopRequestDTO
requestDTO
)
{
if
(
requestDTO
==
null
)
return
new
LinkedMultiValueMap
<>();
Class
<?
extends
BatchMessagingCreateRopRequestDTO
>
aClass
=
requestDTO
.
getClass
();
Field
[]
declaredFields
=
aClass
.
getDeclaredFields
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
requestDTO
));
MultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
for
(
Field
field
:
declaredFields
)
{
if
(
"labelList"
.
equals
(
field
.
getName
()))
{
List
<
LabelRequestDTO
>
o
=
JSON
.
parseArray
(
jsonObject
.
getString
(
field
.
getName
()),
LabelRequestDTO
.
class
);
if
(
CollectionUtils
.
isEmpty
(
o
))
continue
;
for
(
int
i
=
0
;
i
<
o
.
size
();
i
++)
{
LabelRequestDTO
labelRequestDTO
=
o
.
get
(
i
);
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].groupId"
,
labelRequestDTO
.
getGroupId
().
toString
());
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].groupName"
,
labelRequestDTO
.
getGroupName
());
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].groupType"
,
labelRequestDTO
.
getGroupType
());
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].labelId"
,
labelRequestDTO
.
getLabelId
().
toString
());
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].labelName"
,
labelRequestDTO
.
getLabelName
());
}
}
else
if
(
"crowdList"
.
equals
(
field
.
getName
()))
{
List
<
BatchMessagingCrowConditionDTO
>
o
=
JSON
.
parseArray
(
jsonObject
.
getString
(
field
.
getName
()),
BatchMessagingCrowConditionDTO
.
class
);
if
(
CollectionUtils
.
isEmpty
(
o
))
continue
;
for
(
int
i
=
0
;
i
<
o
.
size
();
i
++)
{
BatchMessagingCrowConditionDTO
batchMessagingCrowConditionDTO
=
o
.
get
(
i
);
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].crowdId"
,
batchMessagingCrowConditionDTO
.
getCrowdId
().
toString
());
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].crowdName"
,
batchMessagingCrowConditionDTO
.
getCrowdName
());
}
}
else
if
(
"contentList"
.
equals
(
field
.
getName
()))
{
List
<
BatchMessagingContentDTO
>
o
=
JSON
.
parseArray
(
jsonObject
.
getString
(
field
.
getName
()),
BatchMessagingContentDTO
.
class
);
if
(
CollectionUtils
.
isEmpty
(
o
))
continue
;
for
(
int
i
=
0
;
i
<
o
.
size
();
i
++)
{
BatchMessagingContentDTO
batchMessagingContentDTO
=
o
.
get
(
i
);
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].attType"
,
batchMessagingContentDTO
.
getAttType
().
toString
());
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].attContent"
,
batchMessagingContentDTO
.
getAttContent
());
}
}
else
if
(
"staffIdList"
.
equals
(
field
.
getName
())
||
"staffCloudIdList"
.
equals
(
field
.
getName
())
||
"customerCloudIdList"
.
equals
(
field
.
getName
())
||
"customerIdList"
.
equals
(
field
.
getName
()))
{
List
<
String
>
o
=
JSON
.
parseArray
(
jsonObject
.
getString
(
field
.
getName
()),
String
.
class
);
if
(
CollectionUtils
.
isEmpty
(
o
))
continue
;
for
(
int
i
=
0
;
i
<
o
.
size
();
i
++)
{
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"]"
,
o
.
get
(
i
));
}
}
else
{
Object
o
=
jsonObject
.
get
(
field
.
getName
());
if
(
o
==
null
)
continue
;
if
(
field
.
getType
()
==
Date
.
class
)
{
paramsMap
.
add
(
field
.
getName
(),
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
o
));
}
else
{
paramsMap
.
add
(
field
.
getName
(),
o
.
toString
());
}
}
}
return
paramsMap
;
}
/**
* 详情参数
*
* @param requestDTO
* @return
*/
public
static
MultiValueMap
<
String
,
String
>
toMultiValueMap
(
ByaiGetCustomerDetailRequestDTO
requestDTO
)
{
if
(
requestDTO
==
null
)
return
new
LinkedMultiValueMap
<>();
Class
<?
extends
ByaiGetCustomerDetailRequestDTO
>
aClass
=
requestDTO
.
getClass
();
Field
[]
declaredFields
=
aClass
.
getDeclaredFields
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
requestDTO
));
MultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
for
(
Field
field
:
declaredFields
)
{
Object
o
=
jsonObject
.
get
(
field
.
getName
());
if
(
o
==
null
)
continue
;
if
(
field
.
getType
()
==
Date
.
class
)
{
paramsMap
.
add
(
field
.
getName
(),
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
o
));
}
else
{
paramsMap
.
add
(
field
.
getName
(),
o
.
toString
());
}
}
return
paramsMap
;
}
/**
* 机器人列表参数封装
*
* @param requestDTO
* @return
*/
public
static
MultiValueMap
<
String
,
String
>
toMultiValueMap
(
ByaiGetRobotListRequestDTO
requestDTO
)
{
if
(
requestDTO
==
null
)
return
new
LinkedMultiValueMap
<>();
Class
<?
extends
ByaiGetRobotListRequestDTO
>
aClass
=
requestDTO
.
getClass
();
Field
[]
declaredFields
=
aClass
.
getDeclaredFields
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
requestDTO
));
MultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
for
(
Field
field
:
declaredFields
)
{
Object
o
=
jsonObject
.
get
(
field
.
getName
());
if
(
o
==
null
)
continue
;
if
(
field
.
getType
()
==
Date
.
class
)
{
paramsMap
.
add
(
field
.
getName
(),
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
o
));
}
else
{
paramsMap
.
add
(
field
.
getName
(),
o
.
toString
());
}
}
return
paramsMap
;
}
/**
* 外呼参数封装
*
* @param requestDTO
* @return
*/
public
static
MultiValueMap
<
String
,
String
>
toMultiValueMap
(
ByaiImportCallJobCustomerRequestDTO
requestDTO
)
{
if
(
requestDTO
==
null
)
return
new
LinkedMultiValueMap
<>();
Class
<?
extends
ByaiImportCallJobCustomerRequestDTO
>
aClass
=
requestDTO
.
getClass
();
Field
[]
declaredFields
=
aClass
.
getDeclaredFields
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
requestDTO
));
MultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
for
(
Field
field
:
declaredFields
)
{
if
(
"customerInfoVOList"
.
equals
(
field
.
getName
()))
{
List
<
ByaiImportCallJobCustomerRequestDTO
.
CustomerInfoVO
>
o
=
JSON
.
parseArray
(
jsonObject
.
getString
(
field
.
getName
()),
ByaiImportCallJobCustomerRequestDTO
.
CustomerInfoVO
.
class
);
if
(
CollectionUtils
.
isEmpty
(
o
))
continue
;
for
(
int
i
=
0
;
i
<
o
.
size
();
i
++)
{
ByaiImportCallJobCustomerRequestDTO
.
CustomerInfoVO
customerInfoVO
=
o
.
get
(
i
);
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].name"
,
customerInfoVO
.
getName
());
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].phone"
,
customerInfoVO
.
getPhone
());
if
(
customerInfoVO
.
getProperties
()
!=
null
&&
customerInfoVO
.
getProperties
().
size
()
>
0
)
{
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].properties"
,
JSON
.
toJSONString
(
customerInfoVO
.
getProperties
()));
}
}
}
else
if
(
"workingTimeRuleList"
.
equals
(
field
.
getName
()))
{
List
<
ByaiImportCallJobCustomerRequestDTO
.
JobWorkingTimeRuleDetailVO
>
o
=
JSON
.
parseArray
(
jsonObject
.
getString
(
field
.
getName
()),
ByaiImportCallJobCustomerRequestDTO
.
JobWorkingTimeRuleDetailVO
.
class
);
if
(
CollectionUtils
.
isEmpty
(
o
))
continue
;
for
(
int
i
=
0
;
i
<
o
.
size
();
i
++)
{
if
(!
CollectionUtils
.
isEmpty
(
o
.
get
(
i
).
getWeeks
()))
{
for
(
int
j
=
0
;
j
<
o
.
get
(
i
).
getWeeks
().
size
();
j
++)
{
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].weeks["
+
j
+
"]"
,
o
.
get
(
i
).
getWeeks
().
get
(
j
).
toString
());
}
}
if
(!
CollectionUtils
.
isEmpty
(
o
.
get
(
i
).
getTimeRanges
()))
{
for
(
int
j
=
0
;
j
<
o
.
get
(
i
).
getTimeRanges
().
size
();
j
++)
{
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].timeRanges["
+
j
+
"].startTime"
,
o
.
get
(
i
).
getTimeRanges
().
get
(
j
).
getStartTime
());
paramsMap
.
add
(
field
.
getName
()
+
"["
+
i
+
"].timeRanges["
+
j
+
"].endTime"
,
o
.
get
(
i
).
getTimeRanges
().
get
(
j
).
getEndTime
());
}
}
}
}
else
{
Object
o
=
jsonObject
.
get
(
field
.
getName
());
if
(
o
==
null
)
continue
;
if
(
field
.
getType
()
==
Date
.
class
)
{
paramsMap
.
add
(
field
.
getName
(),
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
o
));
}
else
{
paramsMap
.
add
(
field
.
getName
(),
o
.
toString
());
}
}
}
return
paramsMap
;
}
public
static
MultiValueMap
<
String
,
String
>
toMultiValueMap
(
Object
request
,
Class
clazz
)
{
if
(
request
==
null
)
return
new
LinkedMultiValueMap
<>();
Field
[]
declaredFields
=
clazz
.
getDeclaredFields
();
JSONObject
jsonObject
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
request
));
MultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
for
(
Field
field
:
declaredFields
)
{
Object
o
=
jsonObject
.
get
(
field
.
getName
());
if
(
o
==
null
)
continue
;
if
(
field
.
getType
()
==
Date
.
class
)
{
paramsMap
.
add
(
field
.
getName
(),
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
o
));
}
else
{
paramsMap
.
add
(
field
.
getName
(),
o
.
toString
());
}
}
return
paramsMap
;
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/converter/rop/RopResponseConveter.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
converter
.
rop
;
import
cn.com.glsx.execute.modules.model.rop.RopResponseDTO
;
import
com.alibaba.fastjson.JSON
;
/**
* @Author yelq
* @Version 1.0
* @Description: rop框架请求返回转化
* @Date 2023/9/11 11:44
*/
public
class
RopResponseConveter
{
public
static
<
T
>
RopResponseDTO
<
T
>
convertRopResponse
(
String
source
,
Class
<
T
>
clazz
)
{
if
(
source
==
null
)
return
null
;
RopResponseDTO
ropResponseDTO
=
JSON
.
parseObject
(
source
,
RopResponseDTO
.
class
);
Object
data
=
ropResponseDTO
.
getData
();
if
(
data
!=
null
)
{
T
t
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
data
),
clazz
);
ropResponseDTO
.
setData
(
t
);
}
RopResponseDTO
<
T
>
resp
=
ropResponseDTO
;
return
resp
;
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/rabbitmq/consumer/DirectReceiver.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
rabbitmq
.
consumer
;
import
cn.com.glsx.execute.modules.service.shorturl.ShortUrlService
;
import
com.rabbitmq.client.Channel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.amqp.core.Message
;
import
org.springframework.amqp.rabbit.annotation.RabbitListener
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
@Component
@Slf4j
public
class
DirectReceiver
{
@Resource
private
ShortUrlService
shortUrlService
;
// @RabbitListener(queues = RabbitConfig.MY_QUEUE_NAME_01)//监听的队列名称
public
void
listener
(
String
testMessage
)
{
log
.
info
(
"test-queue消费-----------{}"
,
testMessage
);
}
// @RabbitListener(queues = "")//监听的队列名称
public
void
buryingPointListener
(
Message
message
,
Channel
channel
)
throws
IOException
{
try
{
log
.
info
(
"burying_point_queue消费-----------{}"
,
new
String
(
message
.
getBody
()));
channel
.
basicAck
(
message
.
getMessageProperties
().
getDeliveryTag
(),
false
);
}
catch
(
Exception
e
)
{
// 两个布尔值,若第二个设为false,则丢弃该消息;若设为true,则返回给队列
channel
.
basicNack
(
message
.
getMessageProperties
().
getDeliveryTag
(),
false
,
true
);
System
.
out
.
println
(
"消费失败 消息将返回给队列"
);
}
}
@RabbitListener
(
queues
=
"dataDelay_queue"
)
public
void
dataDelayListener
(
String
message
)
{
log
.
info
(
"dataDelayListener 消费-----------{}"
,
message
);
try
{
shortUrlService
.
sendDelaySopEvent
(
message
);
}
catch
(
Exception
e
)
{
log
.
error
(
"dataDelayListener 消费异常-----------{}"
,
e
.
getMessage
(),
e
);
e
.
printStackTrace
();
}
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/rabbitmq/produce/MsgProducer.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
rabbitmq
.
produce
;
import
cn.com.glsx.execute.config.RabbitMQConfig
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.amqp.rabbit.connection.CorrelationData
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
java.util.UUID
;
/**
* 编写消息的生产者
*/
@Component
@Slf4j
public
class
MsgProducer
implements
RabbitTemplate
.
ConfirmCallback
{
//由于rabbitTemplate的scope属性设置为ConfigurableBeanFactory.SCOPE_PROTOTYPE,所以不能自动注入
private
RabbitTemplate
rabbitTemplate
;
/**
* 构造方法注入rabbitTemplate
*/
@Autowired
public
MsgProducer
(
RabbitTemplate
rabbitTemplate
)
{
this
.
rabbitTemplate
=
rabbitTemplate
;
rabbitTemplate
.
setConfirmCallback
(
this
);
//rabbitTemplate如果为单例的话,那回调就是最后设置的内容
}
/**
* 发送消息方法一个交换机配一个路由配一个队列
*
* @param content
*/
public
void
sendMsg
(
String
queue
,
String
content
)
{
//把消息放入ROUTINGKEY_A对应的队列当中去,对应的是队列A
rabbitTemplate
.
convertAndSend
(
queue
,
content
);
}
/**
* 简单模式
*
* @param content
*/
public
void
simpleSend
(
String
content
)
{
rabbitTemplate
.
convertAndSend
(
RabbitConfig
.
MY_QUEUE_NAME_01
,
content
);
}
/**
* 广播模式
*
* @param content
*/
public
void
fanoutSend
(
String
content
)
{
rabbitTemplate
.
convertAndSend
(
RabbitConfig
.
MY_QUEUE_NAME_01
,
""
,
content
);
}
/**
* topic模式
*
* @param content
*/
public
void
topicSend
(
String
exchange
,
String
routingKey
,
String
content
)
{
CorrelationData
correlationId
=
new
CorrelationData
(
UUID
.
randomUUID
().
toString
());
log
.
info
(
"消息id:{},推送埋点数据到mq:{}"
,
correlationId
,
content
);
rabbitTemplate
.
convertAndSend
(
exchange
,
routingKey
,
content
,
correlationId
);
}
/**
* 埋点数据推送
* @param content
*/
public
void
buryingPointSend
(
String
content
)
{
CorrelationData
correlationId
=
new
CorrelationData
(
UUID
.
randomUUID
().
toString
());
log
.
info
(
"消息id:{},推送埋点数据到mq:{}"
,
correlationId
,
content
);
rabbitTemplate
.
convertAndSend
(
RabbitConfig
.
MY_QUEUE_NAME_01
,
(
Object
)
content
,
correlationId
);
}
/**
* 客户事件推送
* @param content
*/
public
void
customerEventSend
(
Object
content
)
{
log
.
info
(
"obj推送客户事件数据到mq:{}"
,
content
);
rabbitTemplate
.
convertAndSend
(
RabbitMQConfig
.
DATA_REPORT_EXCHANGE_NAME
,
"dataReport.customer.event"
,
JSON
.
toJSONString
(
content
));
}
/**
* 客户事件推送
* @param content
*/
public
void
customerEventSend
(
String
content
)
{
log
.
info
(
"str推送客户事件数据到mq:{}"
,
content
);
rabbitTemplate
.
convertAndSend
(
RabbitMQConfig
.
DATA_REPORT_EXCHANGE_NAME
,
"dataReport.customer.event"
,
content
);
}
/**
* 推送延迟队列消息
* @param content
*/
public
void
sendDelayedMessage
(
Object
content
,
int
delay
)
{
log
.
info
(
"推送延迟队列消息:{}"
,
content
);
rabbitTemplate
.
convertAndSend
(
RabbitMQConfig
.
DATA_DELAY_EXCHANGE_NAME
,
"dataDead.customer.event"
,
content
,
message
->
{
message
.
getMessageProperties
().
setExpiration
(
delay
+
""
);
return
message
;
},
new
CorrelationData
(
String
.
valueOf
(
UUID
.
randomUUID
())));
}
/**
* 回调
*/
@Override
public
void
confirm
(
CorrelationData
correlationData
,
boolean
ack
,
String
cause
)
{
log
.
info
(
" 回调id:"
+
correlationData
);
if
(
ack
)
{
log
.
info
(
"交换机已收到id为:{}的消息"
,
correlationData
);
}
else
{
log
.
info
(
"交换机已收到id为:{}的消息,原因:{}"
,
correlationData
,
cause
);
}
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/rabbitmq/produce/RabbitConfig.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
rabbitmq
.
produce
;
import
org.springframework.amqp.core.*
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
RabbitConfig
{
public
static
final
String
MY_QUEUE_NAME_01
=
"hello_queue"
;
public
static
final
String
FANOUT_QUEUE1
=
"fanout.queue1"
;
public
static
final
String
FANOUT_QUEUE2
=
"fanout.queue2"
;
public
static
final
String
TOPIC_QUEUE1
=
"topic.queue1"
;
public
static
final
String
TOPIC_QUEUE2
=
"topic.queue2"
;
public
static
final
String
FANOUT_EXCHANGE
=
"fanout.exchange"
;
public
static
final
String
TOPIC_EXCHANGE
=
"topic.exchange"
;
public
static
final
String
ROUTINGKEY1
=
"topic.#"
;
public
static
final
String
ROUTINGKEY2
=
"topic.*"
;
public
static
final
String
DATA_REPORT_QUEUE_NAME
=
"dataReport_queue"
;
public
static
final
String
DATA_REPORT_EXCHANGE_NAME
=
"dataReport_exchange"
;
public
static
final
String
DATA_REPORT_TOPIC
=
"dataReport.#"
;
public
static
final
String
DATA_DELAY_QUEUE_NAME
=
"dataDelay_queue"
;
/**
* 在Spring中,只需要将一个Queue对象注册到Spring容器中,RabbitMQ就会自动创建该队列
* @return
*/
@Bean
Queue
myQueue
(){
/**
* 1.队列的名字 我们这里为"hello-queue"
* 2.队列是否持久化:RabbitMQ重启之后,队列是否还存在 我们这里设置为true,即队列存在
* 3.队列的排他性:这个为true,只有创建这个队列的连接才能给这个队列发消息 我们这里设置为false,即谁都可以给这个队列发消息
* 4.如果没有人消费这个队列,是否直接删除该队列
*/
return
new
Queue
(
MY_QUEUE_NAME_01
,
true
,
false
,
false
);
}
@Bean
public
Queue
buryingPointQueue
(){
return
new
Queue
(
DATA_REPORT_QUEUE_NAME
,
true
,
false
,
false
);
}
//声明FANOUT_QUEUE1队列
@Bean
public
Queue
fanoutQueue1
(){
return
new
Queue
(
FANOUT_QUEUE1
);
}
//声明FANOUT_QUEUE2队列
@Bean
public
Queue
fanoutQueue2
()
{
return
new
Queue
(
FANOUT_QUEUE2
);
}
@Bean
public
Queue
topicQueue1
()
{
return
new
Queue
(
TOPIC_QUEUE1
,
true
);
}
@Bean
public
Queue
topicQueue2
()
{
return
new
Queue
(
TOPIC_QUEUE2
,
true
);
}
//声明fanout交换机
@Bean
public
FanoutExchange
fanoutExchange
(){
//durable(true) 持久化,mq重启之后交换机还在
return
ExchangeBuilder
.
fanoutExchange
(
FANOUT_EXCHANGE
).
durable
(
true
).
build
();
}
//声明topic交换机
@Bean
public
TopicExchange
topicExchange
(){
//durable(true) 持久化,mq重启之后交换机还在
return
ExchangeBuilder
.
topicExchange
(
TOPIC_EXCHANGE
).
durable
(
true
).
build
();
}
@Bean
public
TopicExchange
buryingPointExchange
(){
//durable(true) 持久化,mq重启之后交换机还在
return
new
TopicExchange
(
DATA_REPORT_EXCHANGE_NAME
,
true
,
false
);
}
@Bean
public
Binding
fanoutBinding01
(){
return
BindingBuilder
.
bind
(
fanoutQueue1
()).
to
(
fanoutExchange
());
}
@Bean
public
Binding
fanoutBinding02
()
{
return
BindingBuilder
.
bind
(
fanoutQueue2
()).
to
(
fanoutExchange
());
}
@Bean
public
Binding
topicBinding01
()
{
return
BindingBuilder
.
bind
(
topicQueue1
()).
to
(
topicExchange
()).
with
(
ROUTINGKEY1
);
}
@Bean
public
Binding
topicBinding02
()
{
return
BindingBuilder
.
bind
(
topicQueue2
()).
to
(
topicExchange
()).
with
(
ROUTINGKEY2
);
}
@Bean
public
Binding
buryingPointBinding
()
{
return
BindingBuilder
.
bind
(
buryingPointQueue
()).
to
(
buryingPointExchange
()).
with
(
DATA_REPORT_TOPIC
);
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/request/shorturl/GenerateShortUrlRequest.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
request
.
shorturl
;
import
lombok.Data
;
import
javax.validation.constraints.NotNull
;
@Data
public
class
GenerateShortUrlRequest
{
/**
* 要生成的短链接地址
*/
@NotNull
private
String
url
;
private
String
requestId
;
private
String
description
;
private
String
b4RedirectPage
;
private
Boolean
addTimestamp
;
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/service/proxy/AiOutboundCallService.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
service
.
proxy
;
import
cn.com.glsx.execute.modules.converter.rop.RopRequestConveter
;
import
cn.com.glsx.execute.modules.converter.rop.RopResponseConveter
;
import
cn.com.glsx.execute.modules.enums.rop.MethodEnum
;
import
cn.com.glsx.execute.modules.enums.rop.ModelBaseUrlEnum
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.*
;
import
cn.com.glsx.execute.modules.model.rop.RopResponseDTO
;
import
cn.com.glsx.execute.utils.RopHttpUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.MultiValueMap
;
/**
* @Author yelq
* @Version 1.0
* @Description: Ai外呼http对接
* @Date 2023/9/8 13:53
*/
@Service
@Slf4j
public
class
AiOutboundCallService
{
@Autowired
private
Environment
environment
;
/**
* 获取客户通话详情
* @param requestDTO
* @return
* @throws Exception
*/
public
ByaiGetCustomerDetailResponseDTO
getCustomerDetail
(
ByaiGetCustomerDetailRequestDTO
requestDTO
)
throws
Exception
{
String
url
=
environment
.
getProperty
(
ModelBaseUrlEnum
.
ROP_SCRM_MARKETING
.
getBaseUrlConfig
(),
""
);
MultiValueMap
<
String
,
String
>
paramsMap
=
RopRequestConveter
.
toMultiValueMap
(
requestDTO
);
log
.
info
(
"请求参数:{}"
,
paramsMap
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
CUSTOMER_CALL_DETAIL
.
getMethod
(),
null
);
log
.
info
(
"请求结果:{}"
,
post
);
RopResponseDTO
<
ByaiGetCustomerDetailResponseDTO
>
ropResponseDTO
=
RopResponseConveter
.
convertRopResponse
(
post
,
ByaiGetCustomerDetailResponseDTO
.
class
);
return
ropResponseDTO
.
getData
();
}
/**
* 导入客户执行外呼
* @param requestDTO
* @return
* @throws Exception
*/
public
ByaiImportCallJobCustomerResponseDTO
outboundCallInvoke
(
ByaiImportCallJobCustomerRequestDTO
requestDTO
)
throws
Exception
{
String
url
=
environment
.
getProperty
(
ModelBaseUrlEnum
.
ROP_SCRM_MARKETING
.
getBaseUrlConfig
(),
""
);
MultiValueMap
<
String
,
String
>
paramsMap
=
RopRequestConveter
.
toMultiValueMap
(
requestDTO
);
log
.
info
(
"请求参数:{}"
,
paramsMap
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
INVOKE_AI_CALL
.
getMethod
(),
null
);
log
.
info
(
"请求结果:{}"
,
post
);
RopResponseDTO
<
ByaiImportCallJobCustomerResponseDTO
>
ropResponseDTO
=
RopResponseConveter
.
convertRopResponse
(
post
,
ByaiImportCallJobCustomerResponseDTO
.
class
);
return
ropResponseDTO
.
getData
();
}
/**
* 获取机器人列表
* @param requestDTO
* @return
* @throws Exception
*/
public
ByaiGetRobotListResponseDTO
getRobotList
(
ByaiGetRobotListRequestDTO
requestDTO
)
throws
Exception
{
String
url
=
environment
.
getProperty
(
ModelBaseUrlEnum
.
ROP_SCRM_MARKETING
.
getBaseUrlConfig
(),
""
);
MultiValueMap
<
String
,
String
>
paramsMap
=
RopRequestConveter
.
toMultiValueMap
(
requestDTO
);
log
.
info
(
"请求参数:{}"
,
paramsMap
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
ROBOT_LIST
.
getMethod
(),
null
);
log
.
info
(
"请求结果:{}"
,
post
);
RopResponseDTO
<
ByaiGetRobotListResponseDTO
>
ropResponseDTO
=
RopResponseConveter
.
convertRopResponse
(
post
,
ByaiGetRobotListResponseDTO
.
class
);
return
ropResponseDTO
.
getData
();
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/service/proxy/BatchMessageService.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
service
.
proxy
;
import
cn.com.glsx.execute.modules.converter.rop.RopRequestConveter
;
import
cn.com.glsx.execute.modules.converter.rop.RopResponseConveter
;
import
cn.com.glsx.execute.modules.enums.AppKeyEnum
;
import
cn.com.glsx.execute.modules.enums.rop.MethodEnum
;
import
cn.com.glsx.execute.modules.enums.rop.ModelBaseUrlEnum
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.ByaiGetCustomerDetailResponseDTO
;
import
cn.com.glsx.execute.modules.model.oneVone.BatchMessagingCreateRopRequestDTO
;
import
cn.com.glsx.execute.modules.model.rop.RopResponseDTO
;
import
cn.com.glsx.execute.utils.RopHttpUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.MultiValueMap
;
import
static
cn
.
com
.
glsx
.
execute
.
modules
.
enums
.
AppKeyEnum
.
ROP_SCRM_ENTMICRO
;
/**
* @Author yelq
* @Version 1.0
* @Description: 1v1群发服务
* @Date 2023/9/12 17:32
*/
@Slf4j
@Service
public
class
BatchMessageService
{
@Autowired
private
Environment
environment
;
/**
* 1v1群发
* @param requestDTO
* @return
* @throws Exception
*/
public
Boolean
createBatchMessagingNoSessionTask
(
BatchMessagingCreateRopRequestDTO
requestDTO
)
throws
Exception
{
String
url
=
environment
.
getProperty
(
ModelBaseUrlEnum
.
ROP_SCRM_ENTMICRO
.
getBaseUrlConfig
(),
""
);
MultiValueMap
<
String
,
String
>
paramsMap
=
RopRequestConveter
.
toMultiValueMap
(
requestDTO
);
log
.
info
(
"请求参数:{}"
,
paramsMap
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
BATCH_MESSAGE_CREATE
.
getMethod
(),
ROP_SCRM_ENTMICRO
);
log
.
info
(
"请求结果:{}"
,
post
);
RopResponseDTO
<
Boolean
>
ropResponseDTO
=
RopResponseConveter
.
convertRopResponse
(
post
,
Boolean
.
class
);
return
ropResponseDTO
.
getData
();
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/service/proxy/SendMessageService.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
service
.
proxy
;
import
cn.com.glsx.execute.common.constant.SmsConstants
;
import
cn.com.glsx.execute.modules.model.sms.SmsResponseDTO
;
import
cn.com.glsx.execute.utils.RopHttpUtil
;
import
cn.com.glsx.framework.core.enums.DefaultErrorEnum
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
@Service
@Slf4j
public
class
SendMessageService
{
@Value
(
"${sendMessageUrl:http://qcdidicb.glsx.com.cn:7060/router}"
)
private
String
sendMessageUrl
;
@Value
(
"${sendMessageMethod:glsx.accounts.send.message}"
)
private
String
sendMessageMethod
;
/**
* 发送短信
*
* @param phone 电话号码,批量用逗号隔开
* @param source 来源
* @param type 类型(默认为1)
* @param context 发送内容
*/
public
SmsResponseDTO
sendMessage
(
String
phone
,
String
source
,
String
type
,
String
context
)
{
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<>(
4
);
try
{
params
.
add
(
"phone"
,
phone
);
params
.
add
(
"source"
,
source
);
params
.
add
(
"messageSource"
,
source
);
params
.
add
(
"type"
,
type
==
null
?
SmsConstants
.
SMS_TYPE
:
type
);
params
.
add
(
"context"
,
context
);
log
.
info
(
"短信发送参数:{}"
,
JSON
.
toJSONString
(
params
));
SmsResponseDTO
post
=
RopHttpUtil
.
postE
(
params
,
SmsResponseDTO
.
class
,
sendMessageUrl
+
"?method="
+
sendMessageMethod
,
sendMessageMethod
,
null
);
log
.
info
(
"发送短信结果{}"
,
post
);
return
post
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
info
(
"发送短信异常:"
,
e
);
throw
new
RpcServiceException
(
DefaultErrorEnum
.
SERVER_ERROR
);
}
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/service/proxy/WechatUserInfoService.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
service
.
proxy
;
import
cn.com.glsx.execute.modules.converter.rop.RopRequestConveter
;
import
cn.com.glsx.execute.modules.enums.rop.MethodEnum
;
import
cn.com.glsx.execute.modules.enums.rop.ModelBaseUrlEnum
;
import
cn.com.glsx.execute.modules.model.rop.RopResponseDTO
;
import
cn.com.glsx.execute.modules.model.wechat.GetUserInfoRequest
;
import
cn.com.glsx.execute.modules.model.wechat.GetUserInfoResponse
;
import
cn.com.glsx.execute.utils.JacksonUtils
;
import
cn.com.glsx.execute.utils.RopHttpUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.MultiValueMap
;
import
java.util.List
;
/**
* @Description 微信用户信息http对接
* @author chizw
* @create 2023/10/12 16:49
* @version ver.1.0.0
*/
@Service
@Slf4j
public
class
WechatUserInfoService
{
@Autowired
private
Environment
environment
;
/**
* 批量获取用户基础信息
* @param requestDTO
* @return
* @throws Exception
*/
public
List
<
GetUserInfoResponse
>
getUserListByUnionId
(
GetUserInfoRequest
requestDTO
)
throws
Exception
{
String
url
=
environment
.
getProperty
(
ModelBaseUrlEnum
.
ROP_SCRM_WECHAT
.
getBaseUrlConfig
(),
""
);
MultiValueMap
<
String
,
String
>
paramsMap
=
RopRequestConveter
.
toMultiValueMap
(
requestDTO
,
GetUserInfoRequest
.
class
);
log
.
info
(
"WechatUserInfoService.getUserListByUnionId 请求参数:{}"
,
paramsMap
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
WECHAT_USERINFO_BY_UNIONID
.
getMethod
(),
null
);
log
.
info
(
"WechatUserInfoService.getUserListByUnionId 请求结果:{}"
,
JSON
.
toJSONString
(
post
));
RopResponseDTO
<
List
<
GetUserInfoResponse
>>
ropResponseDTO
=
JacksonUtils
.
X
.
parse
(
post
,
new
TypeReference
<
RopResponseDTO
<
List
<
GetUserInfoResponse
>>>(){});
return
ropResponseDTO
.
getData
();
}
}
platform-execute/src/main/java/cn/com/glsx/execute/modules/service/shorturl/ShortUrlService.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
service
.
shorturl
;
import
cn.com.glsx.execute.common.constant.Constants
;
import
cn.com.glsx.execute.common.constant.DBConstants
;
import
cn.com.glsx.execute.common.constant.shorturl.CompressCodeStatus
;
import
cn.com.glsx.execute.common.constant.shorturl.DomainStatus
;
import
cn.com.glsx.execute.common.constant.shorturl.UrlMapStatus
;
import
cn.com.glsx.execute.common.exception.ChainFilterErrorException
;
import
cn.com.glsx.execute.filter.AccessFilterChain
;
import
cn.com.glsx.execute.filter.AccessFilterChainFactory
;
import
cn.com.glsx.execute.filter.TransformContext
;
import
cn.com.glsx.execute.filter.shorturl.RedirectUrlFilter
;
import
cn.com.glsx.execute.modules.entity.shortutl.ShortUrlCompressCodeDTO
;
import
cn.com.glsx.execute.modules.entity.shortutl.ShortUrlDomainConfigDTO
;
import
cn.com.glsx.execute.modules.entity.shortutl.ShortUrlMappingDTO
;
import
cn.com.glsx.execute.modules.entity.shortutl.SopEventDelaySendLogDTO
;
import
cn.com.glsx.execute.modules.enums.ExceptionEnum
;
import
cn.com.glsx.execute.modules.enums.shorturl.RedirectType
;
import
cn.com.glsx.execute.modules.mapper.*
;
import
cn.com.glsx.execute.modules.model.shorturl.GenerateUrlRequest
;
import
cn.com.glsx.execute.modules.model.wechat.GetUserInfoRequest
;
import
cn.com.glsx.execute.modules.model.wechat.GetUserInfoResponse
;
import
cn.com.glsx.execute.modules.rabbitmq.produce.MsgProducer
;
import
cn.com.glsx.execute.modules.request.shorturl.GenerateShortUrlRequest
;
import
cn.com.glsx.execute.modules.service.proxy.WechatUserInfoService
;
import
cn.com.glsx.execute.utils.HashUtil
;
import
cn.com.glsx.execute.utils.JacksonUtils
;
import
cn.com.glsx.execute.utils.UrlUtil
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
com.alibaba.fastjson.JSON
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.glsx.plat.common.utils.StringUtils
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.apache.commons.validator.routines.UrlValidator
;
import
org.oreframework.distribute.lock.annotation.GlsxDistributeLockable
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.Assert
;
import
org.springframework.util.CollectionUtils
;
import
tk.mybatis.mapper.entity.Example
;
import
javax.annotation.Resource
;
import
java.util.*
;
/**
* @author chizw
* @version ver.1.0.0
* @Description 短链service
* @create 2023/9/14 16:51
*/
@Slf4j
@Service
@RequiredArgsConstructor
public
class
ShortUrlService
{
@Resource
private
ShortUrlCompressCodeMapper
shortUrlCompressCodeMapper
;
@Resource
private
ShortUrlDomainConfigMapper
shortUrlDomainConfigMapper
;
@Resource
private
ShortUrlAccessEventRecordMapper
shortUrlAccessEventRecordMapper
;
@Resource
private
ShortUrlMappingMapper
shortUrlMappingMapper
;
@Resource
private
SopEventDelaySendLogMapper
sopEventDelaySendLogMapper
;
@Resource
private
WechatUserInfoService
wechatUserInfoService
;
@Resource
private
MsgProducer
msgProducer
;
@Value
(
"${sop.shorturl.default.auth.page:https://scrm.dev.glsx.com.cn/sopurl}"
)
private
String
defaultAuthPage
;
private
ShortUrlService
self
;
private
final
AccessFilterChainFactory
accessFilterChainFactory
;
private
final
UrlValidator
urlValidator
=
new
UrlValidator
(
new
String
[]{
Constants
.
HTTP_PROTOCOL
,
Constants
.
HTTPS_PROTOCOL
});
private
static
final
String
URL_DUPLICATED
=
"[DUPLICATED]"
;
/******************************************** Async&Cache ***********************************************/
@GlsxDistributeLockable
(
name
=
"'asyncGenerate' + #request.url"
,
timeoutException
=
RpcServiceException
.
class
,
time
=
10
*
1000
)
public
String
asyncGenerate
(
GenerateShortUrlRequest
request
)
{
String
b4RedirectPage
=
request
.
getB4RedirectPage
();
// 分布式锁
// 校验长链
String
longUrl
=
request
.
getUrl
();
Assert
.
isTrue
(
urlValidator
.
isValid
(
longUrl
),
String
.
format
(
"链接[%s]非法"
,
longUrl
));
// 获取域名
RedirectType
redirectType
=
StringUtils
.
isNotEmpty
(
b4RedirectPage
)
?
RedirectType
.
THROUGH_AUTH_PAGE
:
RedirectType
.
DIRECT
;
ShortUrlDomainConfigDTO
domain
=
selectDomain
(
redirectType
);
Assert
.
notNull
(
domain
,
String
.
format
(
"域名不存在[c:%s]"
,
domain
));
// 获取压缩码
String
code
=
getCompressCode
();
Assert
.
hasLength
(
code
,
String
.
format
(
"压缩码不存在[c:%s]"
,
code
));
// 插入数据库
String
shortUrl
=
String
.
format
(
"%s://%s/%s"
,
domain
.
getProtocol
(),
domain
.
getDomainValue
(),
code
);
ShortUrlMappingDTO
dto
=
new
ShortUrlMappingDTO
();
dto
.
setLongUrl
(
longUrl
);
dto
.
setShortUrl
(
shortUrl
);
dto
.
setCompressCode
(
code
);
dto
.
setDescription
(
request
.
getDescription
());
dto
.
setShortUrlDigest
(
DigestUtils
.
sha1Hex
(
shortUrl
));
dto
.
setLongUrlDigest
(
DigestUtils
.
sha1Hex
(
longUrl
));
// 更新压缩码状态
self
.
saveUrlMapAndUpdateCompressCode
(
dto
,
code
);
// 返回短链
return
shortUrl
;
}
private
String
getCompressCode
()
{
// 查询缓存
// 缓存为空时,更新压缩码池
// 返回压缩码
return
null
;
}
/**
* 保存短链映射和更新压缩码状态
*
* @param dto dto
* @param code code
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
{
Exception
.
class
})
public
void
saveUrlMapAndUpdateCompressCode
(
ShortUrlMappingDTO
dto
,
String
code
)
{
ShortUrlCompressCodeDTO
codeDTO
=
new
ShortUrlCompressCodeDTO
();
codeDTO
.
setCodeStatus
(
CompressCodeStatus
.
USED
);
boolean
updateSuccess
=
updateCompressCodeByCode
(
codeDTO
,
code
);
Assert
.
isTrue
(
updateSuccess
,
"压缩码更新失败"
);
boolean
insertSuccess
=
insertUrlMap
(
dto
);
Assert
.
isTrue
(
insertSuccess
,
"短链映射更新失败"
);
}
/************************************************** Sync *****************************************************/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
{
Exception
.
class
})
public
String
generate
(
GenerateUrlRequest
request
)
{
log
.
info
(
"短链服务生成短链请求 request:{}"
,
request
);
String
b4RedirectPage
=
request
.
getB4RedirectPage
();
Boolean
isThroughAuth
=
request
.
getIsThroughAuth
();
// 校验长链
String
longUrl
=
request
.
getUrl
();
Assert
.
isTrue
(
urlValidator
.
isValid
(
longUrl
),
String
.
format
(
"链接[%s]非法"
,
longUrl
));
RedirectType
redirectType
=
RedirectType
.
DIRECT
;
if
(
isThroughAuth
!=
null
&&
isThroughAuth
)
{
redirectType
=
RedirectType
.
THROUGH_AUTH_PAGE
;
b4RedirectPage
=
StringUtils
.
isNotEmpty
(
b4RedirectPage
)
?
b4RedirectPage
:
defaultAuthPage
;
}
// 获取域名
ShortUrlDomainConfigDTO
domain
=
selectDomain
(
redirectType
);
Assert
.
notNull
(
domain
,
String
.
format
(
"域名不存在[c:%s]"
,
domain
));
// 插入数据库
ShortUrlMappingDTO
urlMapDto
=
new
ShortUrlMappingDTO
();
urlMapDto
.
setUrlParam
(
UrlUtil
.
extractUrlParam
(
longUrl
));
urlMapDto
.
setLongUrl
(
UrlUtil
.
extractUrl
(
longUrl
));
urlMapDto
.
setLongUrlDigest
(
DigestUtils
.
sha1Hex
(
longUrl
));
urlMapDto
.
setDescription
(
request
.
getDescription
());
urlMapDto
.
setUrlStatus
(
UrlMapStatus
.
AVAILABLE
);
urlMapDto
.
setB4RedirectPage
(
b4RedirectPage
);
urlMapDto
.
setAddTimestamp
(
request
.
getAddTimestamp
());
StringBuilder
builder
=
new
StringBuilder
(
longUrl
);
String
shortUrl
;
String
code
;
boolean
flag
;
int
count
=
0
;
do
{
if
(
count
>
0
)
builder
.
append
(
URL_DUPLICATED
);
code
=
getCompressCode
(
builder
.
toString
());
shortUrl
=
UrlUtil
.
splicingUrl
(
domain
.
getProtocol
(),
domain
.
getDomainValue
(),
code
);
urlMapDto
.
setCompressCode
(
code
);
urlMapDto
.
setShortUrl
(
shortUrl
);
urlMapDto
.
setShortUrlDigest
(
DigestUtils
.
sha1Hex
(
shortUrl
));
flag
=
atomicSelectAndSaveUrlMap
(
urlMapDto
,
code
);
if
(
count
++
>
5
)
log
.
warn
(
"{}该链接的短链压缩码生成已重复超过{}次"
,
longUrl
,
count
);
}
while
(!
flag
);
// 返回短链
log
.
info
(
"短链服务生成短链返回 response:{}"
,
shortUrl
);
return
shortUrl
;
}
private
String
getCompressCode
(
String
param
)
{
return
HashUtil
.
X
.
encode2Base62
(
param
);
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
{
Exception
.
class
})
@GlsxDistributeLockable
(
name
=
"'atomicSelectAndSaveUrlMap' + #base62"
,
timeoutException
=
RpcServiceException
.
class
,
time
=
60
*
1000
)
public
boolean
atomicSelectAndSaveUrlMap
(
ShortUrlMappingDTO
dto
,
String
base62
)
{
ShortUrlCompressCodeDTO
codeDTO
=
selectCompressCodeByCode
(
base62
);
if
(
codeDTO
==
null
)
{
codeDTO
=
new
ShortUrlCompressCodeDTO
();
codeDTO
.
setCompressCode
(
base62
);
codeDTO
.
setCodeStatus
(
CompressCodeStatus
.
USED
);
Assert
.
isTrue
(
insertCompressCode
(
codeDTO
),
ExceptionEnum
.
DB_EXCEPTION
.
getMsg
());
}
else
{
Integer
status
=
codeDTO
.
getCodeStatus
();
if
(
status
==
null
||
CompressCodeStatus
.
AVAILABLE
!=
status
)
return
false
;
Assert
.
isTrue
(
updateCompressCodeByCode
(
codeDTO
,
codeDTO
.
getCompressCode
()),
ExceptionEnum
.
DB_EXCEPTION
.
getMsg
());
}
ShortUrlMappingDTO
mappingDTO
=
selectUrlMapByCompressCode
(
base62
);
if
(
mappingDTO
!=
null
)
return
false
;
Assert
.
isTrue
(
insertUrlMap
(
dto
),
ExceptionEnum
.
DB_EXCEPTION
.
getMsg
());
return
true
;
}
public
String
processFilterChain
(
TransformContext
context
)
{
AccessFilterChain
chain
=
accessFilterChainFactory
.
buildTransformFilterChain
(
context
,
RedirectUrlFilter
.
class
);
try
{
chain
.
doFilter
(
context
);
}
finally
{
chain
.
release
();
context
.
release
();
}
return
context
.
getLocation
();
}
public
String
process
(
TransformContext
context
)
{
String
compressCode
=
context
.
getCompressCode
();
ShortUrlMappingDTO
mappingDTO
=
selectUrlMapByCompressCode
(
compressCode
);
if
(
mappingDTO
==
null
)
{
// 标记ip无效访问一次
log
.
warn
(
"压缩码[{}]不存在或异常,终止TransformFilterChain执行,并且重定向到404页面......"
,
compressCode
);
throw
new
ChainFilterErrorException
(
String
.
format
(
"[c:%s]"
,
compressCode
));
}
String
longUrl
=
mappingDTO
.
getLongUrl
();
String
urlParam
=
mappingDTO
.
getUrlParam
();
String
b4RedirectPage
=
mappingDTO
.
getB4RedirectPage
();
Boolean
addTimeTamp
=
mappingDTO
.
getAddTimestamp
();
if
(
StringUtils
.
isNotEmpty
(
urlParam
))
{
longUrl
=
String
.
format
(
"%s?%s"
,
longUrl
,
urlParam
);
}
if
(
addTimeTamp
!=
null
&&
addTimeTamp
)
{
longUrl
=
String
.
format
(
"%s%stimetamp=%s"
,
longUrl
,
(
longUrl
.
contains
(
"?"
)
?
"?"
:
"&"
),
new
Date
().
getTime
());
}
if
(
StringUtils
.
isNotEmpty
(
b4RedirectPage
))
{
longUrl
=
b4RedirectPage
+
"?route="
+
context
.
getParam
(
TransformContext
.
PARAM_SHORT_URL_KEY
)
+
"/redirect"
;
}
context
.
setLocation
(
longUrl
);
return
longUrl
;
}
public
void
sendDelaySopEvent
(
String
message
)
throws
Exception
{
Assert
.
hasLength
(
message
,
"delay sop event send message is empty"
);
List
<
Map
<
String
,
Object
>>
list
=
JacksonUtils
.
X
.
parse
(
message
,
new
TypeReference
<
List
<
Map
<
String
,
Object
>>>()
{});
if
(!
CollectionUtils
.
isEmpty
(
list
))
{
for
(
Map
<
String
,
Object
>
map
:
list
)
{
String
unionId
=
(
String
)
map
.
get
(
"unionId"
);
if
(
StringUtils
.
isEmpty
(
unionId
))
continue
;
String
phone
=
getAppPhoneByUnionId
(
unionId
);
if
(
StringUtils
.
isEmpty
(
phone
))
continue
;
map
.
put
(
"customerPhone"
,
phone
);
}
}
log
.
info
(
"delay sop event mq message send:{}"
,
JSON
.
toJSONString
(
list
));
msgProducer
.
customerEventSend
(
list
);
}
public
String
getAppPhoneByUnionId
(
String
unionId
)
{
String
phone
=
null
;
try
{
GetUserInfoRequest
requestDTO
=
new
GetUserInfoRequest
();
requestDTO
.
setUnionId
(
unionId
);
List
<
GetUserInfoResponse
>
userList
=
wechatUserInfoService
.
getUserListByUnionId
(
requestDTO
);
if
(!
CollectionUtils
.
isEmpty
(
userList
))
{
Optional
<
GetUserInfoResponse
>
max
=
userList
.
stream
().
filter
(
s
->
StringUtils
.
isNotEmpty
(
s
.
getPhone
()))
.
max
(
Comparator
.
comparing
(
GetUserInfoResponse:
:
getCreatedDate
));
if
(
max
.
isPresent
())
{
phone
=
max
.
get
().
getPhone
();
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
return
phone
;
}
/******************************************** DataBase ***********************************************/
public
ShortUrlDomainConfigDTO
selectDomain
(
RedirectType
redirectType
)
{
Integer
type
=
redirectType
==
null
?
RedirectType
.
DIRECT
.
getValue
()
:
redirectType
.
getValue
();
Example
example
=
new
Example
(
ShortUrlDomainConfigDTO
.
class
);
example
.
createCriteria
().
andEqualTo
(
DBConstants
.
DEL_FLAG
,
Constants
.
NORMAL_FLAG
)
.
andEqualTo
(
"domainStatus"
,
DomainStatus
.
NORMAL
).
andEqualTo
(
"redirectType"
,
type
);
example
.
orderBy
(
"level"
);
ShortUrlDomainConfigDTO
dto
=
shortUrlDomainConfigMapper
.
selectOneByExample
(
example
);
log
.
info
(
"select short_url_domain_config table result:{}"
,
dto
);
return
dto
;
}
public
boolean
insertUrlMap
(
ShortUrlMappingDTO
dto
)
{
if
(
dto
==
null
)
return
false
;
dto
.
setDelFlag
(
Constants
.
NORMAL_FLAG
);
int
i
=
shortUrlMappingMapper
.
insertSelective
(
dto
);
return
i
>
0
;
}
public
Integer
insertUrlMapUseKey
(
ShortUrlMappingDTO
dto
)
{
dto
.
setUrlStatus
(
UrlMapStatus
.
AVAILABLE
);
dto
.
setDelFlag
(
Constants
.
NORMAL_FLAG
);
dto
.
setCreatedTime
(
new
Date
());
shortUrlMappingMapper
.
insertUseGeneratedKeys
(
dto
);
return
dto
.
getId
().
intValue
();
}
public
ShortUrlMappingDTO
selectUrlMapByCompressCode
(
String
code
)
{
Example
example
=
new
Example
(
ShortUrlMappingDTO
.
class
);
example
.
createCriteria
().
andEqualTo
(
DBConstants
.
DEL_FLAG
,
Constants
.
NORMAL_FLAG
).
andEqualTo
(
DBConstants
.
ShortUrl
.
COMPRESS_CODE
,
code
);
ShortUrlMappingDTO
shortUrlMappingDTO
=
shortUrlMappingMapper
.
selectOneByExample
(
example
);
log
.
info
(
"select short_url_domain_config table result:{}"
,
shortUrlMappingDTO
);
return
shortUrlMappingDTO
;
}
public
boolean
insertCompressCode
(
ShortUrlCompressCodeDTO
dto
)
{
if
(
dto
==
null
)
return
false
;
dto
.
setDelFlag
(
Constants
.
NORMAL_FLAG
);
int
i
=
shortUrlCompressCodeMapper
.
insertSelective
(
dto
);
return
i
>
0
;
}
public
ShortUrlCompressCodeDTO
selectCompressCodeByCode
(
String
code
)
{
Example
example
=
new
Example
(
ShortUrlCompressCodeDTO
.
class
);
example
.
createCriteria
().
andEqualTo
(
DBConstants
.
DEL_FLAG
,
Constants
.
NORMAL_FLAG
)
.
andEqualTo
(
DBConstants
.
ShortUrl
.
COMPRESS_CODE
,
code
);
ShortUrlCompressCodeDTO
codeDTO
=
shortUrlCompressCodeMapper
.
selectOneByExample
(
example
);
log
.
info
(
"select short_url_compress_code table result:{}"
,
codeDTO
);
return
codeDTO
;
}
public
boolean
updateCompressCodeByCode
(
ShortUrlCompressCodeDTO
dto
,
String
code
)
{
if
(
dto
==
null
)
return
false
;
Example
example
=
new
Example
(
ShortUrlCompressCodeDTO
.
class
);
example
.
createCriteria
().
andEqualTo
(
DBConstants
.
DEL_FLAG
,
Constants
.
NORMAL_FLAG
).
andEqualTo
(
DBConstants
.
ShortUrl
.
COMPRESS_CODE
,
code
);
int
i
=
shortUrlCompressCodeMapper
.
updateByExampleSelective
(
dto
,
example
);
return
i
>
0
;
}
public
boolean
insertSopEventDelaySendLog
(
SopEventDelaySendLogDTO
dto
)
{
if
(
dto
==
null
)
return
false
;
dto
.
setDelFlag
(
Constants
.
NORMAL_FLAG
);
int
i
=
sopEventDelaySendLogMapper
.
insertSelective
(
dto
);
return
i
>
0
;
}
}
platform-execute/src/main/java/cn/com/glsx/execute/utils/CacheUtil.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
utils
;
import
lombok.RequiredArgsConstructor
;
import
org.redisson.Redisson
;
import
org.redisson.api.RBloomFilter
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.config.Config
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Component
;
/**
* @Description 缓存工具
* @author chizw
* @create 2023/9/18 16:08
* @version ver.1.0.0
*/
@RequiredArgsConstructor
@Component
public
class
CacheUtil
{
private
final
StringRedisTemplate
stringRedisTemplate
;
public
void
test
(){
Config
config
=
new
Config
();
config
.
useSingleServer
().
setAddress
(
"redis://192.168.x.x:6379"
);
config
.
useSingleServer
().
setPassword
(
"xxx"
);
RedissonClient
client
=
Redisson
.
create
(
config
);
RBloomFilter
<
Object
>
bloomFilter
=
client
.
getBloomFilter
(
"nameBloom"
);
//初始化布隆过滤器:预计元素为100000000L,误差半为3%
//第二个 0.01 期代表误判率最大允许为 1%,在我们以前的项目中通常也是设置为 1%,如果把这个数值设置太小,虽然会降低误判率,但会产生更多次的
bloomFilter
.
tryInit
(
100000000L
,
0.01
);
//将数据插入布隆过滤器
bloomFilter
.
add
(
"qqq"
);
bloomFilter
.
contains
(
"qqq"
);
bloomFilter
.
contains
(
"xxx"
);
}
}
platform-execute/src/main/java/cn/com/glsx/execute/utils/HashUtil.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
utils
;
import
com.google.common.hash.Hashing
;
import
org.springframework.util.Assert
;
import
java.util.Stack
;
/**
* @Description 哈希工具
* @author chizw
* @create 2023/9/18 16:08
* @version ver.1.0.0
*/
public
enum
HashUtil
{
X
;
/**
* 62个字符
*/
private
static
final
String
CHARS
=
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
private
static
final
char
[]
CHAR_SET
=
CHARS
.
toCharArray
();
public
String
encode2Base62
(
String
param
)
{
Assert
.
hasLength
(
param
,
"encode2Base62 method param must not be empty"
);
return
this
.
_10_to_62
(
this
.
murmurHash32
(
param
));
}
/**
* murmurhash算法
* @param param
*/
private
long
murmurHash32
(
String
param
){
return
Hashing
.
murmur3_32
().
hashUnencodedChars
(
param
).
padToLong
();
}
/**
* 10进制转62进制
* @param num
* @return
*/
private
String
encodeToBase62
(
long
num
){
// StringBuffer线程安全,StringBuilder线程不安全
StringBuffer
sb
=
new
StringBuffer
();
do
{
int
i
=
(
int
)(
num
%
62
);
sb
.
append
(
CHARS
.
charAt
(
i
));
num
=
num
/
62
;
}
while
(
num
>
0
);
String
value
=
sb
.
reverse
().
toString
();
return
value
;
}
/**
* 将10进制转化为62进制
*
* @param number
* @return
*/
private
String
_10_to_62
(
long
number
)
{
long
rest
=
Math
.
abs
(
number
);
Stack
<
Character
>
stack
=
new
Stack
<>();
StringBuilder
result
=
new
StringBuilder
(
0
);
while
(
rest
!=
0
)
{
stack
.
add
(
CHAR_SET
[(
int
)
(
rest
-
(
rest
/
62
)
*
62
)]);
rest
=
rest
/
62
;
}
for
(;
!
stack
.
isEmpty
();
)
{
result
.
append
(
stack
.
pop
());
}
return
result
.
toString
();
}
}
platform-execute/src/main/java/cn/com/glsx/execute/utils/IpUtils.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
utils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.server.reactive.ServerHttpRequest
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.Map
;
import
java.util.Objects
;
/**
* @author throwable
* @version v1
* @description IP提取工具
* @since 2020/12/26 12:58
*/
public
enum
IpUtils
{
/**
* 单例
*/
X
;
private
static
final
String
UNKNOWN_VALUE
=
"unknown"
;
private
static
final
String
LOCALHOST_V0
=
"0.0.0.0"
;
private
static
final
String
LOCALHOST_V4
=
"127.0.0.1"
;
private
static
final
String
LOCALHOST_V6
=
"0:0:0:0:0:0:0:1"
;
private
static
final
String
X_FORWARDED_FOR_KEY
=
"X-Forwarded-For"
;
private
static
final
String
PROXY_CLIENT_IP_KEY
=
"Proxy-Client-IP"
;
private
static
final
String
WL_PROXY_CLIENT_IP_KEY
=
"WL-Proxy-Client-IP"
;
private
static
final
String
HTTP_CLIENT_IP_KEY
=
"HTTP_CLIENT_IP"
;
private
static
final
String
HTTP_X_FORWARDED_FOR_KEY
=
"HTTP_X_FORWARDED_FOR"
;
/**
* 提取客户端IP
*
* @return String
*/
public
String
extractClientIp
(
Map
<
String
,
String
>
headers
,
String
remoteHostName
)
{
String
clientIp
=
headers
.
get
(
X_FORWARDED_FOR_KEY
);
if
(
StringUtils
.
isBlank
(
clientIp
)
||
UNKNOWN_VALUE
.
equalsIgnoreCase
(
clientIp
))
{
clientIp
=
headers
.
get
(
PROXY_CLIENT_IP_KEY
);
}
if
(
StringUtils
.
isBlank
(
clientIp
)
||
UNKNOWN_VALUE
.
equalsIgnoreCase
(
clientIp
))
{
clientIp
=
headers
.
get
(
WL_PROXY_CLIENT_IP_KEY
);
}
if
(
StringUtils
.
isBlank
(
clientIp
)
||
UNKNOWN_VALUE
.
equalsIgnoreCase
(
clientIp
))
{
clientIp
=
headers
.
get
(
HTTP_CLIENT_IP_KEY
);
}
if
(
StringUtils
.
isBlank
(
clientIp
)
||
UNKNOWN_VALUE
.
equalsIgnoreCase
(
clientIp
))
{
clientIp
=
headers
.
get
(
HTTP_X_FORWARDED_FOR_KEY
);
}
if
(
StringUtils
.
isBlank
(
clientIp
)
||
UNKNOWN_VALUE
.
equalsIgnoreCase
(
clientIp
))
{
if
(
StringUtils
.
isNotBlank
(
remoteHostName
))
{
clientIp
=
remoteHostName
;
}
}
if
(
Objects
.
equals
(
LOCALHOST_V4
,
clientIp
)
||
Objects
.
equals
(
LOCALHOST_V6
,
clientIp
))
{
try
{
clientIp
=
InetAddress
.
getLocalHost
().
getHostAddress
();
}
catch
(
UnknownHostException
unknownhostexception
)
{
clientIp
=
LOCALHOST_V0
;
}
}
return
clientIp
;
}
/**
* 通过ServerHttpRequest提取客户端IP
*
* @param request request
* @return String
*/
public
String
extractClientIp
(
ServerHttpRequest
request
)
{
HttpHeaders
headers
=
request
.
getHeaders
();
String
clientIp
=
headers
.
getFirst
(
X_FORWARDED_FOR_KEY
);
if
(
StringUtils
.
isBlank
(
clientIp
)
||
UNKNOWN_VALUE
.
equalsIgnoreCase
(
clientIp
))
{
clientIp
=
headers
.
getFirst
(
PROXY_CLIENT_IP_KEY
);
}
if
(
StringUtils
.
isBlank
(
clientIp
)
||
UNKNOWN_VALUE
.
equalsIgnoreCase
(
clientIp
))
{
clientIp
=
headers
.
getFirst
(
WL_PROXY_CLIENT_IP_KEY
);
}
if
(
StringUtils
.
isBlank
(
clientIp
)
||
UNKNOWN_VALUE
.
equalsIgnoreCase
(
clientIp
))
{
clientIp
=
headers
.
getFirst
(
HTTP_CLIENT_IP_KEY
);
}
if
(
StringUtils
.
isBlank
(
clientIp
)
||
UNKNOWN_VALUE
.
equalsIgnoreCase
(
clientIp
))
{
clientIp
=
headers
.
getFirst
(
HTTP_X_FORWARDED_FOR_KEY
);
}
if
(
StringUtils
.
isBlank
(
clientIp
)
||
UNKNOWN_VALUE
.
equalsIgnoreCase
(
clientIp
))
{
if
(
Objects
.
nonNull
(
request
.
getRemoteAddress
()))
{
clientIp
=
request
.
getRemoteAddress
().
getHostName
();
}
}
if
(
Objects
.
equals
(
LOCALHOST_V4
,
clientIp
)
||
Objects
.
equals
(
LOCALHOST_V6
,
clientIp
))
{
try
{
clientIp
=
InetAddress
.
getLocalHost
().
getHostAddress
();
}
catch
(
UnknownHostException
unknownhostexception
)
{
clientIp
=
LOCALHOST_V0
;
}
}
return
clientIp
;
}
}
platform-execute/src/main/java/cn/com/glsx/execute/utils/JacksonUtils.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
utils
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
/**
* @Description JSON工具类
* @author chizw
* @create 2023/10/17 16:15
* @version ver.1.0.0
*/
public
enum
JacksonUtils
{
/**
* 单例
*/
X
;
private
static
final
ObjectMapper
MAPPER
=
new
ObjectMapper
();
static
{
MAPPER
.
disable
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
);
MAPPER
.
setSerializationInclusion
(
JsonInclude
.
Include
.
NON_EMPTY
);
}
public
String
format
(
Object
content
)
throws
JsonProcessingException
{
return
MAPPER
.
writeValueAsString
(
content
);
}
public
<
T
>
T
parse
(
String
content
,
Class
<
T
>
targetClass
)
throws
JsonProcessingException
{
return
MAPPER
.
readValue
(
content
,
targetClass
);
}
public
<
T
>
T
parse
(
String
content
,
TypeReference
<
T
>
typeReference
)
throws
JsonProcessingException
{
return
MAPPER
.
readValue
(
content
,
typeReference
);
}
}
platform-execute/src/main/java/cn/com/glsx/execute/utils/MD5.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
utils
;
import
java.security.MessageDigest
;
/**
* @author zhouhaibao
* @version 1.0
* @description: TODO
* @date 2021/11/23 21:39
*/
public
class
MD5
{
/**
* 32位MD5加密算法
* @param s
* @return
*/
public
static
String
convert32
(
String
s
){
char
hexChars
[]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
try
{
byte
[]
bytes
=
s
.
getBytes
();
MessageDigest
md
=
MessageDigest
.
getInstance
(
"MD5"
);
md
.
update
(
bytes
);
bytes
=
md
.
digest
();
int
j
=
bytes
.
length
;
char
[]
chars
=
new
char
[
j
*
2
];
int
k
=
0
;
for
(
int
i
=
0
;
i
<
bytes
.
length
;
i
++)
{
byte
b
=
bytes
[
i
];
chars
[
k
++]
=
hexChars
[
b
>>>
4
&
0xf
];
chars
[
k
++]
=
hexChars
[
b
&
0xf
];
}
return
new
String
(
chars
);
}
catch
(
Exception
e
){
return
null
;
}
}
/**
* 16位MD5加密算法
* @param s
* @return
*/
public
static
String
convert16
(
String
s
){
char
hexChars
[]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
try
{
byte
[]
bytes
=
s
.
getBytes
();
MessageDigest
md
=
MessageDigest
.
getInstance
(
"MD5"
);
md
.
update
(
bytes
);
bytes
=
md
.
digest
();
int
j
=
bytes
.
length
;
char
[]
chars
=
new
char
[
j
*
2
];
int
k
=
0
;
for
(
int
i
=
0
;
i
<
bytes
.
length
;
i
++)
{
byte
b
=
bytes
[
i
];
chars
[
k
++]
=
hexChars
[
b
>>>
4
&
0xf
];
chars
[
k
++]
=
hexChars
[
b
&
0xf
];
}
return
new
String
(
chars
).
substring
(
8
,
24
);
}
catch
(
Exception
e
){
return
null
;
}
}
}
platform-execute/src/main/java/cn/com/glsx/execute/utils/RopHttpUtil.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
utils
;
import
cn.com.glsx.execute.modules.enums.AppKeyEnum
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.util.DefaultUriBuilderFactory
;
import
org.springframework.web.util.UriBuilder
;
import
java.net.URI
;
import
java.util.Map
;
import
java.util.Map.Entry
;
/**
* @author zhouhaibao
* @version 1.0
* @description: http调用rop端服务
* @date 2021/7/30 11:26
*/
public
class
RopHttpUtil
{
private
static
final
String
appKey
=
"48e5e13229b82c1b4e6e8c96151f0637"
;
private
static
final
String
secret
=
"c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b"
;
private
static
void
addBaseParam
(
MultiValueMap
<
String
,
String
>
paramsMap
,
String
method
)
{
paramsMap
.
add
(
"v"
,
"1.0.0"
);
paramsMap
.
add
(
"method"
,
method
);
}
/**
* get 请求到rop
* @param paramsMap 参数列表
* @param responseType 返回类型
* @param baseurl 访问url地址
* @param method 方法名
* @param appKeyEnum 密钥对
* @return
* @param <T>
* @throws Exception
*/
public
static
<
T
>
T
get
(
MultiValueMap
<
String
,
String
>
paramsMap
,
Class
<
T
>
responseType
,
String
baseurl
,
String
method
,
AppKeyEnum
appKeyEnum
)
throws
Exception
{
addBaseParam
(
paramsMap
,
method
);
MultiValueMap
<
String
,
String
>
params
=
getSysParams
(
appKeyEnum
);
params
.
putAll
(
paramsMap
);
for
(
Entry
<
String
,
String
>
entry
:
params
.
toSingleValueMap
().
entrySet
())
{
if
(
StringUtils
.
isEmpty
(
entry
.
getValue
()))
{
params
.
remove
(
entry
.
getKey
());
}
}
String
sign
=
RopUtils
.
sign
(
params
.
toSingleValueMap
(),
appKeyEnum
==
null
?
secret
:
appKeyEnum
.
getSecret
());
params
.
add
(
"sign"
,
sign
);
RestTemplate
rest
=
new
RestTemplate
();
RopUriTemplateHandler
uriTemplateHandler
=
new
RopUriTemplateHandler
(
baseurl
);
uriTemplateHandler
.
setDefaultUriVariables
(
params
.
toSingleValueMap
());
rest
.
setUriTemplateHandler
(
uriTemplateHandler
);
return
rest
.
getForObject
(
baseurl
,
responseType
,
params
.
toSingleValueMap
());
}
/**
* pos 请求到rop
* @param paramsMap 参数列表
* @param responseType 返回类型
* @param baseurl 访问url地址
* @param method 方法名
* @param appKeyEnum 密钥对
* @return
* @param <T>
* @throws Exception
*/
public
static
<
T
>
T
post
(
MultiValueMap
<
String
,
String
>
paramsMap
,
Class
<
T
>
responseType
,
String
baseurl
,
String
method
,
AppKeyEnum
appKeyEnum
)
throws
Exception
{
addBaseParam
(
paramsMap
,
method
);
MultiValueMap
<
String
,
String
>
params
=
getSysParams
(
appKeyEnum
);
params
.
putAll
(
paramsMap
);
for
(
Entry
<
String
,
String
>
entry
:
params
.
toSingleValueMap
().
entrySet
())
{
if
(
StringUtils
.
isEmpty
(
entry
.
getValue
()))
{
params
.
remove
(
entry
.
getKey
());
}
}
String
sign
=
RopUtils
.
sign
(
params
.
toSingleValueMap
(),
appKeyEnum
==
null
?
secret
:
appKeyEnum
.
getSecret
());
params
.
add
(
"sign"
,
sign
);
return
new
RestTemplate
().
postForObject
(
baseurl
,
params
,
responseType
);
}
/**
* pos 请求到rop 系统参数增加了时间戳
* @param paramsMap 参数列表
* @param responseType 返回类型
* @param baseurl 访问url地址
* @param method 方法名
* @param appKeyEnum 密钥对
* @return
* @param <T>
* @throws Exception
*/
public
static
<
T
>
T
postE
(
MultiValueMap
<
String
,
String
>
paramsMap
,
Class
<
T
>
responseType
,
String
baseurl
,
String
method
,
AppKeyEnum
appKeyEnum
)
throws
Exception
{
addBaseParam
(
paramsMap
,
method
);
MultiValueMap
<
String
,
String
>
params
=
getSysParamsE
(
appKeyEnum
);
params
.
putAll
(
paramsMap
);
for
(
Entry
<
String
,
String
>
entry
:
params
.
toSingleValueMap
().
entrySet
())
{
if
(
StringUtils
.
isEmpty
(
entry
.
getValue
()))
{
params
.
remove
(
entry
.
getKey
());
}
}
String
sign
=
RopUtils
.
signE
(
params
.
toSingleValueMap
(),
null
,
appKeyEnum
==
null
?
secret
:
appKeyEnum
.
getSecret
());
params
.
add
(
"sign"
,
sign
);
return
new
RestTemplate
().
postForObject
(
baseurl
,
params
,
responseType
);
}
/**
* 封装系统参数
* @param appKeyEnum 密钥对
* @return
*/
public
static
MultiValueMap
<
String
,
String
>
getSysParams
(
AppKeyEnum
appKeyEnum
)
{
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<>(
16
);
params
.
add
(
"appKey"
,
appKeyEnum
==
null
?
appKey
:
appKeyEnum
.
getAppKey
());
params
.
add
(
"format"
,
"json"
);
return
params
;
}
/**
* 封装系统参数
* @param appKeyEnum 密钥对
* @return
*/
public
static
MultiValueMap
<
String
,
String
>
getSysParamsE
(
AppKeyEnum
appKeyEnum
)
{
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<>(
16
);
params
.
add
(
"app_key"
,
appKeyEnum
==
null
?
appKey
:
appKeyEnum
.
getAppKey
());
params
.
add
(
"format"
,
"json"
);
params
.
add
(
"timestamp"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
return
params
;
}
static
class
RopUriTemplateHandler
extends
DefaultUriBuilderFactory
{
public
RopUriTemplateHandler
(
String
baseUriTemplate
)
{
super
(
baseUriTemplate
);
}
@Override
public
URI
expand
(
String
uriTemplate
,
Map
<
String
,
?>
uriVars
)
{
UriBuilder
builder
=
uriString
(
uriTemplate
);
if
(!
uriVars
.
isEmpty
())
{
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<>();
for
(
Entry
<
String
,
?>
entry
:
uriVars
.
entrySet
())
{
params
.
add
(
entry
.
getKey
(),
entry
.
getValue
().
toString
());
}
builder
.
queryParams
(
params
);
}
return
builder
.
build
(
uriVars
);
}
}
}
platform-execute/src/main/java/cn/com/glsx/execute/utils/RopUtils.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
utils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.nio.charset.StandardCharsets
;
import
java.security.GeneralSecurityException
;
import
java.security.MessageDigest
;
import
java.util.*
;
public
class
RopUtils
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RopUtils
.
class
);
public
RopUtils
()
{
}
public
static
String
sign
(
Map
<
String
,
String
>
paramValues
,
String
secret
)
{
return
sign
(
paramValues
,
null
,
secret
);
}
public
static
String
sign
(
Map
<
String
,
String
>
paramValues
,
List
<
String
>
ignoreParamNames
,
String
secret
)
{
try
{
StringBuilder
sb
=
new
StringBuilder
();
List
<
String
>
paramNames
=
new
ArrayList
<>(
paramValues
.
size
());
paramNames
.
addAll
(
paramValues
.
keySet
());
Iterator
var5
;
String
paramName
;
if
(
ignoreParamNames
!=
null
&&
!
ignoreParamNames
.
isEmpty
())
{
var5
=
ignoreParamNames
.
iterator
();
while
(
var5
.
hasNext
())
{
paramName
=
(
String
)
var5
.
next
();
paramNames
.
remove
(
paramName
);
}
}
Collections
.
sort
(
paramNames
);
sb
.
append
(
secret
);
var5
=
paramNames
.
iterator
();
while
(
var5
.
hasNext
())
{
paramName
=
(
String
)
var5
.
next
();
sb
.
append
(
paramName
).
append
(
paramValues
.
get
(
paramName
));
}
sb
.
append
(
secret
);
byte
[]
sha1Digest
=
getSHA1Digest
(
sb
.
toString
());
return
byte2hex
(
sha1Digest
);
}
catch
(
IOException
var7
)
{
logger
.
info
(
"异常信息"
,
var7
);
return
null
;
}
}
public
static
String
utf8Encoding
(
String
value
,
String
sourceCharsetName
)
{
try
{
return
new
String
(
value
.
getBytes
(
sourceCharsetName
),
StandardCharsets
.
UTF_8
);
}
catch
(
UnsupportedEncodingException
var3
)
{
throw
new
IllegalArgumentException
(
var3
);
}
}
private
static
byte
[]
getSHA1Digest
(
String
data
)
throws
IOException
{
try
{
MessageDigest
md
=
MessageDigest
.
getInstance
(
"SHA-1"
);
return
md
.
digest
(
data
.
getBytes
(
StandardCharsets
.
UTF_8
));
}
catch
(
GeneralSecurityException
var3
)
{
throw
new
IOException
(
var3
);
}
}
private
static
byte
[]
getMD5Digest
(
String
data
)
throws
IOException
{
try
{
MessageDigest
md
=
MessageDigest
.
getInstance
(
"MD5"
);
return
md
.
digest
(
data
.
getBytes
(
StandardCharsets
.
UTF_8
));
}
catch
(
GeneralSecurityException
var3
)
{
throw
new
IOException
(
var3
);
}
}
private
static
String
byte2hex
(
byte
[]
bytes
)
{
StringBuilder
sign
=
new
StringBuilder
();
for
(
byte
aByte
:
bytes
)
{
String
hex
=
Integer
.
toHexString
(
aByte
&
255
);
if
(
hex
.
length
()
==
1
)
{
sign
.
append
(
"0"
);
}
sign
.
append
(
hex
.
toUpperCase
());
}
return
sign
.
toString
();
}
public
static
String
getUUID
()
{
UUID
uuid
=
UUID
.
randomUUID
();
return
uuid
.
toString
().
toUpperCase
();
}
public
static
String
signE
(
Map
<
String
,
String
>
paramValues
,
List
<
String
>
ignoreParamNames
,
String
secret
)
{
StringBuilder
sb
=
new
StringBuilder
();
List
<
String
>
paramNames
=
new
ArrayList
<>(
paramValues
.
size
());
paramNames
.
addAll
(
paramValues
.
keySet
());
if
(
ignoreParamNames
!=
null
&&
!
ignoreParamNames
.
isEmpty
())
{
for
(
String
ignoreParamName
:
ignoreParamNames
)
{
paramNames
.
remove
(
ignoreParamName
);
}
}
Collections
.
sort
(
paramNames
);
sb
.
append
(
secret
);
for
(
String
paramName
:
paramNames
)
{
sb
.
append
(
paramName
).
append
(
paramValues
.
get
(
paramName
));
}
sb
.
append
(
secret
);
return
MD5
.
convert32
(
sb
.
toString
());
}
}
platform-execute/src/main/java/cn/com/glsx/execute/utils/UrlUtil.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
utils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.logging.log4j.util.Strings
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.net.URLEncoder
;
import
java.nio.charset.StandardCharsets
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @Description url工具
* @author chizw
* @create 2023/9/18 16:08
* @version ver.1.0.0
*/
@Slf4j
public
enum
UrlUtil
{
X
;
/**
* 提取url
* @param url 链接
* @return url
*/
public
static
String
extractUrl
(
String
url
)
{
int
index
=
url
.
indexOf
(
"?"
);
String
target
=
url
;
if
(
index
>
0
)
{
String
substring
=
url
.
substring
(
0
,
index
);
if
(
StringUtils
.
isNotEmpty
(
substring
))
{
target
=
substring
;
}
}
return
target
;
}
/**
* 提取url参数
* @param url 链接
* @return 参数
*/
public
static
String
extractUrlParam
(
String
url
)
{
int
index
=
url
.
indexOf
(
"?"
);
String
param
=
Strings
.
EMPTY
;
if
(
index
>
0
)
{
String
substring
=
url
.
substring
(
index
+
1
);
if
(
StringUtils
.
isNotEmpty
(
substring
))
{
param
=
substring
;
}
}
return
param
;
}
public
static
String
encodeUrlParam
(
String
param
)
{
try
{
if
(
StringUtils
.
isEmpty
(
param
))
return
Strings
.
EMPTY
;
return
URLEncoder
.
encode
(
param
,
StandardCharsets
.
UTF_8
.
toString
());
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
return
Strings
.
EMPTY
;
}
}
public
static
String
decodeUrlParam
(
String
param
)
{
try
{
if
(
StringUtils
.
isEmpty
(
param
))
return
Strings
.
EMPTY
;
return
URLDecoder
.
decode
(
param
,
StandardCharsets
.
UTF_8
.
toString
());
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
return
Strings
.
EMPTY
;
}
}
public
static
Map
<
String
,
String
>
convertUrlParamsToMap
(
String
...
urlParam
)
{
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
if
(
urlParam
==
null
)
return
paramMap
;
for
(
String
param
:
urlParam
)
{
if
(
StringUtils
.
isEmpty
(
param
))
continue
;
String
[]
urlParts
=
param
.
split
(
"\\?"
);
String
[]
split
;
if
(
urlParts
.
length
>
1
)
{
split
=
urlParts
[
1
].
split
(
"&"
);
}
else
{
split
=
param
.
split
(
"&"
);
}
for
(
int
i
=
split
.
length
-
1
;
i
>=
0
;
i
--)
{
String
pair
=
split
[
i
];
String
[]
keyValue
=
pair
.
split
(
"="
);
if
(
keyValue
.
length
>
1
)
{
String
key
=
keyValue
[
0
];
String
value
=
keyValue
[
1
];
paramMap
.
put
(
key
,
value
);
}
else
{
paramMap
.
put
(
pair
,
null
);
}
}
}
return
paramMap
;
}
public
static
String
splicingUrl
(
String
protocol
,
String
domain
,
String
code
)
{
return
String
.
format
(
"%s://%s/%s"
,
protocol
,
domain
,
code
);
}
}
platform-execute/src/main/resources/bootstrap.properties
View file @
3220cd3
...
@@ -4,7 +4,7 @@ logging.path=/data/java_log/jetty/${spring.application.name}/${spring.applicatio
...
@@ -4,7 +4,7 @@ logging.path=/data/java_log/jetty/${spring.application.name}/${spring.applicatio
spring.cloud.nacos.config.server-
addr
=
192.168.0.63:8868
spring.cloud.nacos.config.server-
addr
=
192.168.0.63:8868
spring.cloud.nacos.config.group
=
PLATFORM_GROUP
spring.cloud.nacos.config.group
=
platform
spring.cloud.nacos.config.prefix
=
${spring.application.name}
spring.cloud.nacos.config.prefix
=
${spring.application.name}
spring.profiles.active
=
dev
spring.profiles.active
=
dev
spring.cloud.nacos.config.file-
extension
=
properties
spring.cloud.nacos.config.file-
extension
=
properties
...
...
platform-execute/src/main/resources/mapper/ShortUrlAccessEventRecordMapper.xml
0 → 100644
View file @
3220cd3
<?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=
"cn.com.glsx.execute.modules.mapper.ShortUrlAccessEventRecordMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.execute.modules.entity.shortutl.ShortUrlAccessEventRecordDTO"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"unique_identity"
jdbcType=
"VARCHAR"
property=
"uniqueIdentity"
/>
<result
column=
"client_ip"
jdbcType=
"VARCHAR"
property=
"clientIp"
/>
<result
column=
"short_url"
jdbcType=
"VARCHAR"
property=
"shortUrl"
/>
<result
column=
"long_url"
jdbcType=
"VARCHAR"
property=
"longUrl"
/>
<result
column=
"short_url_digest"
jdbcType=
"VARCHAR"
property=
"shortUrlDigest"
/>
<result
column=
"long_url_digest"
jdbcType=
"VARCHAR"
property=
"longUrlDigest"
/>
<result
column=
"compress_code"
jdbcType=
"VARCHAR"
property=
"compressCode"
/>
<result
column=
"record_time"
jdbcType=
"TIMESTAMP"
property=
"recordTime"
/>
<result
column=
"user_agent"
jdbcType=
"VARCHAR"
property=
"userAgent"
/>
<result
column=
"cookie_value"
jdbcType=
"VARCHAR"
property=
"cookieValue"
/>
<result
column=
"query_param"
jdbcType=
"VARCHAR"
property=
"queryParam"
/>
<result
column=
"province"
jdbcType=
"VARCHAR"
property=
"province"
/>
<result
column=
"city"
jdbcType=
"VARCHAR"
property=
"city"
/>
<result
column=
"phone_type"
jdbcType=
"VARCHAR"
property=
"phoneType"
/>
<result
column=
"browser_type"
jdbcType=
"VARCHAR"
property=
"browserType"
/>
<result
column=
"browser_version"
jdbcType=
"VARCHAR"
property=
"browserVersion"
/>
<result
column=
"os_type"
jdbcType=
"VARCHAR"
property=
"osType"
/>
<result
column=
"device_type"
jdbcType=
"VARCHAR"
property=
"deviceType"
/>
<result
column=
"os_version"
jdbcType=
"VARCHAR"
property=
"osVersion"
/>
<result
column=
"transform_status"
jdbcType=
"TINYINT"
property=
"transformStatus"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"created_time"
jdbcType=
"TIMESTAMP"
property=
"createdTime"
/>
<result
column=
"updated_by"
jdbcType=
"INTEGER"
property=
"updatedBy"
/>
<result
column=
"updated_time"
jdbcType=
"TIMESTAMP"
property=
"updatedTime"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
-->
id, unique_identity, client_ip, short_url, long_url, short_url_digest, long_url_digest,
compress_code, record_time, user_agent, cookie_value, query_param, province, city,
phone_type, browser_type, browser_version, os_type, device_type, os_version, transform_status,
del_flag, created_by, created_time, updated_by, updated_time
</sql>
</mapper>
\ No newline at end of file
\ No newline at end of file
platform-execute/src/main/resources/mapper/ShortUrlCompressCodeMapper.xml
0 → 100644
View file @
3220cd3
<?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=
"cn.com.glsx.execute.modules.mapper.ShortUrlCompressCodeMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.execute.modules.entity.shortutl.ShortUrlCompressCodeDTO"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"compress_code"
jdbcType=
"VARCHAR"
property=
"compressCode"
/>
<result
column=
"code_status"
jdbcType=
"TINYINT"
property=
"codeStatus"
/>
<result
column=
"sequence_value"
jdbcType=
"VARCHAR"
property=
"sequenceValue"
/>
<result
column=
"strategy"
jdbcType=
"VARCHAR"
property=
"strategy"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"created_time"
jdbcType=
"TIMESTAMP"
property=
"createdTime"
/>
<result
column=
"updated_by"
jdbcType=
"INTEGER"
property=
"updatedBy"
/>
<result
column=
"updated_time"
jdbcType=
"TIMESTAMP"
property=
"updatedTime"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
-->
id, compress_code, code_status, sequence_value, strategy, del_flag, created_by, created_time,
updated_by, updated_time
</sql>
</mapper>
\ No newline at end of file
\ No newline at end of file
platform-execute/src/main/resources/mapper/ShortUrlDomainConfigMapper.xml
0 → 100644
View file @
3220cd3
<?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=
"cn.com.glsx.execute.modules.mapper.ShortUrlDomainConfigMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.execute.modules.entity.shortutl.ShortUrlDomainConfigDTO"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"domain_value"
jdbcType=
"VARCHAR"
property=
"domainValue"
/>
<result
column=
"protocol"
jdbcType=
"VARCHAR"
property=
"protocol"
/>
<result
column=
"domain_status"
jdbcType=
"TINYINT"
property=
"domainStatus"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"created_time"
jdbcType=
"TIMESTAMP"
property=
"createdTime"
/>
<result
column=
"updated_by"
jdbcType=
"INTEGER"
property=
"updatedBy"
/>
<result
column=
"updated_time"
jdbcType=
"TIMESTAMP"
property=
"updatedTime"
/>
<result
column=
"level"
jdbcType=
"INTEGER"
property=
"level"
/>
<result
column=
"redirect_type"
jdbcType=
"INTEGER"
property=
"redirectType"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
-->
id, domain_value, protocol, domain_status, del_flag, created_by, created_time, updated_by,
updated_time, `level`, redirect_type
</sql>
</mapper>
\ No newline at end of file
\ No newline at end of file
platform-execute/src/main/resources/mapper/ShortUrlMappingMapper.xml
0 → 100644
View file @
3220cd3
<?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=
"cn.com.glsx.execute.modules.mapper.ShortUrlMappingMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.execute.modules.entity.shortutl.ShortUrlMappingDTO"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"short_url"
jdbcType=
"VARCHAR"
property=
"shortUrl"
/>
<result
column=
"long_url"
jdbcType=
"VARCHAR"
property=
"longUrl"
/>
<result
column=
"short_url_digest"
jdbcType=
"VARCHAR"
property=
"shortUrlDigest"
/>
<result
column=
"long_url_digest"
jdbcType=
"VARCHAR"
property=
"longUrlDigest"
/>
<result
column=
"compress_code"
jdbcType=
"VARCHAR"
property=
"compressCode"
/>
<result
column=
"description"
jdbcType=
"VARCHAR"
property=
"description"
/>
<result
column=
"url_status"
jdbcType=
"TINYINT"
property=
"urlStatus"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"created_time"
jdbcType=
"TIMESTAMP"
property=
"createdTime"
/>
<result
column=
"updated_by"
jdbcType=
"INTEGER"
property=
"updatedBy"
/>
<result
column=
"updated_time"
jdbcType=
"TIMESTAMP"
property=
"updatedTime"
/>
<result
column=
"url_param"
jdbcType=
"VARCHAR"
property=
"urlParam"
/>
<result
column=
"b4_redirect_page"
jdbcType=
"VARCHAR"
property=
"b4RedirectPage"
/>
<result
column=
"add_timestamp"
jdbcType=
"TINYINT"
property=
"addTimestamp"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
-->
id, short_url, long_url, short_url_digest, long_url_digest, compress_code, description, url_param
url_status, del_flag, created_by, created_time, updated_by, updated_time, b4_redirect_page, add_timestamp
</sql>
</mapper>
\ No newline at end of file
\ No newline at end of file
platform-execute/src/main/resources/mapper/SopEventDelaySendLogMapper.xml
0 → 100644
View file @
3220cd3
<?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=
"cn.com.glsx.execute.modules.mapper.SopEventDelaySendLogMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.execute.modules.entity.shortutl.SopEventDelaySendLogDTO"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"event_type"
jdbcType=
"INTEGER"
property=
"eventType"
/>
<result
column=
"del_flag"
jdbcType=
"TINYINT"
property=
"delFlag"
/>
<result
column=
"created_by"
jdbcType=
"INTEGER"
property=
"createdBy"
/>
<result
column=
"created_time"
jdbcType=
"TIMESTAMP"
property=
"createdTime"
/>
<result
column=
"updated_by"
jdbcType=
"INTEGER"
property=
"updatedBy"
/>
<result
column=
"updated_time"
jdbcType=
"TIMESTAMP"
property=
"updatedTime"
/>
<result
column=
"send_status"
jdbcType=
"INTEGER"
property=
"sendStatus"
/>
</resultMap>
<resultMap
extends=
"BaseResultMap"
id=
"ResultMapWithBLOBs"
type=
"cn.com.glsx.execute.modules.entity.shortutl.SopEventDelaySendLogDTO"
>
<!--
WARNING - @mbg.generated
-->
<result
column=
"event_content"
jdbcType=
"LONGVARCHAR"
property=
"eventContent"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
-->
id, event_type, del_flag, created_by, created_time, updated_by, updated_time, send_status
</sql>
<sql
id=
"Blob_Column_List"
>
<!--
WARNING - @mbg.generated
-->
event_content
</sql>
</mapper>
\ No newline at end of file
\ No newline at end of file
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/BaseTest.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
cn
.
com
.
glsx
;
import
cn.com.glsx.Application
;
import
cn.com.glsx.execute.modules.rabbitmq.produce.MsgProducer
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
javax.annotation.Resource
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
* @Author yelq
* @Version 1.0
* @Description: 基础测试类
* @Date 2023/9/8 14:00
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
Application
.
class
)
public
class
BaseTest
{
@Resource
private
RabbitTemplate
rabbitTemplate
;
@Resource
private
MsgProducer
msgProducer
;
@Test
public
void
rabbitTest
()
throws
InterruptedException
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
long
l
=
System
.
currentTimeMillis
();
Thread
.
sleep
(
3000
);
msgProducer
.
sendDelayedMessage
(
i
+
"hello world"
+
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
new
Date
()),
3000
);
}
}
}
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/TestApplication.java
View file @
3220cd3
//package cn.com.glsx;
//
//import com.glsx.microservice.api.EchoCenterFeignService;
//import com.glsx.plat.core.web.R;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.SpringApplication;
//import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
//import org.springframework.cloud.client.loadbalancer.LoadBalanced;
//import org.springframework.context.annotation.Bean;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.client.RestTemplate;
//
//import javax.annotation.Resource;
//
///**
// * 测试spring cloud 服务调用方式
// */
//@EnableDiscoveryClient
//@SpringBootApplication
//public class TestApplication {
//
// public static void main(String[] args) {
// SpringApplication.run(TestApplication.class, args);
// }
//
// @Slf4j
// @RestController
// static class TestController {
//
// @Autowired
// RestTemplate restTemplate;
//
// @Resource
// private EchoCenterFeignService echoCenterFeignService;
//
//// @Autowired
//// private WebClient.Builder webClientBuilder;
//
// @GetMapping("/test1")
// public String test1() {
// String result = restTemplate.getForObject("http://192.168.0.63:8829/rest-echo-center/echo/didi", String.class);
// return "Return : " + result;
// }
//
//// @GetMapping("/test")
//// public Mono<String> test() {
//// Mono<String> result = webClientBuilder.build()
//// .get()
//// .uri("http://alibaba-nacos-discovery-server/hello?name=didi")
//// .retrieve()
//// .bodyToMono(String.class);
//// return result;
//// }
//
// @GetMapping("/test3")
// public R test3() {
// String result = echoCenterFeignService.echo("this is a test!");
// return R.ok().data(result);
// }
// }
//
// @Bean
// @LoadBalanced
// public RestTemplate restTemplate() {
// return new RestTemplate();
// }
//
//// @Bean
//// @LoadBalanced
//// public WebClient.Builder loadBalancedWebClientBuilder() {
//// return WebClient.builder();
//// }
//
//}
\ No newline at end of file
\ No newline at end of file
package
cn
.
com
.
glsx
.
cn
.
com
.
glsx
;
import
cn.com.glsx.Application
;
import
cn.com.glsx.execute.modules.service.proxy.SendMessageService
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
/**
* 测试spring cloud 服务调用方式
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
Application
.
class
)
public
class
TestApplication
{
@Autowired
private
SendMessageService
sendMessageService
;
@Test
public
void
restTemplate
()
{
sendMessageService
.
sendMessage
(
""
,
""
,
""
,
""
);
}
}
\ No newline at end of file
\ No newline at end of file
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/Utils/RopHttpUtilTest.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
cn
.
com
.
glsx
.
Utils
;
import
cn.com.glsx.execute.modules.model.rop.RopResponseDTO
;
import
cn.com.glsx.execute.utils.RopHttpUtil
;
import
org.junit.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
/**
* @Author yelq
* @Version 1.0
* @Description:
* @Date 2023/9/7 15:37
*/
@SpringBootTest
public
class
RopHttpUtilTest
{
@Test
public
void
Test01
()
throws
Exception
{
MultiValueMap
<
String
,
String
>
paramsMap
=
new
LinkedMultiValueMap
<>();
paramsMap
.
add
(
"pageSize"
,
"10"
);
paramsMap
.
add
(
"currentPage"
,
"1"
);
// paramsMap.add("format","json");
paramsMap
.
add
(
"sessionId"
,
"scrm-base-53c2afc0-7bb7-455f-ba0f-2ac0d3fa4a12-rop"
);
Object
o
=
RopHttpUtil
.
get
(
paramsMap
,
RopResponseDTO
.
class
,
"http://scrm.test.glsx.com.cn/rop-scrm-shopmall/router"
,
"scrm.api.shopmall.integralcustomer.page"
,
null
);
System
.
out
.
println
(
o
);
}
}
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/Utils/SendMessageServiceTest.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
cn
.
com
.
glsx
.
Utils
;
import
cn.com.glsx.Application
;
import
cn.com.glsx.execute.common.constant.SmsConstants
;
import
cn.com.glsx.execute.config.RabbitMQConfig
;
import
cn.com.glsx.execute.modules.model.sms.SmsResponseDTO
;
import
cn.com.glsx.execute.modules.rabbitmq.produce.MsgProducer
;
import
cn.com.glsx.execute.modules.service.proxy.SendMessageService
;
import
com.alibaba.fastjson.JSONObject
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.amqp.rabbit.core.RabbitTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.core.env.Environment
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* @Author yelq
* @Version 1.0
* @Description:
* @Date 2023/9/7 17:14
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
(
classes
=
Application
.
class
)
public
class
SendMessageServiceTest
{
@Autowired
private
SendMessageService
sendMessageService
;
@Autowired
private
Environment
environment
;
@Autowired
private
MsgProducer
msgProducer
;
@Resource
private
RabbitTemplate
rabbitTemplate
;
@Test
public
void
Test01
()
throws
Exception
{
String
text
=
"【波波的单店门店】SOP营销测试https://dwz.cn/sHkDTMo9"
;
SmsResponseDTO
s
=
sendMessageService
.
sendMessage
(
"15555405026"
,
SmsConstants
.
SMS_SOURCE
,
SmsConstants
.
SMS_TYPE
,
text
);
System
.
out
.
println
(
s
);
}
@Test
public
void
sendMsg
()
throws
Exception
{
msgProducer
.
sendMsg
(
"dataReport_queue"
,
"测试mq"
);
}
@Test
public
void
fanoutSendMsg
()
throws
Exception
{
msgProducer
.
fanoutSend
(
"测试fanoutMsg"
);
}
@Test
public
void
topicSendMsg
()
throws
Exception
{
msgProducer
.
topicSend
(
"topic.1"
,
"测试topic"
,
""
);
}
@Test
public
void
buryingPointSendMsg
()
throws
Exception
{
msgProducer
.
buryingPointSend
(
"测试埋点数据上报"
);
}
@Test
public
void
test
()
{
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
2
;
i
++)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"org_id"
,
"44211227"
);
map
.
put
(
"customer_name"
,
"张三"
+
i
);
map
.
put
(
"gender"
,
"Male"
);
map
.
put
(
"birthday"
,
"1990-01-01"
);
map
.
put
(
"age"
,
"300"
);
map
.
put
(
"customer_phone"
,
"1380013800"
+
i
);
list
.
add
(
map
);
}
rabbitTemplate
.
convertAndSend
(
RabbitMQConfig
.
DATA_REPORT_EXCHANGE_NAME
,
"dataReport.customer.event"
,
JSONObject
.
toJSONString
(
list
));
}
}
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/aioutboundcall/AiOutboundCallTest.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
cn
.
com
.
glsx
.
aioutboundcall
;
import
cn.com.glsx.cn.com.glsx.BaseTest
;
import
cn.com.glsx.execute.modules.converter.rop.RopRequestConveter
;
import
cn.com.glsx.execute.modules.converter.rop.RopResponseConveter
;
import
cn.com.glsx.execute.modules.enums.rop.MethodEnum
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.ByaiGetRobotListRequestDTO
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.ByaiGetRobotListResponseDTO
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.ByaiImportCallJobCustomerRequestDTO
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.ByaiImportCallJobCustomerResponseDTO
;
import
cn.com.glsx.execute.modules.model.rop.RopResponseDTO
;
import
cn.com.glsx.execute.modules.model.wechat.GetUserInfoRequest
;
import
cn.com.glsx.execute.modules.model.wechat.GetUserInfoResponse
;
import
cn.com.glsx.execute.utils.RopHttpUtil
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.junit.Test
;
import
org.springframework.util.MultiValueMap
;
import
java.util.*
;
/**
* @Author yelq
* @Version 1.0
* @Description: 外呼对接测试
* @Date 2023/9/8 13:59
*/
public
class
AiOutboundCallTest
extends
BaseTest
{
@Test
public
void
Test01
()
throws
Exception
{
String
url
=
"https://scrm.dev.glsx.com.cn/rop-scrm-wechat/router"
;
GetUserInfoRequest
request
=
new
GetUserInfoRequest
();
request
.
setUnionId
(
"oV6hWt8ymah1Tg5EG0-aOmyhaFN0"
);
MultiValueMap
<
String
,
String
>
paramsMap
=
RopRequestConveter
.
toMultiValueMap
(
request
,
GetUserInfoRequest
.
class
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
WECHAT_USERINFO_BY_UNIONID
.
getMethod
(),
null
);
RopResponseDTO
<
List
<
GetUserInfoResponse
>>
ropResponseDTO
=
new
ObjectMapper
().
readValue
(
post
,
new
TypeReference
<
RopResponseDTO
<
List
<
GetUserInfoResponse
>>>(){});
System
.
out
.
println
(
ropResponseDTO
.
getData
().
get
(
0
).
getPhone
());
}
@Test
public
void
invokeAICallTest01
()
throws
Exception
{
String
url
=
"http://192.168.1.104:8097/rop-scrm-marketing/router"
;
ByaiImportCallJobCustomerRequestDTO
requestDTO
=
new
ByaiImportCallJobCustomerRequestDTO
();
ByaiImportCallJobCustomerRequestDTO
.
CustomerInfoVO
vo
=
new
ByaiImportCallJobCustomerRequestDTO
.
CustomerInfoVO
();
vo
.
setName
(
"叶之魂"
);
vo
.
setPhone
(
"18126301457"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"uuid"
,
UUID
.
randomUUID
().
toString
());
map
.
put
(
"robotDefId"
,
"320475"
);
//机器人id
map
.
put
(
"importCustomerId"
,
"18126301457"
);
//客户唯一标识
map
.
put
(
"sopId"
,
"10241024"
);
//sopid
vo
.
setProperties
(
map
);
requestDTO
.
setCustomerInfoVOList
(
Arrays
.
asList
(
vo
));
// requestDTO.setMerchantId(44211277);
requestDTO
.
setCallJobType
(
1L
);
requestDTO
.
setStartDate
(
"2023-09-11"
);
ByaiImportCallJobCustomerRequestDTO
.
JobWorkingTimeRuleDetailVO
jobWorkingTimeRuleDetailVO
=
new
ByaiImportCallJobCustomerRequestDTO
.
JobWorkingTimeRuleDetailVO
();
ByaiImportCallJobCustomerRequestDTO
.
JobWorkingTimeRuleDetailVO
.
TimeRangeVO
timeRangeVO
=
new
ByaiImportCallJobCustomerRequestDTO
.
JobWorkingTimeRuleDetailVO
.
TimeRangeVO
();
timeRangeVO
.
setStartTime
(
"2023-09-11 17:00:00"
);
timeRangeVO
.
setEndTime
(
"2023-09-11 18:00:00"
);
jobWorkingTimeRuleDetailVO
.
setTimeRanges
(
Arrays
.
asList
(
timeRangeVO
));
jobWorkingTimeRuleDetailVO
.
setWeeks
(
Arrays
.
asList
(
1
));
requestDTO
.
setWorkingTimeRuleList
(
Arrays
.
asList
(
jobWorkingTimeRuleDetailVO
));
MultiValueMap
<
String
,
String
>
paramsMap
=
RopRequestConveter
.
toMultiValueMap
(
requestDTO
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
INVOKE_AI_CALL
.
getMethod
(),
null
);
System
.
out
.
println
(
post
);
RopResponseDTO
<
ByaiImportCallJobCustomerResponseDTO
>
ropResponseDTO
=
RopResponseConveter
.
convertRopResponse
(
post
,
ByaiImportCallJobCustomerResponseDTO
.
class
);
System
.
out
.
println
(
ropResponseDTO
);
}
@Test
public
void
outboundCallTest01
()
throws
Exception
{
String
url
=
"http://192.168.1.104:8097/rop-scrm-marketing/router"
;
ByaiGetRobotListRequestDTO
requestDTO
=
new
ByaiGetRobotListRequestDTO
();
requestDTO
.
setSelectAll
(
true
);
MultiValueMap
<
String
,
String
>
paramsMap
=
RopRequestConveter
.
toMultiValueMap
(
requestDTO
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
ROBOT_LIST
.
getMethod
(),
null
);
RopResponseDTO
<
ByaiGetRobotListResponseDTO
>
ropResponseDTO
=
RopResponseConveter
.
convertRopResponse
(
post
,
ByaiGetRobotListResponseDTO
.
class
);
System
.
out
.
println
(
ropResponseDTO
);
}
}
platform-execute/src/test/java/cn/com/glsx/cn/com/glsx/oneVone/BatchMessageServiceTest.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
cn
.
com
.
glsx
.
oneVone
;
import
cn.com.glsx.execute.modules.converter.rop.RopRequestConveter
;
import
cn.com.glsx.execute.modules.converter.rop.RopResponseConveter
;
import
cn.com.glsx.execute.modules.enums.rop.MethodEnum
;
import
cn.com.glsx.execute.modules.model.aioutboundcall.ByaiGetCustomerDetailResponseDTO
;
import
cn.com.glsx.execute.modules.model.oneVone.BatchMessagingContentDTO
;
import
cn.com.glsx.execute.modules.model.oneVone.BatchMessagingCreateRopRequestDTO
;
import
cn.com.glsx.execute.modules.model.oneVone.BatchMessagingCrowConditionDTO
;
import
cn.com.glsx.execute.modules.model.oneVone.LabelRequestDTO
;
import
cn.com.glsx.execute.modules.model.rop.RopResponseDTO
;
import
cn.com.glsx.execute.utils.RopHttpUtil
;
import
org.junit.Test
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
static
cn
.
com
.
glsx
.
execute
.
modules
.
enums
.
AppKeyEnum
.
ROP_SCRM_ENTMICRO
;
/**
* @Author yelq
* @Version 1.0
* @Description: 1v1群发
* @Date 2023/9/12 14:09
*/
public
class
BatchMessageServiceTest
{
@Test
public
void
Test01
()
throws
Exception
{
//https://scrm.dev.glsx.com.cn/rop-scrm-entmicro/router/entmicro.api.wechatcloudcontrol.batchmessaging.create/1.0.0
// String url = "https://scrm.dev.glsx.com.cn/rop-scrm-entmicro/router";
String
url
=
"http://localhost:8064/rop-scrm-entmicro/router"
;
BatchMessagingCreateRopRequestDTO
request
=
new
BatchMessagingCreateRopRequestDTO
();
request
.
setMsgName
(
"4444"
);
request
.
setMsgMerchantId
(
44210895
);
// request.setMsgMerchantName("老梁单店");
request
.
setCustomerType
(
3
);
// request.setCombineType(1);
// request.setAsyncProcess(true);
request
.
setCreatedBy
(
1024
);
// request.setSendTime(new Date());
request
.
setSendType
(
1
);
ArrayList
<
LabelRequestDTO
>
labelList
=
new
ArrayList
<>();
LabelRequestDTO
labelRequest
=
new
LabelRequestDTO
();
labelRequest
.
setGroupId
(
13558
);
labelRequest
.
setGroupName
(
"苹果标签"
);
labelRequest
.
setGroupType
(
"已加微"
);
labelRequest
.
setLabelId
(
37182
);
labelRequest
.
setLabelName
(
"我是苹果"
);
labelList
.
add
(
labelRequest
);
// request.setLabelList(labelList);
ArrayList
<
BatchMessagingContentDTO
>
contentList
=
new
ArrayList
<>();
BatchMessagingContentDTO
content1
=
new
BatchMessagingContentDTO
();
content1
.
setAttType
(
1
);
content1
.
setAttContent
(
"11111[害羞]"
);
contentList
.
add
(
content1
);
BatchMessagingContentDTO
content2
=
new
BatchMessagingContentDTO
();
content2
.
setAttType
(
2
);
content2
.
setAttContent
(
"https://wx.glsx.com.cn/upload/biz/bf9c77f4-2578-405e-ba50-942dbd3b0c91.jpg"
);
contentList
.
add
(
content2
);
request
.
setContentList
(
contentList
);
BatchMessagingContentDTO
content3
=
new
BatchMessagingContentDTO
();
content3
.
setAttType
(
7
);
content3
.
setAttContent
(
"{\"marketingId\":1,\"marketingType\":3,\"marketingName\":\"招商银行信用卡\",\"marketingContent\":{\"equityName\":\"招商银行信用卡\",\"effectivedDay\":365,\"effectiveType\":2,\"freeDay\":30,\"selectType\":\"card\"}}"
);
contentList
.
add
(
content3
);
BatchMessagingContentDTO
content4
=
new
BatchMessagingContentDTO
();
content4
.
setAttType
(
6
);
content4
.
setAttContent
(
"{\"fileName\":\"fgsf\",\"url\":\"https://wx.glsx.com.cn/upload/biz/4a9b53db-94cc-493e-9867-889d8a3ef7a8.pdf\"}"
);
contentList
.
add
(
content4
);
request
.
setContentList
(
contentList
);
BatchMessagingCrowConditionDTO
batchMessagingCrowConditionDTO
=
new
BatchMessagingCrowConditionDTO
();
batchMessagingCrowConditionDTO
.
setCrowdId
(
1024
);
batchMessagingCrowConditionDTO
.
setCrowdName
(
"haha"
);
// request.setCrowdList(Arrays.asList(batchMessagingCrowConditionDTO));
// request.setStaffIdList(Arrays.asList(1024,1123));
// request.setCustomerIdList(Arrays.asList(1024,1596));
request
.
setStaffCloudIdList
(
Arrays
.
asList
(
"1688857929361201"
));
request
.
setCustomerCloudIdList
(
Arrays
.
asList
(
"7881303040924792"
));
MultiValueMap
<
String
,
String
>
paramsMap
=
RopRequestConveter
.
toMultiValueMap
(
request
);
System
.
out
.
println
(
paramsMap
);
String
post
=
RopHttpUtil
.
post
(
paramsMap
,
String
.
class
,
url
,
MethodEnum
.
BATCH_MESSAGE_CREATE
.
getMethod
(),
ROP_SCRM_ENTMICRO
);
System
.
out
.
println
(
post
);
RopResponseDTO
<
Boolean
>
ropResponseDTO
=
RopResponseConveter
.
convertRopResponse
(
post
,
Boolean
.
class
);
System
.
out
.
println
(
ropResponseDTO
);
}
}
platform-execute/src/test/resources/generatorConfig.xml
View file @
3220cd3
...
@@ -24,8 +24,15 @@
...
@@ -24,8 +24,15 @@
<plugin
type=
"org.mybatis.generator.plugins.ToStringPlugin"
/>
<plugin
type=
"org.mybatis.generator.plugins.ToStringPlugin"
/>
<!-- 配置 tk.mybatis 插件 -->
<!-- 配置 tk.mybatis 插件 -->
<!-- <plugin type="tk.mybatis.mapper.generator.MapperPlugin">-->
<!-- <property name="mappers" value="com.glsx.plat.mybatis.mapper.CommonBaseMapper"/>-->
<!-- </plugin>-->
<plugin
type=
"tk.mybatis.mapper.generator.MapperPlugin"
>
<plugin
type=
"tk.mybatis.mapper.generator.MapperPlugin"
>
<property
name=
"mappers"
value=
"com.glsx.plat.mybatis.mapper.CommonBaseMapper"
/>
<property
name=
"mappers"
value=
"com.glsx.plat.mybatis.mapper.CommonBaseMapper"
/>
<property
name=
"caseSensitive"
value=
"true"
/>
<property
name=
"useActualColumnNames"
value=
"true"
/>
<!--<property name="beginningDelimiter" value="`"/>-->
<!--<property name="endingDelimiter" value="`"/>-->
</plugin>
</plugin>
<!--配置生成注释信息,最多配置一个 -->
<!--配置生成注释信息,最多配置一个 -->
...
@@ -36,13 +43,15 @@
...
@@ -36,13 +43,15 @@
<property
name=
"addRemarkComments"
value=
"true"
/>
<property
name=
"addRemarkComments"
value=
"true"
/>
</commentGenerator>
</commentGenerator>
<!-- jdbc连接-->
<!-- jdbc连接-->
<jdbcConnection
driverClass=
"com.mysql.cj.jdbc.Driver"
<!-- <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"-->
connectionURL=
"jdbc:mysql://192.168.0.39:3306/seata_storage?serverTimeZone=Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false"
<!-- connectionURL="jdbc:mysql://192.168.0.39:3306/seata_storage?serverTimeZone=Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false"-->
userId=
"root"
<!-- userId="root"-->
password=
"123456"
>
<!-- password="123456">-->
<!--防止生成其他库同名表-->
<!-- <!–防止生成其他库同名表–>-->
<property
name=
"nullCatalogMeansCurrent"
value=
"true"
/>
<!-- <property name="nullCatalogMeansCurrent" value="true"/>-->
</jdbcConnection>
<!-- </jdbcConnection>-->
<jdbcConnection
driverClass=
"com.mysql.jdbc.Driver"
connectionURL=
"jdbc:mysql://192.168.3.227:3306/platform_execute?characterEncoding=utf8"
userId=
"root"
password=
"manager"
/>
<!-- 类型转换 -->
<!-- 类型转换 -->
<javaTypeResolver>
<javaTypeResolver>
<!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->
<!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->
...
@@ -50,11 +59,15 @@
...
@@ -50,11 +59,15 @@
</javaTypeResolver>
</javaTypeResolver>
<!-- 生成实体类地址 -->
<!-- 生成实体类地址 -->
<javaModelGenerator
targetPackage=
"cn.com.payu.modules.entity"
targetProject=
"src/main/java"
>
<!-- <javaModelGenerator targetPackage="cn.com.payu.modules.entity" targetProject="src/main/java">-->
<!-- 是否让schema作为包的后缀 -->
<!-- <!– 是否让schema作为包的后缀 –>-->
<property
name=
"enableSubPackages"
value=
"true"
/>
<!-- <property name="enableSubPackages" value="true"/>-->
<!-- 从数据库返回的值去掉前后空格 -->
<!-- <!– 从数据库返回的值去掉前后空格 –>-->
<property
name=
"trimStrings"
value=
"true"
/>
<!-- <property name="trimStrings" value="true"/>-->
<!-- </javaModelGenerator>-->
<javaModelGenerator
targetPackage=
"cn.com.glsx.execute.modules.entity"
targetProject=
"D:\projects\sop\execute\platform-execute-api\src\main\java"
>
<property
name=
"enableSubPackages"
value=
"true"
/>
<property
name=
"trimStrings"
value=
"true"
/>
</javaModelGenerator>
</javaModelGenerator>
<!-- 生成mapper.xml文件存放地址 -->
<!-- 生成mapper.xml文件存放地址 -->
...
@@ -63,11 +76,18 @@
...
@@ -63,11 +76,18 @@
</sqlMapGenerator>
</sqlMapGenerator>
<!-- 生成接口dao type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象 type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象 type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<!-- 生成接口dao type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象 type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象 type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator
targetPackage=
"cn.com.payu.modules.mapper"
targetProject=
"src/main/java"
type=
"XMLMAPPER"
>
<!-- <javaClientGenerator targetPackage="cn.com.payu.modules.mapper" targetProject="src/main/java" type="XMLMAPPER">-->
<property
name=
"enableSubPackages"
value=
"false"
/>
<!-- <property name="enableSubPackages" value="false"/>-->
<!-- </javaClientGenerator>-->
<javaClientGenerator
targetPackage=
"cn.com.glsx.execute.modules.mapper"
targetProject=
"D:\projects\sop\execute\platform-execute-api\src\main\java"
type=
"XMLMAPPER"
>
<property
name=
"enableSubPackages"
value=
"true"
/>
</javaClientGenerator>
</javaClientGenerator>
<!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 -->
<!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 -->
<table
tableName=
"t_storage"
domainObjectName=
"Storage"
enableCountByExample=
"false"
enableUpdateByExample=
"false"
enableDeleteByExample=
"false"
enableSelectByExample=
"false"
selectByExampleQueryId=
"false"
/>
<!-- <table tableName="t_storage" domainObjectName="Storage" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" -->
<!-- selectByExampleQueryId="false"/>-->
<table
tableName=
"sop_event_delay_send_log"
domainObjectName=
"SopEventDelaySendLogDTO"
enableSelectByExample=
"false"
enableCountByExample=
"false"
enableDeleteByExample=
"false"
enableUpdateByExample=
"false"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
</context>
</context>
</generatorConfiguration>
</generatorConfiguration>
\ No newline at end of file
\ No newline at end of file
platform-execute/target/generated-sources/annotations/cn/com/glsx/execute/modules/converter/UserConverterImpl.java
0 → 100644
View file @
3220cd3
package
cn
.
com
.
glsx
.
execute
.
modules
.
converter
;
import
cn.com.glsx.execute.modules.entity.User
;
import
cn.com.glsx.execute.modules.model.UserBO
;
import
cn.com.glsx.execute.modules.model.UserDTO
;
import
javax.annotation.Generated
;
@Generated
(
value
=
"org.mapstruct.ap.MappingProcessor"
,
date
=
"2023-10-15T17:20:19+0800"
,
comments
=
"version: 1.5.2.Final, compiler: javac, environment: Java 1.8.0_181 (Oracle Corporation)"
)
public
class
UserConverterImpl
implements
UserConverter
{
@Override
public
UserDTO
do2dto
(
User
user
)
{
if
(
user
==
null
)
{
return
null
;
}
UserDTO
userDTO
=
new
UserDTO
();
userDTO
.
setId
(
user
.
getId
()
);
userDTO
.
setAccount
(
user
.
getAccount
()
);
userDTO
.
setUsername
(
user
.
getUsername
()
);
userDTO
.
setRealname
(
user
.
getRealname
()
);
userDTO
.
setPassword
(
user
.
getPassword
()
);
userDTO
.
setPhone
(
user
.
getPhone
()
);
return
userDTO
;
}
@Override
public
User
dto2do
(
UserDTO
userDTO
)
{
if
(
userDTO
==
null
)
{
return
null
;
}
User
user
=
new
User
();
user
.
setId
(
userDTO
.
getId
()
);
user
.
setAccount
(
userDTO
.
getAccount
()
);
user
.
setPassword
(
userDTO
.
getPassword
()
);
user
.
setUsername
(
userDTO
.
getUsername
()
);
user
.
setRealname
(
userDTO
.
getRealname
()
);
user
.
setPhone
(
userDTO
.
getPhone
()
);
return
user
;
}
@Override
public
UserBO
do2bo
(
User
user
)
{
if
(
user
==
null
)
{
return
null
;
}
UserBO
userBO
=
new
UserBO
();
userBO
.
setRealName
(
user
.
getRealname
()
);
userBO
.
setId
(
user
.
getId
()
);
userBO
.
setAccount
(
user
.
getAccount
()
);
userBO
.
setPassword
(
user
.
getPassword
()
);
userBO
.
setUsername
(
user
.
getUsername
()
);
userBO
.
setPhone
(
user
.
getPhone
()
);
userBO
.
setAvatar
(
user
.
getAvatar
()
);
return
userBO
;
}
@Override
public
User
bo2do
(
UserBO
userBO
)
{
if
(
userBO
==
null
)
{
return
null
;
}
User
user
=
new
User
();
user
.
setRealname
(
userBO
.
getRealName
()
);
user
.
setId
(
userBO
.
getId
()
);
user
.
setAccount
(
userBO
.
getAccount
()
);
user
.
setPassword
(
userBO
.
getPassword
()
);
user
.
setUsername
(
userBO
.
getUsername
()
);
user
.
setPhone
(
userBO
.
getPhone
()
);
user
.
setAvatar
(
userBO
.
getAvatar
()
);
return
user
;
}
}
pom.xml
View file @
3220cd3
...
@@ -20,6 +20,15 @@
...
@@ -20,6 +20,15 @@
<maven.compiler.target>
1.8
</maven.compiler.target>
<maven.compiler.target>
1.8
</maven.compiler.target>
</properties>
</properties>
<dependencies>
<!-- <dependency>-->
<!-- <groupId>org.oreframework.boot</groupId>-->
<!-- <artifactId>ore-boot-autoconfigure</artifactId>-->
<!-- <version>2.2.0-SNAPSHOT</version>-->
<!-- </dependency>-->
</dependencies>
<build>
<build>
<resources>
<resources>
<resource>
<resource>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment