Commit 6f5d4833 by chizw

sop短链 短链转换优化

1 parent 7ab36120
......@@ -101,6 +101,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
......
......@@ -57,28 +57,26 @@ public class SopEventProcessFilter implements AccessFilter {
public void doFilter(AccessFilterChain chain, TransformContext context) {
//sop事件
try {
List<Map<String, Object>> mapList = new ArrayList<>();
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");
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));
log.info("sop event mq message:{}", JSON.toJSONString(mapList));
msgProducer.customerEventSend(mapList);
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));
GetUserInfoRequest requestDTO = new GetUserInfoRequest();
requestDTO.setUnionId(unionId);
List<GetUserInfoResponse> userList = wechatUserInfoService.getUserListByUnionId(requestDTO);
......
......@@ -38,7 +38,7 @@ public class UrlTransformFilter implements AccessFilter {
@Resource
private Environment environment;
private String b4RedirectPage;
// private String b4RedirectPage;
private String protocol;
......@@ -52,7 +52,7 @@ public class UrlTransformFilter implements AccessFilter {
@Override
public void init(TransformContext context) {
String page = environment.getProperty("sop.shorturl.default.auth.page");
if (StringUtils.isNotEmpty(page)) b4RedirectPage = page;
// if (StringUtils.isNotEmpty(page)) b4RedirectPage = page;
ShortUrlDomainConfigDTO domain = shortUrlService.selectDomain(RedirectType.DIRECT);
if (domain != null) {
protocol = domain.getProtocol();
......@@ -77,9 +77,9 @@ public class UrlTransformFilter implements AccessFilter {
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());
b4RedirectPage = StringUtils.isNotEmpty(mappingDTO.getB4RedirectPage()) ? mappingDTO.getB4RedirectPage() : b4RedirectPage;
String b4RedirectPage = mappingDTO.getB4RedirectPage();
Boolean addTimestamp = mappingDTO.getAddTimestamp();
if (redirectType.equals(RedirectType.THROUGH_AUTH_PAGE)) {
if (redirectType.equals(RedirectType.THROUGH_AUTH_PAGE) && StringUtils.isNotEmpty(b4RedirectPage)) {
longUrl = b4RedirectPage + "?url=" + UrlUtil.splicingUrl(protocol,domainValue,context.getCompressCode());
} else {
if (StringUtils.isNotEmpty(urlParam)) {
......
......@@ -26,6 +26,7 @@ import java.util.Enumeration;
@Tag(name = "短链映射")
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/sop")
public class UrlMapController {
@Resource
......
......@@ -64,8 +64,8 @@ public class ShortUrlService {
@Resource
private SopEventDelaySendLogMapper sopEventDelaySendLogMapper;
@Value("sop.shorturl.default.auth.page:https://scrm.dev.glsx.com.cn/sopurl")
private String DEFAULT_AUTH_PAGE;
@Value("${sop.shorturl.default.auth.page:https://scrm.dev.glsx.com.cn/sopurl}")
private String defaultAuthPage;
private ShortUrlService self;
......@@ -143,7 +143,7 @@ public class ShortUrlService {
RedirectType redirectType = RedirectType.DIRECT;
if (isThroughAuth != null && isThroughAuth) {
redirectType = RedirectType.THROUGH_AUTH_PAGE;
b4RedirectPage = StringUtils.isNotEmpty(b4RedirectPage) ? b4RedirectPage : DEFAULT_AUTH_PAGE;
b4RedirectPage = StringUtils.isNotEmpty(b4RedirectPage) ? b4RedirectPage : defaultAuthPage;
}
// 获取域名
ShortUrlDomainConfigDTO domain = selectDomain(redirectType);
......
......@@ -30,7 +30,7 @@ public enum UrlUtil {
*/
public static String extractUrl(String url) {
int index = url.indexOf("?");
String target = null;
String target = url;
if (index > 0) {
String substring = url.substring(0, index);
if (StringUtils.isNotEmpty(substring)) {
......
......@@ -7,7 +7,7 @@ import javax.annotation.Generated;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2023-10-13T10:56:15+0800",
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 {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!