Skip to content

Commit

Permalink
feat: 소속 조회 결과에 소속 생성일자를 포함한다. (#82)
Browse files Browse the repository at this point in the history
* feat: 내 소속 조회 결과에 소속의 생성일자도 포함한다.

* chore: remove unused fields

* chore: userToken 필드를 삭제한다.
  • Loading branch information
rlarltj committed May 12, 2024
1 parent 00bee67 commit f1ab63c
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
@AllArgsConstructor
public class CreateAgencyRequest {
private String name;
private String description;
private AgencyType agencyType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import lombok.Builder;
import lombok.Getter;

import java.time.ZonedDateTime;

@Getter
@Builder
@AllArgsConstructor
Expand All @@ -14,13 +16,15 @@ public class AgencyResponse {
private String name;
private int headCount;
private AgencyType type;
private ZonedDateTime createdAt;

public static AgencyResponse from(Agency agency) {
return AgencyResponse.builder()
.id(agency.getId())
.name(agency.getAgencyName())
.headCount(agency.getHeadCount())
.type(agency.getAgencyType())
.createdAt(agency.getCreatedAt())
.build();
}
}
8 changes: 2 additions & 6 deletions src/main/java/com/moneymong/domain/agency/entity/Agency.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,22 @@ public class Agency extends BaseEntity {
)
private Integer headCount;

private String description;

@Column(name = "university_name")
private String universityName;

@Builder
private Agency(Long id, String agencyName, AgencyType agencyType, Integer headCount, String description, String universityName) {
private Agency(Long id, String agencyName, AgencyType agencyType, Integer headCount, String universityName) {
this.id = id;
this.agencyName = agencyName;
this.agencyType = agencyType;
this.headCount = headCount;
this.description = description;
this.universityName = universityName;
}

public static Agency of(String agencyName, AgencyType agencyType, String description, int headCount, String universityName) {
public static Agency of(String agencyName, AgencyType agencyType, int headCount, String universityName) {
return Agency.builder()
.agencyName(agencyName)
.agencyType(agencyType)
.description(description)
.headCount(headCount)
.universityName(universityName)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

public enum AgencyType {
STUDENT_COUNCIL,
IN_SCHOOL_CLUB,
OUT_OF_SCHOOL_CLUB
IN_SCHOOL_CLUB
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

@Service
@RequiredArgsConstructor
@Transactional(readOnly = true)
public class AgencyService {

private static final int INITIAL_HEAD_COUNT = 1;
Expand Down Expand Up @@ -65,7 +66,6 @@ public CreateAgencyResponse create(Long userId, CreateAgencyRequest request) {
Agency agency = Agency.of(
request.getName(),
request.getAgencyType(),
request.getDescription(),
INITIAL_HEAD_COUNT,
universityName
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
@AllArgsConstructor
public class UserProfileResponse {
private Long id;
private String userToken;
private String provider;
private String nickname;
private String email;
Expand All @@ -21,7 +20,6 @@ public class UserProfileResponse {
public static UserProfileResponse from(User user, UserUniversity userUniversity) {
return UserProfileResponse.builder()
.id(user.getId())
.userToken(user.getUserToken())
.provider(user.getProvider())
.nickname(user.getNickname())
.email(user.getEmail())
Expand Down
10 changes: 1 addition & 9 deletions src/main/java/com/moneymong/domain/user/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ public class User extends BaseEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(
name = "user_token",
unique = true,
nullable = false
)
private String userToken;

@Column(nullable = false)
private String email;

Expand All @@ -56,9 +49,8 @@ public class User extends BaseEntity {

private LocalDate birthDay;

public static User of(String userToken, String email, String nickname, String provider, String oauthId) {
public static User of(String email, String nickname, String provider, String oauthId) {
return User.builder()
.userToken(userToken)
.email(email)
.nickname(nickname)
.provider(provider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
import java.util.Optional;

public interface UserRepository extends JpaRepository<User, Long>, UserRepositoryCustom {
Optional<User> findByUserToken(String userToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public User save(User unsavedUser) {
@Transactional
public User registerUser(OAuthUserInfo oauthUserInfo) {
User newUser = User.of(
UUID.randomUUID().toString(),
oauthUserInfo.getEmail(),
oauthUserInfo.getNickname(),
oauthUserInfo.getProvider(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class JwtAuthentication{

public JwtAuthentication(Long id, String accessToken) {
this.id = validateId(id);
this.accessToken = validateUserToken(accessToken);
this.accessToken = validateAccessToken(accessToken);
}

private Long validateId(Long id) {
Expand All @@ -26,11 +26,11 @@ private Long validateId(Long id) {
return id;
}

private String validateUserToken(String userToken) {
if (StringUtils.isEmpty(userToken)) {
private String validateAccessToken(String accessToken) {
if (StringUtils.isEmpty(accessToken)) {
throw new InvalidTokenException(ErrorCode.INVALID_TOKEN);
}

return userToken;
return accessToken;
}
}

0 comments on commit f1ab63c

Please sign in to comment.