liusheng
7 天以前 da1db3c859e25d796d1030cc61f2c3023be53031
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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);
    }
}