Esempio n. 1
0
    def post(self):
        user_name = self.data.get("user_name")
        pwd = self.data.get("pwd")
        user_token = self.data.get("user_token")

        if user_token:
            # 查库
            db_ret = read_local(1, user_name)
            if db_ret[-2] == user_token:
                return self.finish({"code": 200, "msg": "用户登陆成功"})

        if user_name is None or pwd is None:
            return self.finish({"code": 400, "msg": "用户名或密码为空"})

        # 查库
        db_ret = read_local(1, user_name)

        if db_ret is None:
            return self.finish({"code": 400, "msg": "用户名或密码错误"})
        elif db_ret[1] == user_name and db_ret[2] == md5(pwd):
            # 更新token, 此处未设置token过期时间,文本对比过期时间过于繁琐
            token = md5(uuid.uuid4())
            update_local(1, user_name, -2, token)
            logger.info("用户登陆成功")
            return self.finish({"code": 200, "msg": "用户登陆成功"})
        else:
            return self.finish({"code": 400, "msg": "用户名或密码错误"})
    def post(self):
        user_name = self.data.get("user_name")
        user_interview = self.data.get("user_interview")

        if user_name is None:
            return self.finish({"code": 400, "msg": "未检测到用户名称"})

        if user_interview is None:
            return self.finish({"code": 400, "msg": "未检测到修改内容"})

        # 改库
        update_local(1, user_name, -3, user_interview)

        logger.info("用户修改成功")

        return self.finish({"code": 200, "msg": "用户修改成功"})
    def post(self):
        user_name = self.data.get("user_name")
        aid_user_name = self.data.get("aid_user_name")
        user_auth = self.data.get("user_auth")

        # 查询用户权限
        db_ret = read_local(1, user_name)

        # 权限不足
        if user_auth is not None and db_ret[-4] != "admin":
            return self.finish({"code": 400, "msg": "用户权限不足,无法修改"})

        # 改库
        update_local(1, aid_user_name, -4, user_auth)

        logger.info("用户修改成功")

        return self.finish({"code": 200, "msg": "用户修改成功"})
    def post(self):
        user_name = self.data.get("user_name")

        if user_name is None:
            return self.finish({"code": 400, "msg": "未检测到用户名称"})

        # 查询
        db_ret = read_local(1, user_name)
        status = db_ret[-3]

        logger.info("用户查询成功")

        return self.finish({
            "code": 200,
            "msg": "用户查询成功",
            "data": [{
                "status": status
            }]
        })
# coding:utf8

from log.log_handler import logger
from config.config import http_server
import tornado.ioloop


if __name__ == "__main__":
    logger.info("服务器启动")
    tornado.ioloop.IOLoop.instance().start()