Skip to content

Commit

Permalink
Merge pull request #79 from Happy-HOBAK/feat/#58
Browse files Browse the repository at this point in the history
[#58] 기타 카테고리 미조회 에러 해결
  • Loading branch information
yel-m authored May 14, 2024
2 parents 2c69933 + 04812f3 commit 45b927b
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.hobak.happinessql.domain.activity.application;

import com.hobak.happinessql.domain.activity.converter.CategoryConverter;
import com.hobak.happinessql.domain.activity.domain.Category;
import com.hobak.happinessql.domain.activity.dto.CategoryResponseDto;
import com.hobak.happinessql.domain.activity.repository.CategoryRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
@RequiredArgsConstructor
public class CategoryCreateService {
private final CategoryRepository categoryRepository;
public CategoryResponseDto createCategory(Long userId){
Category category = CategoryConverter.toCategory(userId);
categoryRepository.save(category);
return CategoryConverter.toCategoryResponseDto(category.getCategoryId());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.hobak.happinessql.domain.activity.converter;

import com.hobak.happinessql.domain.activity.domain.Category;
import com.hobak.happinessql.domain.activity.dto.CategoryResponseDto;

public class CategoryConverter {
public static Category toCategory(Long userId) {
return Category.builder()
.name("기타")
.userId(userId)
.build();
}
public static CategoryResponseDto toCategoryResponseDto(Long categoryId){
return CategoryResponseDto.builder()
.categoryId(categoryId)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public class Category extends BaseTimeEntity {
private Long userId;

@Builder
public Category(Long categoryId, String name, List<Activity> activities, Long userId) {
this.categoryId = categoryId;
public Category(String name, List<Activity> activities, Long userId) {
this.name = name;
this.activities = activities;
this.userId = userId;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.hobak.happinessql.domain.activity.dto;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class CategoryResponseDto {
private Long categoryId;
@Builder
CategoryResponseDto(Long categoryId){
this.categoryId = categoryId;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.hobak.happinessql.domain.user.api;

import com.hobak.happinessql.domain.activity.application.CategoryCreateService;
import com.hobak.happinessql.domain.user.application.CustomUserDetailsService;
import com.hobak.happinessql.domain.user.application.UserFindService;
import com.hobak.happinessql.domain.user.application.UserProfileService;
Expand Down Expand Up @@ -65,9 +66,11 @@ public DataResponseDto<JwtToken> signIn(@RequestBody SignInDto signInDto) {
public String test(){
return "success";
}
private final CategoryCreateService categoryCreateService;
@PostMapping("/sign-up")
public DataResponseDto<Object> signUp(@RequestBody SignUpDto signUpDto){
UserDto savedUserDto = userService.signUp(signUpDto);
categoryCreateService.createCategory(savedUserDto.getUserid());
return DataResponseDto.of("회원가입이 성공적으로 처리되었습니다.");
}
}
Expand Down

0 comments on commit 45b927b

Please sign in to comment.