Sample avap code
This commit is contained in:
parent
1c9ee8d5dd
commit
8379033900
|
|
@ -0,0 +1,3 @@
|
|||
nivel = 5
|
||||
es_admin = nivel >= 10
|
||||
addResult(es_admin)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
subtotal = 150.50
|
||||
iva = subtotal * 0.21
|
||||
total = subtotal + iva
|
||||
addResult(total)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
startLoop(i,1,10)
|
||||
item = "item_%s" % i
|
||||
AddvariableToJSON(item,'valor_generado',mi_json)
|
||||
endLoop()
|
||||
addResult(mi_json)
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
registros = ['1','2','3']
|
||||
getListLen(registros, total)
|
||||
contador = 0
|
||||
startLoop(idx, 0, 2)
|
||||
actual = registros[int(idx)]
|
||||
endLoop()
|
||||
addResult(actual)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
getDateTime("", 86400, "UTC", expira)
|
||||
addResult(expira)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
addParam("client_id", id_interno)
|
||||
addResult(id_interno)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
addParam(emails,emails)
|
||||
getQueryParamList(lista_correos)
|
||||
addResult(lista_correos)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
addParam("lang", l)
|
||||
if(l, "es", "=")
|
||||
addVar(msg, "Hola")
|
||||
end()
|
||||
addResult(msg)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
nombre = "Sistema"
|
||||
log = "Evento registrado por: %s" % nombre
|
||||
addResult(log)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
datos_cliente = "datos"
|
||||
addVar(clave, "cliente_vip")
|
||||
AddvariableToJSON(clave, datos_cliente, mi_json_final)
|
||||
addResult(mi_json_final)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
addParam("data_list", mi_lista)
|
||||
getListLen(mi_lista, cantidad)
|
||||
addResult(cantidad)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
stampToDatetime(1708726162, "%d/%m/%Y", 0, fecha_human)
|
||||
addResult(fecha_human)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
addParam(sal_par,saldo)
|
||||
if(saldo, 0, ">")
|
||||
permitir = True
|
||||
else()
|
||||
permitir = False
|
||||
end()
|
||||
addResult(permitir)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
addParam(userrype, user_type)
|
||||
addParam(sells, compras)
|
||||
if(None, None, " user_type == 'VIP' or compras > 100")
|
||||
addVar(descuento, 0.20)
|
||||
end()
|
||||
addResult(descuento)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
getDateTime("%Y-%m-%d %H:%M:%S", 0, "Europe/Madrid", sql_date)
|
||||
addResult(sql_date)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
function suma(a, b){
|
||||
total = a + b
|
||||
return(total)
|
||||
}
|
||||
resultado = suma(10, 20)
|
||||
addResult(resultado)
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
function es_valido(token){
|
||||
response = False
|
||||
if(token, "SECRET", "=")
|
||||
response = True
|
||||
end()
|
||||
return(response)
|
||||
}
|
||||
autorizado = es_valido("SECRET")
|
||||
addResult(autorizado)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
randomString("[A-Z]\d", 32, token_seguridad)
|
||||
addResult(token_seguridad)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
encodeSHA256("payload_data", checksum)
|
||||
addResult(checksum)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
addVar(mensaje, "Hola mundo desde AVAP")
|
||||
addResult(mensaje)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
addParam(password,pass_nueva)
|
||||
pass_antigua = "password"
|
||||
if(pass_nueva, pass_antigua, "!=")
|
||||
addVar(cambio, "Contraseña actualizada")
|
||||
end()
|
||||
addResult(cambio)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
replace("REF_1234_OLD","OLD", "NEW", ref_actualizada)
|
||||
addResult(ref_actualizada)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
try()
|
||||
ormDirect("UPDATE table_inexistente SET a=1", res)
|
||||
exception(e)
|
||||
addVar(_status,500)
|
||||
addResult("Error de base de datos")
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
getDateTime("", 0, "UTC", ahora)
|
||||
addResult(ahora)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
ormCheckTable(tabla_pruebas,resultado_comprobacion)
|
||||
if(resultado_comprobacion,False,'==')
|
||||
ormCreateTable("username,age",'VARCHAR,INTEGER',tabla_pruebas,resultado_creacion)
|
||||
end()
|
||||
addResult(resultado_comprobacion)
|
||||
addResult(resultado_creacion)
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
addParam("page", p)
|
||||
addParam("size", s)
|
||||
registros = ["u1", "u2", "u3", "u4", "u5", "u6"]
|
||||
offset = int(p) * int(s)
|
||||
limite = offset + int(s)
|
||||
contador = 0
|
||||
addResult(offset)
|
||||
addResult(limite)
|
||||
startLoop(i, 2, limite)
|
||||
actual = registros[int(i)]
|
||||
titulo = "reg_%s" % i
|
||||
AddvariableToJSON(titulo, actual, pagina_json)
|
||||
endLoop()
|
||||
addResult(pagina_json)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
addVar(base, 1000)
|
||||
addVar(copia, $base)
|
||||
addResult(copia)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
addVar(code, 200)
|
||||
addVar(status, "Success")
|
||||
addResult(code)
|
||||
addResult(status)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
encontrado = False
|
||||
startLoop(i, 1, 10)
|
||||
if(i, 5, "==")
|
||||
encontrado = True
|
||||
i = 11
|
||||
end()
|
||||
endLoop()
|
||||
addResult(encontrado)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
try()
|
||||
RequestGet("https://api.test.com/data", 0, 0, respuesta)
|
||||
exception(e)
|
||||
addVar(error_trace, "Fallo de conexión: %s" % e)
|
||||
addResult(error_trace)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
addParam("api_key", key)
|
||||
if(key, None, "==")
|
||||
addVar(_status, 403)
|
||||
addVar(error, "Acceso denegado: falta API KEY")
|
||||
addResult(error)
|
||||
end()
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
addParam("rol", r)
|
||||
if(r, ["admin", "editor", "root"], "in")
|
||||
acceso = True
|
||||
end()
|
||||
addResult(acceso)
|
||||
Loading…
Reference in New Issue