@LoadLevel(name="min-id", order=50) public class MinIdShortCodeServiceImpl extends Object implements IShortCodeService
该实现的目的是为了缩短短字符的长度。
按照default的实现,id值越小,生成的短字符串的长度就越短。
可以适当的缩短长度,在短链接码的应用中,缩短几个长度也能减少很多的短信成本。
| Modifier and Type | Field and Description |
|---|---|
protected long |
minId |
protected IShortCodeService |
shortCodeService |
| Constructor and Description |
|---|
MinIdShortCodeServiceImpl(IShortCodeService shortCodeService,
long minId)
构造函数
|
MinIdShortCodeServiceImpl(long minId) |
| Modifier and Type | Method and Description |
|---|---|
long |
getMinId() |
IShortCodeService |
getShortCodeService() |
String |
toCode(Long id)
long型ID 转换为 短字符串
|
long |
toId(String shortCode)
短字符串 转换为 long长整形ID
|
protected final IShortCodeService shortCodeService
protected final long minId
public MinIdShortCodeServiceImpl(IShortCodeService shortCodeService, long minId)
shortCodeService - 短字符串服务minId - 最小IDpublic MinIdShortCodeServiceImpl(long minId)
@NonNull public String toCode(@NonNull Long id)
IShortCodeServicetoCode in interface IShortCodeServiceid - ID(必须大于等于0)public long toId(@NonNull
String shortCode)
IShortCodeServicetoId in interface IShortCodeServiceshortCode - 短字符串public IShortCodeService getShortCodeService()
public long getMinId()
Copyright © 2021–2022 EasyJ开源社区. All rights reserved.