[新增功能](master): 修复bug及文档更新

1.更新了短链的说明文档
2,修复了多条短链的调用请求返回为null Bug
3.修复了https redirect bug
master
土豆兄弟 3 years ago
parent e7e22fd96b
commit 84f291d1c5

@ -22,53 +22,37 @@
short-server-pojo - dto/bo 用于模块之间的传输实体/领域模型定义
short-server-service - 短链生成服务
#### 附加功能说明
支持默认定时30天的清除短链(默认开启)
支持带签名区分的短链形式,例如:
request:
{
"baseUrlAddr": "htttps://www.baidu.com/xxdsd/sdsdsds?sadsads=xxxx",
"variableList": [
13111112211,
12111112222
]
}
response:
{
"status": 0,
"data": {
"shortChainResult": [
"e4ig5miu1n|13111112211",
"rtyt8vhx6l|12111112222"
]}
}
也支持不带签名的短链(这里只支持单条调用)
request:
{
"baseUrlAddr": "htttps://www.baidu.com/xxdsd/sdsdsds?sadsads=xxxx"
}
response:
{
"status": 0,
"data": {
"shortChainResult": [
"e4ig5miu1n"
]}
}
#### 调用方式及API
批量生成短链API : {{host}}:{{ip}}/send
短链兑换真实地址API : {{host}}:{{ip}}/返回的短链
注意事项(原始链接要求)
1. 前期不支持微信小程序内嵌h5页面
2. 跳转后请求地址为 http:://t.p.tuoz.net/短链
### 调用方式1 - 生成单一短链服务[支持默认定时30天的清除短链(默认开启)]
- 请求
- 方式及body格式
- POST | json
- 地址及参数
- s.z48.cn/trans
- {"baseUrlAddr": "http://www.baidu.com"}
- ps baseUrlAddr 表示要进行缩短的长链接
- 响应
- {"status": 0,"data": {"shortChainResult": ["tG"]}}
- ps: shortChainResult 表示缩短后的结果
- 生成后的请求
- s.z48.cn/tG
### 调用方式2 - 生成带单一用户记录的服务[支持默认定时30天的清除短链(默认开启)]
- 请求
- 方式及body格式
- POST | json
- 地址及参数
- s.z48.cn/trans
- {"baseUrlAddr": "htttps://www.baidu.com/xxdsd/sdsdsds?sadsads=xxxx","variableList": [13111112211, 12111112222]}
- ps: baseUrlAddr 表示要进行缩短的长链接; variableList 表示要记录的手机号
- 响应
- {"status": 0,"data": {"shortChainResult": ["pINbght|13111112211","2Mfje8y|12111112222"]}}
- "|" 前面为唯一标识随机码,后面为对应的手机号
- 生成后的请求
- s.z48.cn/pINbght
- s.z48.cn/2Mfje8y
#### 部署方式
by-short-server 目录下 mvn clean install 进行打包
by-short-server 目录下 mvn clean package -Dmaven.test.skip=true 进行打包
上传到服务器
上传到服务器 /home/www/sms/目录下
运行 /home/www/ 下的 run-short-server.sh 脚本启动

@ -14,7 +14,7 @@ public class ShortUrlUtil {
/**
*
*/
private static final Integer BASE_LIMIT_LENGTH = 10;
private static final Integer BASE_LIMIT_LENGTH = 7;
/**
* 3

@ -62,9 +62,11 @@ public class ShortServerOpenApiController {
ThreadLocalUtil.set(CUSTOMER_IP_ADDR_KEY, SystemConstant.DEFAULT_IP);
}
// 参数不存在的时候,给一个标识,来缩短短链
// 参数不存在的时候,给一个标识,来缩短短链,该种短链只能代表一个长网址
if (CollectionUtil.isEmpty(shortChainRequestVO.getVariableList())){
shortChainDTO = shortServerService.handleOriginUrlsToShortUrls(shortChainDTO, true);
}else {
shortChainDTO = shortServerService.handleOriginUrlsToShortUrls(shortChainDTO, false);
}
@ -77,8 +79,13 @@ public class ShortServerOpenApiController {
return CommonResponse.createBySuccess(shortChainResponseVO);
}
/**
* modify by q , /s/ ,
* @param redeem
* @return
*/
@ApiOperation("短链接兑换长链接并进行")
@GetMapping(value = "/s/{redeem}")
@GetMapping(value = "/{redeem}")
@CrossOrigin
public ModelAndView redeemShortChainClick(@PathVariable("redeem") String redeem) {
log.info("=== [ShortServerOpenApiController|redeemShortChainClick, one request is coming, request param is {} ] ===", redeem);
@ -99,7 +106,8 @@ public class ShortServerOpenApiController {
}
return new ModelAndView("redirect:" + originUrl);
// return new ModelAndView("redirect:" + originUrl);
return new ModelAndView(new RedirectView(originUrl,true,false));
}
@ApiOperation("用于测试转发")
@ -108,7 +116,8 @@ public class ShortServerOpenApiController {
@Deprecated
public ModelAndView testRedirect(@PathVariable("redeem") String redeem) {
System.out.println(redeem);
return new ModelAndView(new RedirectView("http://www.baidu.com"));
return new ModelAndView(new RedirectView("https://www.baidu.com",true,false));
}
}

@ -64,11 +64,13 @@ public interface ShortUrlRepository extends JpaRepository<ShortUrl, Long>, JpaSp
/**
* ()day -
*
* modify by q :
*
* @param expirationDay
* @return ()
*/
@Modifying
@Query( value = "DELETE FROM ShortUrl t WHERE t.expirationDay = ?1")
@Query( value = "DELETE FROM ShortUrl t WHERE t.expirationDay = ?1 AND t.pointTag = 0")
Integer batchDeleteExpirationDayIs(Integer expirationDay);
}

@ -119,4 +119,5 @@ public class ShortServerServiceImpl implements ShortServerService {
.map(ShortUrl::getId)
.collect(Collectors.toList()));
}
}

Loading…
Cancel
Save