Skip to content

Commit

Permalink
Merge pull request #183 from CoolPeace-yanolza/develop
Browse files Browse the repository at this point in the history
01-24 오후 배포(데이터 초기화)
  • Loading branch information
whdgns5059 authored Jan 24, 2024
2 parents ba7441b + 5a048b8 commit 8124d56
Show file tree
Hide file tree
Showing 24 changed files with 726 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.coolpeace.domain.accommodation.repository;

import com.coolpeace.domain.accommodation.entity.Sido;
import org.springframework.data.jpa.repository.JpaRepository;

public interface SidoRepository extends JpaRepository<Sido, Integer> {

}
30 changes: 27 additions & 3 deletions src/main/java/com/coolpeace/domain/coupon/entity/Coupon.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.coolpeace.global.common.BaseTimeEntity;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

Expand All @@ -19,6 +21,8 @@
@Getter
@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Builder
@AllArgsConstructor
public class Coupon extends BaseTimeEntity {

@Id
Expand Down Expand Up @@ -67,13 +71,13 @@ public class Coupon extends BaseTimeEntity {
private LocalDate exposureEndDate;

@Column(nullable = false)
private final Integer couponExpiration = 14;
private Integer couponExpiration = 14;

@Column(nullable = false)
private final Integer downloadCount = 0;
private Integer downloadCount = 0;

@Column(nullable = false)
private final Integer useCount = 0;
private Integer useCount = 0;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "accommodation_id")
Expand Down Expand Up @@ -219,4 +223,24 @@ public void updateCoupon(
this.exposureEndDate = Optional.ofNullable(exposureEndDate).orElse(this.exposureEndDate);
updateCouponStatusByExposureDate();
}

public void addDownloadCount(){
this.downloadCount += 1;
}

public void setDownloadCount(Integer count){
this.downloadCount = count;
}

public void addUseCount(){
this.useCount += 1;
}

public void setUseCount(Integer count){
this.useCount = count;
}

public void setCouponExpiration(Integer couponExpiration){
this.couponExpiration = couponExpiration;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.coolpeace.domain.data.controller;

import com.coolpeace.domain.data.dto.request.GenerateAccommodationRequest;
import com.coolpeace.domain.data.dto.request.GenerateCouponRequest;
import com.coolpeace.domain.data.dto.request.GenerateReservationRequest;
import com.coolpeace.domain.data.dto.request.GenerateSettlementRequset;
import com.coolpeace.domain.data.service.GenerateDataService;
import jakarta.persistence.criteria.CriteriaBuilder.In;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequiredArgsConstructor
@RequestMapping("/v1/data")
public class GenerateDataController {


private final GenerateDataService generateDataService;

@PostMapping("/accommodation")
public ResponseEntity<Integer> generateAccommodation(
@RequestBody GenerateAccommodationRequest req
){
return ResponseEntity.ok(generateDataService.generateAccommodation(req));

}


@PostMapping("/coupon")
public ResponseEntity<Integer> generateCoupon(
@RequestBody GenerateCouponRequest req
){
return ResponseEntity.ok(generateDataService.generateCoupon(req));
}


@PostMapping("/reservation")
public ResponseEntity<Integer> generateReservation(
@RequestBody GenerateReservationRequest req
){
return ResponseEntity.ok(generateDataService.generateReservation(req));
}

@PostMapping("/settlement")
public ResponseEntity<Integer> generateSettlement(
@RequestBody GenerateSettlementRequset req
){
return ResponseEntity.ok(generateDataService.generateSettlemnet(req));
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.coolpeace.domain.data.dto.request;

public record GenerateAccommodationRequest(

Integer count,
Long member
){

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.coolpeace.domain.data.dto.request;

public record GenerateCouponRequest (

Long member,
Long accommodation,
Integer count


){



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.coolpeace.domain.data.dto.request;

public record GenerateReservationRequest (
int count
){



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.coolpeace.domain.data.dto.request;

import java.time.LocalDate;

public record GenerateSettlementRequset (
LocalDate start,
LocalDate end
){



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.coolpeace.domain.data.dto.request;

import java.time.LocalDate;

public interface SettlementStatistic {

Long getCouponId();

Long getAccommodationId();

LocalDate getCouponUseDate();

LocalDate getCompleteAt();

Integer getCount();

Integer getCancelPrice();

Integer getDiscountPrice();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.coolpeace.domain.data.repository;

import com.coolpeace.domain.accommodation.entity.Accommodation;
import org.springframework.data.jpa.repository.JpaRepository;

public interface GenerateAccommodationRepository extends JpaRepository<Accommodation, Long> {

}
Loading

0 comments on commit 8124d56

Please sign in to comment.