Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
templateService
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bazarbay Tulenov
templateService
Commits
762803b1
Commit
762803b1
authored
Jun 25, 2024
by
George Novikov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
рефакторинг сохранения документа и проверки шаблона по templateId
parent
8dad440b
Pipeline
#396
failed with stage
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
+19
-4
src/main/java/kz/project/printedFormsService/service/impl/DocumentsServiceImpl.java
...rintedFormsService/service/impl/DocumentsServiceImpl.java
+18
-3
src/main/java/kz/project/printedFormsService/service/impl/TemplateServiceImpl.java
...printedFormsService/service/impl/TemplateServiceImpl.java
+1
-1
No files found.
src/main/java/kz/project/printedFormsService/service/impl/DocumentsServiceImpl.java
View file @
762803b1
...
@@ -14,18 +14,22 @@ import kz.project.printedFormsService.service.DocumentsService;
...
@@ -14,18 +14,22 @@ import kz.project.printedFormsService.service.DocumentsService;
import
kz.project.printedFormsService.service.TemplateService
;
import
kz.project.printedFormsService.service.TemplateService
;
import
lombok.RequiredArgsConstructor
;
import
lombok.RequiredArgsConstructor
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.NotNull
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.HashSet
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
@Service
@Service
@RequiredArgsConstructor
@RequiredArgsConstructor
public
class
DocumentsServiceImpl
implements
DocumentsService
{
public
class
DocumentsServiceImpl
implements
DocumentsService
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
DocumentsServiceImpl
.
class
);
private
static
final
Set
<
Long
>
INEXISTENT_TEMPLATES
=
new
HashSet
<>();
private
final
DocumentJdbcRepository
documentJdbcRepository
;
private
final
DocumentJdbcRepository
documentJdbcRepository
;
private
final
TemplateService
templateService
;
private
final
TemplateService
templateService
;
private
final
DocumentRepository
documentRepository
;
private
final
DocumentRepository
documentRepository
;
...
@@ -74,13 +78,24 @@ public class DocumentsServiceImpl implements DocumentsService {
...
@@ -74,13 +78,24 @@ public class DocumentsServiceImpl implements DocumentsService {
@Transactional
@Transactional
@Override
@Override
public
void
saveDocument
(
Long
templateId
)
throws
ValidationException
,
JsonProcessingException
{
public
void
saveDocument
(
Long
templateId
)
throws
ValidationException
,
JsonProcessingException
{
DocumentEntity
documentEntity
=
new
DocumentEntity
();
TemplateEntity
templateEntity
=
templateService
.
getTemplateEntity
(
templateId
);
TemplateEntity
templateEntity
=
templateService
.
getTemplateEntity
(
templateId
);
if
(
templateEntity
==
null
){
printOrBypass
(
templateId
);
return
;
}
DocumentEntity
documentEntity
=
new
DocumentEntity
();
documentEntity
.
setTemplate
(
templateEntity
);
documentEntity
.
setTemplate
(
templateEntity
);
documentEntity
.
setProject
(
templateEntity
.
getProject
());
documentEntity
.
setProject
(
templateEntity
.
getProject
());
documentEntity
.
setCreatedAt
(
LocalDateTime
.
now
());
documentEntity
.
setCreatedAt
(
LocalDateTime
.
now
());
documentRepository
.
save
(
documentEntity
);
documentRepository
.
save
(
documentEntity
);
}
private
void
printOrBypass
(
Long
templateId
){
if
(!
INEXISTENT_TEMPLATES
.
contains
(
templateId
)){
LOGGER
.
warn
(
"Не найден шаблон с таким идентификатором {}"
,
templateId
);
}
INEXISTENT_TEMPLATES
.
add
(
templateId
);
}
}
}
}
src/main/java/kz/project/printedFormsService/service/impl/TemplateServiceImpl.java
View file @
762803b1
...
@@ -175,7 +175,7 @@ public class TemplateServiceImpl implements TemplateService {
...
@@ -175,7 +175,7 @@ public class TemplateServiceImpl implements TemplateService {
@Override
@Override
public
TemplateEntity
getTemplateEntity
(
Long
id
)
throws
ValidationException
{
public
TemplateEntity
getTemplateEntity
(
Long
id
)
throws
ValidationException
{
return
repository
.
findById
(
id
).
orElse
Throw
(()
->
new
ValidationException
(
"Не найден шаблон с таким идентификатором"
,
13
)
);
return
repository
.
findById
(
id
).
orElse
(
null
);
}
}
...
...
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