mirror of
https://github.com/Eyre-S/sekai-scores.git
synced 2024-11-22 11:14:56 +08:00
add database config class in cli. add a function that can get all songs object from songs definition class.
- changed the target database from mysql to postgresql - so the db.table_prefix changed to db.struct. - added getAll on Difficulties type - renamed sekai-scores-db to sekai-meta - add a new resource file, it will be the next song data storage method.
This commit is contained in:
parent
0ad227ac8e
commit
2fd49d2bdb
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@
|
|||||||
build
|
build
|
||||||
|
|
||||||
src/test/java/test/
|
src/test/java/test/
|
||||||
|
*/src/test/java/test/
|
||||||
|
@ -19,7 +19,7 @@ dependencies {
|
|||||||
testImplementation "org.junit.jupiter:junit-jupiter-api:${lib_junit_v}"
|
testImplementation "org.junit.jupiter:junit-jupiter-api:${lib_junit_v}"
|
||||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${lib_junit_v}"
|
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${lib_junit_v}"
|
||||||
|
|
||||||
testImplementation project(":sekai-scores-db")
|
testImplementation project(":sekai-meta")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
## Project Configurations
|
## Project Configurations
|
||||||
|
|
||||||
# Proj Metadata
|
# Proj Metadata
|
||||||
projVersion = 0.4
|
projVersion = 0.5
|
||||||
|
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
@ -15,6 +15,9 @@ dependencies {
|
|||||||
compileOnly "com.github.spotbugs:spotbugs-annotations:${lib_spotbugs_v}"
|
compileOnly "com.github.spotbugs:spotbugs-annotations:${lib_spotbugs_v}"
|
||||||
|
|
||||||
implementation rootProject
|
implementation rootProject
|
||||||
|
implementation project(":sekai-meta")
|
||||||
|
|
||||||
|
implementation "org.postgresql:postgresql:${lib_postgres_driver}"
|
||||||
|
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-api:${lib_junit_v}"
|
testImplementation "org.junit.jupiter:junit-jupiter-api:${lib_junit_v}"
|
||||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${lib_junit_v}"
|
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${lib_junit_v}"
|
||||||
|
@ -2,3 +2,6 @@
|
|||||||
|
|
||||||
# Proj Metadata
|
# Proj Metadata
|
||||||
moduleVersion = 0.5.1
|
moduleVersion = 0.5.1
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
lib_postgres_driver = 42.5.1
|
||||||
|
@ -23,7 +23,7 @@ public class Config {
|
|||||||
@Nonnull public final String db_name;
|
@Nonnull public final String db_name;
|
||||||
@Nonnull public final String db_auth_user;
|
@Nonnull public final String db_auth_user;
|
||||||
@Nonnull public final String db_auth_pwd;
|
@Nonnull public final String db_auth_pwd;
|
||||||
@Nullable public final String db_prefix;
|
@Nullable public final String db_schema;
|
||||||
|
|
||||||
private Config (Properties props) {
|
private Config (Properties props) {
|
||||||
// user config field
|
// user config field
|
||||||
@ -37,8 +37,8 @@ public class Config {
|
|||||||
_debug("config field db.auth.user set: " + this.db_auth_user);
|
_debug("config field db.auth.user set: " + this.db_auth_user);
|
||||||
this.db_auth_pwd = getNonnull(props, "db.auth.password");
|
this.db_auth_pwd = getNonnull(props, "db.auth.password");
|
||||||
_debug("config field db.auth.password set.");
|
_debug("config field db.auth.password set.");
|
||||||
this.db_prefix = props.getProperty("db.table-prefix");
|
this.db_schema = props.getProperty("db.schema");
|
||||||
_debug(this.db_prefix == null ? "config field db.prefix unset." : "config field db.table-prefix set: " + this.db_prefix);
|
_debug(this.db_schema == null ? "config field db.schema unset." : "config field db.schema set: " + this.db_schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -54,7 +54,7 @@ public class Config {
|
|||||||
echo("db.database", db_name);
|
echo("db.database", db_name);
|
||||||
echo("db.auth.user", db_auth_user);
|
echo("db.auth.user", db_auth_user);
|
||||||
echo("db.auth.password", db_auth_pwd);
|
echo("db.auth.password", db_auth_pwd);
|
||||||
echo("db.table-prefix", db_prefix);
|
echo("db.schema", db_schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void echo (String k, String v) {
|
private void echo (String k, String v) {
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
package cc.sukazyo.sekai_cli.db;
|
||||||
|
|
||||||
|
import cc.sukazyo.sekai_cli.Config;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
public class PostgresConfig {
|
||||||
|
|
||||||
|
@Nonnull public final String host;
|
||||||
|
@Nonnull public final String database;
|
||||||
|
@Nullable public final String struct;
|
||||||
|
@Nonnull public final String user;
|
||||||
|
@Nonnull public final String token;
|
||||||
|
|
||||||
|
public PostgresConfig (
|
||||||
|
@Nonnull String host, @Nonnull String database, @Nullable String struct,
|
||||||
|
@Nonnull String user, @Nonnull String token
|
||||||
|
) {
|
||||||
|
this.host = host;
|
||||||
|
this.database = database;
|
||||||
|
this.struct = struct;
|
||||||
|
this.user = user;
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PostgresConfig (Config global) {
|
||||||
|
this(global.db_host, global.db_name, global.db_schema, global.db_auth_user, global.db_auth_pwd);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString () {
|
||||||
|
return String.format("jdbc:postgresql://%s/%s", host, database);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String struct() {
|
||||||
|
return struct == null ? "default" : struct;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Connection connect () throws SQLException {
|
||||||
|
return DriverManager.getConnection(this.toString(), user, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
## Project Configurations
|
## Project Configurations
|
||||||
|
|
||||||
# Proj Metadata
|
# Proj Metadata
|
||||||
moduleVersion = 0.2.1
|
moduleVersion = 0.3
|
@ -1,4 +1,4 @@
|
|||||||
package cc.sukazyo.sekai_scores.db.project_sekai_colorful_stage;
|
package cc.sukazyo.sekai_scores.meta.project_sekai_colorful_stage;
|
||||||
|
|
||||||
import cc.sukazyo.sekai_scores.Difficulty;
|
import cc.sukazyo.sekai_scores.Difficulty;
|
||||||
import cc.sukazyo.sekai_scores.DifficultiesSekai;
|
import cc.sukazyo.sekai_scores.DifficultiesSekai;
|
||||||
@ -7,7 +7,7 @@ import cc.sukazyo.sekai_scores.SongUnit;
|
|||||||
|
|
||||||
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
|
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
|
||||||
|
|
||||||
public class LeoNeed {
|
public class LeoNeed extends SongDefinition {
|
||||||
|
|
||||||
/** <a href="https://www.sekaipedia.org/wiki/Calc.">...</a> */
|
/** <a href="https://www.sekaipedia.org/wiki/Calc.">...</a> */
|
||||||
public static final Song Calc = new Song(
|
public static final Song Calc = new Song(
|
@ -1,4 +1,4 @@
|
|||||||
package cc.sukazyo.sekai_scores.db.project_sekai_colorful_stage;
|
package cc.sukazyo.sekai_scores.meta.project_sekai_colorful_stage;
|
||||||
|
|
||||||
import cc.sukazyo.sekai_scores.Difficulty;
|
import cc.sukazyo.sekai_scores.Difficulty;
|
||||||
import cc.sukazyo.sekai_scores.DifficultiesSekai;
|
import cc.sukazyo.sekai_scores.DifficultiesSekai;
|
||||||
@ -7,7 +7,7 @@ import cc.sukazyo.sekai_scores.SongUnit;
|
|||||||
|
|
||||||
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
|
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
|
||||||
|
|
||||||
public class Nightcord25ji {
|
public class Nightcord25ji extends SongDefinition {
|
||||||
|
|
||||||
/** <a href="https://www.sekaipedia.org/wiki/Kuyamu_to_Kaite_Mirai">...</a> */
|
/** <a href="https://www.sekaipedia.org/wiki/Kuyamu_to_Kaite_Mirai">...</a> */
|
||||||
public static final Song Kuyamu_to_Kaite_Mirai = new Song(
|
public static final Song Kuyamu_to_Kaite_Mirai = new Song(
|
||||||
@ -32,7 +32,7 @@ public class Nightcord25ji {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
/** <a href="https://www.sekaipedia.org/wiki/ID_Smile">...</a> */
|
/** <a href="https://www.sekaipedia.org/wiki/ID_Smile">...</a> */
|
||||||
public static final Song ID_SMILE = new Song(
|
public static final Song ID_Smile = new Song(
|
||||||
116, "アイディスマイル", SongUnit.NIGHTCORD_25JI,
|
116, "アイディスマイル", SongUnit.NIGHTCORD_25JI,
|
||||||
new DifficultiesSekai(
|
new DifficultiesSekai(
|
||||||
new Difficulty( EASY_NAME, 7, 263),
|
new Difficulty( EASY_NAME, 7, 263),
|
@ -1,4 +1,4 @@
|
|||||||
package cc.sukazyo.sekai_scores.db.project_sekai_colorful_stage;
|
package cc.sukazyo.sekai_scores.meta.project_sekai_colorful_stage;
|
||||||
|
|
||||||
import cc.sukazyo.sekai_scores.Difficulty;
|
import cc.sukazyo.sekai_scores.Difficulty;
|
||||||
import cc.sukazyo.sekai_scores.DifficultiesSekai;
|
import cc.sukazyo.sekai_scores.DifficultiesSekai;
|
||||||
@ -7,7 +7,7 @@ import cc.sukazyo.sekai_scores.SongUnit;
|
|||||||
|
|
||||||
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
|
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
|
||||||
|
|
||||||
public class Other {
|
public class Other extends SongDefinition {
|
||||||
|
|
||||||
|
|
||||||
/** <a href="https://www.sekaipedia.org/wiki/Don%27t_Fight_The_Music">...</a> */
|
/** <a href="https://www.sekaipedia.org/wiki/Don%27t_Fight_The_Music">...</a> */
|
@ -1,4 +1,4 @@
|
|||||||
package cc.sukazyo.sekai_scores.db.project_sekai_colorful_stage;
|
package cc.sukazyo.sekai_scores.meta.project_sekai_colorful_stage;
|
||||||
|
|
||||||
import cc.sukazyo.sekai_scores.Difficulty;
|
import cc.sukazyo.sekai_scores.Difficulty;
|
||||||
import cc.sukazyo.sekai_scores.DifficultiesSekai;
|
import cc.sukazyo.sekai_scores.DifficultiesSekai;
|
||||||
@ -7,7 +7,7 @@ import cc.sukazyo.sekai_scores.SongUnit;
|
|||||||
|
|
||||||
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
|
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
|
||||||
|
|
||||||
public class SekaiSpecial {
|
public class SekaiSpecial extends SongDefinition {
|
||||||
|
|
||||||
/** <a href="https://www.sekaipedia.org/wiki/Yoru_ni_Kakeru">...</a> */
|
/** <a href="https://www.sekaipedia.org/wiki/Yoru_ni_Kakeru">...</a> */
|
||||||
public static final Song Yoru_ni_Kakeru = new Song(
|
public static final Song Yoru_ni_Kakeru = new Song(
|
@ -0,0 +1,25 @@
|
|||||||
|
package cc.sukazyo.sekai_scores.meta.project_sekai_colorful_stage;
|
||||||
|
|
||||||
|
import cc.sukazyo.sekai_scores.Song;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class SongDefinition {
|
||||||
|
|
||||||
|
public Song[] songs() {
|
||||||
|
final List<Song> songs = new ArrayList<>();
|
||||||
|
for (Field field : this.getClass().getFields()) {
|
||||||
|
if (field.getType() == Song.class) {
|
||||||
|
try {
|
||||||
|
songs.add((Song)field.get(new Object()));
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return songs.toArray(Song[]::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package cc.sukazyo.sekai_scores.db.project_sekai_colorful_stage;
|
package cc.sukazyo.sekai_scores.meta.project_sekai_colorful_stage;
|
||||||
|
|
||||||
import cc.sukazyo.sekai_scores.Difficulty;
|
import cc.sukazyo.sekai_scores.Difficulty;
|
||||||
import cc.sukazyo.sekai_scores.DifficultiesSekai;
|
import cc.sukazyo.sekai_scores.DifficultiesSekai;
|
||||||
@ -7,7 +7,7 @@ import cc.sukazyo.sekai_scores.SongUnit;
|
|||||||
|
|
||||||
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
|
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
|
||||||
|
|
||||||
public class VSinger {
|
public class VSinger extends SongDefinition {
|
||||||
|
|
||||||
/** <a href="https://www.sekaipedia.org/wiki/Donna_Ketsumatsu_ga_Onozomi_Dai%3F">...</a> */
|
/** <a href="https://www.sekaipedia.org/wiki/Donna_Ketsumatsu_ga_Onozomi_Dai%3F">...</a> */
|
||||||
public static final Song Luka_Luka_Night_Fever = new Song(
|
public static final Song Luka_Luka_Night_Fever = new Song(
|
@ -1,4 +1,4 @@
|
|||||||
package cc.sukazyo.sekai_scores.db.project_sekai_colorful_stage;
|
package cc.sukazyo.sekai_scores.meta.project_sekai_colorful_stage;
|
||||||
|
|
||||||
import cc.sukazyo.sekai_scores.Difficulty;
|
import cc.sukazyo.sekai_scores.Difficulty;
|
||||||
import cc.sukazyo.sekai_scores.DifficultiesSekai;
|
import cc.sukazyo.sekai_scores.DifficultiesSekai;
|
||||||
@ -7,7 +7,7 @@ import cc.sukazyo.sekai_scores.SongUnit;
|
|||||||
|
|
||||||
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
|
import static cc.sukazyo.sekai_scores.DifficultiesSekai.*;
|
||||||
|
|
||||||
public class WonderlandsShowtime {
|
public class WonderlandsShowtime extends SongDefinition {
|
||||||
|
|
||||||
/** <a href="https://www.sekaipedia.org/wiki/Donna_Ketsumatsu_ga_Onozomi_Dai%3F">...</a> */
|
/** <a href="https://www.sekaipedia.org/wiki/Donna_Ketsumatsu_ga_Onozomi_Dai%3F">...</a> */
|
||||||
public static final Song Donna_Ketsumatsu_ga_Onozomi_Dai = new Song(
|
public static final Song Donna_Ketsumatsu_ga_Onozomi_Dai = new Song(
|
17
sekai-meta/src/main/resources/sekai-meta/VSinger.list
Normal file
17
sekai-meta/src/main/resources/sekai-meta/VSinger.list
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
[Tell_Your_World]
|
||||||
|
id=1
|
||||||
|
title=Tell Your World
|
||||||
|
producer=kz
|
||||||
|
arranger=kz
|
||||||
|
composer=kz
|
||||||
|
lyricist=kz
|
||||||
|
commissioned=false
|
||||||
|
bpm=150
|
||||||
|
duration=2:03.3
|
||||||
|
released_date=2019-06-10
|
||||||
|
difficulty.easy=5;220
|
||||||
|
difficulty.normal=10;492
|
||||||
|
difficulty.hard=16;719
|
||||||
|
difficulty.expert=22;961
|
||||||
|
difficulty.master=26;1147
|
@ -1,4 +1,4 @@
|
|||||||
rootProject.name = 'sekai-scores'
|
rootProject.name = 'sekai-scores'
|
||||||
include 'sekai-cli'
|
include 'sekai-cli'
|
||||||
include 'sekai-scores-db'
|
include 'sekai-meta'
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
public interface Difficulties {
|
public interface Difficulties {
|
||||||
|
|
||||||
|
Difficulty[] getAll ();
|
||||||
|
|
||||||
void forEach(@Nonnull Consumer<Difficulty> action);
|
void forEach(@Nonnull Consumer<Difficulty> action);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,11 @@ public record DifficultiesSekai(
|
|||||||
public static final String EXPERT_NAME = "EXPERT";
|
public static final String EXPERT_NAME = "EXPERT";
|
||||||
public static final String MASTER_NAME = "MASTER";
|
public static final String MASTER_NAME = "MASTER";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Difficulty[] getAll () {
|
||||||
|
return new Difficulty[]{easy, normal, hard, expert, master};
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach (@Nonnull Consumer<Difficulty> action) {
|
public void forEach (@Nonnull Consumer<Difficulty> action) {
|
||||||
action.accept(easy);
|
action.accept(easy);
|
||||||
|
Loading…
Reference in New Issue
Block a user