Skip to content

Commit

Permalink
Merge pull request #91 from WooRibound/fix/#77-admin-knowhow
Browse files Browse the repository at this point in the history
Fix/#77 admin knowhow
  • Loading branch information
haewoni authored Nov 13, 2024
2 parents af95202 + 7d70a85 commit ba98e3e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/knowhow/")
@RequestMapping("/admin/knowhow")
public class AdminKnowhowController {
private final AdminKnowhowFacade adminKnowhowFacade;

Expand Down
35 changes: 17 additions & 18 deletions src/main/java/com/wooribound/domain/knowhow/Knowhow.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<KnowhowReported> knowhowReportedList;
@ManyToOne
@JoinColumn(name = "user_id", nullable = false)
private WbUser wbUser;

@OneToMany(mappedBy = "knowhow", fetch = FetchType.LAZY, cascade = CascadeType.ALL) // cascade 추가
private List<KnowhowReported> knowhowReportedList;

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ List<AdminKnowhowProjection> 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<AdminKnowhowDetailProjection> findByKnowhowId(@Param("knowhowId") Long knowhowId);

@Modifying
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public interface AdminKnowhowDetailProjection {

String getUserId();

String getUserName();

String getKnowhowTitle();

String getKnowhowContent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit ba98e3e

Please sign in to comment.