Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
BackEnd-V2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Joel Andres Molina Velez
BackEnd-V2
Commits
f54c1584
Commit
f54c1584
authored
Aug 24, 2023
by
Joel Andres Molina Velez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Se modifican el servicio de guardar de ServiceUzyTavConvoca
parent
f77f42cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
7 deletions
+10
-7
DaoUzyTavConvoca.java
.../edu/espe/movilidad/MovilidadWS/Dao/DaoUzyTavConvoca.java
+5
-2
ServiceUzyTavConvoca.java
...vilidadWS/Service/UzyTavConvoca/ServiceUzyTavConvoca.java
+5
-5
No files found.
src/main/java/ec/edu/espe/movilidad/MovilidadWS/Dao/DaoUzyTavConvoca.java
View file @
f54c1584
...
...
@@ -12,7 +12,10 @@ public interface DaoUzyTavConvoca extends JpaRepository<ModelUzyTavConvoca, Long
@Query
(
"SELECT c FROM ModelUzyTavConvoca c ORDER BY c.uzytavconvoca_id DESC"
)
List
<
ModelUzyTavConvoca
>
findAll
();
@Query
(
"SELECT CASE WHEN COUNT(c) > 0 THEN true ELSE false END FROM ModelUzyTavConvoca c WHERE c.uzytavconvoca_estado IN ('A', 'I')"
)
boolean
existsByUzytavconvocaEstadoAorI
();
@Query
(
"SELECT CASE WHEN COUNT(c) > 0 THEN true ELSE false END FROM ModelUzyTavConvoca c WHERE c.uzytavconvoca_estado = 'A'"
)
boolean
existsActive
();
@Query
(
"SELECT CASE WHEN COUNT(c) > 0 THEN true ELSE false END FROM ModelUzyTavConvoca c WHERE c.uzytavconvoca_estado = 'I'"
)
boolean
existsInactive
();
}
src/main/java/ec/edu/espe/movilidad/MovilidadWS/Service/UzyTavConvoca/ServiceUzyTavConvoca.java
View file @
f54c1584
...
...
@@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.transaction.Transactional
;
import
java.io.IOException
;
import
java.nio.file.*
;
import
java.util.*
;
...
...
@@ -198,9 +197,11 @@ public class ServiceUzyTavConvoca implements IServiceUzyTavConvoca{
}
@Override
public
DtoUzyTavConvoca
guardar
(
DtoUzyTavConvoca
dtoUzyTavConvoca
)
{
boolean
existsWithStateAorI
=
daoUzyTavConvoca
.
existsByUzytavconvocaEstadoAorI
();
if
(
existsWithStateAorI
)
{
throw
new
DuplicateStateException
(
"Solo puede haber un registro con un estado A o I"
);
boolean
active
=
daoUzyTavConvoca
.
existsActive
();
boolean
inactive
=
daoUzyTavConvoca
.
existsInactive
();
if
(
active
||
inactive
)
{
throw
new
DuplicateStateException
(
"No se puede guardar el registro debido a que ya existe un registro con estado 'A' o 'I'"
);
}
try
{
ModelUzyTavConvoca
entityw
=
modelMapper
.
dtoToEntity
(
dtoUzyTavConvoca
);
...
...
@@ -214,7 +215,6 @@ public class ServiceUzyTavConvoca implements IServiceUzyTavConvoca{
}
@Override
@Transactional
public
DtoUzyTavConvoca
editar
(
Long
id
,
DtoUzyTavConvoca
dtoUzyTavConvoca
)
{
if
(
id
<=
0
)
{
throw
new
IllegalArgumentException
(
"El ID del registro debe ser válido y mayor que cero."
);
...
...
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