当前位置: 首页 > news >正文

做新零售这些注册网站和找货源6西宁网站建设优化案例

做新零售这些注册网站和找货源6,西宁网站建设优化案例,纯静态网站怎么做cdn,云主机可以做几个网站说明#xff1a; 应用Pydantic Model 验证/出入 数据#xff0c; SqlAlchemy Model数据实体#xff0c;Fastapi提供API机制支持。数据表的坐标字段采用Mysql的GEOMETRY类型目前还没成功使用Pydantic的Coordinate类型#xff0c;待后续改良 要点#xff1a; 输出的结果是…说明 应用Pydantic Model 验证/出入 数据 SqlAlchemy Model数据实体Fastapi提供API机制支持。数据表的坐标字段采用Mysql的GEOMETRY类型目前还没成功使用Pydantic的Coordinate类型待后续改良 要点 输出的结果是DeviceLocationSimpleOut模型里面的验证/转换方法需通过否则不能录入成功 设计 建表sql /**/ /* Table: ia_iot_device_location */ /**/ create table ia_iot_device_location (id bigint not null auto_increment comment ,iot_device_id bigint default 0 comment ,label varchar(255) comment ,coordinates GEOMETRY not null comment 地理坐标,create_datetime datetime not null default CURRENT_TIMESTAMP comment 创建时间,update_datetime datetime not null default CURRENT_TIMESTAMP comment 更新时间,delete_datetime datetime comment ,is_delete tinyint not null default 0 comment ,primary key (id) );/**/ /* Index: Index_1 */ /**/ create index Index_1 on ia_iot_device_location (iot_device_id );/**/ /* Index: Index_2 */ /**/ create SPATIAL index Index_2 on ia_iot_device_location (coordinates );Pydantic Model (apps\vadmin\iot\schemas\DeviceLocation.py) #!/usr/bin/python # -*- coding: utf-8 -*- # version : 1.0 # Create Time : 2024/05/22 20:45 # File : Device.py # IDE : PyCharm # desc : pydantic 模型用于数据库序列化操作from pydantic import BaseModel, Field, ConfigDict, ValidationError, validator, field_validator, constr from core.data_types import DatetimeStr from datetime import datetime, timezone, timedelta from apps.vadmin.iot.models.data_types import * from apps.vadmin.iot.utils import utils from application import settings from pydantic_extra_types.coordinate import Coordinate from geoalchemy2.shape import to_shapeclass DeviceLocation(BaseModel):label: str | None Field(None, title标签)iot_device_id: int | None Field(..., titleNone)# coordinates: Coordinate | None Field(..., title地理坐标)coordinates: str | None Field(..., title地理坐标)class DeviceLocationSimpleIn(DeviceLocation):passclass DeviceLocationSimpleOut(DeviceLocation):model_config ConfigDict(from_attributesTrue)id: int Field(..., title编号)create_datetime: DatetimeStr Field(..., title创建时间)update_datetime: DatetimeStr Field(..., title更新时间)validator(create_datetime, update_datetime, preTrue)def convert_utc_to_local(cls, value):return utils.convert_utc_to_local(value)field_validator(coordinates, modebefore)def turn_coordinates_into_wkt(cls, value):return to_shape(value).wkt SqlAlchemy Model (apps\vadmin\iot\models\models.py) from typing import List, Optional from datetime import datetime from sqlalchemy import BigInteger, Column, DateTime, ForeignKey, ForeignKeyConstraint, Index, Integer, String, Table, Text, text from sqlalchemy.dialects.mysql import TINYINT from sqlalchemy.orm import Mapped, declarative_base, mapped_column, relationship from sqlalchemy.orm.base import Mapped from geoalchemy2 import Geometry, WKBElement from sqlalchemy.orm import relationship, Mapped, mapped_column from db.db_base import BaseModel from .data_types import DeviceType import uuid import secretsmetadata BaseModel.metadataclass DeviceLocation(BaseModel):__tablename__ ia_iot_device_location__table_args__ (Index(Index_1, iot_device_id),Index(Index_2, coordinates))id mapped_column(BigInteger, primary_keyTrue)coordinates: Mapped[WKBElement] mapped_column(Geometry(geometry_typePOINT, spatial_indexTrue), nullableFalse, comment地理坐标)iot_device_id mapped_column(BigInteger, server_defaulttext(0))label mapped_column(String(255, utf8mb4_general_ci)) FastApi 入口 (apps\vadmin\iot\views.py) ########################################################### # 设备地理位置 ########################################################### app.get(/device-location, summary获取设备地理位置列表, tags[设备地理位置]) async def get_deviceLocation_list(p: params.DeviceLocation Depends(), auth: Auth Depends(AllUserAuth())):datas, count await crud.DeviceLocationDal(auth.db).get_datas(**p.dict(), v_return_countTrue)return SuccessResponse(datas, countcount)app.post(/device-location, summary创建设备地理位置, tags[设备地理位置]) async def create_deviceLocation(data: schemas.DeviceLocation, auth: Auth Depends(AllUserAuth())):return SuccessResponse(await crud.DeviceLocationDal(auth.db).create_data(datadata))app.delete(/device-location, summary删除设备地理位置, description硬删除, tags[设备地理位置]) async def delete_deviceLocation_list(ids: IdList Depends(), auth: Auth Depends(AllUserAuth())):await crud.DeviceLocationDal(auth.db).delete_datas(idsids.ids, v_softFalse)return SuccessResponse(删除成功)app.put(/device-location/{data_id}, summary更新设备地理位置, tags[设备地理位置]) async def put_deviceLocation(data_id: int, data: schemas.DeviceLocation, auth: Auth Depends(AllUserAuth())):return SuccessResponse(await crud.DeviceLocationDal(auth.db).put_data(data_id, data))app.get(/device-location/{data_id}, summary获取设备地理位置信息, tags[设备地理位置]) async def get_deviceLocation(data_id: int, db: AsyncSession Depends(db_getter)):schema schemas.deviceLocationSimpleOutreturn SuccessResponse(await crud.DeviceLocationDal(db).get_data(data_id, v_schemaschema)) 接口Example 数据库记录 参考 - Working with Spatial Data using FastAPI and GeoAlchemy - sql server中对geometry类型的常用操作、SRID、GeoTools工具简单使用geometry和geojson格式之间的转换_sqlserver sde geometry 转text-CSDN博客
http://www.hkea.cn/news/14541407/

相关文章:

  • 页面设计好看的网站哈尔滨网络开发
  • 临沂市开发区可以做分销的网站做酒店工作去哪个招聘网站好
  • 石家庄规划建设局网站门户网站建设多久
  • 建设资讯网站全球做网站的公司排名
  • 晨光文具店网站建设响水做网站的
  • 营销网站的成功案例外贸公司英文网站
  • 直播网站建设需要多少钱青岛做家纺的公司网站
  • 福州市网站建设公司莱芜网站优化是什么
  • 广东睿营建设有限公司网站做网站大概费用
  • 廊坊网站建设制作天猫与京东的网站建设管理
  • 企业免费网站建设哪里比较好南昌seo网站推广
  • 咸宁有做网站的吗网站右下角弹出广告代码
  • 如何做网站 seo有免费查企业的软件吗
  • 怎么做好营销网站开发公众号第三方建微网站
  • 漯河有没有做网站的中国设计网室内
  • 电脑端网站和手机网站区别2022年中国电商行业分析报告
  • 网站开发学什么语言wordpress edd支付宝
  • 要建网站怎么做可以做问卷赚钱的网站
  • 做网站的收入来源小程序代理哪家好济宁
  • 做期货应关注什么网站wordpress文章分类插件
  • 建设工程消防设计备案哪个网站做网站的经历感想
  • 建网站带支付链接淘宝网页模板免费下载
  • dw设计做网站案例惠州专业做网站
  • 星沙网站优化seo全国企业信息查询官网系统
  • 深圳手机网站建设报价推广网站是什么意思
  • 唐山网站建设拓seo设置是什么
  • 网站建设与管理作业手机网站开发企业
  • 网站怎么做架构网站如何做数据分析报告
  • 云南建设网官方网站h5企业网站定制排名
  • 单页网站上传教程网站建设中怎么解决