Resource group service list sorted in descending order of creation time
This commit is contained in:
1 parent
8abc7469cd
commit
dab04242e6
7 files changed
+15
-14
No files matched your search
@@ -2,14 +2,12 @@ SET FOREIGN_KEY_CHECKS=0;
|
||||
|
||||
CREATE TABLE `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`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Resource group table';
|
||||
|
||||
CREATE TABLE `resource_group_service_map` (
|
||||
@@ -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;
|
||||
|
||||
@@ -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.0",
|
||||
"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"
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -46,7 +46,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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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()]
|
||||
|
||||
@@ -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":
|
||||
|
||||
Reference in new issue
Block a user