diff --git a/src/main/java/com/wooribound/api/admin/controller/AdminKnowhowController.java b/src/main/java/com/wooribound/api/admin/controller/AdminKnowhowController.java index d0fbb82..2e13755 100644 --- a/src/main/java/com/wooribound/api/admin/controller/AdminKnowhowController.java +++ b/src/main/java/com/wooribound/api/admin/controller/AdminKnowhowController.java @@ -11,7 +11,7 @@ @RequiredArgsConstructor @RestController -@RequestMapping("/admin/knowhow/") +@RequestMapping("/admin/knowhow") public class AdminKnowhowController { private final AdminKnowhowFacade adminKnowhowFacade; diff --git a/src/main/java/com/wooribound/domain/knowhow/Knowhow.java b/src/main/java/com/wooribound/domain/knowhow/Knowhow.java index 27d175a..ab39844 100644 --- a/src/main/java/com/wooribound/domain/knowhow/Knowhow.java +++ b/src/main/java/com/wooribound/domain/knowhow/Knowhow.java @@ -23,28 +23,27 @@ ) public class Knowhow { - @Id - @Column(name = "knowhow_id") - private Long knowhowId; + @Id + @Column(name = "knowhow_id") + private Long knowhowId; - @Column(name = "knowhow_job", length = 30, nullable = false) - private String knowhowJob; + @Column(name = "knowhow_job", length = 30, nullable = false) + private String knowhowJob; - @Column(name = "knowhow_title", length = 100, nullable = false) - private String knowhowTitle; + @Column(name = "knowhow_title", length = 100, nullable = false) + private String knowhowTitle; - @Lob - @Column(name = "knowhow_content", nullable = false) - private String knowhowContent; + @Column(name = "knowhow_content", length = 4000, nullable = false) + private String knowhowContent; - @Column(name = "upload_date", nullable = false) - private Date uploadDate; + @Column(name = "upload_date", nullable = false) + private Date uploadDate; - @ManyToOne - @JoinColumn(name = "user_id", nullable = false) - private WbUser wbUser; - - @OneToMany(mappedBy = "knowhow", fetch = FetchType.LAZY, cascade = CascadeType.ALL) // cascade 추가 - private List knowhowReportedList; + @ManyToOne + @JoinColumn(name = "user_id", nullable = false) + private WbUser wbUser; + + @OneToMany(mappedBy = "knowhow", fetch = FetchType.LAZY, cascade = CascadeType.ALL) // cascade 추가 + private List knowhowReportedList; } diff --git a/src/main/java/com/wooribound/domain/knowhow/KnowhowRepository.java b/src/main/java/com/wooribound/domain/knowhow/KnowhowRepository.java index a015499..1bd2508 100644 --- a/src/main/java/com/wooribound/domain/knowhow/KnowhowRepository.java +++ b/src/main/java/com/wooribound/domain/knowhow/KnowhowRepository.java @@ -53,10 +53,10 @@ List findAllWithUploadDateDesc(@Param("knowhowTitle") St @Query("SELECT k.knowhowId AS knowhowId, k.knowhowJob AS knowhowJob, " + "k.knowhowTitle AS knowhowTitle, k.uploadDate AS uploadDate, " + "k.knowhowContent AS knowhowContent, COUNT(k_report) AS reportedCnt, " + - "k.wbUser.userId AS userId FROM Knowhow k " + + "k.wbUser.userId AS userId, k.wbUser.name AS userName FROM Knowhow k " + "LEFT JOIN KnowhowReported k_report ON k_report.knowhow = k " + "WHERE k.knowhowId = :knowhowId " + - "GROUP BY k.knowhowId, k.knowhowJob, k.knowhowTitle, k.uploadDate, k.knowhowContent, k.wbUser.userId") + "GROUP BY k.knowhowId, k.knowhowJob, k.knowhowTitle, k.uploadDate, k.knowhowContent, k.wbUser.userId, k.wbUser.name") Optional findByKnowhowId(@Param("knowhowId") Long knowhowId); @Modifying diff --git a/src/main/java/com/wooribound/domain/knowhow/dto/AdminKnowhowDetailDTO.java b/src/main/java/com/wooribound/domain/knowhow/dto/AdminKnowhowDetailDTO.java index 8054613..a3585c4 100644 --- a/src/main/java/com/wooribound/domain/knowhow/dto/AdminKnowhowDetailDTO.java +++ b/src/main/java/com/wooribound/domain/knowhow/dto/AdminKnowhowDetailDTO.java @@ -12,6 +12,7 @@ public class AdminKnowhowDetailDTO { private Long knowhowId; private String userId; + private String userName; private String knowhowJob; private String knowhowTitle; private String knowhowContent; diff --git a/src/main/java/com/wooribound/domain/knowhow/dto/AdminKnowhowDetailProjection.java b/src/main/java/com/wooribound/domain/knowhow/dto/AdminKnowhowDetailProjection.java index 0319c24..7bfff0a 100644 --- a/src/main/java/com/wooribound/domain/knowhow/dto/AdminKnowhowDetailProjection.java +++ b/src/main/java/com/wooribound/domain/knowhow/dto/AdminKnowhowDetailProjection.java @@ -9,6 +9,8 @@ public interface AdminKnowhowDetailProjection { String getUserId(); + String getUserName(); + String getKnowhowTitle(); String getKnowhowContent(); diff --git a/src/main/java/com/wooribound/domain/knowhow/service/AdminKnowhowServiceImpl.java b/src/main/java/com/wooribound/domain/knowhow/service/AdminKnowhowServiceImpl.java index 8878d8c..e70dee7 100644 --- a/src/main/java/com/wooribound/domain/knowhow/service/AdminKnowhowServiceImpl.java +++ b/src/main/java/com/wooribound/domain/knowhow/service/AdminKnowhowServiceImpl.java @@ -54,6 +54,7 @@ public AdminKnowhowDetailDTO getKnowhowDetail(Long knowhowId) { return AdminKnowhowDetailDTO.builder() .knowhowId(knowhow.getKnowhowId()) .userId(knowhow.getUserId()) + .userName(knowhow.getUserName()) .knowhowJob(knowhow.getKnowhowJob()) .knowhowTitle(knowhow.getKnowhowTitle()) .knowhowContent(knowhow.getKnowhowContent())