SUPPORT-8381: some fixes

This commit is contained in:
Alexandr Shalaginov 2024-07-22 16:44:28 +03:00
parent c516bcdf85
commit c48770bb5a
7 changed files with 28 additions and 25 deletions

View file

@ -35,7 +35,8 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
"gen",
"ru.cg",
"ru.micord",
"ervu"
"ervu",
"esia"
})
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableWebMvc

View file

@ -2,19 +2,14 @@ package ervu.controller;
import ervu.service.fileupload.EmployeeInfoFileUploadService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import ru.cg.webbpm.modules.webkit.beans.Behavior;
/**
* @author Alexandr Shalaginov
*/
@RestController
public class EmployeeInfoFileUploadController extends Behavior {
public class EmployeeInfoFileUploadController {
public EmployeeInfoFileUploadService fileUploadService;
public EmployeeInfoFileUploadController(EmployeeInfoFileUploadService fileUploadService) {
@ -22,8 +17,9 @@ public class EmployeeInfoFileUploadController extends Behavior {
}
@RequestMapping(value = "/employee/document", method = RequestMethod.POST)
public ResponseEntity<?> saveEmployeeInformationFile(@RequestParam("file") MultipartFile multipartFile) {
if (this.fileUploadService.saveEmployeeInformationFile(multipartFile)) {
public ResponseEntity<?> saveEmployeeInformationFile(@RequestParam("file") MultipartFile multipartFile,
@RequestHeader("X-Employee-Info-File-Form-Type") String formType) {
if (this.fileUploadService.saveEmployeeInformationFile(multipartFile, formType)) {
return ResponseEntity.ok("File successfully uploaded.");
}
else {

View file

@ -4,10 +4,10 @@ package ervu.service.fileupload;
* @author Alexandr Shalaginov
*/
public enum EmployeeInfoFileFormType {
EMPLOYMENT_DISMISSAL_INFO("9", "Сведение о приеме на работу (увольнении), зачислении в образовательное учреждение (или отчислении)"),
CHANGE_INFO("2", "Изменения сведений сотрудников, необходимых для ведения воинского учета");
private final String filePatternCode;
private final String filePatternName;
FORM_9("9", "Сведение о приеме на работу (увольнении), зачислении в образовательное учреждение (или отчислении)"),
FORM_2("2", "Изменения сведений сотрудников, необходимых для ведения воинского учета");
private String filePatternCode;
private String filePatternName;
EmployeeInfoFileFormType(String filePatternCode, String filePatternName) {
this.filePatternCode = filePatternCode;

View file

@ -16,9 +16,6 @@ import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import ru.cg.webbpm.modules.standard_annotations.editor.Visible;
import ru.cg.webbpm.modules.standard_annotations.validation.NotNull;
/**
* @author Alexandr Shalaginov
*/
@ -26,10 +23,6 @@ import ru.cg.webbpm.modules.standard_annotations.validation.NotNull;
public class EmployeeInfoFileUploadService {
private static final Logger logger = LoggerFactory.getLogger(EmployeeInfoFileUploadService.class);
@Visible
@NotNull
public EmployeeInfoFileFormType formType;
private final FileUploadWebDavClient fileWebDavUploadClient;
private final EmployeeInfoKafkaMessageService employeeInfoKafkaMessageService;
private final KafkaTemplate<String, String> kafkaTemplate;
@ -51,16 +44,16 @@ public class EmployeeInfoFileUploadService {
this.kafkaTemplate = kafkaTemplate;
}
public boolean saveEmployeeInformationFile(MultipartFile multipartFile) {
public boolean saveEmployeeInformationFile(MultipartFile multipartFile, String formType) {
String fileUploadUrl = this.url + "/" + getNewFilename(multipartFile.getOriginalFilename());
String departureDateTime = getDepartureDateTime();
if (this.fileWebDavUploadClient.webDavUploadFile(url, username, password, multipartFile)) {
if (this.fileWebDavUploadClient.webDavUploadFile(fileUploadUrl, username, password, multipartFile)) {
String jsonMessage = getJsonKafkaMessage(
employeeInfoKafkaMessageService.getKafkaMessage(
fileUploadUrl,
multipartFile.getOriginalFilename(),
formType,
EmployeeInfoFileFormType.valueOf(formType),
departureDateTime
)
);

View file

@ -4,11 +4,13 @@ import esia.model.ChiefPersonModel;
import esia.model.MillitaryRegistrationPersonModel;
import esia.model.OrganizationModel;
import esia.service.UlDataService;
import org.springframework.stereotype.Service;
/**
* @author Alexandr Shalaginov
*/
// TODO: 22.07.2024 delete this after real realisation of UlDataService
@Service
public class DummyUlDataServiceImpl implements UlDataService {
@Override
public MillitaryRegistrationPersonModel getPersonModel() {