Commit 6dd750a8 authored by Bazarbay Tulenov's avatar Bazarbay Tulenov

commit add cors filter

parent f2b61cc8
Pipeline #335 failed with stage
package kz.project.printedFormsService.config;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
......@@ -24,4 +29,16 @@ public class AppConfig implements WebMvcConfigurer {
corsConfiguration.addAllowedHeader("*");
return corsConfiguration;
}
@Bean
public MessageConverter messageConverter(){
return new Jackson2JsonMessageConverter();
}
@Bean
public AmqpTemplate amqpTemplate(ConnectionFactory connectionFactory){
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
rabbitTemplate.setMessageConverter(messageConverter());
return rabbitTemplate;
}
}
......@@ -21,7 +21,7 @@ public class DocumentEntity {
private Long id;
@ManyToOne
@JoinColumn(name = "template_id", referencedColumnName = "template_id",insertable = false,updatable = false)
@JoinColumn(name = "template_id")
private TemplateEntity template;
@CreationTimestamp
......
......@@ -7,6 +7,7 @@ import kz.project.printedFormsService.data.dto.DocumentByTemplateDto;
import kz.project.printedFormsService.data.entity.DocumentEntity;
import kz.project.printedFormsService.data.entity.TemplateEntity;
import kz.project.printedFormsService.data.repository.DocumentJdbcRepository;
import kz.project.printedFormsService.data.repository.DocumentRepository;
import kz.project.printedFormsService.data.repository.TemplateRepository;
import kz.project.printedFormsService.exception.ValidationException;
import kz.project.printedFormsService.service.DocumentsService;
......@@ -14,6 +15,7 @@ import kz.project.printedFormsService.service.TemplateService;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.LocalDateTime;
......@@ -26,6 +28,7 @@ public class DocumentsServiceImpl implements DocumentsService {
private final DocumentJdbcRepository documentJdbcRepository;
private final TemplateService templateService;
private final DocumentRepository documentRepository;
@Override
public @NotNull DocumentByDateDto getDocumentCountsByDate(@NotNull LocalDate startDate, @NotNull LocalDate endDate, @NotNull Set<String> projects) {
......@@ -68,15 +71,15 @@ public class DocumentsServiceImpl implements DocumentsService {
.build()
);
}
@Transactional
@Override
public void saveDocument(Long templateId) throws ValidationException, JsonProcessingException {
DocumentEntity documentEntity = new DocumentEntity();
TemplateEntity templateEntity = templateService.getTemplateEntity(templateId);
DocumentEntity documentEntity = new DocumentEntity();
documentEntity.setTemplate(templateEntity);
documentEntity.setProject(templateEntity.getProject());
documentEntity.setCreatedAt(LocalDateTime.now());
documentJdbcRepository.saveDocument(documentEntity);
documentRepository.save(documentEntity);
}
......
......@@ -5,7 +5,6 @@ import kz.project.printedFormsService.data.dto.TemplateDataForReportDto;
import kz.project.printedFormsService.data.dto.TemplateDto;
import kz.project.printedFormsService.data.dto.TemplateResponseDto;
import kz.project.printedFormsService.data.dto.TemplateShortDto;
import kz.project.printedFormsService.data.entity.DocumentEntity;
import kz.project.printedFormsService.data.entity.TemplateEntity;
import kz.project.printedFormsService.data.entity.TemplateFileInfoEntity;
import kz.project.printedFormsService.data.repository.DTemplateTypeRepository;
......@@ -23,7 +22,6 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment