Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Bamsongee/back-end
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunji-Yun committed Aug 18, 2024
2 parents 5785943 + d864734 commit 94133d1
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 306 deletions.
4 changes: 3 additions & 1 deletion src/main/java/com/ohmea/todayrecipe/config/CorsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ public class CorsConfig implements WebMvcConfigurer {

@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/api/**")
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowedMethods("GET", "POST", "PUT", "DELETE")
.exposedHeaders("accesstoken", "refreshtoken")
.allowedHeaders("*")
.allowCredentials(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static ProductResponseDTO toDto(ProductEntity productEntity) {
return ProductResponseDTO.builder()
.id(productEntity.getId())
.image(productEntity.getImage())
.title(productEntity.getTitle())
.description(productEntity.getDescription())
.percent(productEntity.getPercent())
.price(productEntity.getPrice())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class RecipeResponseDTO {
private List<String> ingredients;
private String recipe;
private String serving;
private String time;
private Integer time;
private String difficulty;
private String keyword;
private String category;
Expand Down Expand Up @@ -60,7 +60,7 @@ public static class list {
private String name;
private String link;
private String imageUrl;
private String time;
private Integer time;
private String difficulty;
private String keyword;
private String category;
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/ohmea/todayrecipe/dto/user/JoinDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public class JoinDTO {
private String username;
private String password;
private GenderEnum gender;
private Integer age;
private CookingSkillEnum cookingSkill;
private Integer cookingBudget;
private String filter;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@
public class UpdateUserDTO {
private CookingSkillEnum cookingSkill;
private Integer cookingBudget;
private String filter;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
public class UserResponseDTO {
private String username;
private GenderEnum gender;
private Integer age;
private CookingSkillEnum cookingSkill;
private Integer cookingBudget;
private String filter;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class RecipeEntity extends BaseEntity{
private String serving;

@CsvBindByName(column = "time")
private String time;
private Integer time;

@CsvBindByName(column = "difficulty")
private String difficulty;
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/com/ohmea/todayrecipe/entity/UserEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@ public class UserEntity extends BaseEntity{
private String password;
// 성별
private GenderEnum gender;
// 나이
private Integer age;
// 요리 실력
private CookingSkillEnum cookingSkill;
// 예산
private Integer cookingBudget;
// 맞춤 필터링 제공
private String filter;
// admin
private String role;
// refrigerator 식재료들
Expand All @@ -41,10 +37,9 @@ public class UserEntity extends BaseEntity{
private List<LikeEntity> likes = new ArrayList<>();

// user 정보 업데이트
public void updateUser(CookingSkillEnum cookingSkill, Integer cookingBudget, String filter) {
public void updateUser(CookingSkillEnum cookingSkill, Integer cookingBudget) {
this.cookingSkill = cookingSkill == null ? this.cookingSkill : cookingSkill;
this.cookingBudget = cookingBudget == null ? this.cookingBudget : cookingBudget;
this.filter = filter == null ? this.filter : filter;
}

@OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
Expand Down
10 changes: 1 addition & 9 deletions src/main/java/com/ohmea/todayrecipe/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ public ResponseDTO<String> joinProcess(JoinDTO joinDTO) {
String username = joinDTO.getUsername();
String password = joinDTO.getPassword();
GenderEnum gender = joinDTO.getGender();
Integer age = joinDTO.getAge();
Integer cookingBudget = joinDTO.getCookingBudget();
String filter = joinDTO.getFilter();
CookingSkillEnum cookingSkill = joinDTO.getCookingSkill();

Boolean isExist = userRepository.existsByUsername(username);
Expand All @@ -55,8 +53,6 @@ public ResponseDTO<String> joinProcess(JoinDTO joinDTO) {
.gender(gender)
.cookingSkill(cookingSkill)
.cookingBudget(cookingBudget)
.filter(filter)
.age(age)
.role("ROLE_ADMIN")
.build();

Expand All @@ -72,10 +68,8 @@ public UserResponseDTO getUserInfo(String username) {
return UserResponseDTO.builder()
.username(user.getUsername())
.gender(user.getGender())
.age(user.getAge())
.cookingBudget(user.getCookingBudget())
.cookingSkill(user.getCookingSkill())
.filter(user.getFilter())
.build();
}

Expand All @@ -84,17 +78,15 @@ public UserResponseDTO updateUser(String username, UpdateUserDTO updateUserDTO)
UserEntity user = userRepository.findByUsername(username)
.orElseThrow(() -> new UsernameNotFoundException("해당 사용자 이름을 가진 사용자를 찾을 수 없습니다: " + username));

user.updateUser(updateUserDTO.getCookingSkill(), updateUserDTO.getCookingBudget(), updateUserDTO.getFilter());
user.updateUser(updateUserDTO.getCookingSkill(), updateUserDTO.getCookingBudget());

userRepository.save(user);

return UserResponseDTO.builder()
.username(user.getUsername())
.gender(user.getGender())
.age(user.getAge())
.cookingBudget(user.getCookingBudget())
.cookingSkill(user.getCookingSkill())
.filter(user.getFilter())
.build();
}

Expand Down
Loading

0 comments on commit 94133d1

Please sign in to comment.