-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DEV-10] Fix Zone API 리팩토링 및 Fix Zone Comment API 개발 (#60)
- Loading branch information
Showing
31 changed files
with
729 additions
and
398 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...in/java/ddingdong/ddingdongBE/common/converter/MultipartJackson2HttpMessageConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ddingdong.ddingdongBE.common.converter; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import java.lang.reflect.Type; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class MultipartJackson2HttpMessageConverter extends AbstractJackson2HttpMessageConverter { | ||
|
||
public MultipartJackson2HttpMessageConverter(ObjectMapper objectMapper) { | ||
super(objectMapper, MediaType.APPLICATION_OCTET_STREAM); | ||
} | ||
|
||
@Override | ||
public boolean canWrite(Class<?> clazz, MediaType mediaType) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean canWrite(Type type, Class<?> clazz, MediaType mediaType) { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected boolean canWrite(MediaType mediaType) { | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 56 additions & 28 deletions
84
src/main/java/ddingdong/ddingdongBE/domain/fixzone/controller/AdminFixZoneController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,69 @@ | ||
package ddingdong.ddingdongBE.domain.fixzone.controller; | ||
|
||
import java.util.List; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.ModelAttribute; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import ddingdong.ddingdongBE.domain.fixzone.controller.dto.request.UpdateFiXCompletionRequest; | ||
import ddingdong.ddingdongBE.domain.fixzone.controller.dto.request.UpdateFixRequest; | ||
import ddingdong.ddingdongBE.domain.fixzone.controller.dto.response.AdminDetailFixResponse; | ||
import ddingdong.ddingdongBE.domain.fixzone.controller.dto.response.AdminFixResponse; | ||
import ddingdong.ddingdongBE.auth.PrincipalDetails; | ||
import ddingdong.ddingdongBE.domain.club.entity.Club; | ||
import ddingdong.ddingdongBE.domain.club.service.ClubService; | ||
import ddingdong.ddingdongBE.domain.fixzone.controller.api.AdminFixZoneApi; | ||
import ddingdong.ddingdongBE.domain.fixzone.controller.dto.request.CreateFixZoneCommentRequest; | ||
import ddingdong.ddingdongBE.domain.fixzone.controller.dto.response.GetFixZoneResponse; | ||
import ddingdong.ddingdongBE.domain.fixzone.entity.FixZone; | ||
import ddingdong.ddingdongBE.domain.fixzone.service.FixZoneCommentService; | ||
import ddingdong.ddingdongBE.domain.fixzone.service.FixZoneService; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/server/admin/fix") | ||
@RequiredArgsConstructor | ||
public class AdminFixZoneController { | ||
public class AdminFixZoneController implements AdminFixZoneApi { | ||
|
||
private final FixZoneService fixZoneService; | ||
private final FixZoneCommentService fixZoneCommentService; | ||
private final ClubService clubService; | ||
|
||
@Override | ||
public List<GetFixZoneResponse> getFixZones() { | ||
return fixZoneService.getAll(); | ||
} | ||
|
||
@Override | ||
public void updateFixZoneToComplete(Long fixZoneId) { | ||
fixZoneService.updateToComplete(fixZoneId); | ||
} | ||
|
||
@Override | ||
public void createFixZoneComment( | ||
PrincipalDetails principalDetails, | ||
CreateFixZoneCommentRequest request, | ||
Long fixZoneId | ||
) { | ||
FixZone fixZone = fixZoneService.getById(fixZoneId); | ||
Club club = clubService.getByClubId(principalDetails.getUser().getId()); | ||
|
||
fixZoneCommentService.create(fixZone, club, request); | ||
} | ||
|
||
@Override | ||
public void updateFixZoneComment( | ||
PrincipalDetails principalDetails, | ||
CreateFixZoneCommentRequest request, | ||
Long fixZoneId, | ||
Long commentId | ||
) { | ||
Club club = clubService.getByClubId(principalDetails.getUser().getId()); | ||
|
||
fixZoneCommentService.update(club.getId(), commentId, request); | ||
} | ||
|
||
@GetMapping | ||
public List<AdminFixResponse> getAllFixForAdmin() { | ||
return fixZoneService.getAllForAdmin(); | ||
} | ||
@Override | ||
public void deleteFixZoneComment( | ||
PrincipalDetails principalDetails, | ||
Long fixZoneId, | ||
Long commentId | ||
) { | ||
Club club = clubService.getByClubId(principalDetails.getUser().getId()); | ||
|
||
@GetMapping("/{fixId}") | ||
public AdminDetailFixResponse getFixForAdmin(@PathVariable Long fixId) { | ||
return fixZoneService.getForAdmin(fixId); | ||
} | ||
fixZoneCommentService.delete(commentId); | ||
} | ||
|
||
@PatchMapping("/{fixId}") | ||
public void updateFix(@PathVariable Long fixId, @RequestBody UpdateFiXCompletionRequest request) { | ||
fixZoneService.updateIsCompleted(fixId, request); | ||
} | ||
} |
Oops, something went wrong.