Ejemplo n.º 1
0
    def get(self, instid):
        opList = OperationSubModel.query.filter_by(instanceid=instid).all()

        return query_request({
            'rows': OperationSubSchema(many=True).dump(opList),
            'count': len(opList)
        })
Ejemplo n.º 2
0
 def get(self):
     # 返回所有数据
     page = request.args.get("page", 1, type=int)
     pagesize = min(request.args.get("limit", 50, type=int), 100)
     data = SubappModel.query.paginate(page, pagesize)
     subapps_result = subapps_schema.dump(data.items)
     return query_request(subapps_result)
Ejemplo n.º 3
0
 def get(self):
     # 返回所有数据
     page = request.args.get("page", 1, type=int)
     pagesize = min(request.args.get("limit", 50, type=int), 100)
     data = LoginModel.query.paginate(page, pagesize)
     datacount = LoginModel.query.count()
     logins_result = logins_schema.dump(data.items)
     return query_request({'rows': logins_result, 'count': datacount})
Ejemplo n.º 4
0
 def get(self):
     # 返回所有数据
     page = request.args.get("page", 1, type=int)
     pagesize = min(request.args.get("limit", 50, type=int), 100)
     data = InstanceModel.query.paginate(page, pagesize)
     # data = App.query.all()
     instances_result = instances_schema.dump(data.items)
     return query_request(instances_result)
Ejemplo n.º 5
0
 def get(self, appid):
     # 返回所有数据
     page = request.args.get("page", 1, type=int)
     pagesize = min(request.args.get("limit", 50, type=int), 100)
     subapps = SubappModel.query.filter_by(appid=appid).order_by(
         SubappModel.createdAt.desc()).paginate(page, pagesize)
     datacount = SubappModel.query.filter_by(appid=appid).order_by(
         SubappModel.createdAt.desc()).count()
     subapps_result = subapps_schema.dump(subapps.items)
     return query_request({'rows': subapps_result, 'count': datacount})
Ejemplo n.º 6
0
    def get(self, subappid):
        # get operations list
        instList = InstanceModel.query.filter_by(subappid=subappid).all()
        instidlist = [inst.instid for inst in instList]
        oplist = OperationSubModel.query.filter(
            InstanceModel.instid.in_(instidlist)).all()

        return query_request({
            'rows': OperationSubSchema(many=True).dump(oplist),
            'count': len(oplist)
        })
Ejemplo n.º 7
0
 def get(self, hostid):
     # 返回所有数据
     page = request.args.get("page", 1, type=int)
     pagesize = min(request.args.get("limit", 50, type=int), 100)
     instances = InstanceModel.query.filter_by(hostid=hostid).order_by(
         InstanceModel.createdAt.desc()).paginate(page, pagesize)
     instancescount = InstanceModel.query.filter_by(hostid=hostid).order_by(
         InstanceModel.createdAt.desc()).count()
     instances_result = instances_schema.dump(instances.items)
     return query_request({
         'rows': instances_result,
         'count': instancescount
     })
Ejemplo n.º 8
0
    def post(self):
        # 新增数据
        if not request.is_json:
            return bad_request('post json data fail')

        username = request.json.get('username', None)
        password = request.json.get('password', None)
        if not username:
            return bad_request('Missing username parameter')
        if not password:
            return bad_request('Missing password parameter')

        user = UserModel.query.filter_by(username=username,
                                         password=password).first()
        if not user:
            return bad_request('username or password is incorrect')

        # Identity can be any data that is json serializable
        access_token = create_access_token(identity=username)
        return query_request(
            {
                'token': access_token,
                'user': user_schema.dump(user)
            }, "create token success")
Ejemplo n.º 9
0
 def get(self, loginid):
     # 返回所有数据
     app = LoginModel.query.get(loginid)
     app_result = login_schema.dump(app)
     return query_request(app_result)
Ejemplo n.º 10
0
 def get(self, subappid):
     # 返回所有数据
     app = SubappModel.query.get(subappid)
     app_result = subapp_schema.dump(app)
     return query_request(app_result)
Ejemplo n.º 11
0
 def get(self, instid):
     # 返回所有数据
     app = InstanceModel.query.get(instid)
     app_result = instance_schema.dump(app)
     return query_request(app_result)
Ejemplo n.º 12
0
 def get(self, hostid):
     # 返回所有数据
     app = HostModel.query.get(hostid)
     app_result = host_schema.dump(app)
     return query_request(app_result)