Skip to content

Commit

Permalink
Merge pull request #290 from CELEBIT/feature/admin-migration
Browse files Browse the repository at this point in the history
feat : admin migration
  • Loading branch information
KJBig authored Oct 6, 2024
2 parents d080837 + 2f7c691 commit 6881d10
Show file tree
Hide file tree
Showing 127 changed files with 3,569 additions and 190 deletions.
11 changes: 9 additions & 2 deletions sluv-admin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ jar.enabled = false

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'

implementation 'org.springframework.boot:spring-boot-starter-security'

//swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.3'

testImplementation 'org.springframework.security:spring-security-test'

implementation project(":sluv-domain")
implementation project(":sluv-common")
implementation project(":sluv-infra")
}

tasks.named('test') {
dependsOn ':sluv-domain:test', ':sluv-common:test'
dependsOn ':sluv-domain:test', ':sluv-common:test', ':sluv-infra:test'
}
3 changes: 3 additions & 0 deletions sluv-admin/src/main/java/com/sluv/admin/AdminApplication.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.sluv.admin;

import com.sluv.domain.config.JpaConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;

@Import(JpaConfig.class)
@SpringBootApplication
public class AdminApplication {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.sluv.admin.brand.controller;

import com.sluv.admin.brand.dto.HotBrandResDto;
import com.sluv.admin.brand.service.BrandService;
import com.sluv.admin.common.response.SuccessDataResponse;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/backoffice/item/dashBoard")
public class BrandDashBoardController {

private final BrandService brandService;

@Operation(
summary = "대시보드 - 인기 사용 브랜드 조회",
description = "대시보드에서 가장 많이 사용된 브랜드 Top 3을 조회한다."
)
@GetMapping("/hotBrand")
public ResponseEntity<SuccessDataResponse<List<HotBrandResDto>>> getHotBrand() {
List<HotBrandResDto> response = brandService.getTop3HotBrand();
return ResponseEntity.ok().body(SuccessDataResponse.create(response));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.sluv.admin.brand.dto;


import com.sluv.domain.brand.entity.Brand;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class HotBrandResDto {
private Long id;
private String name;
private String imgUrl;
@Schema(description = "해당 Brand가 사용되는 횟수")
private Long useCount;

public static HotBrandResDto of(Brand brand, Long useCount) {
return HotBrandResDto.builder()
.id(brand.getId())
.name(brand.getBrandKr() + " (" + brand.getBrandEn() + ")")
.imgUrl(brand.getBrandImgUrl())
.useCount(useCount)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.sluv.admin.brand.service;

import com.sluv.admin.brand.dto.HotBrandResDto;
import com.sluv.domain.brand.service.BrandDomainService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class BrandService {
private final BrandDomainService brandDomainService;

public List<HotBrandResDto> getTop3HotBrand() {
return brandDomainService.getTopHotBrandWithLimit(3).stream()
.map(brandCountDto -> HotBrandResDto.of(brandCountDto.getBrand(), brandCountDto.getUseCount()))
.toList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.sluv.admin.comment.controller;

import com.sluv.admin.comment.dto.CommentReportDetailResponse;
import com.sluv.admin.comment.dto.CommentReportInfoDto;
import com.sluv.admin.comment.dto.UpdateCommentReportResDto;
import com.sluv.admin.comment.service.CommentReportService;
import com.sluv.admin.common.response.ErrorResponse;
import com.sluv.admin.common.response.PaginationResponse;
import com.sluv.admin.common.response.SuccessDataResponse;
import com.sluv.domain.common.enums.ReportStatus;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
@RequestMapping("/backoffice/comment")
public class CommentController {

private final CommentReportService commentReportService;

@Operation(
summary = "댓글 신고 정보 조히",
description = "WAITING, COMPLETED, REJECTED 로 검색 조건, 없으면 전체 검색"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "1000", description = "요청성공"),
@ApiResponse(responseCode = "5000", description = "서버내부 에러", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "5001", description = "DB 에러", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@GetMapping("/report")
public ResponseEntity<SuccessDataResponse<PaginationResponse<CommentReportInfoDto>>> getAllCommentReport(Pageable pageable,
@RequestParam(required = false) ReportStatus reportStatus) {
PaginationResponse<CommentReportInfoDto> response = commentReportService.getAllCommentReport(pageable, reportStatus);
return ResponseEntity.ok().body(SuccessDataResponse.create(response));
}

@Operation(
summary = "댓글 신고 상세 정보 조히",
description = "댓글 신고 id를 통해 댓글 신고 상세 정보 조회"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "1000", description = "요청성공"),
@ApiResponse(responseCode = "5000", description = "서버내부 에러", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "5001", description = "DB 에러", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@GetMapping("/report/{commentReportId}")
public ResponseEntity<SuccessDataResponse<CommentReportDetailResponse>> getCommentReportDetail(@PathVariable Long commentReportId) {
CommentReportDetailResponse response = commentReportService.getCommentReportDetail(commentReportId);
return ResponseEntity.ok().body(SuccessDataResponse.create(response));
}

@Operation(
summary = "댓글 신고 처리",
description = "댓글 신고 id와 reportStatus(COMPLETED, REJECTED)를 통해 댓글 신고 처리"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "1000", description = "요청성공"),
@ApiResponse(responseCode = "5000", description = "서버내부 에러", content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = "5001", description = "DB 에러", content = @Content(schema = @Schema(implementation = ErrorResponse.class)))
})
@PostMapping("/report/{commentReportId}")
public ResponseEntity<SuccessDataResponse<UpdateCommentReportResDto>> changeCommentReportStatus(@PathVariable Long commentReportId,
@RequestParam ReportStatus reportStatus) {
UpdateCommentReportResDto response = commentReportService.updateCommentReportStatus(commentReportId, reportStatus);
return ResponseEntity.ok().body(SuccessDataResponse.create(response));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.sluv.admin.comment.controller;

import com.sluv.admin.comment.dto.CommentBlockCountResponse;
import com.sluv.admin.comment.service.CommentService;
import com.sluv.admin.common.response.SuccessDataResponse;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequiredArgsConstructor
@RequestMapping("/backoffice/comment/dashBoard")
public class CommentDashBoardController {

private final CommentService commentService;

@Operation(
summary = "대시보드 - Block된 댓글 통계 조회",
description = "대시보드에서 Block된 댓글 통계를 조회한다."
)
@GetMapping("/blockCount")
public ResponseEntity<SuccessDataResponse<CommentBlockCountResponse>> getCommentBlockCount() {
CommentBlockCountResponse response = commentService.getCommentBlockCount();
return ResponseEntity.ok().body(SuccessDataResponse.create(response));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.sluv.admin.comment.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class CommentBlockCountResponse {
@Schema(description = "오늘 기준으로 한달전 대비 증가 비율")
private Double percent;
@Schema(description = "총 Block 댓글 수")
private Long totalCount;
@Schema(description = "이번주 기준으로 10주간 가입자 수 그래프")
private List<Long> countGraph;

public static CommentBlockCountResponse of(Long totalCount, Long recentMonthCount, List<Long> countGraph) {
return CommentBlockCountResponse.builder()
.percent(getPercent(recentMonthCount, totalCount))
.totalCount(totalCount)
.countGraph(countGraph)
.build();
}

private static Double getPercent(Long recentCount, Long totalCount) {
if (totalCount == 0) {
return 0.0;
}
// 계산 후 소숫점 2자리까지 반올림1
return BigDecimal.valueOf((double) recentCount / totalCount * 100)
.setScale(2, RoundingMode.HALF_UP)
.doubleValue();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.sluv.admin.comment.dto;

import com.sluv.domain.comment.entity.Comment;
import com.sluv.domain.comment.entity.CommentReport;
import com.sluv.domain.comment.enums.CommentReportReason;
import com.sluv.domain.common.enums.ReportStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CommentReportDetailResponse {

private Long reporterId;
private String reporterNickname;
private Long reportedId;
private String reportedNickname;
private Long reportId;
private CommentReportReason reportReason;
@Schema(description = "신고 상세 내용")
private String content;
@Schema(description = "신고 접수 상태")
private ReportStatus reportStatus;
@Schema(description = "신고 당한 원본 댓글 내용")
private String reportedCommentContent;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;

public static CommentReportDetailResponse of(CommentReport commentReport, Comment comment) {
return CommentReportDetailResponse.builder()
.reporterId(commentReport.getReporter().getId())
.reporterNickname(commentReport.getReporter().getNickname())
.reportedId(comment.getUser().getId())
.reportedNickname(comment.getUser().getNickname())
.reportReason(commentReport.getCommentReportReason())
.content(commentReport.getContent())
.reportStatus(commentReport.getReportStatus())
.reportedCommentContent(comment.getContent())
.createdAt(commentReport.getCreatedAt())
.updatedAt(commentReport.getUpdatedAt())
.build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.sluv.admin.comment.dto;

import com.sluv.domain.comment.entity.Comment;
import com.sluv.domain.comment.entity.CommentReport;
import com.sluv.domain.comment.enums.CommentReportReason;
import com.sluv.domain.common.enums.ReportStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CommentReportInfoDto {

private Long reporterId;
private String reporterNickname;
private Long reportedId;
private String reportedNickname;
private Long reportId;
@Schema(description = "댓글 신고 이유(enums)")
private CommentReportReason reportReason;
@Schema(description = "신고 상세 내용")
private String content;
@Schema(description = "신고 접수 상태")
private ReportStatus reportStatus;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;

public static CommentReportInfoDto of(CommentReport commentReport, Comment comment) {
return CommentReportInfoDto.builder()
.reporterId(commentReport.getReporter().getId())
.reporterNickname(commentReport.getReporter().getNickname())
.reportedId(comment.getUser().getId())
.reportedNickname(comment.getUser().getNickname())
.reportId(commentReport.getId())
.reportReason(commentReport.getCommentReportReason())
.content(commentReport.getContent())
.reportStatus(commentReport.getReportStatus())
.createdAt(commentReport.getCreatedAt())
.updatedAt(commentReport.getUpdatedAt())
.build();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.sluv.admin.comment.dto;

import com.sluv.domain.common.enums.ReportStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class UpdateCommentReportResDto {

private ReportStatus reportStatus;

public static UpdateCommentReportResDto of(ReportStatus reportStatus) {
return new UpdateCommentReportResDto(
reportStatus
);
}
}
Loading

0 comments on commit 6881d10

Please sign in to comment.