Skip to content

Commit

Permalink
Merge pull request #20 from MEME-UMC/add/#13
Browse files Browse the repository at this point in the history
[Add] 관심 아티스트/포트폴리오 추가
  • Loading branch information
yeopyeop-82 authored Jan 23, 2024
2 parents 8925fb4 + 952eec9 commit c90f11c
Show file tree
Hide file tree
Showing 58 changed files with 1,541 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/umc/meme/shop/ShopApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@SpringBootApplication
@EnableJpaAuditing
public class ShopApplication {

public static void main(String[] args) {
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/umc/meme/shop/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package umc.meme.shop.config;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {
// http://localhost:8080/swagger-ui/index.html#/
@Bean
public OpenAPI MemeAPI() {
Info info = new Info()
.title("MEME_SERVICE API Docs")
.description("MEME_SERVICE API 명세서입니다.")
.version("1.0.0");

String jwtSchemeName = "accessToken";
// API 요청헤더에 인증정보 포함
SecurityRequirement securityRequirement = new SecurityRequirement().addList(jwtSchemeName);

// SecuritySchemes 등록
Components components = new Components()
.addSecuritySchemes(jwtSchemeName, new SecurityScheme()
.name(jwtSchemeName)
.type(SecurityScheme.Type.HTTP) // HTTP 방식
.scheme("bearer")
.bearerFormat("JWT"));

return new OpenAPI()
.addServersItem(new Server().url("/"))
.info(info)
.addSecurityItem(securityRequirement)
.components(components);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package umc.meme.shop.domain.artist.controller;

import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import umc.meme.shop.domain.artist.dto.request.ArtistProfileDto;
import umc.meme.shop.domain.review.dto.request.UpdateReviewDto;
import umc.meme.shop.domain.artist.service.ArtistService;
import umc.meme.shop.global.SuccessStatus;
import umc.meme.shop.global.response.ApiResponse;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1")
public class ArtistController {
private final ArtistService artistService;

@Operation(summary = "아티스트 프로필 관리")
@PatchMapping("/mypage/{userId}/profile/artist")
public ApiResponse updateProfile(@PathVariable Long userId, @RequestBody ArtistProfileDto profileDto){
return ApiResponse.SuccessResponse(SuccessStatus.PROFILE_UPDATE);
}

@Operation(summary = "리뷰 관리", description = "block 상태를 통해 리뷰 공개 유무를 결정할 수 있는 API입니다.")
@PatchMapping("/artist/review")
public ApiResponse updateReview(@RequestBody UpdateReviewDto reviewDto){
return ApiResponse.SuccessResponse(SuccessStatus.REVIEW_UPDATE);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package umc.meme.shop.domain.artist.dto.request;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import umc.meme.shop.domain.artist.entity.enums.AvailableTime;
import umc.meme.shop.domain.artist.entity.enums.Gender;
import umc.meme.shop.domain.artist.entity.enums.MakeupLocation;
import umc.meme.shop.domain.artist.entity.enums.Region;
import umc.meme.shop.domain.portfolio.entity.enums.Category;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ArtistProfileDto {
private String profileImg;
private String nickname;
private Gender gender;
private String introduction;
private List<Region> region;
private List<Category> specialization;
private MakeupLocation makeupLocation;
private AvailableTime availableTime;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package umc.meme.shop.domain.artist.dto.response;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import umc.meme.shop.domain.artist.entity.Artist;
import umc.meme.shop.domain.artist.entity.enums.*;
import umc.meme.shop.domain.favorite.entity.FavoriteArtist;
import umc.meme.shop.domain.portfolio.dto.response.PortfolioDto;
import umc.meme.shop.domain.portfolio.entity.enums.Category;

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

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ArtistDto {
private Long artistId;

private Gender gender;

private String nickname;

private String profileImg;

private String introduction;

private WorkExperience workExperience;

private List<Region> region;

private List<Category> specialization;

private MakeupLocation makeupLocation;

private List<PortfolioDto> portfolioDtoList;

public static ArtistDto from(Artist artist){
List<PortfolioDto> portfolioDtoList = artist.getPortfolioList()
.stream()
.map(PortfolioDto::from)
.toList();

return ArtistDto.builder()
.gender(artist.getGender())
.nickname(artist.getNickname())
.profileImg(artist.getProfileImg())
.introduction(artist.getIntroduction())
.workExperience(artist.getWorkExperience())
.region(artist.getRegion())
.specialization(artist.getSpecialization())
.makeupLocation(artist.getMakeupLocation())
.portfolioDtoList(portfolioDtoList)
.build();
}

//관심 아티스트
public static ArtistDto from(FavoriteArtist favoriteArtist){
Artist artist = favoriteArtist.getArtist();
List<PortfolioDto> portfolioDtoList = artist.getPortfolioList()
.stream()
.map(PortfolioDto::from)
.toList();

return ArtistDto.builder()
.gender(artist.getGender())
.nickname(artist.getNickname())
.profileImg(artist.getProfileImg())
.introduction(artist.getIntroduction())
.workExperience(artist.getWorkExperience())
.region(artist.getRegion())
.specialization(artist.getSpecialization())
.makeupLocation(artist.getMakeupLocation())
.portfolioDtoList(portfolioDtoList)
.build();
}

}


73 changes: 73 additions & 0 deletions src/main/java/umc/meme/shop/domain/artist/entity/Artist.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package umc.meme.shop.domain.artist.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import umc.meme.shop.domain.artist.entity.enums.*;
import umc.meme.shop.domain.portfolio.entity.Portfolio;
import umc.meme.shop.domain.portfolio.entity.enums.Category;

import java.util.Date;
import java.util.List;

@Builder
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class Artist {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "artist_id")
private Long artistId;

@Column(nullable = false, length = 20)
private String name;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
private Gender gender;

@Column(nullable = false, length = 40)
private String email;

@Column(nullable = false, length = 40)
private String nickname;

@Column(nullable = false)
private String profileImg;

@Column(nullable = false, length = 500)
private String introduction = "안녕하세요! 저는 ___입니다!";

@Enumerated(EnumType.STRING)
@Column(nullable = false)
private WorkExperience workExperience;

@Enumerated(EnumType.STRING)
// @Column(nullable = false)
private List<Region> region;

@Enumerated(EnumType.STRING)
// @Column(nullable = false)
private List<Category> specialization;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
private MakeupLocation makeupLocation;

@Column(nullable = true)
private String shopLocation; //샵의 위치

@Column(nullable = true)
private Date inactiveDate;

@Enumerated(EnumType.STRING)
@Column(nullable = true)
private AvailableTime availableTime;

@OneToMany(cascade = CascadeType.ALL, mappedBy = "artist")
private List<Portfolio> portfolioList;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package umc.meme.shop.domain.artist.entity.enums;

public enum AvailableTime {
MON, TUE, WED, THU, FRI, SAT, SUN
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package umc.meme.shop.domain.artist.entity.enums;

public enum Gender {
MALE, FEMALE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package umc.meme.shop.domain.artist.entity.enums;

public enum MakeupLocation {
SHOP, VISIT, BOTH
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package umc.meme.shop.domain.artist.entity.enums;

public enum Region {
JONGNO, JUNG, YONGSAN, SEONGDONG, GWANGJIN, DONGDAEMUN,
JUNGNANG, SEONGBUK, GANGBUK, DOBONG, NOWON, EUNPYEONG,
SEODAEMUN, MAPO, YANGCHEON, GANGSEO, GURO, GEUMCHEON,
YEONGDEUNGPO, DONGJAK, GWANAK, SEOCHO, GANGNAM, SONGPA, GANGDONG
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package umc.meme.shop.domain.artist.entity.enums;

public enum WorkExperience {
ONE, TWO, THREE, FOUR,
FIVE, SIX, SEVEN, EIGHT,
NINE, TEN
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package umc.meme.shop.domain.artist.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import umc.meme.shop.domain.artist.entity.Artist;

public interface ArtistRepository extends JpaRepository<Artist, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package umc.meme.shop.domain.artist.service;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import umc.meme.shop.domain.artist.repository.ArtistRepository;
import umc.meme.shop.domain.reservation.repository.ReservationRepository;


@Service
@RequiredArgsConstructor
public class ArtistService {
private final ArtistRepository artistRepository;
private final ReservationRepository reservationRepository;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package umc.meme.shop.domain.favorite.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import umc.meme.shop.domain.artist.entity.Artist;
import umc.meme.shop.domain.model.entity.Model;

@Builder
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class FavoriteArtist {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long favoriteArtistId;

@ManyToOne
@JoinColumn(name="model_id", nullable = false)
private Model model;

@ManyToOne
@JoinColumn(name="artist_id", nullable = false)
private Artist artist;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package umc.meme.shop.domain.favorite.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import umc.meme.shop.domain.model.entity.Model;
import umc.meme.shop.domain.portfolio.entity.Portfolio;

@Builder
@Getter
@AllArgsConstructor
@NoArgsConstructor
@Entity
public class FavoritePortfolio {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long favoritePortfolioId;

@ManyToOne
@JoinColumn(name="model_id", nullable = false)
private Model model;

@ManyToOne
@JoinColumn(name="portfolio_id", nullable = false)
private Portfolio portfolio;
}
Loading

0 comments on commit c90f11c

Please sign in to comment.