Class MinIdShortCodeServiceImpl

java.lang.Object
icu.easyj.core.util.shortcode.impls.MinIdShortCodeServiceImpl
All Implemented Interfaces:
IShortCodeService

@LoadLevel(name="min-id", order=50) public class MinIdShortCodeServiceImpl extends Object implements IShortCodeService
long型ID 与 短字符串 互相转换服务

该实现的目的是为了缩短短字符的长度。
按照default的实现,id值越小,生成的短字符串的长度就越短。
可以适当的缩短长度,在短链接码的应用中,缩短几个长度也能减少很多的短信成本。

Author:
wangliang181230
  • Field Details

    • shortCodeService

      protected final IShortCodeService shortCodeService
    • minId

      protected final long minId
  • Constructor Details

    • MinIdShortCodeServiceImpl

      public MinIdShortCodeServiceImpl(IShortCodeService shortCodeService, long minId)
      构造函数
      Parameters:
      shortCodeService - 短字符串服务
      minId - 最小ID
    • MinIdShortCodeServiceImpl

      public MinIdShortCodeServiceImpl(long minId)
  • Method Details

    • toCode

      @NonNull public String toCode(@NonNull Long id)
      Description copied from interface: IShortCodeService
      long型ID 转换为 短字符串
      Specified by:
      toCode in interface IShortCodeService
      Parameters:
      id - ID(必须大于等于0)
      Returns:
      短字符串
    • toId

      public long toId(@NonNull String shortCode)
      Description copied from interface: IShortCodeService
      短字符串 转换为 long长整形ID
      Specified by:
      toId in interface IShortCodeService
      Parameters:
      shortCode - 短字符串
      Returns:
      原ID
    • getShortCodeService

      public IShortCodeService getShortCodeService()
    • getMinId

      public long getMinId()