Skip to content

Commit

Permalink
fix : #18 data.sql 오타 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
j2noo committed Mar 6, 2024
2 parents 0766555 + 2fe61bb commit c31b501
Show file tree
Hide file tree
Showing 37 changed files with 577 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.backend.soullive_a.controller;

import com.backend.soullive_a.dto.response.model.popularity.ModelPopularityResponse;
import com.backend.soullive_a.exception.base.BaseResponse;
import com.backend.soullive_a.service.ModelPopularityService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/model/popularity")
public class ModelPopularityController {

private final ModelPopularityService modelPopularityService;

@GetMapping("")
public BaseResponse<ModelPopularityResponse> getModelPopularity(
@RequestParam String name
) {
return BaseResponse.<ModelPopularityResponse>builder()
.isSuccess(true)
.code(200)
.message(name+" 모델 화제성 조회에 성공했습니다.")
.data(modelPopularityService.getModelPopularity(name))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,16 @@ public BaseResponse<ProductResponse> getProduct(@PathVariable Long id) {
.data(productService.getProduct(id))
.build();
}

@DeleteMapping("/{id}")
public BaseResponse<Void> deleteProduct(@PathVariable Long id) {

productService.deleteProduct(id);

return BaseResponse.<Void>builder()
.isSuccess(true)
.code(200)
.message("광고 상품 삭제 성공")
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public record ModelRequest(
LocalDate birth,
String age,
String job,

String info,
String agency,
Float aiRate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ public record ModelResponse(
String imageUrl,
String modelName,
LocalDate birth,

String age,

String job,
String info,
String agency,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.backend.soullive_a.dto.response.model.popularity;

import com.backend.soullive_a.constant.AgeType;

public record ModelPopularAgeResponse(
Long ageId,
AgeType ageType
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.backend.soullive_a.dto.response.model.popularity;

import com.backend.soullive_a.constant.GenderType;

public record ModelPopularGenderResponse(
Long genderId,
GenderType gender
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.backend.soullive_a.dto.response.model.popularity;

import com.backend.soullive_a.entity.model.popularity.ModelPopularAge;
import com.backend.soullive_a.entity.model.popularity.ModelPopularGender;
import com.backend.soullive_a.entity.model.popularity.ModelPopularity;
import com.backend.soullive_a.entity.model.popularity.ModelScheduledWork;
import lombok.Builder;

import java.util.List;
import java.util.stream.Collectors;

@Builder
public record ModelPopularityResponse(
Long modelPopularityId,
Long modelId,
String scoreUrl,
String aiComment,
List<ModelPopularGenderResponse> genders,
List<ModelPopularAgeResponse> ages,
String snsUrl,
String searchUrl,
String brandScoreUrl,
List<ModelScheduledWorkResponse> modelScheduledWorks
) {
public static ModelPopularityResponse fromModel(
ModelPopularity modelPopularity,
List<ModelPopularGender> modelPopularGender,
List<ModelPopularAge> modelPopularAge,
List<ModelScheduledWork> modelScheduledWork
) {
List<ModelPopularGenderResponse> modelPopularGenders = modelPopularGender.stream()
.map(gender -> new ModelPopularGenderResponse(gender.getId(), gender.getGender()))
.collect(Collectors.toList());

List<ModelPopularAgeResponse> modelPopularAges = modelPopularAge.stream()
.map(age -> new ModelPopularAgeResponse(age.getId(), age.getAge()))
.collect(Collectors.toList());

List<ModelScheduledWorkResponse> modelScheduledWorks = modelScheduledWork.stream()
.map(work -> new ModelScheduledWorkResponse(
work.getId(),
work.getImageUrl(),
work.getYear(),
work.getCategory(),
work.getTitle(),
work.getIsMainActor(),
work.getGenre()))
.collect(Collectors.toList());

return ModelPopularityResponse.builder()
.modelId(modelPopularity.getModel().getId())
.modelPopularityId(modelPopularity.getId())
.scoreUrl(modelPopularity.getScoreUrl())
.aiComment(modelPopularity.getAiComment())
.genders(modelPopularGenders)
.ages(modelPopularAges)
.snsUrl(modelPopularity.getSnsUrl())
.searchUrl(modelPopularity.getSearchUrl())
.brandScoreUrl(modelPopularity.getBrandScoreUrl())
.modelScheduledWorks(modelScheduledWorks)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.backend.soullive_a.dto.response.model.popularity;

public record ModelScheduledWorkResponse(
Long modelScheduledWorkId,
String imageUrl,
Integer year,
String category,
String title,
Boolean isMainActor,
String genre
) {
}
3 changes: 3 additions & 0 deletions src/main/java/com/backend/soullive_a/entity/Age.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.backend.soullive_a.constant.AgeType;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Entity
@Table(name = "AGE")
Expand All @@ -18,6 +20,7 @@ public class Age {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PRODUCT_ID", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
private Product product;

@Enumerated(EnumType.STRING)
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/backend/soullive_a/entity/BrandImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Entity
@Table(name = "BRAND_IMAGE")
Expand All @@ -17,6 +19,7 @@ public class BrandImage {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PRODUCT_ID", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
private Product product;

@Column(name = "BRAND_IMAGE")
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/backend/soullive_a/entity/Gender.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.backend.soullive_a.constant.GenderType;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Entity
@Table(name = "GENDER")
Expand All @@ -18,6 +20,7 @@ public class Gender {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PRODUCT_ID", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
private Product product;

@Enumerated(EnumType.STRING)
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/backend/soullive_a/entity/ProductImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Entity
@Table(name = "PRODUCT_IMAGE")
Expand All @@ -17,6 +19,7 @@ public class ProductImage {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PRODUCT_ID", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
private Product product;

@Column(name = "PRODUCT_IMAGE", nullable = false)
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/backend/soullive_a/entity/Range.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

@Entity
@Table(name = "TARGETRANGE")
Expand All @@ -17,6 +19,7 @@ public class Range {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PRODUCT_ID", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
private Product product;

@Column(name = "RANGE_VALUE", nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import lombok.*;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Entity
@Getter
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.backend.soullive_a.entity.model;

import com.backend.soullive_a.entity.Product;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import java.time.LocalDateTime;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "PRODUCT_MODEL")
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ProductModel {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID")
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PRODUCT_ID", nullable = false)
private Product product;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "MODEL_ID", nullable = false)
private Model model;

@Column(name = "SEARCH_TIME", nullable = false)
private LocalDateTime searchTime;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.backend.soullive_a.entity.model.popularity;

import com.backend.soullive_a.constant.AgeType;
import com.backend.soullive_a.entity.Product;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Table(name = "MODEL_POPULAR_AGE")
@Builder
@Getter
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ModelPopularAge {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "AGE_ID")
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "MODEL_POPULARITY_ID", nullable = false)
private ModelPopularity modelPopularity;

@Enumerated(EnumType.STRING)
@Column(name = "AGE_TYPE")
private AgeType age;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.backend.soullive_a.entity.model.popularity;

import com.backend.soullive_a.constant.GenderType;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Table(name = "MODEL_POPULAR_GENDER")
@Builder
@Getter
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ModelPopularGender {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "GENDER_ID")
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "MODEL_POPULARITY_ID", nullable = false)
private ModelPopularity modelPopularity;

@Enumerated(EnumType.STRING)
@Column(name = "GENDER_TYPE")
private GenderType gender;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.backend.soullive_a.entity.model.popularity;

import com.backend.soullive_a.entity.model.Model;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Table(name = "MODEL_POPULARITY")
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ModelPopularity{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "MODEL_POPULARITY_ID", nullable = false)
private Long id;

@OneToOne
@JoinColumn(name = "MODEL_ID", nullable = false)
private Model model;

@Column(name = "SCORE_URL")
private String scoreUrl;

@Column(name = "AI_COMMENT")
private String aiComment;

@Column(name = "SNS_URL")
private String snsUrl;

@Column(name = "SEARCH_URL")
private String searchUrl;

@Column(name = "BRAND_SCORE_URL")
private String brandScoreUrl;
}
Loading

0 comments on commit c31b501

Please sign in to comment.