Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import jakarta.validation.constraints.NotBlank;
import org.hibernate.validator.constraints.URL;
import org.runimo.runimo.auth.service.dtos.UserSignupCommand;
import org.runimo.runimo.user.domain.Gender;

@Schema(description = "사용자 회원가입 요청 DTO")
public record AuthSignupRequest(
Expand All @@ -14,10 +15,13 @@ public record AuthSignupRequest(
@NotBlank String nickname,

@Schema(description = "프로필 이미지 URL", example = "https://example.com/image.jpg")
@URL String imgUrl
@URL String imgUrl,

@Schema(description = "성별", example = "FEMALE")
Gender gender
) {

public UserSignupCommand toUserSignupCommand() {
return new UserSignupCommand(registerToken, nickname, imgUrl);
return new UserSignupCommand(registerToken, nickname, imgUrl, gender);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public SignupUserResponse register(UserSignupCommand command) {
User savedUser = userRegisterService.registerUser(new UserRegisterCommand(
command.nickname(),
command.imgUrl(),
command.gender(),
payload.providerId(),
payload.socialProvider())
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.runimo.runimo.auth.service.dtos;


import org.runimo.runimo.user.domain.Gender;

public record UserSignupCommand(
String registerToken,
String nickname,
String imgUrl
String imgUrl,
Gender gender
) {

}
5 changes: 5 additions & 0 deletions src/main/java/org/runimo/runimo/user/domain/Gender.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.runimo.runimo.user.domain;

public enum Gender {
MALE, FEMALE, UNKNOWN;
}
5 changes: 4 additions & 1 deletion src/main/java/org/runimo/runimo/user/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ public class User extends BaseEntity {
private Long totalTimeInSeconds = 0L;
@Column(name = "main_runimo_id")
private Long mainRunimoId;
@Column(name = "gender")
private Gender gender;

@Builder
public User(String nickname, String imgUrl, Long totalDistanceInMeters,
Long totalTimeInSeconds) {
Long totalTimeInSeconds, Gender gender) {
this.nickname = nickname;
this.imgUrl = imgUrl;
this.totalDistanceInMeters = totalDistanceInMeters != null ? totalDistanceInMeters : 0L;
this.totalTimeInSeconds = totalTimeInSeconds != null ? totalTimeInSeconds : 0L;
this.gender = gender;
}

public boolean checkUserFirstRun() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public User createUser(UserCreateCommand command) {
User user = User.builder()
.nickname(command.nickname())
.imgUrl(command.imgUrl())
.gender(command.gender())
.build();
return userRepository.saveAndFlush(user);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class UserRegisterService {
@Transactional
public User registerUser(UserRegisterCommand command) {
User savedUser = userCreator.createUser(
new UserCreateCommand(command.nickname(), command.imgUrl()));
new UserCreateCommand(command.nickname(), command.imgUrl(), command.gender()));
userCreator.createUserOAuthInfo(savedUser, command.socialProvider(), command.providerId());
userCreator.createLovePoint(savedUser.getId());
userItemCreator.createAll(savedUser.getId());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.runimo.runimo.user.service.dtos;

import org.runimo.runimo.user.domain.Gender;

public record UserCreateCommand(
String nickname,
String imgUrl
String imgUrl,
Gender gender
) {

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.runimo.runimo.user.service.dtos;

import org.runimo.runimo.user.domain.Gender;
import org.runimo.runimo.user.domain.SocialProvider;

public record UserRegisterCommand(
String nickname,
String imgUrl,
Gender gender,
String providerId,
SocialProvider socialProvider
) {
Expand Down
79 changes: 40 additions & 39 deletions src/main/resources/sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ CREATE TABLE `users`
`public_id` VARCHAR(255),
`nickname` VARCHAR(255),
`img_url` VARCHAR(255),
`total_distance_in_meters` BIGINT NOT NULL DEFAULT 0,
`total_time_in_seconds` BIGINT NOT NULL DEFAULT 0,
`total_distance_in_meters` BIGINT NOT NULL DEFAULT 0,
`total_time_in_seconds` BIGINT NOT NULL DEFAULT 0,
`main_runimo_id` BIGINT,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`gender` VARCHAR(24),
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`deleted_at` TIMESTAMP NULL
);

Expand All @@ -35,25 +36,25 @@ CREATE TABLE `user_token`
`device_token` VARCHAR(255) NOT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted_at` TIMESTAMP NULL,
`deleted_at` TIMESTAMP NULL,

FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
);

CREATE TABLE `user_love_point`
(
`id` BIGINT PRIMARY KEY AUTO_INCREMENT,
`user_id` BIGINT NOT NULL,
`amount` BIGINT NOT NULL DEFAULT 0,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`id` BIGINT PRIMARY KEY AUTO_INCREMENT,
`user_id` BIGINT NOT NULL,
`amount` BIGINT NOT NULL DEFAULT 0,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted_at` TIMESTAMP NULL
);

CREATE TABLE `oauth_account`
(
`id` BIGINT PRIMARY KEY AUTO_INCREMENT,
`user_id` BIGINT NOT NULL,
`user_id` BIGINT NOT NULL,
`provider` VARCHAR(255),
`provider_id` VARCHAR(255),
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
Expand All @@ -65,7 +66,7 @@ CREATE TABLE `oauth_account`
CREATE TABLE `running_record`
(
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
`user_id` INTEGER NOT NULL,
`user_id` INTEGER NOT NULL,
`record_public_id` VARCHAR(255) NOT NULL,
`title` VARCHAR(255),
`started_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
Expand All @@ -76,7 +77,7 @@ CREATE TABLE `running_record`
`pace_per_km` VARCHAR(10000),
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted_at` TIMESTAMP NULL
`deleted_at` TIMESTAMP NULL
);

CREATE TABLE `item`
Expand All @@ -92,27 +93,27 @@ CREATE TABLE `item`
`hatch_require_amount` BIGINT,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted_at` TIMESTAMP NULL
`deleted_at` TIMESTAMP NULL
);

CREATE TABLE `item_activity`
(
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
`activity_user_id` INTEGER NOT NULL,
`activity_item_id` INTEGER NOT NULL,
`activity_user_id` INTEGER NOT NULL,
`activity_item_id` INTEGER NOT NULL,
`activity_event_type` VARCHAR(255) NOT NULL,
`quantity` INTEGER,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted_at` TIMESTAMP NULL
`deleted_at` TIMESTAMP NULL
);

CREATE TABLE `user_item`
(
`id` BIGINT PRIMARY KEY AUTO_INCREMENT,
`user_id` INTEGER NOT NULL,
`item_id` INTEGER NOT NULL,
`quantity` INTEGER NOT NULL,
`user_id` INTEGER NOT NULL,
`item_id` INTEGER NOT NULL,
`quantity` INTEGER NOT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted_at` TIMESTAMP NULL
Expand All @@ -121,8 +122,8 @@ CREATE TABLE `user_item`
CREATE TABLE `incubating_egg`
(
`id` BIGINT PRIMARY KEY AUTO_INCREMENT,
`user_id` INTEGER NOT NULL,
`egg_id` INTEGER NOT NULL,
`user_id` INTEGER NOT NULL,
`egg_id` INTEGER NOT NULL,
`current_love_point_amount` INTEGER,
`hatch_require_amount` INTEGER,
`egg_status` VARCHAR(255),
Expand All @@ -133,27 +134,27 @@ CREATE TABLE `incubating_egg`

CREATE TABLE `runimo_definition`
(
`id` BIGINT PRIMARY KEY AUTO_INCREMENT,
`name` VARCHAR(255),
`code` VARCHAR(255),
`description` VARCHAR(255),
`img_url` varchar(255),
`egg_type` varchar(255) NOT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted_at` TIMESTAMP NULL
`id` BIGINT PRIMARY KEY AUTO_INCREMENT,
`name` VARCHAR(255),
`code` VARCHAR(255),
`description` VARCHAR(255),
`img_url` varchar(255),
`egg_type` varchar(255) NOT NULL,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted_at` TIMESTAMP NULL
);

CREATE TABLE `runimo`
(
`id` BIGINT PRIMARY KEY AUTO_INCREMENT,
`user_id` BIGINT NOT NULL,
`runimo_definition_id` BIGINT NOT NULL,
`total_run_count` BIGINT NOT NULL DEFAULT 0,
`total_distance_in_meters` BIGINT NOT NULL DEFAULT 0,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted_at` TIMESTAMP NULL
`id` BIGINT PRIMARY KEY AUTO_INCREMENT,
`user_id` BIGINT NOT NULL,
`runimo_definition_id` BIGINT NOT NULL,
`total_run_count` BIGINT NOT NULL DEFAULT 0,
`total_distance_in_meters` BIGINT NOT NULL DEFAULT 0,
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`deleted_at` TIMESTAMP NULL
);

ALTER TABLE `user_token`
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/org/runimo/runimo/rewards/RewardTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.runimo.runimo.rewards.service.RewardService;
import org.runimo.runimo.rewards.service.dtos.RewardClaimCommand;
import org.runimo.runimo.rewards.service.dtos.RewardResponse;
import org.runimo.runimo.user.domain.Gender;
import org.runimo.runimo.user.domain.SocialProvider;
import org.runimo.runimo.user.domain.User;
import org.runimo.runimo.user.domain.UserItem;
Expand Down Expand Up @@ -57,7 +58,7 @@ void setUp() {
//given
String registerToken = jwtTokenFactory.generateRegisterTemporalToken("test-pid",
SocialProvider.KAKAO);
UserSignupCommand command = new UserSignupCommand(registerToken, "name", "1234");
UserSignupCommand command = new UserSignupCommand(registerToken, "name", "1234", Gender.UNKNOWN);
Long useId = signUpUsecaseImpl.register(command).userId();
savedUser = userRepository.findById(useId).orElse(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.runimo.runimo.auth.service.dtos.SignupUserResponse;
import org.runimo.runimo.auth.service.dtos.TokenPair;
import org.runimo.runimo.user.controller.request.UseItemRequest;
import org.runimo.runimo.user.domain.Gender;
import org.runimo.runimo.user.domain.SocialProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down Expand Up @@ -148,7 +149,8 @@ void tearDown() {
AuthSignupRequest request = new AuthSignupRequest(
registerToken,
"test-user",
"https://test-image.com"
"https://test-image.com",
Gender.FEMALE
);

ValidatableResponse res = given()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.runimo.runimo.rewards.service.eggs.EggGrantService;
import org.runimo.runimo.user.domain.Gender;
import org.runimo.runimo.user.domain.SocialProvider;
import org.runimo.runimo.user.domain.User;
import org.runimo.runimo.user.service.UserCreator;
Expand Down Expand Up @@ -48,6 +49,7 @@ void setUp() {
new UserRegisterCommand(
"test-nickname",
"https://test.com",
Gender.UNKNOWN,
providerId,
SocialProvider.KAKAO
);
Expand Down
Loading
Loading