Skip to content

Commit

Permalink
Merge pull request #111 from Billing-Wise/dev
Browse files Browse the repository at this point in the history
[release] 1.0.6
  • Loading branch information
dtd1614 authored Aug 5, 2024
2 parents bef48eb + b031ea7 commit 1f60b8d
Show file tree
Hide file tree
Showing 16 changed files with 293 additions and 10 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@ jobs:
- name: Grant execute permission to Gradle Wrapper
run: chmod +x ./gradlew

- name: Cache Jib layers
uses: actions/cache@v3
with:
path: ./server-api/build/jib-cache
key: ${{ runner.os }}-jib-${{ github.job }}-${{ hashFiles('**/build.gradle') }}
restore-keys: ${{ runner.os }}-jib-${{ github.job }}

- name: Build and push image to Amazon ECR
run: ./gradlew clean jib -x test
run: ./gradlew jib -x test

- name: Deploy to AWS ECS
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group = 'site.billingwise.api'
version = '1.0.5'
version = '1.0.6'

java {
toolchain {
Expand Down Expand Up @@ -119,7 +119,7 @@ tasks.named('asciidoctor') {

jib {
from {
image = "eclipse-temurin:17-jdk"
image = "eclipse-temurin:17-jdk-alpine"
}
to {
image = "891376922202.dkr.ecr.ap-northeast-2.amazonaws.com/t5-api-ecr"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public GetConsentDto editConsentSignImage(Long memberId, MultipartFile multipart
return GetConsentDto.toDto(consentAccount);
}

@Transactional
public void deleteConsent(Long memberId) {
checkMemberPermission(memberId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ public void consentForNonMember(
Item item = itemRepository.findByIdAndClientIdAndIsBasic(dto.getItemId(), clientId, true)
.orElseThrow(() -> new GlobalException(FailureInfo.ITEM_NOT_FOUND));

if (memberRepository.existsByClientIdAndEmail(clientId, dto.getMemberEmail())) {
throw new GlobalException(FailureInfo.ALREADY_EXIST_MEMBER);
}

Member member = Member.builder()
.client(client)
.email(dto.getMemberEmail())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ public BaseResponse editContract(@PathVariable("contractId") Long contractId,
return new BaseResponse(SuccessInfo.CONTRACT_EDITED);
}

@ResponseStatus(HttpStatus.OK)
@PutMapping("/{contractId}/status")
public BaseResponse changeContractStatus(@PathVariable("contractId") Long contractId,
@RequestBody Long statusId) {
contractService.editContractStatus(contractId, statusId);

return new BaseResponse(SuccessInfo.CONTRACT_STATUS_EDITED);
}

@ResponseStatus(HttpStatus.OK)
@DeleteMapping("/{contractId}")
public BaseResponse deleteContract(@PathVariable("contractId") Long contractId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ public class GetContractDto {
private Integer paymentDueCycle;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;

private ContractStatusDto contractStatus;

}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,21 @@ public void editContract(Long contractId, EditContractDto editContractDto) {
contract.setContractStatus(contractStatus);
}

@Transactional
public void editContractStatus(Long contractId, Long contractStatusId) {
User user = SecurityUtil.getCurrentUser().orElseThrow(
() -> new GlobalException(FailureInfo.NOT_EXIST_USER));

Contract contract = getEntity(user.getClient(), contractId);
ContractStatus contractStatus = EnumUtil.toEnum(ContractStatus.class, contractStatusId);

if (contractStatus == ContractStatus.PENDING || contract.getContractStatus() == ContractStatus.PENDING) {
throw new GlobalException(FailureInfo.PENDING_IMPOSSIBLE);
}

contract.setContractStatus(contractStatus);
}

@Transactional
public void deleteContract(Long contractId) {
User user = SecurityUtil.getCurrentUser().orElseThrow(
Expand Down Expand Up @@ -356,6 +371,11 @@ private GetContractDto toGetDtoFromEntity(Contract contract) {
.name(contract.getPaymentType().getName())
.build();

ContractStatusDto contractStatus = ContractStatusDto.builder()
.id(contract.getContractStatus().getId())
.name(contract.getContractStatus().getName())
.build();

GetContractDto getContractDto = GetContractDto.builder()
.id(contract.getId())
.member(member)
Expand All @@ -369,6 +389,7 @@ private GetContractDto toGetDtoFromEntity(Contract contract) {
.paymentType(paymentType)
.contractCycle(contract.getContractCycle())
.paymentDueCycle(contract.getPaymentDueCycle())
.contractStatus(contractStatus)
.createdAt(contract.getCreatedAt())
.updatedAt(contract.getUpdatedAt())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ public void sendInvoice(Long invoiceId) {

Invoice invoice = getEntity(user.getClient(), invoiceId);

if (invoice.getPaymentType() == PaymentType.REALTIME_CMS) {
// 미납되기 전의 실시간CMS는 청구서 발송 불가
if (invoice.getPaymentType() == PaymentType.REALTIME_CMS
&& invoice.getPaymentStatus() != PaymentStatus.UNPAID) {
throw new GlobalException(FailureInfo.INVALID_PAYMENTTYPE);
}

// 이미 결제된 청구건은 청구서 발송 불가
if (invoice.getPaymentStatus() == PaymentStatus.PAID) {
throw new GlobalException(FailureInfo.PAID_INVOICE);
}
Expand Down Expand Up @@ -125,7 +128,7 @@ public Long createInvoice(CreateInvoiceDto createInvoiceDto) {
.contractDate(createInvoiceDto.getContractDate().atStartOfDay())
.dueDate(createInvoiceDto.getDueDate().atStartOfDay())
.build();

invoiceRepository.save(invoice);

// 단건 계약 종료
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public enum FailureInfo {
NOT_PROGRESS_CONTRACT(400, "진행 중인 계약이 아닙니다."),
INVALID_DUE_CYCLE(400, "납부 기한은 약정일 이후여야합니다."),
NOT_EXIST_CONTRACT(404, "존재하지 않는 계약입니다."),
PENDING_IMPOSSIBLE(404, "계약 대기 상태는 변경이 불가능합니다."),

// invoice
INVALID_CONTRACT_DATE(400, "약정일은 현재로부터 다음 날 이후여야합니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public enum SuccessInfo {
CONTRACT_EDITED("계약 정보가 성공적으로 수정되었습니다."),
CONTRACT_DELETED("계약 정보가 성공적으로 삭제되었습니다."),
CONTRACT_LOADED("계약 정보를 성공적으로 조회하였습니다."),
CONTRACT_STATUS_EDITED("계약 상태가 성공적으로 변경되었습니다."),

// Invoice
INVOICE_CREATED("청구 정보가 성공적으로 등록되었습니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.experimental.UtilityClass;

import java.util.Optional;

@UtilityClass
public class CookieUtil {

public static Cookie getCookie(HttpServletRequest request, String name) {
Cookie[] cookies = request.getCookies();
if (cookies != null) {
Expand All @@ -16,6 +19,7 @@ public static Cookie getCookie(HttpServletRequest request, String name) {
}
}
}
System.out.println("hi");
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package site.billingwise.api.serverapi.global.util;

import lombok.experimental.UtilityClass;
import site.billingwise.api.serverapi.domain.common.EnumField;
import site.billingwise.api.serverapi.global.exception.GlobalException;
import site.billingwise.api.serverapi.global.response.info.FailureInfo;

import java.util.EnumSet;
import java.util.NoSuchElementException;

@UtilityClass
public class EnumUtil {

public static <T extends Enum<T> & EnumField> Long toId(T enumClass) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package site.billingwise.api.serverapi.global.util;

import lombok.experimental.UtilityClass;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;

import site.billingwise.api.serverapi.global.exception.GlobalException;
import site.billingwise.api.serverapi.global.response.info.FailureInfo;

@UtilityClass
public class PoiUtil {

public static String getCellValue(Cell cell) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package site.billingwise.api.serverapi.global.util;

import lombok.experimental.UtilityClass;
import org.springframework.security.core.context.SecurityContextHolder;
import site.billingwise.api.serverapi.domain.user.CustomUserDetails;
import site.billingwise.api.serverapi.domain.user.Client;
Expand All @@ -9,6 +10,7 @@

import java.util.Optional;

@UtilityClass
public class SecurityUtil {

public static Optional<User> getCurrentUser() {
Expand Down
Loading

0 comments on commit 1f60b8d

Please sign in to comment.