Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
formulario-api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Denys Tito Urbano
formulario-api
Commits
6272171f
Commit
6272171f
authored
Dec 18, 2023
by
Denys Tito Urbano
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mzuniga' of
http://version.sacooliveros.edu.pe/dtito/formulario-api
into mzuniga
parents
032f2942
0a45daae
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
5 deletions
+57
-5
ExcelApi.java
src/main/java/pe/so/api/formulario/api/ExcelApi.java
+22
-0
ExcelDAO.java
src/main/java/pe/so/api/formulario/dao/ExcelDAO.java
+2
-0
CorsFilter.java
src/main/java/pe/so/api/formulario/filters/CorsFilter.java
+5
-5
PostgreSqlExcel.java
...ava/pe/so/api/formulario/postgresdao/PostgreSqlExcel.java
+24
-0
ExcelServices.java
...ain/java/pe/so/api/formulario/services/ExcelServices.java
+4
-0
No files found.
src/main/java/pe/so/api/formulario/api/ExcelApi.java
View file @
6272171f
...
...
@@ -534,4 +534,26 @@ public class ExcelApi {
}
}
@POST
@Path
(
"/procedure"
)
public
Response
procedure
(
String
json
){
JSONObject
salida
=
new
JSONObject
();
try
{
JSONObject
entrada
=
new
JSONObject
(
json
);
salida
=
new
ExcelServices
().
procedure
(
entrada
);
return
Response
.
status
(
200
).
entity
(
salida
.
toString
()).
build
();
}
catch
(
JSONException
ex
)
{
salida
.
put
(
"status"
,
false
);
salida
.
put
(
"message"
,
ex
.
getMessage
());
throw
new
WebApplicationException
(
Response
.
status
(
400
).
entity
(
salida
.
toString
()).
build
());
}
catch
(
BadRequestException
ex
)
{
salida
=
new
JSONObject
(
ex
.
getMessage
());
throw
new
WebApplicationException
(
Response
.
status
(
500
).
entity
(
salida
.
toString
()).
build
());
}
catch
(
Exception
ex
)
{
salida
.
put
(
"status"
,
false
);
salida
.
put
(
"message"
,
ex
.
getMessage
());
throw
new
WebApplicationException
(
Response
.
status
(
500
).
entity
(
salida
.
toString
()).
build
());
}
}
}
src/main/java/pe/so/api/formulario/dao/ExcelDAO.java
View file @
6272171f
...
...
@@ -50,4 +50,6 @@ public interface ExcelDAO{
JSONObject
listar_aniversario_reporte
(
JSONObject
entrada
)
throws
Exception
;
JSONObject
procedure
(
JSONObject
entrada
)
throws
Exception
;
}
src/main/java/pe/so/api/formulario/filters/CorsFilter.java
View file @
6272171f
...
...
@@ -38,20 +38,20 @@ public class CorsFilter implements Filter {
response
.
setHeader
(
"Access-Control-Allow-Credentials"
,
"true"
);
try
{
if
((
response
.
getHeader
(
"Access-Control-Allow-Origin"
).
equals
(
"*"
)
||
/*
if ((response.getHeader("Access-Control-Allow-Origin").equals("*") ||
response.getHeader("Access-Control-Allow-Origin").contains(request.getRemoteHost())) &&
(Arrays.asList(ExcelIds)
.contains(request.getHeader("Authorization")) || existeId(request.getHeader("Authorization")))) {
*/
filterChain
.
doFilter
(
servletRequest
,
response
);
}
else
{
/*
} else {
response.setContentType("application/json");
response.setStatus(401);
response.getWriter()
.write("{\"mensaje\":\"No estas autorizado a usar este recurso.\",\"status\":false}");
}
}
catch
(
SQL
Exception
e
)
{
}
*/
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
...
...
src/main/java/pe/so/api/formulario/postgresdao/PostgreSqlExcel.java
View file @
6272171f
...
...
@@ -709,4 +709,28 @@ public class PostgreSqlExcel implements ExcelDAO {
return
new
JSONObject
(
salida
.
getString
(
"json"
));
}
@Override
public
JSONObject
procedure
(
JSONObject
entrada
)
throws
Exception
{
String
sql
=
entrada
.
getString
(
"procedure"
);
JSONArray
array
=
entrada
.
optJSONArray
(
"array"
);
JSONArray
errores
=
new
JSONArray
();
for
(
int
i
=
0
;
i
<
array
.
length
()
;
i
++){
JSONObject
obj
=
array
.
getJSONObject
(
i
);
try
{
JSONObject
response
=
PostgreSqlFactoryDAO
.
queryPSSingle
(
"siiaa"
,
sql
,
obj
.
getJSONArray
(
"params"
));
JSONObject
json
=
new
JSONObject
(
response
.
getString
(
"json"
));
if
(!
json
.
getBoolean
(
"status"
)){
errores
.
put
(
response
.
put
(
"fila"
,
obj
.
getInt
(
"fila"
)));
}
}
catch
(
Exception
e
){
errores
.
put
(
new
JSONObject
().
put
(
"status"
,
false
).
put
(
"message"
,
e
.
getMessage
()).
put
(
"fila"
,
obj
.
getInt
(
"fila"
)));
}
}
if
(
errores
.
length
()
>
0
){
return
new
JSONObject
().
put
(
"status"
,
false
).
put
(
"message"
,
"se encontrarón errores"
).
put
(
"errors"
,
errores
);
}
else
{
return
new
JSONObject
().
put
(
"status"
,
true
).
put
(
"message"
,
"ok"
);
}
}
}
src/main/java/pe/so/api/formulario/services/ExcelServices.java
View file @
6272171f
...
...
@@ -543,4 +543,8 @@ public class ExcelServices {
return
dao
.
listar_aniversario_reporte
(
entrada
);
}
public
JSONObject
procedure
(
JSONObject
json
)
throws
Exception
{
return
dao
.
procedure
(
json
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment