首页 > 编程语言 >基于Python+Flask实现民办高校教师职称晋升系统

基于Python+Flask实现民办高校教师职称晋升系统

时间:2024-08-30 09:25:20浏览次数:12  
标签:__ code Python req jieguogongbu msg dict Flask 民办高校

作者简介:Java领域优质创作者、CSDN博客专家 、CSDN内容合伙人、掘金特邀作者、阿里云博客专家、51CTO特邀作者、多年架构师设计经验、多年校企合作经验,被多个学校常年聘为校外企业导师,指导学生毕业设计并参与学生毕业答辩指导,有较为丰富的相关经验。期待与各位高校教师、企业讲师以及同行交流合作

主要内容:Java项目、Python项目、前端项目、PHP、ASP.NET、人工智能与大数据、单片机开发、物联网设计与开发设计、简历模板、学习资料、面试题库、技术互助、就业指导等

业务范围:免费功能设计、开题报告、任务书、中期检查PPT、系统功能实现、代码编写、论文编写和辅导、论文降重、长期答辩答疑辅导、腾讯会议一对一专业讲解辅导答辩、模拟答辩演练、和理解代码逻辑思路等

收藏点赞不迷路  关注作者有好处

文末获取源码 

项目编号:BS-Python-042

一,环境介绍

语言环境:Python3.8

数据库:Mysql: mysql5.7

WEB框架:Django

开发工具:IDEA或PyCharm

二,项目简介

基于Python和Flask框架实现的民办高校教师职称晋升系统,旨在提供一个高效、便捷的管理平台,助力学校规范教师职称评审流程,提升管理效率。该系统允许教师在线提交职称晋升申请,包括个人信息、教学成果、科研成果等关键材料。管理员通过系统审核申请材料,跟踪评审进度,并在线反馈评审结果。同时,系统支持数据统计分析,帮助学校领导层快速了解职称分布情况,为决策提供支持。此外,系统采用现代Web技术构建,界面友好,操作简便,有效促进了信息透明与资源共享,是推动民办高校职称评审工作数字化、智能化转型的重要工具。

三,系统展示

管理员角色

教师用户功能

四,核心代码展示

# coding:utf-8
__author__ = "ila"

import logging, os, xlrd
from flask import request, jsonify,session
from sqlalchemy.sql import func,and_,or_
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.header import Header


# 注册接口
@main_bp.route("/python1f1ty/jieguogongbu/register", methods=['POST'])
def python1f1ty_jieguogongbu_register():
    if request.method == 'POST':
        msg = {'code': normal_code, 'message': 'success', 'data': [{}]}
        req_dict = session.get("req_dict")


        error = jieguogongbu.createbyreq(jieguogongbu, jieguogongbu, req_dict)
        if error!=None:
            msg['code'] = crud_error_code
            msg['msg'] = "注册用户已存在"
        return jsonify(msg)

# 登录接口
@main_bp.route("/python1f1ty/jieguogongbu/login", methods=['GET','POST'])
def python1f1ty_jieguogongbu_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:
            pass


        datas = jieguogongbu.getbyparams(jieguogongbu, jieguogongbu, req_model)
        if not datas:
            msg['code'] = password_error_code
            msg['msg']='密码错误或用户不存在'
            return jsonify(msg)


        req_dict['id'] = datas[0].get('id')
        return Auth.authenticate(Auth, jieguogongbu, req_dict)

# 登出接口
@main_bp.route("/python1f1ty/jieguogongbu/logout", methods=['POST'])
def python1f1ty_jieguogongbu_logout():
    if request.method == 'POST':
        msg = {
            "msg": "退出成功",
            "code": 0
        }
        req_dict = session.get("req_dict")

        return jsonify(msg)

# 重置密码接口
@main_bp.route("/python1f1ty/jieguogongbu/resetPass", methods=['POST'])
def python1f1ty_jieguogongbu_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 = jieguogongbu.updatebyparams(jieguogongbu, jieguogongbu, req_dict)

        if error != None:
            msg['code'] = crud_error_code
            msg['msg'] = error
        else:
            msg['msg'] = '密码已重置为:123456'
        return jsonify(msg)

# 获取会话信息接口
@main_bp.route("/python1f1ty/jieguogongbu/session", methods=['GET'])
def python1f1ty_jieguogongbu_session():
    '''
    '''
    if request.method == 'GET':
        msg = {"code": normal_code, "data": {}}
        req_dict={"id":session.get('params').get("id")}
        msg['data']  = jieguogongbu.getbyparams(jieguogongbu, jieguogongbu, req_dict)[0]

        return jsonify(msg)

# 分类接口(后端)
@main_bp.route("/python1f1ty/jieguogongbu/page", methods=['GET'])
def python1f1ty_jieguogongbu_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__=jieguogongbu.__hasMessage__
        except:
            __hasMessage__=None
        if __hasMessage__ and __hasMessage__!="否":
            tablename=session.get("tablename")
            if tablename!="users" and session.get("params")!=None and jieguogongbu!='chat':
                req_dict["userid"]=session.get("params").get("id")

        tablename=session.get("tablename")
        if tablename=="users" :
            try:
                pass
            except:
                pass
        else:
            mapping_str_to_object = {}
            for model in Base_model._decl_class_registry.values():
                if hasattr(model, '__tablename__'):
                    mapping_str_to_object[model.__tablename__] = model

            try:
                __isAdmin__=mapping_str_to_object[tablename].__isAdmin__
            except:
                __isAdmin__=None

            if __isAdmin__!="是" and session.get("params")!=None:
                req_dict["userid"]=session.get("params").get("id")
            else:
                try:
                    del req_dict["userid"]
                except:
                    pass


        clause_args = []
        or_clauses = or_(*clause_args)

        msg['data']['list'], msg['data']['currPage'], msg['data']['totalPage'], msg['data']['total'], \
        msg['data']['pageSize']  = jieguogongbu.page(jieguogongbu, jieguogongbu, req_dict, or_clauses)

        return jsonify(msg)

# 排序接口
@main_bp.route("/python1f1ty/jieguogongbu/autoSort", methods=['GET'])
def python1f1ty_jieguogongbu_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__= jieguogongbu.__browseClick__
        except:
            __browseClick__=None

        if __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']  = jieguogongbu.page(jieguogongbu, jieguogongbu, req_dict)

        return jsonify(msg)

# 分页接口(前端)
@main_bp.route("/python1f1ty/jieguogongbu/list", methods=['GET'])
def python1f1ty_jieguogongbu_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:
            __foreEndList__=jieguogongbu.__foreEndList__
        except:
            __foreEndList__=None

        if __foreEndList__ and __foreEndList__!="否":
            tablename=session.get("tablename")
            if tablename!="users" and session.get("params")!=None:
                req_dict['userid']=session.get("params").get("id")

        try:
            __foreEndListAuth__=jieguogongbu.__foreEndListAuth__
        except:
            __foreEndListAuth__=None

        if __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 tablename=="users" :
            try:
                del req_dict["userid"]
            except:
                pass
        else:
            mapping_str_to_object = {}
            for model in Base_model._decl_class_registry.values():
                if hasattr(model, '__tablename__'):
                    mapping_str_to_object[model.__tablename__] = model

            try:
                __isAdmin__=mapping_str_to_object[tablename].__isAdmin__
            except:
                __isAdmin__=None

            if __isAdmin__!="是" and session.get("params")!=None:
                req_dict["userid"]=session.get("params").get("id")
            else:
                try:
                    del req_dict["userid"]
                except:
                    pass

        if 'luntan' in 'jieguogongbu':
            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']  = jieguogongbu.page(jieguogongbu, jieguogongbu, req_dict)

        return jsonify(msg)

# 保存接口(后端)
@main_bp.route("/python1f1ty/jieguogongbu/save", methods=['POST'])
def python1f1ty_jieguogongbu_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] = None
        error= jieguogongbu.createbyreq(jieguogongbu, jieguogongbu, req_dict)
        if error!=None:
            msg['code'] = crud_error_code
            msg['msg'] = error
        return jsonify(msg)

# 添加接口(前端)
@main_bp.route("/python1f1ty/jieguogongbu/add", methods=['POST'])
def python1f1ty_jieguogongbu_add():
    '''
    '''
    if request.method == 'POST':
        msg = {"code": normal_code, "msg": "success", "data": {}}
        req_dict = session.get("req_dict")
        try:
            __foreEndListAuth__=jieguogongbu.__foreEndListAuth__
        except:
            __foreEndListAuth__=None

        if __foreEndListAuth__ and __foreEndListAuth__!="否":
            tablename=session.get("tablename")
            if tablename!="users":
                req_dict['userid']=session.get("params").get("id")
            
        error= jieguogongbu.createbyreq(jieguogongbu, jieguogongbu, req_dict)
        if error!=None:
            msg['code'] = crud_error_code
            msg['msg'] = error
        return jsonify(msg)

# 踩、赞接口
@main_bp.route("/python1f1ty/jieguogongbu/thumbsup/<id_>", methods=['GET'])
def python1f1ty_jieguogongbu_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=jieguogongbu.getbyid(jieguogongbu, jieguogongbu,id_)

        update_dict={
        "id":id_,
        }
        if type_==1:#赞
            update_dict["thumbsupnum"]=int(rets[0].get('thumbsupnum'))+1
        elif type_==2:#踩
            update_dict["crazilynum"]=int(rets[0].get('crazilynum'))+1
        error = jieguogongbu.updatebyparams(jieguogongbu, jieguogongbu, update_dict)
        if error!=None:
            msg['code'] = crud_error_code
            msg['msg'] = error
        return jsonify(msg)

# 获取详情信息(后端)
@main_bp.route("/python1f1ty/jieguogongbu/info/<id_>", methods=['GET'])
def python1f1ty_jieguogongbu_info(id_):
    '''
    '''
    if request.method == 'GET':
        msg = {"code": normal_code, "msg": "success", "data": {}}

        data = jieguogongbu.getbyid(jieguogongbu, jieguogongbu, int(id_))
        if len(data)>0:
            msg['data']=data[0]
        #浏览点击次数
        try:
            __browseClick__= jieguogongbu.__browseClick__
        except:
            __browseClick__=None

        if __browseClick__  and  "clicknum"  in jieguogongbu.__table__.columns:
            click_dict={"id":int(id_),"clicknum":str(int(data[0].get("clicknum") or 0)+1)}
            ret=jieguogongbu.updatebyparams(jieguogongbu,jieguogongbu,click_dict)
            if ret!=None:
                msg['code'] = crud_error_code
                msg['msg'] = ret
        return jsonify(msg)

# 获取详情信息(前端)
@main_bp.route("/python1f1ty/jieguogongbu/detail/<id_>", methods=['GET'])
def python1f1ty_jieguogongbu_detail(id_):
    '''
    '''
    if request.method == 'GET':
        msg = {"code": normal_code, "msg": "success", "data": {}}

        data = jieguogongbu.getbyid(jieguogongbu, jieguogongbu, int(id_))
        if len(data)>0:
            msg['data']=data[0]

        #浏览点击次数
        try:
            __browseClick__= jieguogongbu.__browseClick__
        except:
            __browseClick__=None

        if __browseClick__   and  "clicknum"  in jieguogongbu.__table__.columns:
            click_dict={"id":int(id_),"clicknum":str(int(data[0].get("clicknum") or 0)+1)}
            ret=jieguogongbu.updatebyparams(jieguogongbu,jieguogongbu,click_dict)
            if ret!=None:
                msg['code'] = crud_error_code
                msg['msg'] = ret
        return jsonify(msg)

# 更新接口
@main_bp.route("/python1f1ty/jieguogongbu/update", methods=['POST'])
def python1f1ty_jieguogongbu_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 jieguogongbu.__table__.columns :
            del req_dict["mima"]
        if req_dict.get("password") and "password" not in jieguogongbu.__table__.columns :
            del req_dict["password"]
        try:
            del req_dict["clicknum"]
        except:
            pass


        error = jieguogongbu.updatebyparams(jieguogongbu, jieguogongbu, req_dict)
        if error!=None:
            msg['code'] = crud_error_code
            msg['msg'] = error
        return jsonify(msg)

# 删除接口
@main_bp.route("/python1f1ty/jieguogongbu/delete", methods=['POST'])
def python1f1ty_jieguogongbu_delete():
    '''
    '''
    if request.method == 'POST':
        msg = {"code": normal_code, "msg": "success", "data": {}}
        req_dict = session.get("req_dict")

        error=jieguogongbu.delete(
            jieguogongbu,
            req_dict
        )
        if error!=None:
            msg['code'] = crud_error_code
            msg['msg'] = error
        return jsonify(msg)

# 投票接口
@main_bp.route("/python1f1ty/jieguogongbu/vote/<int:id_>", methods=['POST'])
def python1f1ty_jieguogongbu_vote(id_):
    '''
    '''
    if request.method == 'POST':
        msg = {"code": normal_code, "msg": "success"}


        data= jieguogongbu.getbyid(jieguogongbu, jieguogongbu, int(id_))
        for i in data:
            votenum=i.get('votenum')
            if votenum!=None:
                params={"id":int(id_),"votenum":votenum+1}
                error=jieguogongbu.updatebyparams(jieguogongbu,jieguogongbu,params)
                if error!=None:
                    msg['code'] = crud_error_code
                    msg['msg'] = error
        return jsonify(msg)





# 分组统计接口
@main_bp.route("/python1f1ty/jieguogongbu/group/<columnName>", methods=['GET'])
def python1f1ty_jieguogongbu_group(columnName):
    '''
    分组统计接口
    '''
    if request.method == 'GET':
        msg = {"code": normal_code, "msg": "success", "data": {}}

        msg['data'] = jieguogongbu.groupbycolumnname(jieguogongbu,jieguogongbu,columnName)
        return jsonify(msg)

# 按值统计接口
@main_bp.route("/python1f1ty/jieguogongbu/value/<xColumnName>/<yColumnName>", methods=['GET'])
def python1f1ty_jieguogongbu_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": {}}

        msg['data'] = jieguogongbu.getvaluebyxycolumnname(jieguogongbu,jieguogongbu,xColumnName,yColumnName)
        return jsonify(msg)

# 按日期统计接口
@main_bp.route("/python1f1ty/jieguogongbu/value/<xColumnName>/<yColumnName>/<timeStatType>", methods=['GET'])
def python1f1ty_jieguogongbu_value_riqi(xColumnName, yColumnName, timeStatType):
    '''
    按日期统计接口
    '''
    if request.method == 'GET':
        msg = {"code": normal_code, "msg": "success", "data": {}}

        where = ' where 1 = 1 '

        sql = ''
        if timeStatType == '日':
            sql = "SELECT DATE_FORMAT({0}, '%Y-%m-%d') {0}, sum({1}) total FROM jieguogongbu {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 jieguogongbu {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 jieguogongbu {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'] = results
        return jsonify(msg)

# 推荐算法接口
@main_bp.route("/python1f1ty/jieguogongbu/autoSort2", methods=['GET'])
def python1f1ty_jieguogongbu_autoSort2():
    if request.method == 'GET':

        leixing = set()
        req_dict = session.get("req_dict")
        userinfo = session.get("params")
        sql = "select inteltype from storeup where userid = "+userinfo.get("id")+" and tablename = 'jieguogongbu' order by addtime desc"
        try:
            data = db.session.execute(sql)
            rows = data.fetchall()
            for row in rows:
                for item in row:
                    if item != None:
                        leixing.add(item)
        except:
            leixing = set()

        L = []
        sql ="select * from jieguogongbu where $intelRecomColumn in ('%s"%("','").join(leixing)+"') union all select * from jieguogongbu where $intelRecomColumn 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")
                else:
                    pass
            L.append(online_dict)

        return jsonify({"code": 0, "msg": '',  "data":{"currPage":1,"totalPage":1,"total":1,"pageSize":5,"list": L[0:6]}})





五,相关作品展示

基于Java开发、Python开发、PHP开发、C#开发等相关语言开发的实战项目

基于Nodejs、Vue等前端技术开发的前端实战项目

基于微信小程序和安卓APP应用开发的相关作品

基于51单片机等嵌入式物联网开发应用

基于各类算法实现的AI智能应用

基于大数据实现的各类数据管理和推荐系统

 

 

标签:__,code,Python,req,jieguogongbu,msg,dict,Flask,民办高校
From: https://blog.csdn.net/znzbs/article/details/141549633

相关文章

  • 基于Python实现校园爱心帮扶平台
    作者简介:Java领域优质创作者、CSDN博客专家、CSDN内容合伙人、掘金特邀作者、阿里云博客专家、51CTO特邀作者、多年架构师设计经验、多年校企合作经验,被多个学校常年聘为校外企业导师,指导学生毕业设计并参与学生毕业答辩指导,有较为丰富的相关经验。期待与各位高校教师、企业......
  • Python--异常的分类
    异常是Python编程中常见的错误类型,帮助开发者识别和调试代码中的问题。以下是对出现的常见异常的详细阐述:IndexError(索引超出序列的范围)当尝试访问一个序列(如列表、元组等)中不存在的索引时,会引发此异常。例如,访问一个长度为5的列表的第10个元素时就会出现IndexErr......
  • 快速排序python实现
    defquick_sort(arr,left,right):origin_left=leftorigin_right=rightpivot_data=arr[left]#枢轴上的值(基准值),就是开始用来比较的值,一般是随机选择一个位置,这儿选择最左边的值#blank_pos=left#最左边的值已经复制到pivot中了,所以这块......
  • 使用 python 升级OTA程序
    依赖文件pymodbus==3.6.3pyserial==3.5importbinasciiimportmathimporttimeimportserialfrompymodbus.clientimportModbusSerialClientasModbusClientimportstruct##设备串口配置#port='/dev/cu.usbserial-1130'#根据实际情况修改为实际串口号#baudra......
  • Python中的“for循环”:探索其无限潜力
    引言for循环是任何Python程序员工具箱中的必备技能之一。无论是在处理数据时需要遍历数组,还是在编写Web应用时循环处理请求,亦或是进行复杂的算法实现,for循环都能派上大用场。通过掌握for循环的不同用法,我们可以更高效地解决问题,写出更加优雅且高效的代码。基础语法介绍核心概念......
  • Python中的`while`循环:探索无限可能
    引言while循环允许我们重复执行一段代码块,直到指定条件不再满足为止。这种机制非常适合处理那些不确定具体重复次数的任务场景,比如读取文件直到末尾、定时任务执行等。掌握好while循环,不仅能让你的代码更加高效、简洁,还能帮助你在面对复杂问题时找到更优的解决方案。基础语法介绍......
  • Python实现图片的拼接
    Python实现图片的拼接Python中有多种方法可以实现图片拼接,下面是一个使用Pillow库的示例:首先,你需要安装Pillow库:pipinstallpillow然后,可以使用以下代码实现图片拼接:fromPILimportImage#读取两张图片img1=Image.open('image1.jpg')img2=Image.open('image2.jpg'......
  • Python的requests库详细介绍
    Pythonrequests库是一个用于发送HTTP请求的简单而强大的库,它可以让你轻松地在Python中处理HTTP请求。这个库是Python中处理HTTP请求的标准工具,因其简洁的API和强大的功能而广受欢迎。1.安装requestspipinstallrequests2.基本用法2.1导入库importr......
  • Python深度学习股价预测、量化交易策略:LSTM、GRU深度门控循环神经网络|附代码数据
    全文链接:https://tecdat.cn/?p=37539原文出处:拓端数据部落公众号 分析师:ShuoZhang本文以上证综指近22年的日交易数据为样本,构建深度门控循环神经网络模型,从股价预测和制定交易策略两方面入手,量化循环神经网络在股票预测以及交易策略中的效果,结合一个Python深度学习股价预测......
  • python实现RC4加解密算法
    目录RC4算法简介RC4算法的加密和解密流程RC4算法的Python实现代码解释RC4算法的应用场景RC4的安全性分析总结RC4(RivestCipher4)是一种流加密算法,由RonRivest于1987年设计。RC4广泛应用于各种加密协议,如SSL/TLS和WEP/WPA等。RC4算法因其简单、高效的特点受到广泛关......