mirror of
https://git.hmsn.ink/kospo/svcm/api.git
synced 2026-03-19 21:05:06 +09:00
계약관리 & 대금지급 첨부파일 삭제 추가
This commit is contained in:
@@ -160,4 +160,27 @@ public class ContController {
|
||||
) {
|
||||
return ResponseEntity.ok(contService.retrieve(contNo));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "계약관리 첨부파일 삭제", description = "계약관리 문서(첨부파일) 삭제")
|
||||
@ApiResponses({
|
||||
@ApiResponse(description = "Success", responseCode = "200",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(oneOf =
|
||||
{String.class}))),
|
||||
@ApiResponse(description = "Not found", responseCode = "404",
|
||||
content = @Content(mediaType = "text/plain", schema = @Schema(oneOf =
|
||||
{String.class}))),
|
||||
@ApiResponse(description = "Internal Error", responseCode = "500",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(oneOf =
|
||||
{CustomErrorResponse.class })))
|
||||
})
|
||||
@DeleteMapping("/cont/{contNo}/{fileOrd}")
|
||||
public ResponseEntity fileDelete(
|
||||
@Parameter(description = "계약번호") @PathVariable String contNo,
|
||||
@Parameter(description = "파일순서") @PathVariable Integer fileOrd,
|
||||
Principal principal
|
||||
) {
|
||||
contService.contAttFileDelete(contNo, fileOrd);
|
||||
return ResponseEntity.ok("삭제 되었습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,4 +119,26 @@ public class SlipController {
|
||||
slipService.delete(contNo);
|
||||
return ResponseEntity.ok("삭제 되었습니다.");
|
||||
}
|
||||
|
||||
@Operation(summary = "대금지급 첨부파일 삭제", description = "대금지급 문서(첨부파일) 삭제")
|
||||
@ApiResponses({
|
||||
@ApiResponse(description = "Success", responseCode = "200",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(oneOf =
|
||||
{String.class}))),
|
||||
@ApiResponse(description = "Not found", responseCode = "404",
|
||||
content = @Content(mediaType = "text/plain", schema = @Schema(oneOf =
|
||||
{String.class}))),
|
||||
@ApiResponse(description = "Internal Error", responseCode = "500",
|
||||
content = @Content(mediaType = "application/json", schema = @Schema(oneOf =
|
||||
{CustomErrorResponse.class })))
|
||||
})
|
||||
@DeleteMapping("/slip/{contNo}/{fileOrd}")
|
||||
public ResponseEntity fileDelete(
|
||||
@Parameter(description = "계약번호") @PathVariable String contNo,
|
||||
@Parameter(description = "파일순서") @PathVariable Integer fileOrd,
|
||||
Principal principal
|
||||
) {
|
||||
slipService.slipAttFileDelete(contNo, fileOrd);
|
||||
return ResponseEntity.ok("삭제 되었습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ public interface ContRepository extends JpaRepository<Cont, String> {
|
||||
|
||||
Cont findByContNoAndContStatCd(String contNo, String contStatCd);
|
||||
|
||||
Cont findByContNoAndRegSabun(String contNo, String sabun);
|
||||
|
||||
interface IContResponse {
|
||||
String getContNo();
|
||||
String getCateCd();
|
||||
|
||||
@@ -5,5 +5,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface SlipRepository extends JpaRepository<Slip, String> {
|
||||
Slip findByContNo(String contNo);
|
||||
Slip findByContNoAndRegSabun(String contNo, String sabun);
|
||||
Slip findByBelnr(String belnr);
|
||||
}
|
||||
|
||||
@@ -24,4 +24,6 @@ public interface ContService {
|
||||
|
||||
@org.springframework.transaction.annotation.Transactional
|
||||
ContSaveResponse retrieve(String contNo);
|
||||
|
||||
void contAttFileDelete(String contNo, Integer fileOrd);
|
||||
}
|
||||
|
||||
@@ -16,4 +16,6 @@ public interface SlipService {
|
||||
|
||||
@Transactional
|
||||
void delete(String contNo);
|
||||
|
||||
void slipAttFileDelete(String contNo, Integer fileOrd);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@@ -283,4 +282,23 @@ public class ContServiceImpl implements ContService {
|
||||
return ContSaveResponse.from(contRepository.save(cont));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contAttFileDelete(String contNo, Integer fileOrd) {
|
||||
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
Cont checker = contRepository.findByContNoAndRegSabun(contNo, user.getSabun());
|
||||
if(checker != null) {
|
||||
ContAtt contAtt = contAttRepository.findById(ContAttId.builder()
|
||||
.contNo(contNo)
|
||||
.fileOrd(fileOrd)
|
||||
.build()).get();
|
||||
if (fileUtils.fileDelete(contAtt.getPath())) {
|
||||
contAttRepository.delete(contAtt);
|
||||
} else {
|
||||
throw new CustomException(ErrorCode.FILE_DELETE_ERROR);
|
||||
}
|
||||
} else {
|
||||
throw new CustomException(ErrorCode.AUTHENTICATION_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,4 +342,24 @@ public class SlipServiceImpl implements SlipService {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void slipAttFileDelete(String contNo, Integer fileOrd) {
|
||||
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
Slip checker = slipRepository.findByContNoAndRegSabun(contNo, user.getSabun());
|
||||
if(checker != null) {
|
||||
SlipAtt slipAtt = slipAttRepository.findById(SlipAttId.builder()
|
||||
.contNo(contNo)
|
||||
.fileOrd(fileOrd)
|
||||
.build()).get();
|
||||
if (fileUtils.fileDelete(slipAtt.getPath())) {
|
||||
slipAttRepository.delete(slipAtt);
|
||||
} else {
|
||||
throw new CustomException(ErrorCode.FILE_DELETE_ERROR);
|
||||
}
|
||||
} else {
|
||||
throw new CustomException(ErrorCode.AUTHENTICATION_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user