예제 #1
0
 def get(self, kkdd_id):
     try:
         kkdd_list = Kkdd.query.filter(
             Kkdd.kkdd_id.startswith(kkdd_id)).all()
         items = []
         for i in kkdd_list:
             items.append({'kkdd_id': i.kkdd_id, 'kkdd_name': i.kkdd_name,
                           'cf_id': i.cf_id, 'sbdh': sbdh})
         return {'total_count': len(items), 'items': items}, 200
     except Exception as e:
         logger.error(e)
         raise
예제 #2
0
 def get(self, kkdd_id):
     try:
         hbc_list = WZImg.query.filter(
             WZImg.kkdd_id.startswith(kkdd_id)).all()
         items = []
         for i in hbc_list:
             items.append({'kkdd_id': i.kkdd_id, 'fxbh_code': i.fxbh_code,
                           'img_path': i.img_path})
         return {'total_count': len(items), 'items': items}, 200
     except Exception as e:
         print (e)
         logger.error(e)
         raise
예제 #3
0
 def get(self, date, hphm, kkdd):
     try:
         hbc_list = Hbc.query.filter(Hbc.date == date, Hbc.hphm == hphm,
                                     Hbc.kkdd_id.startswith(kkdd),
                                     Hbc.imgpath != '').all()
         items = []
         for hbc in hbc_list:
             items.append({'id': hbc.id, 'jgsj': str(hbc.jgsj),
                           'hphm': hbc.hphm, 'kkdd_id': hbc.kkdd_id,
                           'imgpath': hbc.imgpath})
     except Exception as e:
         logger.error(e)
         raise
     return {'total_count': len(items), 'items': items}, 200
예제 #4
0
def get_uid():
    g.uid = -1
    g.scope = ''
    try:
        user = Users.query.filter_by(username=request.json.get('username', ''),
                                     banned=0).first()
    except Exception as e:
        logger.error(e)
        raise
    if user:
        if sha256_crypt.verify(request.json.get('password', ''), user.password):
            g.uid = user.id
            g.scope = user.scope
            return str(g.uid)
    return request.remote_addr
예제 #5
0
    def post(self):
        parser = reqparse.RequestParser()
        parser.add_argument('jgsj', type=unicode, required=True,
                            help='A jgsj field is require', location='json')
        parser.add_argument('hphm', type=unicode, required=True,
                            help='A hphm field is require', location='json')
        parser.add_argument('kkdd_id', type=unicode, required=True,
                            help='A kkdd_id field is require', location='json')
        parser.add_argument('hpys_code', type=unicode, required=True,
                            help='A hpys field is require', location='json')
        parser.add_argument('fxbh_code', type=unicode, required=True,
                            help='A fxbh field is require', location='json')
        parser.add_argument('cdbh', type=int, required=True,
                            help='A cdbh field is require', location='json')
        parser.add_argument('imgurl', type=unicode, required=True,
                            help='A imgurl field is require', location='json')
        parser.add_argument('imgpath', type=unicode,
                            help='A imgurl field is require', location='json')
        args = parser.parse_args()
        try:
            t = arrow.get(request.json['jgsj']).replace(hours=-8).to('local')
            hbc = Hbc(date=t.format('YYYY-MM-DD'),
                      jgsj=t.datetime,
                      hphm=request.json['hphm'],
                      kkdd_id=request.json['kkdd_id'],
                      hpys_code=request.json['hpys_code'],
                      fxbh_code=request.json['fxbh_code'],
                      cdbh=request.json['cdbh'],
                      imgurl=request.json['imgurl'],
                      imgpath=request.json.get('imgpath', ''),
                      banned=0)
            db.session.add(hbc)
            db.session.commit()
        except Exception as e:
            logger.error(e)
            raise

        result = row2dict(hbc)
        result['jgsj'] = str(result['jgsj'])
        del result['date']
        return result, 201