Skip to content

Commit

Permalink
Merge pull request #120 from work-at/feature/get-cs-type-list
Browse files Browse the repository at this point in the history
feat: cs type 리스트 조회
  • Loading branch information
sypark9646 authored Aug 21, 2022
2 parents a2533b6 + 6adec5a commit 1d91a29
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import javax.validation.Valid;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.workat.api.report.dto.request.ReportRequest;
import com.workat.api.report.dto.response.CSTypeListResponse;
import com.workat.api.report.service.ReportService;
import com.workat.common.annotation.UserValidation;
import com.workat.domain.user.entity.Users;
Expand All @@ -21,6 +23,12 @@ public class ReportController {

private final ReportService reportService;

@GetMapping("/api/v1/reports/types")
public ResponseEntity<CSTypeListResponse> getReportTypes() {
CSTypeListResponse response = reportService.getReportTypes();
return ResponseEntity.ok(response);
}

@PostMapping("/api/v1/reports")
public ResponseEntity<?> addReport(@UserValidation Users user, @Valid @RequestBody ReportRequest request) {
reportService.addReport(user, request);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.workat.api.report.dto.response;

import java.util.List;

import com.workat.domain.report.CSType;
import io.swagger.annotations.ApiModelProperty;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class CSTypeListResponse {

@ApiModelProperty(name = "response", notes = "cs 타입")
private List<CSType> CSTypes;

private CSTypeListResponse(List<CSType> CSTypes) {
this.CSTypes = CSTypes;
}

public static CSTypeListResponse of(List<CSType> CSTypes) {
return new CSTypeListResponse(CSTypes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.springframework.stereotype.Service;

import com.workat.api.report.dto.request.ReportRequest;
import com.workat.api.report.dto.response.CSTypeListResponse;
import com.workat.domain.report.CSType;
import com.workat.domain.report.entity.Report;
import com.workat.domain.report.repository.ReportRepository;
import com.workat.domain.user.entity.Users;
Expand All @@ -16,6 +18,10 @@ public class ReportService {

private final ReportRepository reportRepository;

public CSTypeListResponse getReportTypes() {
return CSTypeListResponse.of(CSType.ALL);
}

public void addReport(Users user, ReportRequest request) {
Report report = Report.of(user, request.getEmail(), request.getType(), request.getContent());
reportRepository.save(report);
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/workat/domain/report/CSType.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package com.workat.domain.report;

import java.util.Arrays;
import java.util.List;

public enum CSType {

INQUERY, SERVICE_OFFER, ERROR_REPORT, OTHERS;

public static List<CSType> ALL = Arrays.asList(CSType.values());

public static CSType of(String csType) {
for (CSType csName : CSType.values()) {
if (csName.name().equals(csType)) {
Expand Down

0 comments on commit 1d91a29

Please sign in to comment.