Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
44582bf
refactor: sign-in 관련 패키지 이동 및 정리
m-a-king Jan 13, 2025
bee71b7
feat(cookie): 쿠키 관련 로직 삭제
m-a-king Jan 13, 2025
026c007
feat(sign): 불필요한 클래스 삭제, 로직 개선, 컨트롤러 분리
m-a-king Jan 13, 2025
845a4f4
feat(sign): 불필요한 유저 정보 반환 엔드포인트 삭제
m-a-king Jan 13, 2025
c6db672
feat(ApiResponse): 가독성 개선, 메서드 추가
m-a-king Jan 13, 2025
f7a79b6
refactor: DTO 명명 구체화
m-a-king Jan 13, 2025
46679be
feat(sign-out): 로그아웃 패키지 이동, 불필요한 로직 삭제
m-a-king Jan 13, 2025
9d3165c
feat: 불필요한 로직 삭제
m-a-king Jan 13, 2025
dde36b1
feat(token): 컨트롤러 로직 개선, 명명 구체화
m-a-king Jan 13, 2025
3c4ba14
refactor(token): 로직 개선, 명명 수정, 패키지 이동
m-a-king Jan 13, 2025
9918101
feat(token): 만료된 액세스 토큰 관리 삭제
m-a-king Jan 13, 2025
94c3c1b
feat(user): password 를 accountPassword로 수정
m-a-king Jan 13, 2025
b8c6183
refactor: 코드 일관성을 위한 리팩토링
m-a-king Jan 14, 2025
b76f26c
feat(volunteer): 기존 엔티티들 old 처리
m-a-king Jan 14, 2025
50a1c8b
feat(center): 센터의 id, pw 삭제
m-a-king Jan 14, 2025
6ff9da4
feat(user): 유저에서 뻗어나오는 새로운 봉사자, 기관 추가
m-a-king Jan 14, 2025
df5b987
feat(center): 불필요한 sign 로직 삭제
m-a-king Jan 14, 2025
93fd118
rollback: 삭제가 너무 힘들다... 미뤄야할 것 같음
m-a-king Jan 14, 2025
a12f35a
feat(user): 봉사자/기관 엔티티, 리포지토리 추가
m-a-king Jan 14, 2025
9eee78d
rollback
m-a-king Jan 14, 2025
e9ac763
feat(user): volunteer, center 회원가입 기본 정적 팩토리 메서드 추가 및 관련 ENUM 개선
m-a-king Jan 15, 2025
bfa4b8f
feat(user): volunteer, center 회원가입 서비스 로직 추가
m-a-king Jan 15, 2025
e0be3d4
rollback
m-a-king Jan 15, 2025
157721c
refactor: 클래스 명 파스칼 케이스로 수정
m-a-king Jan 15, 2025
b2f4fbf
feat(register): 회원 가입 로직 (유저가 생성된 후, 봉사자나 기관이 생성)
m-a-king Jan 15, 2025
7fb327c
feat(user): accountId 중복 확인 기능 추가
m-a-king Jan 15, 2025
a2a259d
fix: bean name conflict 해결
m-a-king Jan 15, 2025
b8dc96b
fix: rollback 문제 해결, 테스트 문제 해결
m-a-king Jan 15, 2025
d67b326
feat: 기관의 베이스 엔티티 상속 추가
m-a-king Jan 16, 2025
ec45219
feat(center): 기관 아이디, 유저 아이디 기준 조회 기능 추가
m-a-king Jan 16, 2025
49f3b3f
feat(volunteer): 봉사자 아이디, 유저 아이디 기준 조회 기능 추가
m-a-king Jan 16, 2025
a809255
test(center): 기관 조회, 저장 테스트 추가
m-a-king Jan 16, 2025
302dfa9
test(volunteer): 봉사자 조회, 저장 테스트 추가
m-a-king Jan 16, 2025
d844619
refactor: suffix -> prefix
m-a-king Jan 16, 2025
d43f091
fix: 오타 수정
m-a-king Jan 16, 2025
388a618
refactor: optimize import
m-a-king Jan 16, 2025
678c3a2
refactor: reformat code
m-a-king Jan 16, 2025
6c8230b
refactor: Qualifier 삭제
m-a-king Jan 16, 2025
71b5df0
fix: center import
m-a-king Jan 16, 2025
5f66a07
feat: 봉사자, 기관 register 서비스 메서드 반환 값 수정
m-a-king Jan 16, 2025
ca2bd24
feat(user): 유저 공통 속성 수정, 봉사자와 기관 필드 수정
m-a-king Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/main/java/com/somemore/center/domain/NEWCenter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.somemore.center.domain;

import com.somemore.global.common.entity.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.UUID;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
@Table(name = "new_center") // TODO prefix 삭제
public class NEWCenter extends BaseEntity {

public static final String DEFAULT_NAME = "기관";
@Id
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public으로 열여둔 이유가 있으신가요? 다른데에서 사용되지 않으면 private가 좋아보입니당

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그렇네요! 메서드 내부에서만 사용해야겠어요~

@GeneratedValue(strategy = GenerationType.UUID)
@Column(name = "id", nullable = false, columnDefinition = "BINARY(16)")
private UUID id;

@Column(name = "user_id", nullable = false, columnDefinition = "BINARY(16)")
private UUID userId;

@Column(name = "name", nullable = false)
private String name;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name은 기관과 봉사자가 각자 관리하는건가요?
기존에는 공통속성에 들어있던 부분이라 여쭤봤습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그렇네요.. erd 상에서는 현재 구분되어있습니다. name을 공통 속성으로 옮기는 방법이 더 일관성 있다고 생각해서 코드와 erd 모두 수정하겠습니다!


@Column(name = "homepage_url", nullable = false)
private String homepageUrl;

@Builder
private NEWCenter(UUID userId, String name, String homepageUrl) {
this.userId = userId;
this.name = name;
this.homepageUrl = homepageUrl;
}

public static NEWCenter createDefault(UUID userId) {
return NEWCenter.builder()
.userId(userId)
.name(DEFAULT_NAME + userId.toString().substring(0, 8))
.homepageUrl("")
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.somemore.center.repository;

import com.somemore.center.domain.NEWCenter;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.UUID;

@Repository("newCenterJpaRepository")
public interface NEWCenterJpaRepository extends JpaRepository<NEWCenter, UUID> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.somemore.center.repository;

import com.somemore.center.domain.NEWCenter;

import java.util.Optional;
import java.util.UUID;

public interface NEWCenterRepository {

NEWCenter save(NEWCenter center);

Optional<NEWCenter> findById(UUID id);

Optional<NEWCenter> findByUserId(UUID userId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.somemore.center.repository;

import com.querydsl.jpa.impl.JPAQueryFactory;
import com.somemore.center.domain.NEWCenter;
import com.somemore.center.domain.QNEWCenter;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

import java.util.Optional;
import java.util.UUID;

@Repository("newCenterRepository")
@RequiredArgsConstructor
public class NEWCenterRepositoryImpl implements NEWCenterRepository {

private final NEWCenterJpaRepository NEWCenterJpaRepository;
private final JPAQueryFactory queryFactory;

private static final QNEWCenter center = QNEWCenter.nEWCenter;

@Override
public NEWCenter save(NEWCenter center) {
return NEWCenterJpaRepository.save(center);
}

@Override
public Optional<NEWCenter> findById(UUID id) {
return Optional.ofNullable(
queryFactory.selectFrom(center)
.where(
center.id.eq(id),
center.deleted.eq(false))
.fetchOne()
);
}

@Override
public Optional<NEWCenter> findByUserId(UUID userId) {
return Optional.ofNullable(
queryFactory.selectFrom(center)
.where(
center.userId.eq(userId),
center.deleted.eq(false))
.fetchOne()

);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.somemore.center.service;

import com.somemore.center.domain.NEWCenter;
import com.somemore.center.repository.NEWCenterRepository;
import com.somemore.center.usecase.NEWRegisterCenterUseCase;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.UUID;

@Service
@RequiredArgsConstructor
@Transactional
public class NEWRegisterCenterService implements NEWRegisterCenterUseCase {

private final NEWCenterRepository NEWCenterRepository;

@Override
public NEWCenter register(UUID userId) {
NEWCenter center = NEWCenter.createDefault(userId);
return NEWCenterRepository.save(center);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NEWCenter 엔티티 클래스를 반환하는 이유가 혹시 있으신가요? 없다면 id 정도만 반환하는게 좋아보입니다.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰보고 고민하다가 좋은 인사이트를 얻었네요..
리포지토리 계층에서는 center를 반환한다고 해도 서비스에서 이를 굳이 반환하지 않고, 끊어내면 된다는 것을 인지하지 못했던 것 같습니다. 감사합니다~

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.somemore.center.usecase;

import com.somemore.center.domain.NEWCenter;

import java.util.UUID;

public interface NEWRegisterCenterUseCase {

NEWCenter register(UUID userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

@RequiredArgsConstructor
@RestController
Expand Down
28 changes: 12 additions & 16 deletions src/main/java/com/somemore/domains/center/domain/Center.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

import com.somemore.domains.center.dto.request.CenterProfileUpdateRequestDto;
import com.somemore.global.common.entity.BaseEntity;
import jakarta.persistence.*;
import lombok.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.util.UUID;

Expand Down Expand Up @@ -34,34 +42,22 @@ public class Center extends BaseEntity {
@Column(name = "homepage_link", nullable = false)
private String homepageLink;

@Column(name = "account_id", nullable = false)
private String accountId;

@Column(name = "account_pw", nullable = false)
private String accountPw;


@Builder
private Center(String name, String contactNumber, String imgUrl, String introduce, String homepageLink, String accountId, String accountPw) {

private Center(String name, String contactNumber, String imgUrl, String introduce, String homepageLink) {
this.name = name;
this.contactNumber = contactNumber;
this.imgUrl = imgUrl;
this.introduce = introduce;
this.homepageLink = homepageLink;
this.accountId = accountId;
this.accountPw = accountPw;
}

public static Center create(String name, String contactNumber, String imgUrl, String introduce, String homepageLink, String accountId, String accountPw) {
public static Center create(String name, String contactNumber, String imgUrl, String introduce, String homepageLink) {
return Center.builder()
.name(name)
.contactNumber(contactNumber)
.imgUrl(imgUrl)
.introduce(introduce)
.homepageLink(homepageLink)
.accountId(accountId)
.accountPw(accountPw)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.somemore.domains.center.domain;

import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ public record CenterProfileUpdateRequestDto(
@Schema(description = "센터 소개", example = "저희 도서관은 유명해요")
@NotBlank(message = "센터 소개는 필수 값입니다.")
String introduce
) {}
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,31 @@
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.somemore.domains.center.domain.Center;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.UUID;
import lombok.Builder;

import java.util.UUID;

@Builder
@JsonNaming(SnakeCaseStrategy.class)
@Schema(description = "기관 정보 응답 DTO")
public record CenterSimpleInfoResponseDto(
@Schema(description = "기관 아이디", example = "123e4567-e89b-12d3-a456-426614174000")
UUID id,
@Schema(description = "기관 이름", example = "환경 봉사 센터")
String name
@Schema(description = "기관 아이디", example = "123e4567-e89b-12d3-a456-426614174000")
UUID id,
@Schema(description = "기관 이름", example = "환경 봉사 센터")
String name
) {

public static CenterSimpleInfoResponseDto from(Center center) {
return CenterSimpleInfoResponseDto.builder()
.id(center.getId())
.name(center.getName())
.build();
.id(center.getId())
.name(center.getName())
.build();
}

public static CenterSimpleInfoResponseDto of(UUID centerId, String name) {
return CenterSimpleInfoResponseDto.builder()
.id(centerId)
.name(name)
.build();
.id(centerId)
.name(name)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import java.util.UUID;

@Builder
public record PreferItemResponseDto (
public record PreferItemResponseDto(
Long id,
UUID centerId,
String itemName
){
) {
public static PreferItemResponseDto from(PreferItem preferItem) {
return PreferItemResponseDto.builder()
.id(preferItem.getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

import com.somemore.domains.center.domain.Center;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Optional;
import java.util.UUID;

@Repository("centerJpaRepository")
public interface CenterJpaRepository extends JpaRepository<Center, Long> {

boolean existsById(UUID id);

Optional<Center> findCenterById(UUID id);

Optional<Center> findByName(String name);

boolean existsByIdAndDeletedIsFalse(UUID id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

import com.somemore.domains.center.domain.Center;
import com.somemore.domains.center.repository.mapper.CenterOverviewInfo;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

@Repository
public interface CenterRepository {
Center save(Center center);

boolean existsById(UUID id);

default boolean doesNotExistById(UUID id) {
return !existsById(id);
}

Optional<Center> findCenterById(UUID id);

List<CenterOverviewInfo> findCenterOverviewsByIds(List<UUID> ids);
UUID findIdByAccountId(String accountId);
String findPasswordByAccountId(String accountId);
void deleteAllInBatch();

void deleteAllInBatch();
}
Loading
Loading