package com.ruoyi.common.config;
|
|
import com.ruoyi.common.utils.ShortCode;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.stereotype.Component;
|
|
import javax.annotation.PostConstruct;
|
|
/**
|
* 把配置里的外链短码密钥注入 {@link ShortCode}。
|
*
|
* <p>短码算法是"主键 → 6 位"的带密钥双射。密钥只在服务端参与计算,不出现在链接里;
|
* <b>上线后不要修改</b>,否则已发出的 6 位短链无法反解(会回落到 {@code service_out_path.radix}
|
* 兜底,而该列可能已被截断)。配置项缺省时 {@link ShortCode} 使用内置缺省密钥。
|
*
|
* @author smartor
|
*/
|
@Component
|
public class ShortCodeConfig {
|
|
@Value("${shortcode.secret:}")
|
private String secret;
|
|
@PostConstruct
|
public void init() {
|
ShortCode.setSecret(secret);
|
}
|
}
|