Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
robot_log.py 1.44 KB
Copy Edit Web IDE Raw Blame History
Mendalas authored 2019-06-14 17:01 . remove redis
#coding=utf-8
from flask_restful import Resource
from auth import auth
from flask import Flask, abort, request, jsonify, g, url_for
from flask_sqlalchemy import SQLAlchemy
from api import app
import json
from sqlalchemy import and_,or_
import time
import collections
db = SQLAlchemy(app)
class RobotLog(db.Model):
__tablename__ = 'robot_log'
robot_id = db.Column(db.Integer, primary_key=True)
updatetime = db.Column(db.DateTime,primary_key=True)
#皮带监控信息(key-value)
desc = db.Column(db.String(255))
op_id = db.Column(db.String(255))
def to_json(self):
return {
"robot_id":self.robot_id,
"updatetime":str(self.updatetime),
"desc":self.desc,
"op_id":self.op_id,
}
class getRobotlogApi(Resource):
def post(self):
pageSize = int(request.form["pageSize"])
pageIndex = int(request.form["pageIndex"])
result = []
result = db.session.query(RobotLog).order_by(RobotLog.updatetime).\
limit(pageSize).offset((pageIndex-1)*pageSize)
msg = {}
v = []
size = 0
for r in result:
v.append(r.to_json())
size+=1
msg["data"] = v
if(size == 0):
msg["code"] = -1
msg["message"] = "已经是最后一页了"
else:
msg["code"] = 1
msg["message"] = "ok"
app.logger.info(msg)
return msg

Comment ( 0 )

Sign in for post a comment