提交 | 用户 | 时间
|
722af2
|
1 |
package com.dl.common; |
X |
2 |
|
|
3 |
import com.dl.common.utils.DateUtils; |
|
4 |
import org.springframework.beans.factory.annotation.Autowired; |
|
5 |
import org.springframework.data.redis.core.RedisTemplate; |
|
6 |
import org.springframework.stereotype.Component; |
|
7 |
|
|
8 |
|
|
9 |
@Component |
|
10 |
public class GeneratorNoService { |
|
11 |
@Autowired |
|
12 |
private RedisTemplate redisTemplate; |
|
13 |
|
|
14 |
public String generateNextId(String KEY) { |
|
15 |
Long nextValue = redisTemplate.opsForValue().increment(KEY, 1); |
|
16 |
return String.format(DateUtils.dateNow()+"%03d", nextValue); |
|
17 |
} |
|
18 |
} |