Example #1
0
    def put(self, user_id):
        """

        :param user_id:
        :return:
        """
        info = Request()
        user_id = int(user_id)
        user_object = User()
        username = str_checker(info.get_param('username'), 5, 20, default=None)
        role_id = int_checker(info.get_param('role_id'), 1, 3, default=None)
        content = str_checker(info.get_param('content'), is_html_encode=True)
        print(session.get('role'))
        if session.get('role') == 1:
            if user_object.update(user_id, role_id=role_id) is None:
                return self.error_404('用户不存在')
            else:
                return self.succeed('用户更新信息成功')
        if session.get('admin_user_id') == user_id:
            if user_object.update(user_id, username=username,
                                  content=content) is None:
                return self.error_404('用户不存在')
            else:
                return self.succeed('用户更新信息成功')
        return self.error_403('用户更新信息失败')
Example #2
0
 def post(self):
     """
     用户登陆
     :return:
     """
     request = Request()
     username = request.get_param('username')
     password = request.get_param('password')
     if Authorization.login_check(username, password):
         return self.succeed('登陆成功')
     else:
         return self.error_401('登陆失败,用户名或密码错误')
Example #3
0
 def get(self):
     """
     根据名称查询平台,提供缓存
     :return:
     """
     plat_list = Plat.get_list(Request().get_param('name', ''))
     return self.succeed('平台列表查询成功', plat_list)
Example #4
0
 def put(self, function_id):
     """
     只允许更新urk地址和content
     :param function_id:
     :return:
     """
     try:
         # info = ParamFormat(Request()).get_operate_params()
         info = Request()
     except ValueError as e:
         return self.error_400(str(e))
     if Func().update(function_id,
                      url=info.get_param('url'),
                      coontent=info.get_param('content')) is None:
         return self.error_404('接口%s不存在' % function_id)
     return self.succeed('接口%s更新成功' % function_id)
Example #5
0
 def get(self):
     """
     获取用户列表
     :return:
     """
     info = Request()
     username = str_checker(info.get_param('username'),
                            is_html_encode=False)
     page_size = int_checker(info.get_param('page_size', 10),
                             5,
                             50,
                             default=10)
     page_index = int_checker(info.get_param('page_index', 1), 1, default=1)
     user_info = User.get_list(username, page_size, page_index)
     return self.succeed(
         '查询成功', {
             'user_list': user_info.get('list'),
             'page_info': user_info.get('page_info')
         })
Example #6
0
    def get(self):
        """

        :return:
        """
        try:
            info = ParamFormat(Request()).get_search_params()
            function_info = Func.get_list(**info)
            return self.succeed(
                '查询成功', {
                    'app_list': function_info.get('list'),
                    'page_info': function_info.get('page_info')
                })
        except ValueError as e:
            return self.error_400(str(e))
        except BaseException as e:
            return self.error_500(str(e))
Example #7
0
    def post(self):
        """

        :return:
        """
        try:
            info = ParamFormat(Request()).get_operate_params()
        except ValueError as e:
            return self.error_400(str(e))
        func = Func()
        if func.check_name(info.get('name'), info.get('app_id'),
                           info.get('env_id'), info.get('version'),
                           info.get('platform_num')) is False:
            return self.error_400('路由名已被占用')
        if func.check_function_name(info.get('name'), info.get('app_id'),
                                    info.get('env_id'), info.get('version'),
                                    info.get('platform_num')) is False:
            return self.error_400('函数名已被占用')
        function_id = func.create(**info)
        return self.succeed('接口创建成功', {'function_id': function_id})
Example #8
0
 def post(self):
     """
     创建用户
     :return:
     """
     user_object = User()
     if session.get('role') != 1:
         return self.error_403('创建用户失败')
     info = Request()
     username = str_checker(info.get_param('username'),
                            5,
                            20,
                            default=None,
                            is_html_encode=True)
     password = str_checker((info.get_param('password')),
                            8,
                            default=None,
                            is_html_encode=True)
     if username is None:
         return self.error_400('用户名长度需要需要在5-20个字符之间')
     if password is None:
         return self.error_400('密码不符合要求')
     if user_object.check_username(username):
         user_object.create(username=username,
                            password=sha256(
                                password.encode('utf-8')).hexdigest(),
                            content=str_checker(info.get_param('content'),
                                                is_html_encode=True,
                                                default=''),
                            role_id=int_checker(info.get_param('role_id'),
                                                1,
                                                3,
                                                default=3))
         return self.succeed('用户创建成功')
     else:
         return self.error_400('用户名已被占用')