123
This commit is contained in:
@@ -12,4 +12,6 @@ import com.ruoyi.cai.domain.UserCodeGen;
|
|||||||
public interface UserCodeGenService extends IService<UserCodeGen> {
|
public interface UserCodeGenService extends IService<UserCodeGen> {
|
||||||
|
|
||||||
String getCodeGen();
|
String getCodeGen();
|
||||||
|
|
||||||
|
String getCodeGenRandom();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.ruoyi.cai.service.impl;
|
package com.ruoyi.cai.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.ruoyi.cai.domain.UserCodeGen;
|
import com.ruoyi.cai.domain.UserCodeGen;
|
||||||
import com.ruoyi.cai.mapper.UserCodeGenMapper;
|
import com.ruoyi.cai.mapper.UserCodeGenMapper;
|
||||||
@@ -27,8 +26,16 @@ public class UserCodeGenServiceImpl extends ServiceImpl<UserCodeGenMapper, UserC
|
|||||||
|
|
||||||
private final Random random = new Random();
|
private final Random random = new Random();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCodeGen() {
|
public String getCodeGen(){
|
||||||
|
UserCodeGen gen = new UserCodeGen();
|
||||||
|
this.save(gen);
|
||||||
|
return gen.getId()+"";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCodeGenRandom() {
|
||||||
// 使用数据库唯一索引保证不重复 + 随机生成
|
// 使用数据库唯一索引保证不重复 + 随机生成
|
||||||
for (int i = 0; i < MAX_RETRY_COUNT; i++) {
|
for (int i = 0; i < MAX_RETRY_COUNT; i++) {
|
||||||
// 生成随机用户号
|
// 生成随机用户号
|
||||||
|
|||||||
Reference in New Issue
Block a user