分享一个基于python新闻订阅与分享平台flask新闻发布系统(源码、调试、LW、开题、PPT)

💕💕作者:计算机源码社
💕💕个人简介:本人 八年开发经验,擅长Java、Python、PHP、.NET、Node.js、Android、微信小程序、爬虫、大数据、机器学习等,大家有这一块的问题可以一起交流!
💕💕学习资料、程序开发、技术解答、文档报告
💕💕如需要源码,可以扫取文章下方二维码联系咨询

💕💕Java项目
💕💕微信小程序项目
💕💕Android项目
💕💕Python项目
💕💕PHP项目
💕💕ASP.NET项目
💕💕Node.js项目
💕💕选题推荐

项目实战|基于python的新闻订阅与分享平台flask项目

文章目录

  • 1、选题背景
  • 2、研究目的和意义
  • 3、系统研究内容
  • 4、系统页面设计
  • 5、参考文献
  • 6、核心代码

1、选题背景

   随着互联网的迅猛发展和信息化时代的到来,新闻传播的方式发生了深刻的变化。传统的新闻获取方式已经无法满足用户对即时性、互动性和个性化的需求,特别是在移动互联网的影响下,用户对新闻的获取方式和内容呈现提出了更高的要求。在此背景下,基于Python的新闻订阅与分享平台应运而生,旨在为用户提供一个便捷、高效的新闻获取与交流平台,以应对当前新闻传播方式的变革。

2、研究目的和意义

  本项目的开发旨在构建一个集新闻订阅、分享、评论与互动于一体的平台,为用户提供多样化的新闻内容与交互功能。通过该平台,用户可以根据自己的兴趣定制新闻内容,及时获取最新的新闻资讯,并能与其他用户进行交流与分享。管理员能够通过后台管理系统有效地管理新闻内容、用户信息及平台数据,从而提升平台的运营效率和用户体验。

   基于Python的新闻订阅与分享平台的开发具有重要的现实意义,它为用户提供了个性化新闻获取与社交分享的途径,提升了用户获取信息的效率。平台的开发展示了Python、Flask与Vue等技术在实际应用中的集成与运用,具有较高的学习和研究价值。最后,通过对平台数据的可视化分析,能够为新闻行业提供数据支持,帮助其优化内容分发策略,提高新闻传播的精准度与影响力。

3、系统研究内容

本系统主要研究基于Python的新闻订阅与分享平台的设计与实现过程,系统的需求分析将全面探讨用户需求和功能需求,确定平台的主要功能模块,包括用户管理、新闻类型管理、新闻信息管理、排行榜管理、留言板管理、新闻论坛管理及多种可视化报表的生成。本文将详细描述系统架构的设计,介绍如何使用Python和Flask进行后端开发、如何利用Vue实现前端交互,以及MySQL在数据存储与管理中的应用。

系统将深入探讨平台各功能模块的实现细节,包括用户管理模块的用户注册、登录与权限分配,新闻信息管理模块的新闻发布、编辑与删除,排行榜模块的新闻阅读量统计与排行展示,以及留言板和论坛模块的用户互动功能。还将研究通过数据可视化技术生成新闻总数、排行榜、用户统计等报表的具体实现方法,帮助管理员更好地理解平台运营情况。

4、系统页面设计

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
如需要源码,可以扫取文章下方二维码联系咨询

5、参考文献

[1]傅婷婷.全媒体新闻生产管理系统的设计与实现[J].广播与电视技术,2023,50(09):77-81.DOI:10.16171/j.cnki.rtbe.20230009014.
[2]蒋先梅.基于MVC模式的新闻管理系统的设计与实现[J].无线互联科技,2023,20(11):77-79.
[3]和占全,李晓明,冯汝结,等.基于信创的互联网新闻数据信息安全管理系统的设计与实现[J].网络安全技术与应用,2023,(03):94-96.
[4]申晋祥,鲍美英.基于Android的家校交流平台的设计与实现[J].电子元器件与信息技术,2022,6(02):182-184+187.DOI:10.19772/j.cnki.2096-4455.2022.2.070.
[5]梁宽宏.基于MVC架构的校园新闻发布管理系统[J].电子世界,2021,(18):182-183.DOI:10.19353/j.cnki.dzsj.2021.18.078.
[6]闫慧珍.基于数据爬取的新闻宣传信息系统的设计与实现[D].中北大学,2021. DOI:10.27470/d.cnki.ghbgc.2021.000936.
[7]王钦坤,文档编撰管理系统V1.0.江西省,江西和壹科技有限公司,2021-04-01.
[8]陆岫昶.企业新闻网稿件业务流程管理系统设计[J].数字技术与应用,2021,39(03):117-119.DOI:10.19695/j.cnki.cn12-1369.2021.03.39.
[9]牛怀岗,林关成.基于SSM框架的新闻发布管理系统设计与实现[J].现代电子技术,2020,43(21):127-131.DOI:10.16652/j.issn.1004-373x.2020.21.030.
[10]孙雪兰,华翔采购管理系统V1.0.湖南省,华翔翔能科技股份有限公司,2020-08-01.
[11]陈亮亮.基于大数据平台的通讯数据管理系统研究与应用[D].湖北工业大学,2020. DOI:10.27131/d.cnki.ghugc.2020.000506.
[12]于洪奇,陈卉,叶兴茂,等.自然资源部新闻宣传管理系统建设与应用[J].国土资源信息化,2020,(03):39-43.
[13]段鑫.火电厂检修管理系统的设计与实现[D].西安电子科技大学,2020. DOI:10.27389/d.cnki.gxadu.2020.003140.
[14]任超.面向互联网的新闻管理系统设计与实现[D].山东大学,2020. DOI:10.27272/d.cnki.gshdu.2020.002938.
[15]张立新.基于Android的新闻智能发布及管理系统[J].电脑编程技巧与维护,2020,(05):69-72.DOI:10.16184/j.cnki.comprg.2020.05.024.
[16]韩旭.基于WEB的新闻管理系统的设计与实现[J].电子世界,2020,(03):204-205.DOI:10.19353/j.cnki.dzsj.2020.03.118.
[17]宋江浩,世豪能量管理系统软件V1.0.陕西省,西安世豪汇科智能科技有限公司,2020-02-01.
[18]袁文涛,微擎新闻管理系统V2.5.安徽省,宿州市微擎云计算有限公司,2020-01-14.
[19]牛帆,黄婷婷,史铭.新闻采编业务管理系统的设计与实践[C]//中国新闻技术工作者联合会.中国新闻技术工作者联合会2019年学术年会论文集.新华社技术局;,2019:7. DOI:10.26914/c.cnkihy.2019.021708.
[20]仉允苇.石油新闻管理系统的设计与实现[D].西安电子科技大学,2019. DOI:10.27389/d.cnki.gxadu.2019.003275.

6、核心代码

# coding:utf-8
__author__ = "ila"import logging, os, json, configparser
import time
from datetime import datetime
from werkzeug.utils import redirectfrom flask import request, jsonify,session
from sqlalchemy.sql import func,and_,or_,case
from sqlalchemy import cast, Integer,Float
from api.models.brush_model import *
from . import main_bp
from utils.codes import *
from utils.jwt_auth import Auth
from configs import configs
from utils.helper import *
import random
import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
from email.header import Header
from utils.baidubce_api import BaiDuBce
from api.models.config_model import config# 注册接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/register", methods=['POST'])
def pythonf701pot2_xinwenxinxi_register():if request.method == 'POST':msg = {'code': normal_code, 'message': 'success', 'data': [{}]}req_dict = session.get("req_dict")error = xinwenxinxi.createbyreq(xinwenxinxi, xinwenxinxi, req_dict)if error!=None:msg['code'] = crud_error_codemsg['msg'] = "注册用户已存在"return jsonify(msg)# 登录接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/login", methods=['GET','POST'])
def pythonf701pot2_xinwenxinxi_login():if request.method == 'GET' or request.method == 'POST':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")req_model = session.get("req_dict")try:del req_model['role']except:passdatas = xinwenxinxi.getbyparams(xinwenxinxi, xinwenxinxi, req_model)if not datas:msg['code'] = password_error_codemsg['msg']='密码错误或用户不存在'return jsonify(msg)req_dict['id'] = datas[0].get('id')try:del req_dict['mima']except:passreturn Auth.authenticate(Auth, xinwenxinxi, req_dict)# 登出接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/logout", methods=['POST'])
def pythonf701pot2_xinwenxinxi_logout():if request.method == 'POST':msg = {"msg": "退出成功","code": 0}req_dict = session.get("req_dict")return jsonify(msg)# 重置密码接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/resetPass", methods=['POST'])
def pythonf701pot2_xinwenxinxi_resetpass():''''''if request.method == 'POST':msg = {"code": normal_code, "msg": "success"}req_dict = session.get("req_dict")if req_dict.get('mima') != None:req_dict['mima'] = '123456'error = xinwenxinxi.updatebyparams(xinwenxinxi, xinwenxinxi, req_dict)if error != None:msg['code'] = crud_error_codemsg['msg'] = errorelse:msg['msg'] = '密码已重置为:123456'return jsonify(msg)# 获取会话信息接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/session", methods=['GET'])
def pythonf701pot2_xinwenxinxi_session():''''''if request.method == 'GET':msg = {"code": normal_code, "data": {}}req_dict={"id":session.get('params').get("id")}msg['data']  = xinwenxinxi.getbyparams(xinwenxinxi, xinwenxinxi, req_dict)[0]return jsonify(msg)# 分类接口(后端)
@main_bp.route("/pythonf701pot2/xinwenxinxi/page", methods=['GET'])
def pythonf701pot2_xinwenxinxi_page():''''''if request.method == 'GET':msg = {"code": normal_code, "msg": "success",  "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}req_dict = session.get("req_dict")userinfo = session.get("params")try:__hasMessage__=xinwenxinxi.__hasMessage__except:__hasMessage__=Noneif __hasMessage__ and __hasMessage__!="否":tablename=session.get("tablename")if tablename!="users" and session.get("params")!=None and xinwenxinxi!='chat':req_dict["userid"]=session.get("params").get("id")tablename=session.get("tablename")if tablename=="users" :try:passexcept:passelse:mapping_str_to_object = {}for model in Base_model._decl_class_registry.values():if hasattr(model, '__tablename__'):mapping_str_to_object[model.__tablename__] = modeltry:__isAdmin__=mapping_str_to_object[tablename].__isAdmin__except:__isAdmin__=Nonetry:__authSeparate__ =mapping_str_to_object[tablename].__authSeparate__except:__authSeparate__ = Noneif __isAdmin__!="是" and __authSeparate__ == "是" and session.get("params")!=None:req_dict["userid"]=session.get("params").get("id")else:try:del req_dict["userid"]except:pass# 当前表也是有管理员权限的表if  __isAdmin__ == "是" and 'xinwenxinxi' != 'forum':if req_dict.get("userid") and 'xinwenxinxi' != 'chat':del req_dict["userid"]else:#非管理员权限的表,判断当前表字段名是否有useridif tablename!="users" and 'xinwenxinxi'[:7]!='discuss'and "userid" in xinwenxinxi.getallcolumn(xinwenxinxi,xinwenxinxi):req_dict["userid"] = session.get("params").get("id")clause_args = []or_clauses = or_(*clause_args)msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \msg['data']['pageSize']  = xinwenxinxi.page(xinwenxinxi, xinwenxinxi, req_dict, or_clauses)return jsonify(msg)# 排序接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/autoSort", methods=['GET'])
def pythonf701pot2_xinwenxinxi_autosort():''''''if request.method == 'GET':msg = {"code": normal_code, "msg": "success",  "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}req_dict = session.get("req_dict")req_dict['sort']='clicktime'req_dict['order']='desc'try:__browseClick__= xinwenxinxi.__browseClick__except:__browseClick__=Noneif __browseClick__ =='是':req_dict['sort']='clicknum'elif __browseClick__ =='时长':req_dict['sort']='browseduration'else:req_dict['sort']='clicktime'msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \msg['data']['pageSize']  = xinwenxinxi.page(xinwenxinxi, xinwenxinxi, req_dict)return jsonify(msg)#查询单条数据
@main_bp.route("/pythonf701pot2/xinwenxinxi/query", methods=['GET'])
def pythonf701pot2_xinwenxinxi_query():if request.method == 'GET':msg = {"code": normal_code, "msg": "success",  "data":{}}req_dict = session.get("req_dict")query = db.session.query(xinwenxinxi)for key, value in req_dict.items():query = query.filter(getattr(xinwenxinxi, key) == value)query_result = query.first()query_result.__dict__.pop('_sa_instance_state', None)msg['data'] = query_result.__dict__return jsonify(msg)# 分页接口(前端)
@main_bp.route("/pythonf701pot2/xinwenxinxi/list", methods=['GET'])
def pythonf701pot2_xinwenxinxi_list():''''''if request.method == 'GET':msg = {"code": normal_code, "msg": "success",  "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":10,"list":[]}}req_dict = session.get("req_dict")if req_dict.__contains__('vipread'):del req_dict['vipread']userinfo = session.get("params")try:__foreEndListAuth__=xinwenxinxi.__foreEndListAuth__except:__foreEndListAuth__=Noneif __foreEndListAuth__ and __foreEndListAuth__!="否":tablename=session.get("tablename")if tablename!="users" and session.get("params")!=None:req_dict['userid']=session.get("params").get("id")tablename=session.get("tablename")if 'luntan' in 'xinwenxinxi':if 'userid' in req_dict.keys():del req_dict["userid"]if 'discuss' in 'xinwenxinxi':if 'userid' in req_dict.keys():del req_dict["userid"]msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \msg['data']['pageSize']  = xinwenxinxi.page(xinwenxinxi, xinwenxinxi, req_dict)return jsonify(msg)# 保存接口(后端)
@main_bp.route("/pythonf701pot2/xinwenxinxi/save", methods=['POST'])
def pythonf701pot2_xinwenxinxi_save():''''''if request.method == 'POST':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")for key in req_dict:if req_dict[key] == '':req_dict[key] = Noneerror= xinwenxinxi.createbyreq(xinwenxinxi, xinwenxinxi, req_dict)if error!=None:msg['code'] = crud_error_codemsg['msg'] = errorreturn jsonify(msg)# 添加接口(前端)
@main_bp.route("/pythonf701pot2/xinwenxinxi/add", methods=['POST'])
def pythonf701pot2_xinwenxinxi_add():''''''if request.method == 'POST':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")try:__foreEndListAuth__=xinwenxinxi.__foreEndListAuth__except:__foreEndListAuth__=Noneif __foreEndListAuth__ and __foreEndListAuth__!="否":tablename=session.get("tablename")if tablename!="users":req_dict['userid']=session.get("params").get("id")error= xinwenxinxi.createbyreq(xinwenxinxi, xinwenxinxi, req_dict)if error!=None:msg['code'] = crud_error_codemsg['msg'] = errorreturn jsonify(msg)# 踩、赞接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/thumbsup/<id_>", methods=['GET'])
def pythonf701pot2_xinwenxinxi_thumbsup(id_):''''''if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")id_=int(id_)type_=int(req_dict.get("type",0))rets=xinwenxinxi.getbyid(xinwenxinxi, xinwenxinxi,id_)update_dict={"id":id_,}if type_==1:#赞update_dict["thumbsupnum"]=int(rets[0].get('thumbsupnum'))+1elif type_==2:#踩update_dict["crazilynum"]=int(rets[0].get('crazilynum'))+1error = xinwenxinxi.updatebyparams(xinwenxinxi, xinwenxinxi, update_dict)if error!=None:msg['code'] = crud_error_codemsg['msg'] = errorreturn jsonify(msg)# 获取详情信息(后端)
@main_bp.route("/pythonf701pot2/xinwenxinxi/info/<id_>", methods=['GET'])
def pythonf701pot2_xinwenxinxi_info(id_):''''''if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": {}}data = xinwenxinxi.getbyid(xinwenxinxi, xinwenxinxi, int(id_))if len(data)>0:msg['data']=data[0]#浏览点击次数try:__browseClick__= xinwenxinxi.__browseClick__except:__browseClick__=Noneif __browseClick__  and  "clicknum"  in xinwenxinxi.__table__.columns:click_dict={"id":int(id_),"clicknum":str(int(data[0].get("clicknum") or 0)+1)}ret=xinwenxinxi.updatebyparams(xinwenxinxi,xinwenxinxi,click_dict)if ret!=None:msg['code'] = crud_error_codemsg['msg'] = retreturn jsonify(msg)# 获取详情信息(前端)
@main_bp.route("/pythonf701pot2/xinwenxinxi/detail/<id_>", methods=['GET'])
def pythonf701pot2_xinwenxinxi_detail(id_):''''''if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": {}}data = xinwenxinxi.getbyid(xinwenxinxi, xinwenxinxi, int(id_))if len(data)>0:msg['data']=data[0]#浏览点击次数try:__browseClick__= xinwenxinxi.__browseClick__except:__browseClick__=Noneif __browseClick__ and "clicknum" in xinwenxinxi.__table__.columns:click_dict={"id":int(id_),"clicknum":str(int(data[0].get("clicknum") or 0)+1)}ret=xinwenxinxi.updatebyparams(xinwenxinxi,xinwenxinxi,click_dict)if ret!=None:msg['code'] = crud_error_codemsg['msg'] = retreturn jsonify(msg)# 更新接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/update", methods=['POST'])
def pythonf701pot2_xinwenxinxi_update():''''''if request.method == 'POST':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")if req_dict.get("mima") and "mima" not in xinwenxinxi.__table__.columns :del req_dict["mima"]if req_dict.get("password") and "password" not in xinwenxinxi.__table__.columns :del req_dict["password"]try:del req_dict["clicknum"]except:passerror = xinwenxinxi.updatebyparams(xinwenxinxi, xinwenxinxi, req_dict)if error!=None:msg['code'] = crud_error_codemsg['msg'] = errorreturn jsonify(msg)# 删除接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/delete", methods=['POST'])
def pythonf701pot2_xinwenxinxi_delete():''''''if request.method == 'POST':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")error=xinwenxinxi.delete(xinwenxinxi,req_dict)if error!=None:msg['code'] = crud_error_codemsg['msg'] = errorreturn jsonify(msg)# 投票接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/vote/<int:id_>", methods=['POST'])
def pythonf701pot2_xinwenxinxi_vote(id_):''''''if request.method == 'POST':msg = {"code": normal_code, "msg": "success"}data= xinwenxinxi.getbyid(xinwenxinxi, xinwenxinxi, int(id_))for i in data:votenum=i.get('votenum')if votenum!=None:params={"id":int(id_),"votenum":votenum+1}error=xinwenxinxi.updatebyparams(xinwenxinxi,xinwenxinxi,params)if error!=None:msg['code'] = crud_error_codemsg['msg'] = errorreturn jsonify(msg)# 分组统计接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/group/<columnName>", methods=['GET'])
def pythonf701pot2_xinwenxinxi_group(columnName):'''分组统计接口'''if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")userinfo = session.get("params")msg['data'] = xinwenxinxi.groupbycolumnname(xinwenxinxi,xinwenxinxi,columnName,req_dict)msg['data'] = msg['data'][:10]msg['data'] = [ {**i,columnName:str(i[columnName])} if columnName in i else i for i in msg['data']]json_filename='xinwenxinxi'+f'_group_{columnName}.json'where = ' where 1 = 1 'sql = "SELECT COUNT(*) AS total, " + columnName + " FROM xinwenxinxi " + where + " GROUP BY " + columnNamereturn jsonify(msg)# 按值统计接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/value/<xColumnName>/<yColumnName>", methods=['GET'])
def pythonf701pot2_xinwenxinxi_value(xColumnName, yColumnName):'''按值统计接口,{"code": 0,"data": [{"total": 10.0,"shangpinleibie": "aa"},{"total": 20.0,"shangpinleibie": "bb"},{"total": 15.0,"shangpinleibie": "cc"}]}'''if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": {}}req_dict = session.get("req_dict")userinfo = session.get("params")msg['data'] = xinwenxinxi.getvaluebyxycolumnname(xinwenxinxi,xinwenxinxi,xColumnName,yColumnName,req_dict)msg['data'] = msg['data'][:10]return jsonify(msg)# 按日期统计接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/value/<xColumnName>/<yColumnName>/<timeStatType>", methods=['GET'])
def pythonf701pot2_xinwenxinxi_value_riqi(xColumnName, yColumnName, timeStatType):'''按日期统计接口'''if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": {}}userinfo = session.get("params")where = ' where 1 = 1 'sql = ''if timeStatType == '日':sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM xinwenxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d')".format(xColumnName, yColumnName, where, '%Y-%m-%d')if timeStatType == '月':sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM xinwenxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m')".format(xColumnName, yColumnName, where, '%Y-%m')if timeStatType == '年':sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM xinwenxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y')".format(xColumnName, yColumnName, where, '%Y')data = db.session.execute(sql)data = data.fetchall()results = []for i in range(len(data)):result = {xColumnName: decimalEncoder(data[i][0]),'total': decimalEncoder(data[i][1])}results.append(result)msg['data'] = resultsjson_filename='xinwenxinxi'+f'_value_{xColumnName}_{yColumnName}.json'return jsonify(msg)# 按值统计(多)
@main_bp.route("/pythonf701pot2/xinwenxinxi/valueMul/<xColumnName>", methods=['GET'])
def pythonf701pot2_xinwenxinxi_valueMul(xColumnName):if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": []}req_dict = session.get("req_dict")userinfo = session.get("params")where = ' where 1 = 1 'for item in req_dict['yColumnNameMul'].split(','):sql = "SELECT {0}, sum({1}) AS total FROM xinwenxinxi {2} GROUP BY {0} LIMIT 10".format(xColumnName, item, where)L = []data = db.session.execute(sql)data = data.fetchall() for i in range(len(data)):result = {xColumnName: decimalEncoder(data[i][0]),'total': decimalEncoder(data[i][1])}L.append(result)msg['data'].append(L)return jsonify(msg)# 按值统计(多)
@main_bp.route("/pythonf701pot2/xinwenxinxi/valueMul/<xColumnName>/<timeStatType>", methods=['GET'])
def pythonf701pot2_xinwenxinxi_valueMul_time(xColumnName,timeStatType):if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": []}req_dict = session.get("req_dict")userinfo = session.get("params")where = ' where 1 = 1 'for item in req_dict['yColumnNameMul'].split(','):sql = ''if timeStatType == '日':sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM xinwenxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m-%d') LIMIT 10".format(xColumnName, item, where, '%Y-%m-%d')if timeStatType == '月':sql = "SELECT DATE_FORMAT({0}, '%Y-%m') {0}, sum({1}) total FROM xinwenxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y-%m') LIMIT 10".format(xColumnName, item, where, '%Y-%m')if timeStatType == '年':sql = "SELECT DATE_FORMAT({0}, '%Y') {0}, sum({1}) total FROM xinwenxinxi {2} GROUP BY DATE_FORMAT({0}, '%Y') LIMIT 10".format(xColumnName, item, where, '%Y')L = []data = db.session.execute(sql)data = data.fetchall() for i in range(len(data)):result = {xColumnName: decimalEncoder(data[i][0]),'total': decimalEncoder(data[i][1])}L.append(result)msg['data'].append(L)return jsonify(msg)import base64
import copy# 推荐算法接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/autoSort2", methods=['GET'])
def pythonf701pot2_xinwenxinxi_autoSort2():if request.method == 'GET':leixing = set()req_dict = session.get("req_dict")userinfo = session.get("params")auth_header = request.headers.get('token')if auth_header:auth_token = copy.deepcopy(auth_header)decode_str = base64.b64decode(auth_token).decode("utf8")decode_dict = eval(decode_str)tablename2 = decode_dict.get("tablename")if tablename2 == "yonghu":sql = "select xinwenbiaoqian from yonghu where id = "+str(userinfo.get("id"))+" order by addtime desc"try:data = db.session.execute(sql)rows = data.fetchall()for row in rows:for item in row:if item != None:for i in item.split(','):leixing.add(i)except:leixing = set()L = []where = " AND ".join([f"{key} = '{value}'" for key, value in req_dict.items() if key!="page" and key!="limit" and key!="order"and key!="sort"])if where:sql = f'''SELECT * FROM (SELECT * FROM xinwenxinxi WHERE {where}) AS table1 WHERE xinwenbiaoqian IN ('{"','".join(leixing)}') union all SELECT * FROM (SELECT * FROM xinwenxinxi WHERE {where}) AS table1 WHERE xinwenbiaoqian NOT IN ('{"','".join(leixing)}')'''else:sql ="select * from xinwenxinxi where xinwenbiaoqian in ('%s"%("','").join(leixing)+"') union all select * from xinwenxinxi where xinwenbiaoqian not in('%s"%("','").join(leixing)+"')"data = db.session.execute(sql)data_dict = [dict(zip(result.keys(), result)) for result in data.fetchall()]for online_dict in data_dict:for key in online_dict:if 'datetime.datetime' in str(type(online_dict[key])):online_dict[key] = online_dict[key].strftime("%Y-%m-%d %H:%M:%S")elif 'datetime' in str(type(online_dict[key])):online_dict[key] = online_dict[key].strftime("%Y-%m-%d %H:%M:%S")else:passL.append(online_dict)return jsonify({"code": 0, "msg": '',  "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:int(req_dict['limit'])]}})# 总数量
@main_bp.route("/pythonf701pot2/xinwenxinxi/count", methods=['GET'])
def pythonf701pot2_xinwenxinxi_count():''''''if request.method == 'GET':msg = {"code": normal_code, "msg": "success",  "data": 0}req_dict = session.get("req_dict")userinfo = session.get("params")msg['data']  = xinwenxinxi.count(xinwenxinxi, xinwenxinxi, req_dict)return jsonify(msg)# 统计接口
@main_bp.route("/pythonf701pot2/xinwenxinxi/remind/<columnName>/<type>", methods=['GET'])  #
def pythonf701pot2_xinwenxinxi_remind(columnName,type):''''''if request.method == 'GET':msg = {"code": normal_code, 'count': 0}# 组合查询参数params = session.get("req_dict")remindstart = 0remindend =9999990if int(type)==1:#数字if params.get('remindstart') == None and params.get('remindend') != None:remindstart = 0remindend = int(params['remindend'])elif params.get('remindstart') != None and params.get('remindend') == None:remindstart = int(params['remindstart'])remindend = 999999elif params.get('remindstart') == None and params.get('remindend') == None:remindstart = 0remindend = 999999else:remindstart = params.get('remindstart')remindend =  params.get('remindend')elif int(type)==2:#日期current_time=int(time.time())if params.get('remindstart') == None and params.get('remindend') != None:starttime=current_time-60*60*24*365*2params['remindstart'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(starttime))endtime=current_time+60*60*24*params.get('remindend')params['remindend'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(endtime))elif params.get('remindstart') != None and params.get('remindend') == None:starttime= current_time - 60 * 60 * 24 * params.get('remindstart')params['remindstart']=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(starttime))endtime=current_time+60*60*24*365*2params['remindend'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(endtime))elif params.get('remindstart') == None and params.get('remindend') == None:starttime = current_time - 60 * 60 * 24 * 365 * 2params['remindstart'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(starttime))endtime = current_time + 60 * 60 * 24 * 365 * 2params['remindend'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(endtime))data = xinwenxinxi.getbetweenparams(xinwenxinxi,xinwenxinxi,columnName,{"remindStart": remindstart,"remindEnd": remindend})msg['count'] = len(data)return jsonify(msg)#分类列表
@main_bp.route("/pythonf701pot2/xinwenxinxi/lists", methods=['GET'])
def pythonf701pot2_xinwenxinxi_lists():if request.method == 'GET':msg = {"code": normal_code, "msg": "success", "data": []}list,_,_,_,_ = xinwenxinxi.page(xinwenxinxi,xinwenxinxi,{})msg['data'] = listreturn jsonify(msg)

💕💕作者:计算机源码社
💕💕个人简介:本人 八年开发经验,擅长Java、Python、PHP、.NET、Node.js、Android、微信小程序、爬虫、大数据、机器学习等,大家有这一块的问题可以一起交流!
💕💕学习资料、程序开发、技术解答、文档报告
💕💕如需要源码,可以扫取文章下方二维码联系咨询

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/409423.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

SpringBoot集成kafka开发-消息消费的分区策略(消费者如何判断从哪个分区中消费消息的?)

这里写目录标题 1、kafak消息者消费消息的4种分区策略2、kafka默认的消费分区策略1-RangeAssignor&#xff08;均匀分配、默认分配策略&#xff09;2.1、代码验证RangeAssignor的消息分区策略2.1.1、消费者2.1.2、生产者2.1.3、kafak配置类2.1.4、对象实体类2.1.5、项目配置文件…

卸载通过pip安装的所有Python包的详细指南

卸载所有通过pip安装的Python包的方法总结&#xff08;Windows系统&#xff09; 方法 1: 使用 pip freeze 和 requirements.txt 步骤: 导出依赖到requirements.txt文件: pip freeze > requirements.txt这个命令会将当前环境中所有已安装的Python包及其版本号输出到requirem…

Django | 从中间件的角度来认识Django发送邮件功能

文章目录 概要中间件中间件 ---> 钩子实现中间件demo 邮件发送过程Django如何做邮件服务配置流程 中间件结合邮件服务实现告警 概要 摘要 业务告警 邮件验证 密码找回 邮件告警 中间件 中间件 —> ‘钩子’ 例如 访问路由 的次数【请求】 中间件类须实现下列五个方法…

ubuntu系统在线安装下载firefox-esr流览器

1、在线firefox流览器 Firefox ESR(Extended Support Release)是火狐浏览器的长期支持版本&#xff0c;针对同一个主版本提供一年左右的安全性与稳定性支持。如果您因为火狐浏览器改版而导致有原本能用的功能变得不能使用的话(例如Firefox 64.0把RSS订阅的功能拿掉了)&#xf…

【持续更新】1DM+ 17.1 Pro 号称安卓上的 idm,下载超快!最新免费高级修改版

这款安卓平台上的下载管理器&#xff0c;号称安卓上的 idm&#xff0c;堪称最快。 其下载速度比普通下载快高达 500%&#xff0c;有以下特点&#xff1a; • 无广告干扰 • 提供深色与浅色主题选择 • 支持直接下载至SD卡&#xff08;Android 4.4版本除外&#xff09; • 具备…

文献阅读:Pathway Ensemble Tool癌症通路和治疗法的无偏发现

介绍 正确地识别生物途径的扰动是揭示基本疾病机制和发展急需的治疗策略的关键步骤。然而&#xff0c;目前的工具是否最优化用于无偏发现相关途径仍然不清楚。在这里&#xff0c;我们创建了“基准测试”&#xff08;Benchmark&#xff09;来严格评估现有工具&#xff0c;并发现…

5步掌握Python Django+Vue二手房项目,实现房价预测与知识图谱系统

&#x1f34a;作者&#xff1a;计算机毕设匠心工作室 &#x1f34a;简介&#xff1a;毕业后就一直专业从事计算机软件程序开发&#xff0c;至今也有8年工作经验。擅长Java、Python、微信小程序、安卓、大数据、PHP、.NET|C#、Golang等。 擅长&#xff1a;按照需求定制化开发项目…

【SpringBoot】电脑商城-07-上传头像

基于SpringMVC的文件上传 1 MultipartFile接口 MultipartFile接口常用的的API见下表&#xff1a; 方法功能描述String getOriginalFilename()获取上传文件的原始文件名&#xff0c;即该文件在客户端中的文件名boolean isEmpty()判断上传的文件是否为空&#xff0c;当没有选择…

1-Wired一线式总线

常见的几种通信接口 一线式总线 定义 一线式&#xff1a;说明CPU和外设之间数据通信只需一根信号线,此信号线必然是数据线&#xff0c;并且数据线连接了一个上拉电阻,默认为高电平串行&#xff1a;说明CPU和外设的数据通信一个时钟周期传输一个bit位 问&#xff1a;没有时钟…

GoWeb 设置别名和多环境配置

别名 vite.config.ts中添加代码如下即可 //设置别名resolve: {alias: {"": path.resolve(process.cwd(),"src"),//用替代src}}随后即可使用 配置多环境 vite.config.ts中添加代码如下 envDir: ./viteenv,//相对路径随后在项目根目录创建对应的viteenv…

WEB渗透Win提权篇-RDPFirewall

渗透测试60w字全套md笔记&#xff1a;夸克网盘分享 爆破RDP Hydra爆破RDP >hydra -l admin -P /root/Desktop/passwords -S 192.168.0.0 rdpNlbrute MSF开启 >run post/windows/manage/enable_rdp多用户登陆 Mimikatz设置允许多用户登录 >privilege::debug >t…

游戏开发设计模式之单例模式

单例模式&#xff08;Singleton Pattern&#xff09;是一种常见的设计模式&#xff0c;其主要目的是确保一个类在整个程序的生命周期中只有一个实例&#xff0c;并提供一个全局访问点来获取这个实例。在游戏开发中&#xff0c;单例模式具有广泛的应用和重要的作用。 单例模式的…

Vue3-win7搭建vue3环境

Vue3-win7搭建vue3环境 官方要求的信息是是node.js 18.03以上。而我的环境&#xff1a;win7 x64&#xff0c; vscode 1.34。 参考网址&#xff1a; 0、基本的安装 https://blog.csdn.net/m0_49139268/article/details/126159171 a、这里有各种安装包的下载路径&#xff08;镜…

FedoSSL

题目&#xff1a;《Towards Unbiased Training in Federated Open-world Semi-supervised》 来源&#xff1a;ICML2023 注意比较与 ORCA 的区别 Abstract 联邦半监督学习&#xff08;FedSSL&#xff09;已经成为一种新范式&#xff0c;允许分布式客户端在稀缺的标记数据和丰富…

chapter08-面向对象编程(重写)day09

目录 302-方法重写介绍 303-方法重写细节 304-方法重写课堂练习1 305-方法重写课堂练习2 302-方法重写介绍 本类有这个方法就调用本类的&#xff0c;没有就向父类查找 303-方法重写细节 子类的形参列表、方法名称要和父类完全一致子类的返回类型&#xff08;String&#x…

【Hot100】LeetCode—200. 岛屿数量

目录 1- 思路DFS 深搜 2- 实现⭐200. 岛屿数量——题解思路 3- ACM 思路 题目连接&#xff1a;200. 岛屿数量 1- 思路 DFS 深搜 在遍历中对 res 结果进行 操作 。遇到一个陆地结果为 1 的地方&#xff0c; 就将他们直接填充为 0 思路 ① 先遍历&#xff0c;收集 res② 之后…

LTSPICE使用教程:入门指导

1.常用快捷键 1.鼠标左键选择&#xff0c;鼠标右键取消&#xff0c;F7移动元器件 2.空格键&#xff1a;最大化显示 3.旋转&#xff1a;CtrlR 4.撤销&#xff1a;F9 5.删除&#xff1a;F5 6.退出编辑状态&#xff1a;ESC 7.元器件的镜像&#xff1a;Ctrle 8.原理图页面和…

viewBinding的使用(android studio)

引入 在开发安卓软件的时候&#xff0c;我们会大量的使用点击事件。通常情况下&#xff0c;我们是这样做的&#xff1a;将在xml文件里把目标组件添加id属性&#xff0c;如下&#xff1a; 然后在activity里面通过findViewById(R.id.back) 得到一个对象&#xff0c;通过对象调用…

mac和windows上安装nvm管理node版本

NVM 是 node version manager 的缩写&#xff0c;它是一个用来管理电脑上 node 版本的命令行工具&#xff0c;在日常前端开发中是一个跟 node 一样会经常用到的工具&#xff0c;可以很方便的让我们快速切换不同的node版本。 mac 上安装 nvm 1、下载安装 nvm 下载安装可以直…

Facebook的区块链战略:如何在社交媒体中实现去中心化

随着区块链技术的发展&#xff0c;Facebook&#xff08;现Meta&#xff09;正积极探索如何将这一技术整合进其社交平台中&#xff0c;以提升用户体验和数据安全。区块链技术以去中心化、透明性和不可篡改性为特点&#xff0c;为社交媒体带来了新的可能性。本文将探讨Facebook在…