切换腾讯云数据库
This commit is contained in:
parent
ac6a65fbaf
commit
be75d8d3fa
@ -21,7 +21,8 @@ COPY requirements.txt .
|
|||||||
COPY app app/
|
COPY app app/
|
||||||
|
|
||||||
# 安装Python依赖
|
# 安装Python依赖
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt \
|
||||||
|
&& pip install --no-cache-dir uvicorn
|
||||||
|
|
||||||
# 暴露端口
|
# 暴露端口
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from typing import List, Optional
|
from typing import List, Optional, Dict, Any
|
||||||
from sqlalchemy import text
|
from sqlalchemy import text
|
||||||
from app.models.merchant import (
|
from app.models.merchant import (
|
||||||
MerchantDB,
|
MerchantDB,
|
||||||
@ -127,16 +127,22 @@ async def list_merchants(
|
|||||||
text("distance")
|
text("distance")
|
||||||
).offset(skip).limit(limit).all()
|
).offset(skip).limit(limit).all()
|
||||||
|
|
||||||
return success_response(data=[{
|
merchant_list = [{
|
||||||
**MerchantInfo.model_validate(m[0]).model_dump(),
|
**MerchantInfo.model_validate(m[0]).model_dump(),
|
||||||
"distance": round(m[1]) # 四舍五入到整数米
|
"distance": round(m[1]) # 四舍五入到整数米
|
||||||
} for m in merchants])
|
} for m in merchants]
|
||||||
else:
|
else:
|
||||||
# 如果没有提供经纬度,按创建时间排序
|
# 如果没有提供经纬度,按创建时间排序
|
||||||
merchants = db.query(MerchantDB).order_by(
|
merchants = db.query(MerchantDB).order_by(
|
||||||
MerchantDB.create_time.desc()
|
MerchantDB.create_time.desc()
|
||||||
).offset(skip).limit(limit).all()
|
).offset(skip).limit(limit).all()
|
||||||
|
|
||||||
return success_response(data=[
|
merchant_list = [MerchantInfo.model_validate(m) for m in merchants]
|
||||||
MerchantInfo.model_validate(m) for m in merchants
|
|
||||||
])
|
# 获取总数
|
||||||
|
total = db.query(MerchantDB).count()
|
||||||
|
|
||||||
|
return success_response(data={
|
||||||
|
"total": total,
|
||||||
|
"items": merchant_list
|
||||||
|
})
|
||||||
@ -27,11 +27,18 @@ class Settings(BaseSettings):
|
|||||||
UNI_SMS_SIGN: str = "BAISIJI" # 短信签名
|
UNI_SMS_SIGN: str = "BAISIJI" # 短信签名
|
||||||
|
|
||||||
# MySQL配置
|
# MySQL配置
|
||||||
MYSQL_HOST: str = "101.36.120.145"
|
# MYSQL_HOST: str = "101.36.120.145"
|
||||||
MYSQL_PORT: int = 3306
|
# MYSQL_PORT: int = 3306
|
||||||
|
# MYSQL_USER: str = "root"
|
||||||
|
# MYSQL_PASSWORD: str = "mariadb_4rMwpT"
|
||||||
|
# MYSQL_DB: str = "deliveryman"
|
||||||
|
|
||||||
|
MYSQL_HOST: str = "gz-cynosdbmysql-grp-2j1cnopr.sql.tencentcdb.com"
|
||||||
|
MYSQL_PORT: int = 27469
|
||||||
MYSQL_USER: str = "root"
|
MYSQL_USER: str = "root"
|
||||||
MYSQL_PASSWORD: str = "mariadb_4rMwpT"
|
MYSQL_PASSWORD: str = "Aa#223388"
|
||||||
MYSQL_DB: str = "deliveryman"
|
MYSQL_DB: str = "beefastapp"
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def SQLALCHEMY_DATABASE_URL(self) -> str:
|
def SQLALCHEMY_DATABASE_URL(self) -> str:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user