From 51f04a7224854db2423567ef8249bcd4cc29d230 Mon Sep 17 00:00:00 2001
From: Hatori233 <50367552+Freddd13@users.noreply.github.com>
Date: Mon, 2 Oct 2023 21:26:06 +0800
Subject: [PATCH] feat(route): add freeOnly option for MyMusicSheet (#13450)
* feat: add mymusicsheet route
* Update mymusicsheet route
* fix: missing iso after the price
* docs: add wikipedia page for ISO 4217
* docs: add empty line after MyMusicSheet
* feat: add free sheet retreive option for mymusicsheet-user sheets
* fix: wrong route data in maintainer.js
* fix: wrong route data in maintainer.js
* Update lib/v2/mymusicsheet/templates/description.art
* Update lib/v2/mymusicsheet/templates/description.art
* feat: allow only retrieve free sheets
---------
---
lib/v2/mymusicsheet/maintainer.js | 2 +-
lib/v2/mymusicsheet/router.js | 2 +-
lib/v2/mymusicsheet/usersheets.js | 4 ++--
website/docs/routes/shopping.md | 3 ++-
4 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/v2/mymusicsheet/maintainer.js b/lib/v2/mymusicsheet/maintainer.js
index a9837cb94..6ff5a7a2b 100644
--- a/lib/v2/mymusicsheet/maintainer.js
+++ b/lib/v2/mymusicsheet/maintainer.js
@@ -1,3 +1,3 @@
module.exports = {
- '/user/sheets/:username/:iso?': ['Freddd13'],
+ '/user/sheets/:username/:iso?/:freeOnly?': ['Freddd13'],
};
diff --git a/lib/v2/mymusicsheet/router.js b/lib/v2/mymusicsheet/router.js
index 74a760bcc..5dfbfbae5 100644
--- a/lib/v2/mymusicsheet/router.js
+++ b/lib/v2/mymusicsheet/router.js
@@ -1,3 +1,3 @@
module.exports = (router) => {
- router.get('/user/sheets/:username/:iso?', require('./usersheets'));
+ router.get('/user/sheets/:username/:iso?/:freeOnly?', require('./usersheets'));
};
diff --git a/lib/v2/mymusicsheet/usersheets.js b/lib/v2/mymusicsheet/usersheets.js
index ce4ea7e4b..82cb68ea6 100644
--- a/lib/v2/mymusicsheet/usersheets.js
+++ b/lib/v2/mymusicsheet/usersheets.js
@@ -6,7 +6,7 @@ module.exports = async (ctx) => {
const baseUrl = 'https://www.mymusicsheet.com';
const graphqlUrl = 'https://mms.pd.mapia.io/mms/graphql';
const exchangeRateUrl = 'https://payport.pd.mapia.io/v2/currency';
- const { username, iso = 'CNY' } = ctx.params;
+ const { username, iso = 'CNY', freeOnly } = ctx.params;
const exchangeRateResponse = await got(exchangeRateUrl, {
searchParams: {
@@ -65,7 +65,7 @@ module.exports = async (ctx) => {
orderBy: {
createdAt: 'DESC',
},
- isFree: null,
+ isFree: Boolean(freeOnly),
category: null,
artistUrl: username,
aggregationKeywords: ['PACKAGE_IDS', 'TAG_IDS', 'INSTRUMENTS', 'SHEET_TYPE', 'INCLUDE_CHORD', 'INCLUDE_LYRICS', 'INSTRUMENTATION', 'LEVEL', 'CATEGORY'],
diff --git a/website/docs/routes/shopping.md b/website/docs/routes/shopping.md
index 284a0fa6d..298cec57a 100644
--- a/website/docs/routes/shopping.md
+++ b/website/docs/routes/shopping.md
@@ -272,7 +272,8 @@ Language
### User Sheets {#mymusicsheet-user-sheets}
-
+
+
关于ISO 4217,请参考[维基百科](https://zh.wikipedia.org/zh-cn/ISO_4217#%E7%8E%B0%E8%A1%8C%E4%BB%A3%E7%A0%81)