Git Product home page Git Product logo

tsinghuatuan's Introduction

清华紫荆之声 - 基于微信公众平台的票务管理系统

项目背景

“清华紫荆之声”是清华大学团委支持的微信公众平台,主要承担票务管理、资讯发布等工作。在2014年清华大学元旦新年联欢晚会前夕,全校近千名师生通过“清华紫荆之声”在1秒内将预设的200张网络票全部抢光,这一新颖的放票方式获得师生的好评,也得到了校团委的更多重视。后来,该微信号升级为“清华大学紫荆之声”,是目前仅有的三个以清华大学名义认证的微信公众号之一。

该公众号已经进入升级版的开发工作,现将原项目部分开源,供大家学习。升级版公众号的开发人员也可从本项目源代码中找到一些关键的技术解决方案。

本项目是原项目的一部分,在原项目中承担票务管理的全部功能。

与本项目一同开源的还有原项目中的二维码生成子项目,对应开源版本库地址为:https://github.com/Epsirom/QRservice

推荐一看

原生实现的WSGI

本项目使用的Web服务器网关接口(WSGI)是原生实现的。

具体来说,就是localwsgi.py

资讯与票务功能联动

票务系统是微信消息的入口,当识别到消息是进行非票务操作时,意味着该消息是请求资讯服务的,而资讯的相关功能是另一个项目中实现的。

为将两个项目联动,在发现用户请求的是资讯服务时,本项目会将相应的微信消息通过HTTP的方式转发给资讯系统。具体来说,queryhandler.__init__handle_weixin_request函数中调用了queryhandler.query_transfer.get_information_response函数,这个被调用的函数就是进行HTTP转发的。

这部分也可以通过更高效的方式进行转发,但为了让两个子项目都能自成系统,我们将两个系统的输入都设计成了HTTP,因此转发也就通过HTTP协议进行了。实际上我们将两个系统部署在同一个局域网中,转发通信的额外用时非常少。

数据库事务实践

在数据库课上我们学习了事务,但一直得不到实践的机会。票务系统正是极好的实践机会!

我们简单地利用了事务原子锁来避免票务数据出错,详见queryhandler.tickethandler中的book_ticket函数。

Linux服务器优化

本项目制订了支持500并发用户持续访问的要求,而Linux服务器默认至多同时开启128个套接字,因此需要将服务器的最大套接字数量进行修改。

详见docs中的设计文档。

许可协议

本项目源代码仅供学习之用,不可用于任何其他用途。

tsinghuatuan's People

Contributors

epsirom avatar yl-1993 avatar fanchuang avatar

Watchers

James Cloos avatar Ziru Xu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.