Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
trismegisto-services
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
Mauro Paolo Josue Zuñiga Mallqui
trismegisto-services
Commits
47e71c8c
Commit
47e71c8c
authored
Dec 10, 2025
by
Mauro Paolo Josue Zuñiga Mallqui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD] AVANCES
parent
f3731d0c
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
284 additions
and
76 deletions
+284
-76
DotEnvConfig.java
...eb/multitask/trismegistoservices/config/DotEnvConfig.java
+5
-4
WebSocketConfig.java
...multitask/trismegistoservices/config/WebSocketConfig.java
+0
-1
MHRest.java
...ava/web/multitask/trismegistoservices/rest/MH/MHRest.java
+61
-0
consoleRest.java
...a/web/multitask/trismegistoservices/rest/consoleRest.java
+1
-1
driveRest.java
...ava/web/multitask/trismegistoservices/rest/driveRest.java
+2
-1
emailRest.java
...ava/web/multitask/trismegistoservices/rest/emailRest.java
+20
-18
excelRest.java
...ava/web/multitask/trismegistoservices/rest/excelRest.java
+1
-1
routineRest.java
...a/web/multitask/trismegistoservices/rest/routineRest.java
+23
-22
MHService.java
.../multitask/trismegistoservices/services/MH/MHService.java
+82
-0
DataSourceUtils.java
.../multitask/trismegistoservices/utils/DataSourceUtils.java
+56
-0
DotEnvUtils.java
.../web/multitask/trismegistoservices/utils/DotEnvUtils.java
+5
-4
RoutineUtils.java
...web/multitask/trismegistoservices/utils/RoutineUtils.java
+28
-24
No files found.
src/main/java/web/multitask/trismegistoservices/config/DotEnvConfig.java
View file @
47e71c8c
package
web
.
multitask
.
trismegistoservices
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
io.github.cdimascio.dotenv.Dotenv
;
import
web.multitask.trismegistoservices.utils.
d
otEnvUtils
;
import
web.multitask.trismegistoservices.utils.
D
otEnvUtils
;
@Configuration
public
class
DotEnvConfig
{
//
@Bean
@Bean
Dotenv
getDotEnvPath
()
{
return
Dotenv
.
configure
().
directory
(
dotEnvUtils
.
getDotEnvPath
(
"trismegisto-asistencia
"
)).
load
();
return
Dotenv
.
configure
().
directory
(
DotEnvUtils
.
getDotEnvPath
(
"trismegisto-asistencia_ssl
"
)).
load
();
}
}
\ No newline at end of file
src/main/java/web/multitask/trismegistoservices/config/WebSocketConfig.java
View file @
47e71c8c
...
...
@@ -3,7 +3,6 @@ package web.multitask.trismegistoservices.config;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.messaging.simp.config.ChannelRegistration
;
import
org.springframework.messaging.simp.config.MessageBrokerRegistry
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
;
import
org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker
;
import
org.springframework.web.socket.config.annotation.StompEndpointRegistry
;
...
...
src/main/java/web/multitask/trismegistoservices/rest/MH/MHRest.java
0 → 100644
View file @
47e71c8c
package
web
.
multitask
.
trismegistoservices
.
rest
.
MH
;
import
org.json.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.bind.annotation.*
;
import
web.multitask.trismegistoservices.services.MH.MHService
;
import
web.multitask.trismegistoservices.utils.DataSourceUtils
;
import
web.multitask.trismegistoservices.utils.RoutineUtils
;
@RestController
@CrossOrigin
(
origins
=
"*"
)
@RequestMapping
(
"mh"
)
public
class
MHRest
{
private
final
DataSourceUtils
dataSourceUtils
;
private
final
RoutineUtils
routineUtils
;
public
MHRest
(
DataSourceUtils
dataSourceUtils
,
RoutineUtils
routineUtils
)
{
this
.
dataSourceUtils
=
dataSourceUtils
;
this
.
routineUtils
=
routineUtils
;
}
@PostMapping
(
"/private/consultar_datos_trabajador"
)
public
ResponseEntity
<?>
datosTrabajador
(
@RequestBody
String
json
)
{
MHService
service
=
new
MHService
(
dataSourceUtils
,
routineUtils
);
JSONObject
jsonRequest
=
new
JSONObject
(
json
);
jsonRequest
.
put
(
"opcion"
,
"consultar_datos"
);
JSONObject
jsonResponse
=
service
.
consultarTrabajador
(
jsonRequest
);
return
ResponseEntity
.
ok
(
jsonResponse
.
toMap
());
}
@PostMapping
(
"/private/consultar_saldo_trabajador"
)
public
ResponseEntity
<?>
saldoTrabajador
(
@RequestBody
String
json
)
{
MHService
service
=
new
MHService
(
dataSourceUtils
,
routineUtils
);
JSONObject
jsonRequest
=
new
JSONObject
(
json
);
jsonRequest
.
put
(
"opcion"
,
"consultar_saldo"
);
JSONObject
jsonResponse
=
service
.
consultarTrabajador
(
jsonRequest
);
return
ResponseEntity
.
ok
(
jsonResponse
.
toMap
());
}
@PostMapping
(
"/private/consultar_cargo_trabajador"
)
public
ResponseEntity
<?>
cargoTrabajador
(
@RequestBody
String
json
)
{
MHService
service
=
new
MHService
(
dataSourceUtils
,
routineUtils
);
JSONObject
jsonRequest
=
new
JSONObject
(
json
);
jsonRequest
.
put
(
"opcion"
,
"consultar_cargo"
);
JSONObject
jsonResponse
=
service
.
consultarTrabajador
(
jsonRequest
);
return
ResponseEntity
.
ok
(
jsonResponse
.
toMap
());
}
@PostMapping
(
"/private/registrar_venta"
)
public
ResponseEntity
<?>
registrarVenta
(
@RequestBody
String
json
)
{
MHService
service
=
new
MHService
(
dataSourceUtils
,
routineUtils
);
JSONObject
jsonRequest
=
new
JSONObject
(
json
);
jsonRequest
.
put
(
"opcion"
,
"consultar_cargo"
);
JSONObject
jsonResponse
=
service
.
registrarVenta
(
jsonRequest
);
return
ResponseEntity
.
ok
(
jsonResponse
.
toMap
());
}
}
src/main/java/web/multitask/trismegistoservices/rest/consoleRest.java
View file @
47e71c8c
...
...
@@ -34,7 +34,7 @@ public class consoleRest {
output
.
append
(
"\n"
).
append
(
line
);
}
process
.
waitFor
();
return
ResponseEntity
.
ok
(
output
.
toString
().
replace
(
"[sudo] contraseña para wildfly: "
,
""
));
return
ResponseEntity
.
ok
(
output
.
toString
().
replace
(
"[sudo] contraseña para wildfly: "
,
""
));
}
catch
(
IOException
|
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
...
...
src/main/java/web/multitask/trismegistoservices/rest/driveRest.java
View file @
47e71c8c
...
...
@@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
import
org.springframework.web.multipart.MultipartFile
;
import
web.multitask.trismegistoservices.model.DriveRequest
;
import
web.multitask.trismegistoservices.services.google.DriveService
;
import
javax.annotation.Nullable
;
@RestController
...
...
@@ -38,7 +39,7 @@ public class driveRest {
response
.
put
(
"message"
,
"File uploaded successfully."
);
response
.
put
(
"file_id"
,
id_file_response
);
response
.
put
(
"file_url"
,
"https://drive.google.com/file/d/"
+
id_file_response
+
"/view?usp=sharing"
);
response
.
put
(
"download_url"
,
"https://drive.google.com/uc?export=download&id="
+
id_file_response
);
response
.
put
(
"download_url"
,
"https://drive.google.com/uc?export=download&id="
+
id_file_response
);
return
ResponseEntity
.
ok
(
response
.
toMap
());
}
}
catch
(
Exception
e
)
{
...
...
src/main/java/web/multitask/trismegistoservices/rest/emailRest.java
View file @
47e71c8c
// package web.multitask.app.api;
package
web
.
multitask
.
trismegistoservices
.
rest
;
import
javax.mail.internet.MimeMessage
;
import
lombok.AllArgsConstructor
;
import
org.json.JSONObject
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
web.multitask.trismegistoservices.model.GmailRequest
;
package
web
.
multitask
.
trismegistoservices
.
rest
;
import
javax.mail.internet.MimeMessage
;
import
lombok.AllArgsConstructor
;
import
org.json.JSONObject
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
web.multitask.trismegistoservices.model.GmailRequest
;
// import web.multitask.trismegistoservices.mysql.EmailMysql;
import
web.multitask.trismegistoservices.services.google.GmailService
;
import
web.multitask.trismegistoservices.services.google.GmailService
;
@RestController
@RequestMapping
(
"/gmail"
)
@RestController
@RequestMapping
(
"/gmail"
)
@AllArgsConstructor
public
class
emailRest
{
public
class
emailRest
{
private
final
GmailService
emailService
;
...
...
@@ -25,11 +27,11 @@
public
ResponseEntity
<?>
full
(
@ModelAttribute
GmailRequest
request
)
{
try
{
MimeMessage
message
=
emailService
.
htmlMessage
(
request
);
JSONObject
response
=
emailService
.
send
(
message
,
request
.
getFrom
());
JSONObject
response
=
emailService
.
send
(
message
,
request
.
getFrom
());
return
ResponseEntity
.
ok
(
response
.
toMap
());
}
catch
(
Exception
e
)
{
return
ResponseEntity
.
internalServerError
().
body
(
new
JSONObject
().
put
(
"message"
,
e
.
getMessage
()).
put
(
"status"
,
false
).
toMap
());
}
}
}
\ No newline at end of file
}
\ No newline at end of file
src/main/java/web/multitask/trismegistoservices/rest/excelRest.java
View file @
47e71c8c
...
...
@@ -31,7 +31,7 @@ public class excelRest {
int
size
=
json
.
getBytes
().
length
;
System
.
out
.
println
(
"Size: "
+
size
);
byte
[]
excelByte
=
excelService
.
generateExcel
(
jsonBody
,
size
);
if
(
excelByte
==
null
)
{
if
(
excelByte
==
null
)
{
return
ResponseEntity
.
internalServerError
().
body
(
"Error al generar el archivo"
);
}
if
(
jsonBody
.
optBoolean
(
"base64"
,
false
))
{
...
...
src/main/java/web/multitask/trismegistoservices/rest/routineRest.java
View file @
47e71c8c
...
...
@@ -5,7 +5,7 @@ import org.json.JSONArray;
import
org.json.JSONObject
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
web.multitask.trismegistoservices.
mysql.RoutineSql
;
import
web.multitask.trismegistoservices.
utils.RoutineUtils
;
@RestController
@CrossOrigin
(
"*"
)
...
...
@@ -13,26 +13,26 @@ import web.multitask.trismegistoservices.mysql.RoutineSql;
@AllArgsConstructor
public
class
routineRest
{
final
RoutineSql
procedureMysql
;
@PostMapping
(
"/public/routine"
)
public
ResponseEntity
<?>
callRoutine
(
@RequestBody
String
body
)
{
JSONObject
json
=
new
JSONObject
(
body
);
if
(
json
.
has
(
"routine"
))
{
try
{
JSONArray
params
=
json
.
isNull
(
"params"
)
?
new
JSONArray
()
:
json
.
getJSONArray
(
"params"
);
String
routine
=
json
.
getString
(
"routine"
);
String
database
=
json
.
optString
(
"database"
);
JSONObject
response
=
procedureMysql
.
routineExecutor
(
routine
,
database
,
params
.
toList
().
toArray
());
return
ResponseEntity
.
ok
(
response
.
toMap
());
}
catch
(
Exception
e
)
{
return
ResponseEntity
.
internalServerError
().
body
(
new
JSONObject
().
put
(
"message"
,
e
.
getMessage
()).
put
(
"status"
,
false
).
toMap
());
}
}
else
{
return
ResponseEntity
.
badRequest
().
body
(
new
JSONObject
().
put
(
"message"
,
"Invalid Request"
).
put
(
"status"
,
false
).
toMap
());
}
}
// final RoutineUtils
procedureMysql;
//
//
@PostMapping("/public/routine")
//
public ResponseEntity<?> callRoutine(@RequestBody String body) {
//
JSONObject json = new JSONObject(body);
//
if (json.has("routine")) {
//
try {
//
JSONArray params = json.isNull("params") ? new JSONArray() : json.getJSONArray("params");
//
String routine = json.getString("routine");
//
String database = json.optString("database");
//
JSONObject response = procedureMysql.routineExecutor(routine,
//
database,
//
params.toList().toArray());
//
return ResponseEntity.ok(response.toMap());
//
} catch (Exception e) {
//
return ResponseEntity.internalServerError().body(new JSONObject().put("message", e.getMessage()).put("status", false).toMap());
//
}
//
} else {
//
return ResponseEntity.badRequest().body(new JSONObject().put("message", "Invalid Request").put("status", false).toMap());
//
}
//
}
}
\ No newline at end of file
src/main/java/web/multitask/trismegistoservices/services/MH/MHService.java
0 → 100644
View file @
47e71c8c
package
web
.
multitask
.
trismegistoservices
.
services
.
MH
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Service
;
import
web.multitask.trismegistoservices.utils.RoutineUtils
;
import
web.multitask.trismegistoservices.utils.DataSourceUtils
;
import
javax.sql.DataSource
;
@Service
public
class
MHService
{
private
final
JdbcTemplate
jdbcTemplate
=
new
JdbcTemplate
();
private
final
DataSourceUtils
dataSourceUtils
;
private
final
RoutineUtils
routineUtils
;
public
MHService
(
DataSourceUtils
dataSourceUtils
,
RoutineUtils
routineUtils
)
{
this
.
dataSourceUtils
=
dataSourceUtils
;
this
.
routineUtils
=
routineUtils
;
}
public
JSONObject
consultarTrabajador
(
JSONObject
json
){
JSONObject
response
=
new
JSONObject
();
try
{
DataSource
dataSource
=
dataSourceUtils
.
getDataSourceByName
(
"tp"
);
jdbcTemplate
.
setDataSource
(
dataSource
);
String
p_opcion
=
json
.
optString
(
"opcion"
);
String
p_numero_documento
=
json
.
optString
(
"numero_documento"
);
String
p_tipo_documento
=
json
.
optString
(
"tipo_documento"
);
JSONArray
params
=
new
JSONArray
();
params
.
put
(
p_opcion
);
params
.
put
(
p_numero_documento
);
params
.
put
(
p_tipo_documento
);
response
=
routineUtils
.
mysqlProcedure
(
"SP_TP_REST_DATOS_PERSONAL_MH"
,
"nuevo"
,
params
,
jdbcTemplate
);
JSONArray
data
=
response
.
optJSONArray
(
"data"
,
new
JSONArray
());
if
(
data
.
isEmpty
()){
return
response
;
}
else
{
JSONObject
first
=
data
.
optJSONObject
(
0
);
first
.
put
(
"status"
,
first
.
optInt
(
"status"
,
0
)
==
1
);
return
first
;
}
}
catch
(
Exception
e
)
{
response
.
put
(
"status"
,
false
)
.
put
(
"message"
,
e
.
getMessage
());
}
return
response
;
}
public
JSONObject
registrarVenta
(
JSONObject
json
){
JSONObject
response
=
new
JSONObject
();
try
{
DataSource
dataSource
=
dataSourceUtils
.
getDataSourceByName
(
"tp"
);
jdbcTemplate
.
setDataSource
(
dataSource
);
String
p_numero_documento
=
json
.
optString
(
"numero_documento"
);
String
p_tipo_documento
=
json
.
optString
(
"tipo_documento"
);
String
p_observacion
=
json
.
optString
(
"observacion"
);
Double
p_monto
=
json
.
optDouble
(
"monto"
);
int
p_cuotas
=
json
.
optInt
(
"cuotas"
);
JSONArray
params
=
new
JSONArray
()
.
put
(
p_numero_documento
)
.
put
(
p_tipo_documento
)
.
put
(
p_observacion
)
.
put
(
p_monto
)
.
put
(
p_cuotas
);
response
=
routineUtils
.
mysqlProcedure
(
"SP_TP_REST_REGISTRAR_VENTA_PERSONAL"
,
"nuevo"
,
params
,
jdbcTemplate
);
JSONArray
data
=
response
.
optJSONArray
(
"data"
,
new
JSONArray
());
if
(
data
.
isEmpty
()){
return
response
;
}
else
{
JSONObject
first
=
data
.
optJSONObject
(
0
);
first
.
put
(
"status"
,
first
.
optInt
(
"status"
,
0
)
==
1
);
return
first
;
}
}
catch
(
Exception
e
)
{
response
.
put
(
"status"
,
false
)
.
put
(
"message"
,
e
.
getMessage
());
}
return
response
;
}
}
src/main/java/web/multitask/trismegistoservices/utils/DataSourceUtils.java
0 → 100644
View file @
47e71c8c
package
web
.
multitask
.
trismegistoservices
.
utils
;
import
io.github.cdimascio.dotenv.Dotenv
;
import
org.springframework.jdbc.datasource.DriverManagerDataSource
;
import
org.springframework.stereotype.Component
;
import
javax.sql.DataSource
;
@Component
public
class
DataSourceUtils
{
private
final
Dotenv
dotenv
;
public
DataSourceUtils
(
Dotenv
dotenv
)
{
this
.
dotenv
=
dotenv
;
}
public
DataSource
getDataSourceByName
(
String
connectionName
)
{
String
normalizedName
=
connectionName
.
toUpperCase
();
String
suffix
;
switch
(
normalizedName
)
{
case
"TP"
:
suffix
=
"NUEVO"
;
break
;
default
:
throw
new
IllegalArgumentException
(
"Invalid connection name: "
+
connectionName
+
". Must be 'nuevo' or 'sacoolive3'."
);
}
return
createDataSource
(
suffix
,
normalizedName
);
}
private
DataSource
createDataSource
(
String
suffix
,
String
connectionName
)
{
// Construct the variable keys dynamically
String
host
=
dotenv
.
get
(
"MYSQL_TRISMEGISTOASISTENCIA_DB_"
+
suffix
);
String
port
=
dotenv
.
get
(
"MYSQL_TRISMEGISTOASISTENCIA_DB_PORT_"
+
suffix
);
String
databaseName
=
dotenv
.
get
(
"MYSQL_TRISMEGISTOASISTENCIA_DB_NAME_"
+
suffix
);
String
username
=
dotenv
.
get
(
"MYSQL_TRISMEGISTOASISTENCIA_DB_USER_"
+
suffix
);
String
password
=
dotenv
.
get
(
"MYSQL_TRISMEGISTOASISTENCIA_DB_PASS_"
+
suffix
);
if
(
host
==
null
||
port
==
null
||
databaseName
==
null
||
username
==
null
||
password
==
null
)
{
throw
new
IllegalStateException
(
"Missing required environment variables for "
+
connectionName
+
" connection."
);
}
DriverManagerDataSource
dataSource
=
new
DriverManagerDataSource
();
String
url
=
String
.
format
(
"jdbc:mysql://%s:%s/%s?useSSL=false&serverTimezone=UTC"
,
host
,
port
,
databaseName
);
dataSource
.
setDriverClassName
(
"com.mysql.cj.jdbc.Driver"
);
dataSource
.
setUrl
(
url
);
dataSource
.
setUsername
(
username
);
dataSource
.
setPassword
(
password
);
return
dataSource
;
}
}
src/main/java/web/multitask/trismegistoservices/utils/
d
otEnvUtils.java
→
src/main/java/web/multitask/trismegistoservices/utils/
D
otEnvUtils.java
View file @
47e71c8c
package
web
.
multitask
.
trismegistoservices
.
utils
;
import
org.springframework.stereotype.Component
;
import
java.io.File
;
import
java.util.HashMap
;
import
java.util.Locale
;
import
java.util.Map
;
public
class
dotEnvUtils
{
@Component
public
class
DotEnvUtils
{
static
String
detectedOS
;
...
...
@@ -36,14 +38,13 @@ public class dotEnvUtils {
public
static
String
getDotEnvPath
(
String
projectName
)
{
String
osType
=
getOperatingSystemType
();
return
OS_PATH_MAP
.
getOrDefault
(
osType
,
""
)
+
(
"Windows"
.
equals
(
osType
)
?
getWindowsPath
(
projectName
)
:
projectName
);
return
(
"Windows"
.
equals
(
osType
)
?
getWindowsPath
(
projectName
)
:
projectName
);
}
private
static
String
getWindowsPath
(
String
projectName
)
{
return
OS_PATH_MAP
.
get
(
"Windows"
)
.
chars
()
.
mapToObj
(
letter
->
"/"
+
(
char
)
letter
+
":/dotenv/"
+
projectName
)
.
mapToObj
(
letter
->
(
char
)
letter
+
":/dotenv/"
+
projectName
)
.
filter
(
path
->
new
File
(
path
).
exists
())
.
findFirst
()
.
orElse
(
""
);
...
...
src/main/java/web/multitask/trismegistoservices/
mysql/RoutineSql
.java
→
src/main/java/web/multitask/trismegistoservices/
utils/RoutineUtils
.java
View file @
47e71c8c
package
web
.
multitask
.
trismegistoservices
.
mysql
;
package
web
.
multitask
.
trismegistoservices
.
utils
;
import
lombok.AllArgsConstructor
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
@
Service
@
Component
@AllArgsConstructor
public
class
Routine
Sql
{
public
class
Routine
Utils
{
private
final
web
.
multitask
.
trismegistoservices
.
singleton
.
threadLocalSingleton
threadLocalSingleton
;
public
JSONObject
routineExecutor
(
String
routine
,
String
database
,
Object
[]
params
)
{
String
jdbcUrl
;
JdbcTemplate
jdbcTemplate
=
threadLocalSingleton
.
getJdbcTemplate
();
// public JSONObject routineExecutor(String routine, String database, Object[] params) {
//
// String jdbcUrl;
// JdbcTemplate jdbcTemplate = threadLocalSingleton.getJdbcTemplate();
// try {
// jdbcUrl = Objects.requireNonNull(jdbcTemplate.getDataSource()).getConnection().getMetaData().getURL();
// } catch (Exception e) {
// return new JSONObject().put("message", e.getMessage()).put("status", false);
// }
//
// switch (jdbcUrl.split(":")[1]) {
// case "mysql":
// return mysqlProcedure(routine, database, params, jdbcTemplate);
// case "postgresql":
// return postgreFunction(routine, database, params, jdbcTemplate);
// default:
// return new JSONObject().put("message", "Database not supported").put("status", false);
// }
// }
public
JSONObject
mysqlProcedure
(
String
routine
,
String
database
,
JSONArray
jsonArray
,
JdbcTemplate
jdbcTemplate
)
{
try
{
jdbcUrl
=
Objects
.
requireNonNull
(
jdbcTemplate
.
getDataSource
()).
getConnection
().
getMetaData
().
getURL
();
}
catch
(
Exception
e
)
{
return
new
JSONObject
().
put
(
"message"
,
e
.
getMessage
()).
put
(
"status"
,
false
);
}
switch
(
jdbcUrl
.
split
(
":"
)[
1
])
{
case
"mysql"
:
return
mysqlProcedure
(
routine
,
database
,
params
,
jdbcTemplate
);
case
"postgresql"
:
return
postgreFunction
(
routine
,
database
,
params
,
jdbcTemplate
);
default
:
return
new
JSONObject
().
put
(
"message"
,
"Database not supported"
).
put
(
"status"
,
false
);
}
}
private
JSONObject
mysqlProcedure
(
String
routine
,
String
database
,
Object
[]
params
,
JdbcTemplate
jdbcTemplate
)
{
try
{
Object
[]
params
=
jsonArray
.
toList
().
toArray
();
StringBuilder
query
=
new
StringBuilder
(
"CALL "
+
database
+
"."
+
routine
);
if
(
params
.
length
>
0
)
{
...
...
@@ -68,7 +72,7 @@ public class RoutineSql {
}
}
p
rivate
JSONObject
postgreFunction
(
String
routine
,
String
database
,
Object
[]
params
,
JdbcTemplate
jdbcTemplate
)
{
p
ublic
JSONObject
postgreFunction
(
String
routine
,
String
database
,
Object
[]
params
,
JdbcTemplate
jdbcTemplate
)
{
try
{
StringBuilder
query
=
new
StringBuilder
(
"SELECT * FROM "
+
database
+
"."
+
routine
);
...
...
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