Skip to content

Commit

Permalink
Api-Release-v0.0.2-23
Browse files Browse the repository at this point in the history
Api-Release-v0.0.2-23
  • Loading branch information
imenuuu authored Dec 21, 2023
2 parents a1de764 + e32e005 commit 7f17fa8
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ public class AdminBannerController {
@PostMapping(consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
@Operation(summary = "ADMIN-08-01 배너 업로드")
public CommonResponse<List<BannerRes.BannerList>> uploadBanner(
@RequestPart BannerType bannerType,
@RequestPart MultipartFile bannerImage,
@RequestPart BannerReq.BannerUpload bannerUploadDto
@RequestPart("bannerUploadDto") BannerReq.BannerUpload bannerUploadDto
){
return CommonResponse.onSuccess(adminBannerService.uploadBanner(BannerType.EVENT, bannerImage, bannerUploadDto));
}
Expand All @@ -58,8 +57,9 @@ public CommonResponse<String> deleteBanner(@PathVariable Long bannerId){
@Operation(summary = "ADMIN-08-04 배너 수정")
public CommonResponse<String> patchBanner(
@PathVariable Long bannerId,
BannerReq.BannerPatchDto bannerPatchDto){
adminBannerService.patchBanner(bannerId);
@RequestPart(value = "bannerImage", required = false) MultipartFile bannerImage,
@RequestPart("bannerPatchDto") BannerReq.BannerPatchDto bannerPatchDto){
adminBannerService.patchBanner(bannerId, bannerPatchDto, bannerImage);
return CommonResponse.onSuccess("수정 성공");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.example.matchdomain.banner.adaptor.BannerAdaptor;
import com.example.matchdomain.banner.entity.Banner;
import com.example.matchdomain.banner.enums.BannerType;
import com.example.matchdomain.banner.repository.BannerRepository;
import com.example.matchinfrastructure.config.s3.S3UploadService;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
Expand Down Expand Up @@ -50,8 +49,17 @@ public void deleteBanner(Long bannerId) {
bannerAdaptor.deleteById(bannerId);
}

public void patchBanner(Long bannerId) {

@Transactional
public void patchBanner(Long bannerId, BannerReq.BannerPatchDto bannerPatchDto, MultipartFile bannerImage) {
Banner banner = bannerAdaptor.findById(bannerId);
if(bannerPatchDto.isEditImage()){
s3UploadService.deleteFile(banner.getBannerImg());
String imgUrl = s3UploadService.uploadBannerImage(bannerImage);
banner.updateBanner(bannerPatchDto.getName(), banner.getStartDate(), banner.getEndDate(), imgUrl);
}else{
banner.updateBanner(bannerPatchDto.getName(), banner.getStartDate(), banner.getEndDate(), banner.getBannerImg());
}
bannerAdaptor.save(banner);
}

public PageResponse<List<BannerRes.BannerAdminListDto>> getBannerLists(int page, int size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@ public Banner convertToBannerUpload(BannerType bannerType, String bannerImg, Ban
.bannerType(bannerType)
.name(bannerUploadDto.getName())
.eventId(bannerUploadDto.getEventId())
.startDate(bannerUploadDto.getStartDate())
.endDate(bannerUploadDto.getEndDate())
.contentsUrl(bannerUploadDto.getContentsUrl())
.build();
}
else{
return Banner
.builder()
return Banner.builder()
.bannerImg(bannerImg)
.bannerType(bannerType)
.name(bannerUploadDto.getName())
.contentsUrl(bannerUploadDto.getContentsUrl())
.startDate(bannerUploadDto.getStartDate())
.endDate(bannerUploadDto.getEndDate())
.contentsUrl(bannerUploadDto.getContentsUrl())
.build();
}
}
Expand Down Expand Up @@ -77,6 +82,7 @@ private BannerRes.BannerAdminListDto convertToBannerListDto(Banner result) {
.bannerType(result.getBannerType())
.eventId(result.getEventId())
.name(result.getName())
.contentsUrl(result.getContentsUrl())
.bannerImg(result.getBannerImg())
.startDate(result.getStartDate())
.endDate(result.getEndDate())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ public static class BannerUpload {
@Setter
@Builder
@AllArgsConstructor
@ToString
@NoArgsConstructor
public static class BannerPatchDto {
private String name;

private LocalDateTime startDate;

private LocalDateTime endDate;

private String deleteImgUrl;
private boolean isEditImage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public static class BannerAdminListDto {

private String name;

private String contentsUrl;

private String bannerImg;

private Long eventId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public OrderRes.CompleteDonation paymentForOnetime(OrderCommand.OneTimeDonation

PortOneResponse<PortOneBillPayResponse> portOneResponse = paymentService.payBillKey(card, oneTimeDonation.getAmount(), project.getProjectName(), orderCommand.getOrderId());

if(portOneResponse.getResponse().getFail_reason()!=null) throw new BaseException(BAD_REQUEST, false, "PORT_ONE_BILL_AUTH_001", portOneResponse.getResponse().getFail_reason());

OrderRes.CreateInherenceDto createInherenceDto = orderHelper.createInherence(user);

DonationUser donationUser = donationUserRepository.save(
Expand Down Expand Up @@ -143,6 +145,8 @@ public OrderRes.CompleteDonation paymentForRegular(OrderCommand.RegularDonation

PortOneResponse<PortOneBillPayResponse> portOneResponse = paymentService.payBillKey(card, regularDonation.getAmount(), project.getProjectName(), orderCommand.getOrderId());

if(portOneResponse.getResponse().getFail_reason()!=null) throw new BaseException(BAD_REQUEST, false, "PORT_ONE_BILL_AUTH_001", portOneResponse.getResponse().getFail_reason());

OrderRes.CreateInherenceDto createInherenceDto = orderHelper.createInherence(user);

RegularPayment regularPayment = regularPaymentRepository.save(orderConverter.convertToRegularPayment(user.getId(), regularDonation, card.getId(), project.getId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.example.matchbatch.model.CalculateMonthLastDateDto;
import com.example.matchbatch.model.PaymentCntDto;
import com.example.matchcommon.annotation.RedissonLock;
import com.example.matchcommon.exception.BaseException;
import com.example.matchdomain.donation.adaptor.RegularPaymentAdaptor;
import com.example.matchdomain.donation.adaptor.RequestFailedHistoryAdapter;
import com.example.matchdomain.donation.entity.*;
Expand All @@ -26,6 +27,7 @@
import java.util.stream.Collectors;

import static com.example.matchcommon.constants.MatchStatic.*;
import static org.springframework.http.HttpStatus.*;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -111,7 +113,7 @@ public boolean processRegularPayment(RegularPayment payment, String accessToken,
String orderId = orderHelper.createRandomOrderId();

PortOneResponse<PortOneBillPayResponse> portOneResponse = attemptPayment(payment, accessToken, orderId);
if(portOneResponse.getCode()!=0){
if(portOneResponse.getCode()!=0 || portOneResponse.getResponse().getFail_reason()!=null){
handlePaymentFailure(payment, portOneResponse.getMessage(), type);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,11 @@ public class Banner extends BaseEntity {
private LocalDateTime startDate;

private LocalDateTime endDate;

public void updateBanner(String name, LocalDateTime startDate, LocalDateTime endDate, String bannerImg) {
this.name = name;
this.startDate = startDate;
this.endDate = endDate;
this.bannerImg = bannerImg;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ public String uploadProjectPresentFile(Long projectId,MultipartFile presentFile)
public void deleteFile(String fileName){
int index=fileName.indexOf(awsS3Properties.getS3().getBaseUrl());
String fileRoute=fileName.substring(index+awsS3Properties.getS3().getBaseUrl().length()+1);
System.out.println("deletefilename : "+fileRoute);
try {
boolean isObjectExist = amazonS3.doesObjectExist(awsS3Properties.getS3().getBucket(), fileRoute);
if (isObjectExist) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.util.List;

@Getter
@Setter
@AllArgsConstructor
@RequiredArgsConstructor
@ToString
public class PortOneBillPayResponse {
private String imp_uid;
private String merchant_uid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class PortOneResponse <T>{
@SerializedName("code")
int code;
Expand Down

0 comments on commit 7f17fa8

Please sign in to comment.