-
Notifications
You must be signed in to change notification settings - Fork 0
Release 20250502 #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
527c4cc
feat: add icp info
MistEO b2df80b
fix: icp router
MistEO 391cf5b
fix: error param
MistEO cd8f989
chore: add icp entity
MistEO 17219d6
feat: plan新增字段
MistEO 7c31570
fix: typos
MistEO d37a583
refactor: rft plan API
MistEO a1180b9
feat: 域名根据domain决定
MistEO 548572d
feat: add domain params for icp
MistEO 6f61e04
chore: 更新plan字段
MistEO 4fde712
feat: afdian sku id
MistEO 711f25d
fix: plan typos
MistEO File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,3 +3,5 @@ DATABASE_HOST="127.0.0.1" | |
| DATABASE_PORT=3306 | ||
| DATABASE_USER="" | ||
| DATABASE_PASSWD="" | ||
|
|
||
| STATIC_APP_DIR="/app/static" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,24 @@ | ||
| from fastapi import FastAPI | ||
| from fastapi.staticfiles import StaticFiles | ||
|
|
||
| from src.config import settings | ||
|
|
||
| from src.anno import router as anno_router | ||
| from src.plan import router as plan_router | ||
| from src.plan.summary import router as plan_router | ||
| from src.plan.details import router as plan_details_router | ||
| from src.health_check import router as health_check_router | ||
| from src.project import router as project_router | ||
| from src.ICP import router as icp_router | ||
|
|
||
| app = FastAPI() | ||
|
|
||
| app.mount("/static", StaticFiles(directory="/app/static"), name="static") | ||
| if settings.static_app_dir: | ||
| app.mount("/static", StaticFiles(directory=settings.static_app_dir), name="static") | ||
|
|
||
| app.include_router(anno_router) | ||
| app.include_router(plan_router) | ||
| app.include_router(plan_details_router) | ||
| app.include_router(health_check_router) | ||
| app.include_router(project_router) | ||
| app.include_router(icp_router) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| from fastapi import APIRouter, Request | ||
| from loguru import logger | ||
|
|
||
| from src.database import ICP | ||
|
|
||
| router = APIRouter() | ||
|
|
||
| AllICP = ICP.select() | ||
|
|
||
|
|
||
| @router.get("/icp") | ||
| async def query_icp(domain: str): | ||
| icp = next( | ||
| (icp for icp in AllICP if icp.domain in domain), | ||
| None, | ||
| ) | ||
|
|
||
| if icp is None: | ||
| logger.error(f"domain not found: {domain}") | ||
| return { | ||
| "domain": domain, | ||
| "icp_beian": "", | ||
| "icp_url": "", | ||
| "icp_entity": "", | ||
| } | ||
|
|
||
| return { | ||
| "domain": domain, | ||
| "icp_beian": icp.beian, | ||
| "icp_url": icp.url, | ||
| "icp_entity": icp.entity, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,55 +0,0 @@ | ||
| from datetime import datetime | ||
| from fastapi import APIRouter, Request | ||
| from loguru import logger | ||
| from time import time | ||
|
|
||
| from src.database import Plan | ||
|
|
||
| router = APIRouter() | ||
|
|
||
| CacheExpiration = 60 # 秒 | ||
| plan_cache = None | ||
|
|
||
|
|
||
| @router.get("/plan") | ||
| async def query_anno(type_id: str = "GameTools"): | ||
| logger.debug(f"type_id: {type_id}") | ||
|
|
||
| if not type_id: | ||
| logger.error(f"type_id is required") | ||
| return {"ec": 400, "msg": "type_id is required"} | ||
|
|
||
| now = time() | ||
| global plan_cache | ||
| if not plan_cache or (now - plan_cache[1] > CacheExpiration): | ||
| plan_cache = (Plan.select().where(Plan.available == True).order_by(Plan.plan_index), now) | ||
|
|
||
| data = { | ||
| "home": [], | ||
| "more": [], | ||
| } | ||
|
|
||
| for p in plan_cache[0]: | ||
| if p.type_id == type_id: | ||
| data["home"].append( | ||
| { | ||
| "platform": p.platform, | ||
| "plan_id": p.plan_id, | ||
| "type_id": p.type_id, | ||
| "popular": p.popular, | ||
| } | ||
| ) | ||
| else: | ||
| data["more"].append( | ||
| { | ||
| "platform": p.platform, | ||
| "plan_id": p.plan_id, | ||
| "type_id": p.type_id, | ||
| "popular": p.popular, | ||
| } | ||
| ) | ||
|
|
||
| if not data["home"]: | ||
| data["home"], data["more"] = data["more"], data["home"] | ||
|
|
||
| return {"ec": 200, "data": data} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| from time import time | ||
| from src.database import Plan | ||
|
|
||
| CacheExpiration = 60 # 秒 | ||
| _plan_cache = None | ||
|
|
||
| def get_plan_cache(): | ||
| now = time() | ||
|
|
||
| global _plan_cache | ||
| if not _plan_cache or (now - _plan_cache[1] > CacheExpiration): | ||
| _plan_cache = (Plan.select().order_by(Plan.plan_index), now) | ||
|
|
||
| return _plan_cache[0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| from fastapi import APIRouter | ||
| from loguru import logger | ||
|
|
||
| from .cache import get_plan_cache | ||
|
|
||
| router = APIRouter() | ||
|
|
||
|
|
||
| @router.get("/plan/{plan_id}") | ||
| async def query_details(plan_id: str): | ||
| logger.debug(f"plan_id: {plan_id}") | ||
|
|
||
| if not plan_id: | ||
| logger.error(f"plan_id is required") | ||
| return {"ec": 400, "msg": "plan_id is required"} | ||
|
|
||
| p = next((p for p in get_plan_cache() if p.plan_id == plan_id), None) | ||
| if not p: | ||
| logger.error(f"plan_id not found") | ||
| return {"ec": 404, "msg": "plan_id not found"} | ||
|
|
||
|
|
||
| afdian_info = [s.strip() for s in p.afdian_id.split(",")] | ||
| if len(afdian_info) != 2: | ||
| logger.error(f"afdian_info is invalid") | ||
| return {"ec": 500, "msg": "afdian_info is invalid"} | ||
MistEO marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return { | ||
| "ec": 200, | ||
| "data": { | ||
| "title": p.title, | ||
| "type_id": p.type_id, | ||
| "price": p.price, | ||
| "original_price": p.original_price, | ||
| "popular": p.popular, | ||
| # "afdian_id": p.afdian_id, | ||
| "afdian_info": { | ||
| "plan_id": afdian_info[0], | ||
| "sku_id": afdian_info[1], | ||
| }, | ||
| "yimapay_id": p.yimapay_id, | ||
| }, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| from fastapi import APIRouter | ||
| from loguru import logger | ||
| from time import time | ||
|
|
||
| from .cache import get_plan_cache | ||
|
|
||
| router = APIRouter() | ||
|
|
||
| @router.get("/plan") | ||
| async def query_plan(type_id: str = "GameTools"): | ||
| logger.debug(f"type_id: {type_id}") | ||
|
|
||
| if not type_id: | ||
| logger.error(f"type_id is required") | ||
| return {"ec": 400, "msg": "type_id is required"} | ||
|
|
||
| data = { | ||
| "home": [], | ||
| "more": [], | ||
| } | ||
|
|
||
| for p in get_plan_cache(): | ||
| if not p.available: | ||
| continue | ||
|
|
||
| if p.type_id == type_id: | ||
| data["home"].append( | ||
| { | ||
| "title": p.title, | ||
| "price": p.price, | ||
| "original_price": p.original_price, | ||
| "popular": p.popular, | ||
| "plan_id": p.plan_id, | ||
| } | ||
| ) | ||
| else: | ||
| data["more"].append( | ||
| { | ||
| "title": p.title, | ||
| "price": p.price, | ||
| "original_price": p.original_price, | ||
| "popular": p.popular, | ||
| "plan_id": p.plan_id, | ||
| } | ||
| ) | ||
|
|
||
| if not data["home"]: | ||
| data["home"], data["more"] = data["more"], data["home"] | ||
|
|
||
| return {"ec": 200, "data": data} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.