diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7..b465b7e 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,5 +2,6 @@
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 720cd99..b76edb3 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,352 +2,259 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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+548,11 @@
-
-
+
+
+
+
@@ -603,13 +593,30 @@
1563352800796
-
+
+ 1563411566956
+
+
+
+ 1563411566956
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
@@ -621,10 +628,10 @@
-
+
-
+
@@ -640,6 +647,9 @@
+
+
+
@@ -661,34 +671,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -696,20 +679,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -717,16 +686,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -737,7 +696,7 @@
-
+
@@ -747,26 +706,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -774,5 +713,242 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/application.py b/application.py
index a26ac90..693396a 100644
--- a/application.py
+++ b/application.py
@@ -2,6 +2,7 @@
from flask import Flask
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy
+
import os
class Application( Flask ):
def __init__(self,import_name,template_folder=None,root_path = None):
diff --git a/common/__init__.py b/common/__init__.py
index 7c68785..179cad4 100644
--- a/common/__init__.py
+++ b/common/__init__.py
@@ -1 +1,3 @@
-# -*- coding: utf-8 -*-
\ No newline at end of file
+# -*- coding: utf-8 -*-
+import pymysql
+pymysql.install_as_MySQLdb()
\ No newline at end of file
diff --git a/common/libs/user/UserService.py b/common/libs/user/UserService.py
new file mode 100644
index 0000000..1db57f1
--- /dev/null
+++ b/common/libs/user/UserService.py
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+import hashlib,base64,random,string
+
+class UserService():
+
+ @staticmethod
+ def geneAuthCode(user_info = None ):
+ m = hashlib.md5()
+ str = "%s-%s-%s-%s" % (user_info.uid, user_info.login_name, user_info.login_pwd, user_info.login_salt)
+ m.update(str.encode("utf-8"))
+ return m.hexdigest()
+
+ @staticmethod
+ def genePwd( pwd,salt):
+ m = hashlib.md5()
+ str = "%s-%s" % ( base64.encodebytes( pwd.encode("utf-8") ) , salt)
+ m.update(str.encode("utf-8"))
+ return m.hexdigest()
+
+ @staticmethod
+ def geneSalt( length = 16 ):
+ keylist = [ random.choice( ( string.ascii_letters + string.digits ) ) for i in range( length ) ]
+ return ( "".join( keylist ) )
diff --git a/common/libs/user/__init__.py b/common/libs/user/__init__.py
new file mode 100644
index 0000000..7c68785
--- /dev/null
+++ b/common/libs/user/__init__.py
@@ -0,0 +1 @@
+# -*- coding: utf-8 -*-
\ No newline at end of file
diff --git a/common/models/User.py b/common/models/User.py
new file mode 100644
index 0000000..998e336
--- /dev/null
+++ b/common/models/User.py
@@ -0,0 +1,22 @@
+# coding: utf-8
+from sqlalchemy import BigInteger, Column, DateTime, Integer, String
+from sqlalchemy.schema import FetchedValue
+from application import db
+
+
+
+class User(db.Model):
+ __tablename__ = 'user'
+
+ uid = db.Column(db.BigInteger, primary_key=True)
+ nickname = db.Column(db.String(100), nullable=False, server_default=db.FetchedValue())
+ mobile = db.Column(db.String(20), nullable=False, server_default=db.FetchedValue())
+ email = db.Column(db.String(100), nullable=False, server_default=db.FetchedValue())
+ sex = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
+ avatar = db.Column(db.String(64), nullable=False, server_default=db.FetchedValue())
+ login_name = db.Column(db.String(20), nullable=False, unique=True, server_default=db.FetchedValue())
+ login_pwd = db.Column(db.String(32), nullable=False, server_default=db.FetchedValue())
+ login_salt = db.Column(db.String(32), nullable=False, server_default=db.FetchedValue())
+ status = db.Column(db.Integer, nullable=False, server_default=db.FetchedValue())
+ updated_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
+ created_time = db.Column(db.DateTime, nullable=False, server_default=db.FetchedValue())
diff --git a/config/__init__.py b/config/__init__.py
index 7c68785..40a96af 100644
--- a/config/__init__.py
+++ b/config/__init__.py
@@ -1 +1 @@
-# -*- coding: utf-8 -*-
\ No newline at end of file
+# -*- coding: utf-8 -*-
diff --git a/config/base_setting.py b/config/base_setting.py
index a79c20f..0c861c4 100644
--- a/config/base_setting.py
+++ b/config/base_setting.py
@@ -1,4 +1,16 @@
# -*- coding: utf-8 -*-
SERVER_PORT = 8999
DEBUG = False
-SQLALCHEMY_ECHO = False
\ No newline at end of file
+SQLALCHEMY_ECHO = False
+
+AUTH_COOKIE_NAME = "mooc_food"
+
+##过滤url
+IGNORE_URLS = [
+ "^/user/login"
+]
+
+IGNORE_CHECK_LOGIN_URLS = [
+ "^/static",
+ "^/favicon.ico"
+]
\ No newline at end of file
diff --git a/config/local_setting.py b/config/local_setting.py
index 028f258..7b862fc 100644
--- a/config/local_setting.py
+++ b/config/local_setting.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
+SERVER_PORT = 9000
DEBUG = True
SQLALCHEMY_ECHO = True
-SQLALCHEMY_DATABASE_URI = 'mysql://root:123456@127.0.0.1/mysql?charset=utf8mb4'
+SQLALCHEMY_DATABASE_URI = 'mysql://root:123456@127.0.0.1/food_db'
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_ENCODING = "utf8mb4"
diff --git a/requirements.txt b/requirements.txt
index 3efc93c..8aef395 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,4 +1,6 @@
flask
flask-sqlalchemy
+flask-debugtoolbar
-flask_script
\ No newline at end of file
+flask_script
+requests
diff --git a/venv/Lib/site-packages/Flask_DebugToolbar-0.10.1.dist-info/DESCRIPTION.rst b/venv/Lib/site-packages/Flask_DebugToolbar-0.10.1.dist-info/DESCRIPTION.rst
new file mode 100644
index 0000000..80ec3be
--- /dev/null
+++ b/venv/Lib/site-packages/Flask_DebugToolbar-0.10.1.dist-info/DESCRIPTION.rst
@@ -0,0 +1,204 @@
+Flask Debug-toolbar
+===================
+
+This is a port of the excellent `django-debug-toolbar `_
+for Flask applications.
+
+.. image:: https://travis-ci.org/mgood/flask-debugtoolbar.png?branch=master
+ :target: https://travis-ci.org/mgood/flask-debugtoolbar
+
+
+Installation
+------------
+
+Installing is simple with pip::
+
+ $ pip install flask-debugtoolbar
+
+
+Usage
+-----
+
+Setting up the debug toolbar is simple::
+
+ from flask import Flask
+ from flask_debugtoolbar import DebugToolbarExtension
+
+ app = Flask(__name__)
+
+ # the toolbar is only enabled in debug mode:
+ app.debug = True
+
+ # set a 'SECRET_KEY' to enable the Flask session cookies
+ app.config['SECRET_KEY'] = ''
+
+ toolbar = DebugToolbarExtension(app)
+
+
+The toolbar will automatically be injected into Jinja templates when debug mode is on.
+In production, setting ``app.debug = False`` will disable the toolbar.
+
+See the `documentation`_ for more information.
+
+.. _documentation: https://flask-debugtoolbar.readthedocs.io/
+
+
+Changes
+=======
+
+0.10.1 (2017-02-12)
+-------------------
+
+Enhancements:
+- Add support for Python wheels
+
+Fixes:
+
+- Switch imports from deprecated flask.ext.* to flask_* syntax (#94, thanks
+ Michael Lenzen & #97 thanks Iuri de Silvio)
+
+0.10.0 (2015-04-17)
+-------------------
+
+Enhancements:
+
+- Added new "Routes" panel displaying URL routing rules (#69, thanks Justin McKay)
+- "Versions" panel displays versions of all installed packages (#49, thanks Lucas Taylor)
+- SQLAlchemy displays necessary setup steps to set up query recording
+- Support reformatting SQL queries if ``sqlparse`` library is available (#48, thanks Hyunjun Kim)
+- Enable sorting SQLAlchemy queries (#81, thanks Eric Workman)
+- Support inserting toolbar on HTML5 pages without ``