Commit 5c317aa7 authored by nanahira's avatar nanahira

update

parent 1a90fedf
...@@ -14,6 +14,7 @@ interface Card { ...@@ -14,6 +14,7 @@ interface Card {
interface QueryInfo { interface QueryInfo {
upper: number; upper: number;
lower: number; lower: number;
noFilterAlias: boolean;
where?: Where[]; where?: Where[];
mayIncorrectStatements?: MayIncorrectStatement[]; mayIncorrectStatements?: MayIncorrectStatement[];
} }
...@@ -153,7 +154,7 @@ function getMedianCode(cards: Card[]) { ...@@ -153,7 +154,7 @@ function getMedianCode(cards: Card[]) {
async function queryCards(queryInfo: QueryInfo) { async function queryCards(queryInfo: QueryInfo) {
const whereClauseString = parseWhereClause(queryInfo.where); const whereClauseString = parseWhereClause(queryInfo.where);
const mayIncorrectClauseString = parseMayIncorrectStatements(queryInfo.mayIncorrectStatements); const mayIncorrectClauseString = parseMayIncorrectStatements(queryInfo.mayIncorrectStatements);
const sql = `select datas.id,texts.name from datas,texts where datas.id = texts.id and datas.type & 0x4000 = 0 and datas.id > ? and datas.id <= ? and (datas.alias = 0 or datas.alias - datas.id > 10) ${whereClauseString} ${mayIncorrectClauseString} order by datas.id asc`; const sql = `select datas.id,texts.name from datas,texts where datas.id = texts.id and datas.type & 0x4000 = 0 and datas.id > ? and datas.id <= ? ${queryInfo.noFilterAlias ? "" : "and (datas.alias = 0 or datas.alias - datas.id > 10)"} ${whereClauseString} ${mayIncorrectClauseString} order by datas.id asc`;
console.log(`SQL: ${sql}`); console.log(`SQL: ${sql}`);
const cards: Card[] = await db.all(sql, [queryInfo.lower, queryInfo.upper]); const cards: Card[] = await db.all(sql, [queryInfo.lower, queryInfo.upper]);
return cards; return cards;
......
upper: 100000000 upper: 100000000
lower: 0 lower: 0
noFilterAlias: false
where: where:
- "type & {TYPE_MONSTER} > 0" - "type & {TYPE_MONSTER} > 0"
mayIncorrectStatements: mayIncorrectStatements:
......
...@@ -27,10 +27,12 @@ ...@@ -27,10 +27,12 @@
```yaml ```yaml
upper: 100000000 upper: 100000000
lower: 0 lower: 0
noFilterAlias: false
where: where:
- "type & {TYPE_MONSTER} > 0" - "type & {TYPE_MONSTER} > 0"
mayIncorrectStatements: mayIncorrectStatements:
- incorrectCount: 4 - incorrectCountMin: 4
incorrectCountMax: 4
lessThanOrEqual: true lessThanOrEqual: true
where: where:
- "type & {TYPE_FUSION} = 0" - "type & {TYPE_FUSION} = 0"
...@@ -45,6 +47,8 @@ mayIncorrectStatements: ...@@ -45,6 +47,8 @@ mayIncorrectStatements:
* `lower` 卡号下界,用于二分定卡号。 * `lower` 卡号下界,用于二分定卡号。
* `noFilterAlias` 不过滤异画卡。
* `where` 约束条件,使用 SQL 语句填写,相互之间是 AND 的关系。 * `where` 约束条件,使用 SQL 语句填写,相互之间是 AND 的关系。
### 模糊逻辑 ### 模糊逻辑
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment