Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/#77 admin knowhow #91

Merged
merged 6 commits into from
Nov 13, 2024
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
Loading