From 6c8089ed8ecb146eafc49fc7dd5cb6e65a722936 Mon Sep 17 00:00:00 2001 From: lniwn Date: Mon, 29 Jan 2018 22:10:53 +0800 Subject: [PATCH] =?UTF-8?q?[+]=20=E5=88=9D=E5=A7=8B=E5=8C=96=E5=B7=A5?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 188 ++++++++++++++++++++++++++++++++++++++++++++++++ doc/README.md | 33 +++++++++ run.py | 5 ++ src/__init__.py | 4 ++ src/main.py | 63 ++++++++++++++++ 5 files changed, 293 insertions(+) create mode 100644 .gitignore create mode 100644 doc/README.md create mode 100644 run.py create mode 100644 src/__init__.py create mode 100644 src/main.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..35967bf --- /dev/null +++ b/.gitignore @@ -0,0 +1,188 @@ + +# Created by https://www.gitignore.io/api/venv,python,pycharm + +### PyCharm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/ +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Ruby plugin and RubyMine +/.rakeTasks + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### PyCharm Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/sonarlint + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule.* + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +### venv ### +# Linux +bin/ +include/ + +# Window +Include/ +Lib/ +Scripts/ + +# Shared +pyvenv.cfg + + + +# End of https://www.gitignore.io/api/venv,python,pycharm diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 0000000..8694cc6 --- /dev/null +++ b/doc/README.md @@ -0,0 +1,33 @@ +## 接口 +| 接口名 | 请求方法 | 参数 | 备注 | +| --------------- | -------- | ---------------------------------- | -------------------------------- | +| /index | GET | | | +| /update | POST | [{"name":string, "awards_id":int}] | 提交中奖用户 | +| /revoke | POST | {"uid":string} | 取消用户中奖信息,uid为工号,例如G0001 | +| /lucky_users | GET/POST | {"awards_id":int} | 获取所有中奖用户列表,使用post方式获取指定奖项的中奖用户列表 | +| /users | GET | | 获取所有用户列表 | +| /luckless_users | GET | | 获取未中奖用户列表 | +| /awards | GET | | 获取所有奖项列表 | +| /reset | GET | | 重置所有数据 | + +--- + +## 数据库表-leaders + +| 字段值 | 字段类型 | 字段描述 | +| -------- | ------ | ------------------------------ | +| uid | string | 工号,例如:G0001 | +| name | string | 姓名 | +| award_id | int | 奖项id | +| role | int | 角色值,0:实习生,1:正式员工,2:管理层,3:大boss | + + +## 数据库表-awards + +| 字段值 | 字段类型 | 字段描述 | +| -------------- | ------ | ------- | +| award_id | int | 奖项id | +| award_name | string | 奖项名称 | +| award_size | int | 可抽取奖项数量 | +| award_capacity | int | 奖项总数 | + diff --git a/run.py b/run.py new file mode 100644 index 0000000..de6b39c --- /dev/null +++ b/run.py @@ -0,0 +1,5 @@ +#! /usr/bin/python3 +# -*- coding:utf-8 -*- +from src import main + +main.run('localhost', 8080, True) diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..b8a9e51 --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,4 @@ +#! /usr/bin/python3 +# -*- coding:utf-8 -*- +import os +CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..81e68ce --- /dev/null +++ b/src/main.py @@ -0,0 +1,63 @@ +#! /usr/bin/python3 +# -*- coding:utf-8 -*- +import bottle as b +import os +from . import CURRENT_DIR + +app = b.Bottle() + + +@app.route('/') +def index(): + return b.static_file('index.html', os.path.join(CURRENT_DIR, "templates")) + + +@app.route('/update', method='POST') +def update(): + b.abort(403, "禁止修改中奖用户名单") + + +@app.route('/revoke', method='POST') +def revoke(): + pass + + +@app.route('/users') +def users(): + pass + + +@app.route('/lucky_users') +def lucky_users(): + if b.request.method == 'POST': + pass + else: + pass + + +@app.route('/luckless_users') +def luckless_users(): + pass + + +@app.route('/awards') +def awards(): + pass + + +@app.route('/reset') +def reset(): + pass + + +@app.route('/static/') +def callback(filepath): + return b.static_file(filepath, os.path.join(CURRENT_DIR, "static")) + + +def run(host, port, debug): + app.run(host=host, port=port, debug=debug) + + +if __name__ == '__main__': + run('localhost', 8080, True)