Commit 157cb12a by chizw

[+]增加批量生成短链接口

1 parent 79290f41
......@@ -177,15 +177,15 @@ public class ShortUrlService {
boolean flag;
int count = 0;
do {
if (count > 0) builder.append(URL_DUPLICATED);
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);
if (count > 5) log.warn("{}该链接的短链压缩码生成已重复超过{}次", longUrl, count);
// 返回短链
log.info("短链服务生成短链返回 response:{}", shortUrl);
return shortUrl;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!