Skip to content

Commit

Permalink
[COT-72] Feature: 프로필 링크 관련 테이블 추가 (#209)
Browse files Browse the repository at this point in the history
* feat: add university, introduction column in member entity

* feat: create profile link entity

* refactor: rename hall of fame service

-> myPageService -> HallOfFameService

* feat: create memberProfile service, repository file

* feat: delete limit of introduction, university column length

* refactor: rollback name of hall of fame service

* feat: add TEXT option in introduction

* refactor: change parameter of hall of fame API

-> accessHeader -> AuthenticationPrincipal

* refactor: delete unused Builder from ProfileLink
  • Loading branch information
gikhoon authored Nov 28, 2024
1 parent 1916119 commit 67129a0
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package org.cotato.csquiz.api.mypage.controller;

import org.cotato.csquiz.api.mypage.dto.HallOfFameResponse;
import org.cotato.csquiz.common.config.jwt.JwtTokenProvider;
import org.cotato.csquiz.domain.education.service.MyPageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -19,13 +18,10 @@
public class MyPageController {

private final MyPageService myPageService;
private final JwtTokenProvider jwtTokenProvider;

@GetMapping("/hall-of-fame")
public ResponseEntity<HallOfFameResponse> findHallOfFame(@RequestParam("generationId") Long generationId,
@RequestHeader("Authorization") String authorizationHeader) {
String accessToken = jwtTokenProvider.getBearer(authorizationHeader);

return ResponseEntity.ok(myPageService.findHallOfFame(generationId, jwtTokenProvider.getMemberId(accessToken)));
@AuthenticationPrincipal Long memberId) {
return ResponseEntity.ok(myPageService.findHallOfFame(generationId, memberId));
}
}
14 changes: 14 additions & 0 deletions src/main/java/org/cotato/csquiz/domain/auth/entity/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public class Member extends BaseTimeEntity {
@Column(name = "member_profile_image")
private S3Info profileImage;

@Column(name = "introduction", columnDefinition = "TEXT")
private String introduction;

@Column(name = "university")
private String university;

@Builder
public Member(String email, String password, String name, String phoneNumber) {
this.email = email;
Expand Down Expand Up @@ -90,4 +96,12 @@ public void updatePosition(MemberPosition position) {
public void updateProfileImage(S3Info s3Info) {
this.profileImage = s3Info;
}

public void updateIntroduction(String introduction) {
this.introduction = introduction;
}

public void updateUniversity(String university) {
this.university = university;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.cotato.csquiz.domain.auth.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
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 lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.cotato.csquiz.common.entity.BaseTimeEntity;
import org.cotato.csquiz.domain.auth.enums.LinkType;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class ProfileLink extends BaseTimeEntity {

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

@Column(name = "type", nullable = false)
@Enumerated(EnumType.STRING)
private LinkType role;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id", nullable = false)
private Member member;
}
16 changes: 16 additions & 0 deletions src/main/java/org/cotato/csquiz/domain/auth/enums/LinkType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.cotato.csquiz.domain.auth.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum LinkType {
GITHUB("깃허브"),
BEHANCE("비핸스"),
BLOG("블로그"),
OTHER("기타"),
;

private final String description;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.cotato.csquiz.domain.auth.repository;

import org.cotato.csquiz.domain.auth.entity.ProfileLink;
import org.springframework.data.jpa.repository.JpaRepository;

public interface ProfileLinkRepository extends JpaRepository<ProfileLink, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.cotato.csquiz.domain.auth.service;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
@Transactional(readOnly = true)
@RequiredArgsConstructor
public class MemberProfileService {
}

0 comments on commit 67129a0

Please sign in to comment.