diff --git a/scripts/frontend_build.sh b/scripts/frontend_build.sh index 6705bff..ce60930 100755 --- a/scripts/frontend_build.sh +++ b/scripts/frontend_build.sh @@ -73,7 +73,7 @@ frontend_build() { echo_info "Begin frontend build..." cd "${FRONTEND_DIR}" || exit 1 echo_debug "Running command: pnpm install" - pnpm install || exit 1 + pnpm install --no-frozen-lockfile || exit 1 echo_debug "Running command: pnpm build" pnpm build || exit 1 diff --git a/scripts/quick-start.sh b/scripts/quick-start.sh index 092d930..fd851d1 100644 --- a/scripts/quick-start.sh +++ b/scripts/quick-start.sh @@ -872,13 +872,16 @@ write_redis_env() { upgrade_xpack_mcp_market() { exist_container ${XPACK_MCP_MARKET_CONTAINER_NAME} "true" imageName=$(download_package_docker "program.xpack_mcp_market" "true") - run_xpack_mcp_market + run_xpack_mcp_market ${imageName} echo_pass "Upgrade XPACK MCP MARKET success" } run_xpack_mcp_market() { - imageName=$(download_package_docker "program.xpack_mcp_market") + imageName=$1 + if [[ -z ${imageName} ]]; then + imageName=$(download_package_docker "program.xpack_mcp_market") + fi dockerCmd="docker run -dt --name ${XPACK_MCP_MARKET_CONTAINER_NAME} --restart=always --privileged=true \ --network=${NETWORK_NAME} -p ${XPACK_MCP_MARKET_MAP_PORT}:80 \ ${imageName}" diff --git a/scripts/resource/sql/version-1.2.0.sql b/scripts/resource/sql/version-1.2.0.sql index cd0837c..0507e31 100644 --- a/scripts/resource/sql/version-1.2.0.sql +++ b/scripts/resource/sql/version-1.2.0.sql @@ -1,18 +1,16 @@ SET FOREIGN_KEY_CHECKS=0; -CREATE TABLE `resource_group` ( +CREATE TABLE IF NOT EXISTS `resource_group` ( `id` char(36) NOT NULL COMMENT 'Primary key, group UUID', - `uuid` char(36) NOT NULL COMMENT 'Group UUID (explicit field)', `name` varchar(255) NOT NULL COMMENT 'Group name', `description` text NULL COMMENT 'Group description', `enabled` tinyint NOT NULL DEFAULT 1 COMMENT 'Group status: 0=disabled, 1=enabled', `created_at` timestamp NULL DEFAULT NULL, `updated_at` timestamp NULL DEFAULT NULL, - PRIMARY KEY (`id`), - UNIQUE KEY `uk_group_uuid` (`uuid`) + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Resource group table'; -CREATE TABLE `resource_group_service_map` ( +CREATE TABLE IF NOT EXISTS `resource_group_service_map` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'Primary key', `group_id` char(36) NOT NULL COMMENT 'Resource group UUID', `service_id` char(36) NOT NULL COMMENT 'MCP service UUID', @@ -21,6 +19,14 @@ CREATE TABLE `resource_group_service_map` ( UNIQUE KEY `uq_group_service` (`group_id`, `service_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Resource group to MCP service mapping'; +ALTER TABLE `user` ADD `group_id` char(36) NULL COMMENT 'Resource group UUID'; +UPDATE `user` SET `group_id` = 'allow-all' WHERE `group_id` IS NULL; + +INSERT INTO `sys_config` (`id`,`key`, `value`,`description`,`created_at`,`updated_at`) +VALUES ('xpack-resource-group-version','default_resource_group', 'allow-all', 'Default resource group for new users', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) + ON DUPLICATE KEY UPDATE `value` = VALUES(`value`), `description` = VALUES(`description`), `updated_at` = CURRENT_TIMESTAMP; + + INSERT INTO `sys_config` (`id`,`key`, `value`,`description`,`created_at`,`updated_at`) VALUES ('xpack-version','version', '1.2.0', 'Add resource group tables', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`), `description` = VALUES(`description`), `updated_at` = CURRENT_TIMESTAMP; diff --git a/scripts/resource/start.sh b/scripts/resource/start.sh index 96fc5d6..9cef0cb 100755 --- a/scripts/resource/start.sh +++ b/scripts/resource/start.sh @@ -34,11 +34,11 @@ fi # 初始化数据库 python ./init_db.py -nohup uvicorn services.admin_service.main:app --host 0.0.0.0 --port 8001 --reload --timeout-graceful-shutdown 2 --timeout-keep-alive 1 > ${LOG_DIR}/admin_service.log 2>&1 & +nohup uvicorn services.admin_service.main:app --host 0.0.0.0 --port 8001 --timeout-graceful-shutdown 2 --timeout-keep-alive 1 > ${LOG_DIR}/admin_service.log 2>&1 & sleep 5s -nohup uvicorn services.api_service.main:app --host 0.0.0.0 --port 8002 --reload --timeout-graceful-shutdown 2 --timeout-keep-alive 1 > ${LOG_DIR}/api_service.log 2>&1 & +nohup uvicorn services.api_service.main:app --host 0.0.0.0 --port 8002 --timeout-graceful-shutdown 2 --timeout-keep-alive 1 > ${LOG_DIR}/api_service.log 2>&1 & HOSTNAME="" cd frontend/ && nohup node server.js> ${LOG_DIR}//frontend.log 2>&1 & diff --git a/scripts/version.json b/scripts/version.json index 841d413..350e4b2 100644 --- a/scripts/version.json +++ b/scripts/version.json @@ -1,11 +1,11 @@ { - "version": "v1.1", - "releaseDate": "2025-12-07", + "version": "v1.2", + "releaseDate": "2025-12-22", "description": "This is the latest release of the application.", "downloads": { "program": { "xpack_mcp_market": { - "version": "v1.1.5", + "version": "v1.2.1", "docker": "xpackai/xpack-mcp-market", "tar": "xpack-mcp-market.tar.gz", "url": "https://public.eolinker.com/xpack/images/xpack-mcp-market.${VERSION}.${ARCH}.tar.gz" diff --git a/services/admin_service/controllers/mcp_manager.py b/services/admin_service/controllers/mcp_manager.py index c8993e9..b413122 100644 --- a/services/admin_service/controllers/mcp_manager.py +++ b/services/admin_service/controllers/mcp_manager.py @@ -223,11 +223,7 @@ def get_mcp_service_list( "slug_name": service.slug_name, "short_description": service.short_description, "long_description": service.long_description, - # "auth_method": service.auth_method.value if service.auth_method else None, "base_url": service.base_url, - # "headers": json.loads(service.headers) if service.headers else [], - # "auth_header": service.auth_header, - # "auth_token": service.auth_token, "charge_type": service.charge_type.value if service.charge_type else None, "price": str(float(service.price)) if service.price and service.charge_type == ChargeType.PER_CALL else "0.00", "input_token_price": str(float(service.input_token_price)) if service.input_token_price and service.charge_type == ChargeType.PER_TOKEN else "0.00", @@ -274,6 +270,20 @@ def get_mcp_service_simple_list( logger.error(f"Failed to get service simple list: {str(e)}") return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR) +@router.get("/service/tags", summary="Get MCP service tags") +def get_mcp_service_tags( + request: Request, + mcp_manager_service: McpManagerService = Depends(get_mcp_manager), +): + if not UserUtils.is_admin(request): + return ResponseUtils.error(error_msg=error_msg.NO_PERMISSION) + try: + tags = mcp_manager_service.get_tags_list(enabled_only=False) + return ResponseUtils.success(data=tags) + except Exception as e: + logger.error(f"Failed to get service tags: {str(e)}") + return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR) + @router.get("/service/resource_group/list", summary="Get MCP service's resource group list") def get_mcp_service_resource_group_list( request: Request, @@ -364,4 +374,4 @@ def unbind_group( return ResponseUtils.success() except Exception as e: logger.error(f"Failed to unbind resource groups: {str(e)}") - return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR) \ No newline at end of file + return ResponseUtils.error(error_msg=error_msg.INTERNAL_ERROR) diff --git a/services/admin_service/controllers/order.py b/services/admin_service/controllers/order.py index 34d8821..fe900b9 100644 --- a/services/admin_service/controllers/order.py +++ b/services/admin_service/controllers/order.py @@ -1,4 +1,7 @@ +from os import stat +from typing import Optional, List from fastapi import APIRouter, Depends, Query +from services.common.models.user_wallet_history import TransactionType from sqlalchemy import table from sqlalchemy.orm import Session from services.common.database import get_db @@ -52,3 +55,63 @@ def get_user_order_list( ) return ResponseUtils.success_page(data=result, total=total, page_num=page, page_size=page_size) + +@router.get("/list/by_user", summary="Get user order list by user id") +def get_user_order_list_by_user_id( + user_id: str = Query(..., description="User ID"), + page: int = Query(1, description="Current page number"), + page_size: int = Query(15, description="Number of items per page"), + order_type: Optional[str] = Query(None, description="Order type"), + status: Optional[str] = Query(None, description="Order status"), + user_service: UserService = Depends(get_user_service), + user_wallet_history_service: UserWalletHistoryService = Depends(get_user_wallet_history_service), +): + """Get paginated list of user order history by user id.""" + user = user_service.get_by_id(user_id) + if not user: + return ResponseUtils.error(message="not found user", code=404) + offset = (page - 1) * page_size + order_type_list = [] + if order_type: + # 将字符串转成列表,中间使用逗号分隔 + ots = order_type.split(",") + for ot in ots: + ot = ot.strip() + if ot == "purchase": + order_type_list.append("api_call") + elif ot == "recharge": + order_type_list.append("deposit") + else: + order_type_list.append(ot) + status_list: Optional[List[int]] = [] + if status: + sl = status.split(",") + for s in sl: + status_list.append(int(s.strip())) + total, orders = user_wallet_history_service.success_order_list_by_user(user_id, offset, page_size, order_type_list, status_list) + if not orders: + return ResponseUtils.success_page(data=[], total=total, page_num=page, page_size=page_size) + result = [] + for order in orders: + confirm_at = "" + if order.status == 1: + confirm_at = order.updated_at + for order in orders: + info = { + "id": order.id, + "user_id": order.user_id, + "order_id": order.transaction_id, + "payment_type": order.payment_method, + "payment_state": order.status, + "amount": order.amount, + "create_at": order.created_at, + "confirm_at": confirm_at, + } + if order.type == TransactionType.API_CALL: + info["order_type"] = "purchase" + elif order.type == TransactionType.DEPOSIT: + info["order_type"] = "recharge" + else: + info["order_type"] = order.type + result.append(info) + return ResponseUtils.success_page(data=result, total=total, page_num=page, page_size=page_size) \ No newline at end of file diff --git a/services/admin_service/controllers/sys_config.py b/services/admin_service/controllers/sys_config.py index bf3b0c4..d2ac13d 100644 --- a/services/admin_service/controllers/sys_config.py +++ b/services/admin_service/controllers/sys_config.py @@ -241,8 +241,7 @@ def set_sysconfig( email_smtp_password = email_config.get("smtp_password") email_smtp_sender = email_config.get("smtp_sender") - if not domain: - # 正则检查domain格式 + if domain: try: domain = ValidationUtils.validate_domain(domain) except ValidationException as e: diff --git a/services/admin_service/controllers/user.py b/services/admin_service/controllers/user.py index e9806b5..73e102b 100644 --- a/services/admin_service/controllers/user.py +++ b/services/admin_service/controllers/user.py @@ -1,4 +1,4 @@ -from fastapi import APIRouter, Depends, Request,Body +from fastapi import APIRouter, Depends, Request,Body,Query from sqlalchemy.orm import Session from services.common.database import get_db from services.admin_service.constants.user_task import user_task_ids @@ -10,6 +10,9 @@ from services.admin_service.services.user_wallet_service import UserWalletServic from services.admin_service.services.user_task_service import UserTaskService from services.admin_service.services.auth_service import AuthService from services.admin_service.services.resource_group_service import ResourceGroupService +from services.admin_service.services.user_wallet_history_service import UserWalletHistoryService +from services.common.models.user_wallet_history import TransactionType +from typing import Optional,List router = APIRouter() @@ -27,6 +30,9 @@ def get_user_task_service(db: Session = Depends(get_db)) -> UserTaskService: def get_resource_group_service(db: Session = Depends(get_db)) -> ResourceGroupService: return ResourceGroupService(db) +def get_order_service(db: Session = Depends(get_db)) -> UserWalletHistoryService: + return UserWalletHistoryService(db) + @router.get("/info", response_model=dict) def get_user(request: Request, user_wallet: UserWalletService = Depends(get_user_wallet), user_task: UserTaskService = Depends(get_user_task_service), resource_group_service: ResourceGroupService = Depends(get_resource_group_service)): """Get current user information and wallet balance.""" @@ -46,7 +52,6 @@ def get_user(request: Request, user_wallet: UserWalletService = Depends(get_user elif user.group_id == "deny-all": user_response.allow_all = False else: - print("user group id is:",user.group_id) service_ids = resource_group_service.get_bind_service_ids(user.group_id) user_response.service_ids = service_ids user_response.user_id = user.id @@ -88,3 +93,61 @@ def update_password( return ResponseUtils.error(message="not found user", code=404) +@router.get("/order/list", summary="Get order list") +def get_order_list( + request: Request, + page: int = Query(1, description="Current page number"), + page_size: int = Query(15, description="Number of items per page"), + order_type: Optional[str] = Query(None, description="Order type"), + status: Optional[str] = Query(None, description="Order status"), + user_wallet_history_service: UserWalletHistoryService = Depends(get_order_service), +): + """Get order list.""" + user = UserUtils.get_request_user(request) + if not user: + return ResponseUtils.error(message="not found user", code=404) + offset = (page - 1) * page_size + order_type_list = [] + if order_type: + # 将字符串转成列表,中间使用逗号分隔 + ots = order_type.split(",") + for ot in ots: + ot = ot.strip() + if ot == "purchase": + order_type_list.append("api_call") + elif ot == "recharge": + order_type_list.append("deposit") + else: + order_type_list.append(ot) + status_list: Optional[List[int]] = [] + if status: + sl = status.split(",") + for s in sl: + status_list.append(int(s.strip())) + total, orders = user_wallet_history_service.success_order_list_by_user(user.id, offset, page_size, order_type_list, status_list) + if not orders: + return ResponseUtils.success_page(data=[], total=total, page_num=page, page_size=page_size) + result = [] + for order in orders: + confirm_at = "" + if order.status == 1: + confirm_at = order.updated_at + for order in orders: + info = { + "id": order.id, + "user_id": order.user_id, + "order_id": order.transaction_id, + "payment_type": order.payment_method, + "payment_state": order.status, + "amount": order.amount, + "create_at": order.created_at, + "confirm_at": confirm_at, + } + if order.type == TransactionType.API_CALL: + info["order_type"] = "purchase" + elif order.type == TransactionType.DEPOSIT: + info["order_type"] = "recharge" + else: + info["order_type"] = order.type + result.append(info) + return ResponseUtils.success_page(data=result, total=total, page_num=page, page_size=page_size) \ No newline at end of file diff --git a/services/admin_service/controllers/user_manager.py b/services/admin_service/controllers/user_manager.py index 76d2cd6..24bc0c6 100644 --- a/services/admin_service/controllers/user_manager.py +++ b/services/admin_service/controllers/user_manager.py @@ -132,7 +132,6 @@ async def recharge_balance( # calculate md5 hash of the body and timestamp md5_hash = hashlib.md5(f"{timestamp}{body_str}".encode('utf-8')).hexdigest() calculated_sign = hashlib.sha256(md5_hash.encode('utf-8')).hexdigest() - print(f"sign: {sign}, calculated_sign: {calculated_sign},md5_hash: {md5_hash}") if sign != calculated_sign: return ResponseUtils.error(message="Invalid signature") try: @@ -147,7 +146,6 @@ async def recharge_balance( transaction_id = hashlib.md5(f"{timestamp}{user_id}{balance}{typ}".encode('utf-8')).hexdigest() if payment_service.check_transaction_id_exists(transaction_id): return ResponseUtils.error(message="Transaction ID already exists") - print(f"user_id: {user_id}, amount: {balance}, typ: {typ}, transaction_id: {transaction_id}") success = payment_service.platform_payment(user_id=user_id, amount=balance, typ=typ, transaction_id=transaction_id) if not success: return ResponseUtils.error(message="Failed to recharge wallet balance") diff --git a/services/admin_service/controllers/web.py b/services/admin_service/controllers/web.py index a5f8b47..36e48e4 100644 --- a/services/admin_service/controllers/web.py +++ b/services/admin_service/controllers/web.py @@ -29,6 +29,7 @@ def get_public_mcp_services( keyword: Optional[str] = Query(None, description="Search keyword"), page: Optional[int] = Query(1, description="Page number (starts from 1)"), page_size: Optional[int] = Query(10, description="Page size (default 10)"), + tag: Optional[str] = Query(None, description="Filter by tag"), mcp_manager_service: McpManagerService = Depends(get_mcp_manager), ): """Get paginated list of public MCP services with keyword search.""" @@ -43,12 +44,19 @@ def get_public_mcp_services( # Get service list - let any exception bubble up to middleware service_list, total = mcp_manager_service.get_public_services_paginated( - keyword=search_keyword, page=validated_page, page_size=validated_page_size + keyword=search_keyword, page=validated_page, page_size=validated_page_size, tag=tag ) logger.info(f"Successfully retrieved {len(service_list)} services") return ResponseUtils.success_page(data=service_list, page_num=validated_page, page_size=validated_page_size, total=total) +@router.get("/mcp_tags", summary="Get public MCP tags list") +def get_public_mcp_tags( + mcp_manager_service: McpManagerService = Depends(get_mcp_manager), +): + tags = mcp_manager_service.get_tags_list(enabled_only=True) + return ResponseUtils.success(data=tags) + @router.get("/mcp_service_info", summary="Get public MCP service information") def get_public_mcp_service_info( diff --git a/services/admin_service/repositories/mcp_service_repository.py b/services/admin_service/repositories/mcp_service_repository.py index 98c33eb..3a8e713 100644 --- a/services/admin_service/repositories/mcp_service_repository.py +++ b/services/admin_service/repositories/mcp_service_repository.py @@ -1,4 +1,5 @@ from datetime import datetime, timezone +from sqlalchemy import func from sqlalchemy.orm import Session from services.common.models.mcp_service import McpService from typing import Optional, Tuple, List @@ -103,7 +104,7 @@ class McpServiceRepository: self.db.refresh(mcp_service) return mcp_service - def get_public_services_paginated(self, keyword: str, page: int = 1, page_size: int = 10) -> Tuple[List[McpService], int]: + def get_public_services_paginated(self, keyword: str, page: int = 1, page_size: int = 10, tag: Optional[str] = None) -> Tuple[List[McpService], int]: """Get public service list with pagination, supports keyword search""" offset = (page - 1) * page_size @@ -112,9 +113,21 @@ class McpServiceRepository: if keyword: keyword = f"%{keyword}%" query = query.filter((McpService.name.like(keyword)) | (McpService.short_description.like(keyword))) + if tag: + normalized_tag = tag.strip() + if normalized_tag: + normalized_tags = func.replace(func.replace(McpService.tags, ", ", ","), " ,", ",") + query = query.filter(func.find_in_set(normalized_tag, normalized_tags) > 0) + total = query.count() services = query.order_by(McpService.created_at.desc()).offset(offset).limit(page_size).all() return services, total + + def get_tags_strings(self, enabled_only: bool = False) -> List[str]: + query = self.db.query(McpService.tags).filter(McpService.tags.isnot(None)).filter(McpService.tags != "") + if enabled_only: + query = query.filter(McpService.enabled == 1) + return [row[0] for row in query.all() if row and row[0]] diff --git a/services/admin_service/repositories/resource_group_service_map_repository.py b/services/admin_service/repositories/resource_group_service_map_repository.py index a749629..e0b4ddc 100644 --- a/services/admin_service/repositories/resource_group_service_map_repository.py +++ b/services/admin_service/repositories/resource_group_service_map_repository.py @@ -91,7 +91,7 @@ class ResourceGroupServiceMapRepository: return [r.service_id for r in groups], total def list_service_ids(self, group_id: str) -> List[str]: - return [r.service_id for r in self.db.query(ResourceGroupServiceMap.service_id).filter(ResourceGroupServiceMap.group_id == group_id).all()] + return [r.service_id for r in self.db.query(ResourceGroupServiceMap.service_id).order_by(ResourceGroupServiceMap.created_at.desc()).filter(ResourceGroupServiceMap.group_id == group_id).all()] def list_group_ids(self, service_id: str) -> List[str]: return [r.group_id for r in self.db.query(ResourceGroupServiceMap.group_id).filter(ResourceGroupServiceMap.service_id == service_id).all()] diff --git a/services/admin_service/repositories/user_wallet_history_repository.py b/services/admin_service/repositories/user_wallet_history_repository.py index d47cc95..0da9b47 100644 --- a/services/admin_service/repositories/user_wallet_history_repository.py +++ b/services/admin_service/repositories/user_wallet_history_repository.py @@ -242,8 +242,8 @@ class UserWalletHistoryRepository: .all() ) return total, history - - def get_by_id(self, history_id: str) -> Optional[UserWalletHistory]: + + def success_order_list_by_user(self, user_id: str, offset: int, limit: int, order_type: Optional[List[str]] = None, status: Optional[List[int]] = None) -> Tuple[int, List[UserWalletHistory]]: """ Get user wallet history record by ID. @@ -253,7 +253,25 @@ class UserWalletHistoryRepository: Returns: Optional[UserWalletHistory]: UserWalletHistory object or None """ - return self.db.query(UserWalletHistory).filter(UserWalletHistory.id == history_id).first() + + query = self.db.query(UserWalletHistory).filter( + UserWalletHistory.user_id == user_id, + ) + if order_type and len(order_type) > 0: + query = query.filter(UserWalletHistory.type.in_(order_type)) + if status and len(status) > 0: + query = query.filter(UserWalletHistory.status.in_(status)) + total = query.count() + if total < offset: + return total, [] + history = ( + query + .order_by(UserWalletHistory.created_at.desc()) + .offset(offset) + .limit(limit) + .all() + ) + return total, history def add_consume_record(self, wallet_history: UserWalletHistory) -> Optional[UserWalletHistory]: """ diff --git a/services/admin_service/services/mcp_manager_service.py b/services/admin_service/services/mcp_manager_service.py index 67655ff..e40f654 100644 --- a/services/admin_service/services/mcp_manager_service.py +++ b/services/admin_service/services/mcp_manager_service.py @@ -329,6 +329,31 @@ class McpManagerService: """Get service list with pagination""" return self.mcp_service_repository.get_all_paginated(page=page, page_size=page_size) + def get_tags_list(self, enabled_only: bool = False) -> List[str]: + tags_strings = self.mcp_service_repository.get_tags_strings(enabled_only=enabled_only) + tag_counts: dict[str, int] = {} + canonical: dict[str, str] = {} + + for tags_str in tags_strings: + normalized_in_service: set[str] = set() + for tag in parse_tags_to_array(tags_str): + normalized = tag.casefold() + if not normalized: + continue + if normalized in normalized_in_service: + continue + normalized_in_service.add(normalized) + canonical.setdefault(normalized, tag) + + for normalized in normalized_in_service: + tag_counts[normalized] = tag_counts.get(normalized, 0) + 1 + + sorted_normalized = sorted( + tag_counts.keys(), + key=lambda normalized: (-tag_counts[normalized], canonical[normalized].casefold()), + ) + return [canonical[normalized] for normalized in sorted_normalized] + def create_service_from_openapi(self, openapi_data: OpenApiForAI) -> str: # Convert OpenApiForAI info to McpService object and McpToolApi object list, return service ID or exception. try: @@ -488,9 +513,9 @@ class McpManagerService: logger.error(f"Failed to update service from OpenAPI: {str(e)}") raise ValueError(f"Failed to update service from OpenAPI.") - def get_public_services_paginated(self, keyword: str, page: int = 1, page_size: int = 10) -> Tuple[List[dict], int]: + def get_public_services_paginated(self, keyword: str, page: int = 1, page_size: int = 10, tag: Optional[str] = None) -> Tuple[List[dict], int]: """Get public services list with pagination, returns formatted data with API info""" - services, total = self.mcp_service_repository.get_public_services_paginated(keyword, page, page_size) + services, total = self.mcp_service_repository.get_public_services_paginated(keyword, page, page_size, tag) service_list = [] for service in services: diff --git a/services/admin_service/services/resource_group_service.py b/services/admin_service/services/resource_group_service.py index d6bb1fb..323e4bc 100644 --- a/services/admin_service/services/resource_group_service.py +++ b/services/admin_service/services/resource_group_service.py @@ -306,6 +306,7 @@ class ResourceGroupService: for s in services ],total if keyword: + services = self.mcp_repo.get_all(keyword=keyword) if not services: return [],0 @@ -334,6 +335,7 @@ class ResourceGroupService: else: sids,total = self.map_repo.list_service_ids_paginated(gid, page=page, page_size=page_size) services = self.mcp_repo.get_by_ids(ids=sids) + service_map = {s.id: s for s in services} return [ { "id": s.id, @@ -351,7 +353,7 @@ class ResourceGroupService: "created_at": str(s.created_at) if s.created_at else None, "updated_at": str(s.updated_at) if s.updated_at else None, } - for s in services + for s in (service_map[sid] for sid in sids) ],total def get_unbind_services(self, gid: str) -> List[dict]: if gid == "deny-all" or gid == "allow-all": diff --git a/services/admin_service/services/user_wallet_history_service.py b/services/admin_service/services/user_wallet_history_service.py index caf9a31..85f2556 100644 --- a/services/admin_service/services/user_wallet_history_service.py +++ b/services/admin_service/services/user_wallet_history_service.py @@ -18,6 +18,9 @@ class UserWalletHistoryService: def success_deposit_order_list(self, offset: int, limit: int) -> Tuple[int, List[UserWalletHistory]]: return self.user_wallet_history_repository.success_deposit_order_list(offset, limit) + def success_order_list_by_user(self, user_id: str, offset: int, limit: int, order_type: Optional[List[str]] = None, status: Optional[List[int]] = None) -> Tuple[int, List[UserWalletHistory]]: + return self.user_wallet_history_repository.success_order_list_by_user(user_id, offset, limit, order_type, status) + def order_list(self, payment_method: str, status: int, start: Optional[datetime] = None, end: Optional[datetime] = None) -> List[UserWalletHistory]: return self.user_wallet_history_repository.order_list(payment_method, status, start, end) diff --git a/services/common/config.py b/services/common/config.py index ff8b7ae..6dc19e6 100644 --- a/services/common/config.py +++ b/services/common/config.py @@ -58,6 +58,7 @@ class Config: "/api/auth/account/sign", "/api/auth/email/send_captcha", "/api/auth/google/sign", + "/api/web/mcp_tags", "/api/web/mcp_services", "/api/web/mcp_service_info", "/api/payment/callback_stripe",