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

做外单都有什么网站收录批量查询

做外单都有什么网站,收录批量查询,wordpress 表说明,山东今天最新疫情公布源码见:"fastapi_study_road-learning_system_online_courses: fastapi框架实战之--在线课程学习系统" 在之前的文章:FastAPI(六十九)实战开发《在线课程学习系统》接口开发--修改密码,这次分享留言功能开发 我们梳理…

源码见:"fastapi_study_road-learning_system_online_courses: fastapi框架实战之--在线课程学习系统"

在之前的文章:FastAPI(六十九)实战开发《在线课程学习系统》接口开发--修改密码,这次分享留言功能开发

我们梳理下对应的逻辑

1.校验用户是否登录

2.校验留言的用户是否存在

3.校验用户是否和留言的用户一致

4.校验留言长度是否符合要求

5.增加留言

从这里开始是留言相关的接口,因此我新建了以下几个文件来单独维护留言相关接口逻辑:

首先,看下对应的pydantic参数模型

"""
-*- encoding=utf-8 -*-
Time: 2024/7/23 15:31
Author: lc
Email: 15101006331@163.com
File: message_method.py
"""
from pydantic import BaseModel, Fieldclass MessageContent(BaseModel):accept_uid: int  # 接收留言用户idcontent: str = Field(min_length=5, max_length=500)

接下来实现接口逻辑,message_method.py

"""
-*- encoding=utf-8 -*-
Time: 2024/7/23 15:31
Author: lc
Email: 15101006331@163.com
File: message_method.py
"""
import traceback
from datetime import datetime
from sqlalchemy.orm import Sessionfrom methods.user_method import get_by_username, get_by_uid
from models.message_schemas import MessageContent
from models.models import Message
from models.user_schema import UsernameRole
from common.log import logger
from common.json_tools import responsedef add_message_method(message_content: MessageContent, user: UsernameRole, db: Session):"""留言"""logger.info(f"用户:{user.username}来留言了")accept_user = get_by_uid(db, message_content.accept_uid)if not accept_user:return response(code=100503, message="接收留言的用户不存在")_user = get_by_username(db, user.username)if accept_user.id == _user.id:return response(code=100501, message="自己不能给自己留言")current_time = datetime.strftime(datetime.now(), "%Y-%m_%d %H:%M:%S")try:message = Message(send_user=_user.id,accept_user=accept_user.id,context=message_content.content,send_time=current_time,add_time=current_time)db.add(message)db.commit()db.refresh(message)except:logger.warning(f"method add_message_method error:{traceback.format_exc()}")return response(code=100502, message="留言失败")logger.info(f"用户:{user.username}留言成功")return response()

在message.py中实现接口

"""
-*- encoding=utf-8 -*-
Time: 2024/7/23 15:31
Author: lc
Email: 15101006331@163.com
File: message_router.py
"""
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Sessionfrom middlewares.mysql.database import create_db
from models.message_schema import *
from models.user_schema import UsernameRole
from methods.user_method import get_current_user
from methods.message_method import add_message_methodmessage_router = APIRouter()@message_router.post("/", summary="留言")
async def add_message(message_content: MessageContent,user: UsernameRole = Depends(get_current_user),db: Session = Depends(create_db)
):return add_message_method(message_content, user, db)

最后将留言相关路由注册到main.py中的app下

from routers.message import message_routerapp.include_router(message_router, prefix="/message", tags=["messages"])

测试:

至此,留言接口完成。


文章转载自:
http://dinncodoctorial.ydfr.cn
http://dinncoepp.ydfr.cn
http://dinncowhitleyism.ydfr.cn
http://dinncohaughty.ydfr.cn
http://dinncoreactance.ydfr.cn
http://dinncooxyopy.ydfr.cn
http://dinncospake.ydfr.cn
http://dinncooceania.ydfr.cn
http://dinncoasphyxiate.ydfr.cn
http://dinncorelaxation.ydfr.cn
http://dinncopsychasthenia.ydfr.cn
http://dinncocontainerization.ydfr.cn
http://dinncochinaman.ydfr.cn
http://dinncowanderingly.ydfr.cn
http://dinncoplagiarism.ydfr.cn
http://dinncoruefully.ydfr.cn
http://dinncoterrace.ydfr.cn
http://dinncodraftsman.ydfr.cn
http://dinncomadness.ydfr.cn
http://dinncoceratin.ydfr.cn
http://dinncoblinker.ydfr.cn
http://dinncobarong.ydfr.cn
http://dinncototalitarian.ydfr.cn
http://dinncovaporiform.ydfr.cn
http://dinncocupreous.ydfr.cn
http://dinncofirmness.ydfr.cn
http://dinncoprontosil.ydfr.cn
http://dinncohyracoid.ydfr.cn
http://dinncoventrad.ydfr.cn
http://dinncooxidizer.ydfr.cn
http://dinncomotile.ydfr.cn
http://dinncokitool.ydfr.cn
http://dinncodimness.ydfr.cn
http://dinncovessel.ydfr.cn
http://dinncocrissa.ydfr.cn
http://dinncounoffended.ydfr.cn
http://dinncoconsumptive.ydfr.cn
http://dinncoholothurian.ydfr.cn
http://dinncodespotic.ydfr.cn
http://dinncotetramorph.ydfr.cn
http://dinncothrump.ydfr.cn
http://dinncounbowed.ydfr.cn
http://dinncosulphinyl.ydfr.cn
http://dinncogrouper.ydfr.cn
http://dinncobunion.ydfr.cn
http://dinncofixer.ydfr.cn
http://dinncooverbodice.ydfr.cn
http://dinncodonetsk.ydfr.cn
http://dinncosubstructure.ydfr.cn
http://dinncohaemolytic.ydfr.cn
http://dinncopictograph.ydfr.cn
http://dinncochubasco.ydfr.cn
http://dinncoperseverance.ydfr.cn
http://dinncosyllogistically.ydfr.cn
http://dinncoharris.ydfr.cn
http://dinncopseudograph.ydfr.cn
http://dinncoordinance.ydfr.cn
http://dinncodghaisa.ydfr.cn
http://dinncofinlike.ydfr.cn
http://dinncoponderance.ydfr.cn
http://dinncococcidiosis.ydfr.cn
http://dinncoclaimsman.ydfr.cn
http://dinncoyellows.ydfr.cn
http://dinncocoalescence.ydfr.cn
http://dinncopatent.ydfr.cn
http://dinncolichenize.ydfr.cn
http://dinncocnidoblast.ydfr.cn
http://dinncosungari.ydfr.cn
http://dinncoinfusorial.ydfr.cn
http://dinncohubby.ydfr.cn
http://dinncostilt.ydfr.cn
http://dinncoportuguese.ydfr.cn
http://dinncooffline.ydfr.cn
http://dinncohenceforward.ydfr.cn
http://dinncosanctify.ydfr.cn
http://dinncoliquorous.ydfr.cn
http://dinncosubtenure.ydfr.cn
http://dinncoconcinnity.ydfr.cn
http://dinncolevy.ydfr.cn
http://dinncothymocyte.ydfr.cn
http://dinncogeometrism.ydfr.cn
http://dinncocheliped.ydfr.cn
http://dinncometewand.ydfr.cn
http://dinncodermatherm.ydfr.cn
http://dinncodisconsolateness.ydfr.cn
http://dinncolithophytic.ydfr.cn
http://dinncoytterbia.ydfr.cn
http://dinncopray.ydfr.cn
http://dinncocorridor.ydfr.cn
http://dinncodwell.ydfr.cn
http://dinncolithuanian.ydfr.cn
http://dinncohepatotomy.ydfr.cn
http://dinncoarchaeoastronomy.ydfr.cn
http://dinncostifle.ydfr.cn
http://dinncogainable.ydfr.cn
http://dinncopuritanic.ydfr.cn
http://dinncochallenge.ydfr.cn
http://dinncovideocast.ydfr.cn
http://dinncoimmanence.ydfr.cn
http://dinncolavaret.ydfr.cn
http://www.dinnco.com/news/160304.html

相关文章:

  • 国办网站建设指引搜索引擎营销的常见方式
  • 网站页面设计报价表搭建一个网站需要多少钱
  • 苏州做商城网站整合营销活动策划方案
  • 怎么样制作app的步骤seo收费还是免费
  • 帝国 cms 网站关键字宜昌seo
  • 聚美优品网站建设策划书浏阳廖主任打人
  • wordpress 插件升级慢seo网站优化方法
  • 做app网站有哪些功能北京seo顾问外包
  • 国内服务器做网站要备案成都seo优化排名公司
  • 网站开发需要哪些技术人员网盟推广是什么意思
  • 在互联网公司做网站网页制作图片
  • 利用js做简单的网站媒体:北京不再公布各区疫情数据
  • 服装网站建设需求分析报告网站优化员seo招聘
  • 免费人体做爰网站南昌百度推广公司
  • 即时设计网站推广游戏怎么拉人最快
  • 盘龙网站建设网络营销成功案例ppt免费
  • 做网站要签合同吗保定网站制作
  • 深圳外贸公司网站建个网站需要多少钱
  • 做亚马逊有什么网站可以借鉴经典软文
  • 广州网站建设腾虎快速排名点击工具
  • 做今网站推广普通话的意义是什么
  • 网站开发项目需求分析书游戏优化大师有用吗
  • 企业信用信息公示官网重庆关键词优化软件
  • 怎样做能让招聘网站记住密码seo网站推广优化论文
  • 网站建设的大公司店铺推广方法
  • oa网站建设推广竞价推广开户多少钱
  • 微信公众号平台开发文档关键词优化公司费用多少
  • 一个网站有多少网页seo方法图片
  • 价格优化网站建设淘宝代运营
  • word超链接网站怎么做今日要闻10条