Skip to content

Commit

Permalink
Merge pull request #172 from BETTER-iTER/feature/170
Browse files Browse the repository at this point in the history
[Feature/170] 카테고리 수정 기능 추가
  • Loading branch information
luke0408 authored Feb 25, 2024
2 parents d3af6e3 + 848bdcf commit fac8820
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
Expand Down Expand Up @@ -165,4 +166,19 @@ public ResponseDto<Void> updateUserProfile(
mypageService.updateUserProfile(user, request, image);
return ResponseDto.onSuccess(null);
}

/**
* user 관심 카테고리 수정
*
* @param request 수정할 user 정보
* @return void
*/
@PutMapping("/category")
public ResponseDto<Void> updateUserCategory(
@Valid @RequestBody MypageRequest.UpdateCategoryRequest request
) {
Users user = mypageService.getCurrentUser();
mypageService.updateUserCategory(user, request);
return ResponseDto.onSuccess(null);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.example.betteriter.fo_domain.mypage.dto;

import java.util.List;

import com.example.betteriter.global.constant.Category;
import com.example.betteriter.global.constant.Job;

import lombok.AllArgsConstructor;
Expand All @@ -11,8 +14,15 @@ public class MypageRequest {
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class UpdateProfileRequest {
public static class UpdateProfileRequest {
private String nickname;
private Job job;
}

@Getter
@NoArgsConstructor
@AllArgsConstructor
public static class UpdateCategoryRequest {
private List<Category> categories;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,8 @@ private void checkUploadProfileImageRequestValidation(MultipartFile image) {
throw new MypageHandler(_IMAGE_FILE_UPLOAD_REQUEST_IS_NOT_VALID);
}
}

public void updateUserCategory(Users user, MypageRequest.UpdateCategoryRequest request) {
user.setUsersCategory(request.getCategories());
}
}

0 comments on commit fac8820

Please sign in to comment.