|
|
|
|
@ -4,24 +4,29 @@ import com.quizgenerator.common.Level;
|
|
|
|
|
import com.quizgenerator.entity.User;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import org.springframework.util.DigestUtils;
|
|
|
|
|
|
|
|
|
|
/** 由于数据较少,且不好提交数据库,所以选择写死在代码里面. */
|
|
|
|
|
public class UserDataBase {
|
|
|
|
|
private static final Map<String, User> userDatabase = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
static {
|
|
|
|
|
// 原始密码统一为 "123",现在加密存储
|
|
|
|
|
String encodedPassword = "123";
|
|
|
|
|
encodedPassword = DigestUtils.md5DigestAsHex(encodedPassword.getBytes());
|
|
|
|
|
|
|
|
|
|
// 小学
|
|
|
|
|
userDatabase.put("张三1", new User("张三1", "123", Level.PRIMARY));
|
|
|
|
|
userDatabase.put("张三2", new User("张三2", "123", Level.PRIMARY));
|
|
|
|
|
userDatabase.put("张三3", new User("张三3", "123", Level.PRIMARY));
|
|
|
|
|
userDatabase.put("张三1", new User("张三1", encodedPassword, Level.PRIMARY));
|
|
|
|
|
userDatabase.put("张三2", new User("张三2", encodedPassword, Level.PRIMARY));
|
|
|
|
|
userDatabase.put("张三3", new User("张三3", encodedPassword, Level.PRIMARY));
|
|
|
|
|
// 初中
|
|
|
|
|
userDatabase.put("李四1", new User("李四1", "123", Level.JUNIOR_HIGH));
|
|
|
|
|
userDatabase.put("李四2", new User("李四2", "123", Level.JUNIOR_HIGH));
|
|
|
|
|
userDatabase.put("李四3", new User("李四3", "123", Level.JUNIOR_HIGH));
|
|
|
|
|
userDatabase.put("李四1", new User("李四1", encodedPassword, Level.JUNIOR_HIGH));
|
|
|
|
|
userDatabase.put("李四2", new User("李四2", encodedPassword, Level.JUNIOR_HIGH));
|
|
|
|
|
userDatabase.put("李四3", new User("李四3", encodedPassword, Level.JUNIOR_HIGH));
|
|
|
|
|
// 高中
|
|
|
|
|
userDatabase.put("王五1", new User("王五1", "123", Level.SENIOR_HIGH));
|
|
|
|
|
userDatabase.put("王五2", new User("王五2", "123", Level.SENIOR_HIGH));
|
|
|
|
|
userDatabase.put("王五3", new User("王五3", "123", Level.SENIOR_HIGH));
|
|
|
|
|
userDatabase.put("王五1", new User("王五1", encodedPassword, Level.SENIOR_HIGH));
|
|
|
|
|
userDatabase.put("王五2", new User("王五2", encodedPassword, Level.SENIOR_HIGH));
|
|
|
|
|
userDatabase.put("王五3", new User("王五3", encodedPassword, Level.SENIOR_HIGH));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|