def post(self): ret = self.check_privilege(TP_PRIVILEGE_OPS_AUZ) if ret != TPE_OK: return args = self.get_argument('args', None) if args is None: return self.write_json(TPE_PARAM) try: args = json.loads(args) except: return self.write_json(TPE_JSON_FORMAT) # print('---get operator:', args) sql_filter = {} sql_order = dict() sql_order['name'] = 'id' sql_order['asc'] = True sql_limit = dict() sql_limit['page_index'] = 0 sql_limit['per_page'] = 25 try: tmp = list() _filter = args['filter'] for i in _filter: # if i == 'user_id' and _filter[i] == 0: # tmp.append(i) # continue if i == '_name': if len(_filter[i].strip()) == 0: tmp.append(i) for i in tmp: del _filter[i] sql_filter.update(_filter) _limit = args['limit'] if _limit['page_index'] < 0: _limit['page_index'] = 0 if _limit['per_page'] < 10: _limit['per_page'] = 10 if _limit['per_page'] > 100: _limit['per_page'] = 100 sql_limit.update(_limit) _order = args['order'] if _order is not None: sql_order['name'] = _order['k'] sql_order['asc'] = _order['v'] except: return self.write_json(TPE_PARAM) err, total, page_index, row_data = ops.get_operators( sql_filter, sql_order, sql_limit) ret = dict() ret['page_index'] = page_index ret['total'] = total ret['data'] = row_data self.write_json(err, data=ret)
def post(self): ret = self.check_privilege(TP_PRIVILEGE_OPS_AUZ) if ret != TPE_OK: return args = self.get_argument('args', None) if args is None: return self.write_json(TPE_PARAM) try: args = json.loads(args) except: return self.write_json(TPE_JSON_FORMAT) # print('---get operator:', args) sql_filter = {} sql_order = dict() sql_order['name'] = 'id' sql_order['asc'] = True sql_limit = dict() sql_limit['page_index'] = 0 sql_limit['per_page'] = 25 try: tmp = list() _filter = args['filter'] for i in _filter: # if i == 'user_id' and _filter[i] == 0: # tmp.append(i) # continue if i == '_name': if len(_filter[i].strip()) == 0: tmp.append(i) for i in tmp: del _filter[i] sql_filter.update(_filter) _limit = args['limit'] if _limit['page_index'] < 0: _limit['page_index'] = 0 if _limit['per_page'] < 10: _limit['per_page'] = 10 if _limit['per_page'] > 100: _limit['per_page'] = 100 sql_limit.update(_limit) _order = args['order'] if _order is not None: sql_order['name'] = _order['k'] sql_order['asc'] = _order['v'] except: return self.write_json(TPE_PARAM) err, total, page_index, row_data = ops.get_operators(sql_filter, sql_order, sql_limit) ret = dict() ret['page_index'] = page_index ret['total'] = total ret['data'] = row_data self.write_json(err, data=ret)