Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,6 @@ public ResponseEntity<ProjectPagingResponseDTO> getProjectsByAccountId(
return ResponseEntity.ok(projects);
}

@Operation(summary = "Pagination으로 업무 범위별 프로젝트 의뢰 목록 조회", description = "Pagination으로 특정 업무 범위에 대한 모든 프로젝트 의뢰를 조회합니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "프로젝트 의뢰 목록이 성공적으로 조회됨")
})
@GetMapping("/work-scope")
public ResponseEntity<ProjectPagingResponseDTO> getProjectsByWorkScope(
@RequestParam int page,
@RequestParam String workScope) {

ProjectPagingResponseDTO projects = projectService.findProjectsByWorkScopeWithPaging(page, workScope);
return ResponseEntity.ok(projects);
}

@Operation(summary = "Pagination으로 근무 형태별 프로젝트 의뢰 목록 조회", description = "Pagination으로 근무 형태 범위에 대한 모든 프로젝트 의뢰를 조회합니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "프로젝트 의뢰 목록이 성공적으로 조회됨")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mtvs.devlinkbackend.project.controller;

import com.mtvs.devlinkbackend.project.dto.response.ProjectDetailResponseDTO;
import com.mtvs.devlinkbackend.project.dto.response.ProjectSummaryPagingResponseDTO;
import com.mtvs.devlinkbackend.project.dto.response.ProjectSummaryResponseDTO;
import com.mtvs.devlinkbackend.project.service.ProjectDetailService;
import io.swagger.v3.oas.annotations.Operation;
Expand Down Expand Up @@ -29,6 +30,28 @@ public ResponseEntity<ProjectSummaryResponseDTO> findAllSummary() {
return summary != null ? ResponseEntity.ok(summary) : ResponseEntity.notFound().build();
}

@Operation(summary = "Pagination으로 전체 프로젝트 요약 조회", description = "Pagination으로 전체 프로젝트 요약을 조회합니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "성공적으로 조회됨"),
@ApiResponse(responseCode = "404", description = "찾을 수 없음")
})
@GetMapping("/summary/pagination")
public ResponseEntity<ProjectSummaryPagingResponseDTO> findAllSummary(@RequestParam int page) {
ProjectSummaryPagingResponseDTO summary = projectDetailService.findAllProjectSummaryWithPagination(page);
return summary != null ? ResponseEntity.ok(summary) : ResponseEntity.notFound().build();
}

@Operation(summary = "Pagination으로 전체 프로젝트 요약 조회", description = "Pagination으로 전체 프로젝트 요약을 조회합니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "성공적으로 조회됨"),
@ApiResponse(responseCode = "404", description = "찾을 수 없음")
})
@GetMapping("/summary/home")
public ResponseEntity<ProjectSummaryPagingResponseDTO> findAllSummaryInHome() {
ProjectSummaryPagingResponseDTO summary = projectDetailService.findAllProjectPreviewInHome();
return summary != null ? ResponseEntity.ok(summary) : ResponseEntity.notFound().build();
}

@Operation(summary = "전체 프로젝트 세부 내용 조회", description = "전체 프로젝트 세부 내용을 조회합니다.")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "성공적으로 조회됨"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
@NoArgsConstructor
@ToString
public class ProjectRegistRequestDTO {
private String workScope;
private String workType;
private String progressClassification;
private String companyName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
@ToString
public class ProjectUpdateRequestDTO {
private Long projectId;
private String workScope;
private String workType;
private String progressClassification;
private String companyName;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.mtvs.devlinkbackend.project.dto.response;

import lombok.*;

import java.time.LocalDate;
import java.util.List;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class ProjectPreviewDTO {
private Long projectId;
private String workType;
private String progressClassification;
private String previewTitle;
private List<String> requiredWorkers;
private LocalDate deadlineDate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.mtvs.devlinkbackend.project.dto.response;

import com.mtvs.devlinkbackend.project.repository.projection.ProjectSummary;
import lombok.*;

import java.util.List;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class ProjectSummaryPagingResponseDTO {
private List<ProjectPreviewDTO> data;
private Integer totalPages;
private Long totalProjectCnt;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public class Project {
@Column(name = "PROJECT_ID")
private Long projectId;

@Column(name = "WORK_SCOPE")
private String workScope;

@Column(name = "WORK_TYPE")
private String workType;

Expand All @@ -41,7 +38,7 @@ public class Project {
@Column(name = "TITLE", nullable = false)
private String title;

@Column(name = "CONTENT", nullable = false)
@Column(name = "CONTENT", nullable = false, columnDefinition = "TEXT")
private String content;

@Column(name = "REQUIRED_CLIENT")
Expand Down Expand Up @@ -97,8 +94,7 @@ public Project(String title, String content, LocalDate startDateTime, LocalDate
this.accountId = accountId;
}

public Project(String workScope, String workType, String progressClassification, String companyName, String title, String content, Integer requiredClient, Integer requiredServer, Integer requiredDesign, Integer requiredPlanner, Integer requiredAIEngineer, LocalDate startDateTime, LocalDate endDateTime, Integer estimatedCost, String accountId) {
this.workScope = workScope;
public Project(String workType, String progressClassification, String companyName, String title, String content, Integer requiredClient, Integer requiredServer, Integer requiredDesign, Integer requiredPlanner, Integer requiredAIEngineer, LocalDate startDateTime, LocalDate endDateTime, Integer estimatedCost, String accountId) {
this.workType = workType;
this.progressClassification = progressClassification;
this.companyName = companyName;
Expand All @@ -115,10 +111,6 @@ public Project(String workScope, String workType, String progressClassification,
this.accountId = accountId;
}

public void setWorkScope(String workScope) {
this.workScope = workScope;
}

public void setWorkType(String workType) {
this.workType = workType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public interface ProjectRepository extends JpaRepository<Project, Long> {
// AccountId로 프로젝트 조회 (페이징 추가)
Page<Project> findProjectsByAccountId(String accountId, Pageable pageable);

// WorkScope로 프로젝트 조회 (페이징 추가)
Page<Project> findProjectsByWorkScope(String workScope, Pageable pageable);

// WorkType으로 프로젝트 조회 (페이징 추가)
Page<Project> findProjectsByWorkType(String workType, Pageable pageable);

Expand Down Expand Up @@ -53,5 +50,7 @@ Page<Project> findProjectsWithLargerRequirements(

List<ProjectSummary> findAllBy();

Page<ProjectSummary> findAllBy(Pageable pageable);

ProjectIdAndContent findProjectIdAndContentByProjectId(Long projectId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

public interface ProjectSummary {
Long getProjectId();
String getWorkScope();
String getWorkType();
String getProgressClassification();
String getCompanyName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,27 @@

import com.mtvs.devlinkbackend.comment.entity.Comment;
import com.mtvs.devlinkbackend.comment.repository.CommentRepository;
import com.mtvs.devlinkbackend.project.dto.response.ProjectDetailResponseDTO;
import com.mtvs.devlinkbackend.project.dto.response.ProjectSummaryResponseDTO;
import com.mtvs.devlinkbackend.project.dto.response.*;
import com.mtvs.devlinkbackend.project.repository.projection.ProjectIdAndContent;
import com.mtvs.devlinkbackend.project.repository.projection.ProjectSummary;
import com.mtvs.devlinkbackend.project.repository.ProjectRepository;
import com.mtvs.devlinkbackend.support.repository.SupportRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;

@Service
public class ProjectDetailService {

private static final int pageSize = 15;

private final ProjectRepository projectRepository;
private final CommentRepository commentRepository;
private final SupportRepository supportRepository;
Expand All @@ -29,6 +38,125 @@ public ProjectSummaryResponseDTO findAllProjectSummary() {
return new ProjectSummaryResponseDTO(projectSummaryList);
}

public ProjectSummaryPagingResponseDTO findAllProjectSummaryWithPagination(int page) {
Pageable pageable = PageRequest.of(page, pageSize, Sort.by("createdAt").descending());
Page<ProjectSummary> projectSummaryPage = projectRepository.findAllBy(pageable);
List<ProjectPreviewDTO> projectPreviewDTOList = new ArrayList<>();

for (ProjectSummary summary : projectSummaryPage.getContent()) {
ProjectPreviewDTO previewDTO = new ProjectPreviewDTO();

// workType 설정
previewDTO.setWorkType(summary.getWorkType());
previewDTO.setProgressClassification(summary.getProgressClassification());

// previewTitle 생성: workType + (StartDateTime과 EndDateTime의 월 차이) + title
long monthsDifference = ChronoUnit.MONTHS.between(summary.getStartDateTime(), summary.getEndDateTime());
String previewTitle = "["+summary.getWorkType() + "] [" + monthsDifference + "개월";

// requiredWorkers 설정
List<String> requiredWorkers = new ArrayList<>();
if (summary.getRequiredClient() != null && summary.getRequiredClient() > 0) {
requiredWorkers.add("클라이언트");
previewTitle = previewTitle + "/클라이언트(" + summary.getRequiredClient() + ")";
}
if (summary.getRequiredServer() != null && summary.getRequiredServer() > 0) {
requiredWorkers.add("서버");
previewTitle = previewTitle + "/서버(" + summary.getRequiredServer() + ")";
}
if (summary.getRequiredDesign() != null && summary.getRequiredDesign() > 0) {
requiredWorkers.add("디자인");
previewTitle = previewTitle + "/디자인(" + summary.getRequiredDesign() + ")";
}
if (summary.getRequiredPlanner() != null && summary.getRequiredPlanner() > 0) {
requiredWorkers.add("기획");
previewTitle = previewTitle + "/기획(" + summary.getRequiredPlanner() + ")";
}
if (summary.getRequiredAIEngineer() != null && summary.getRequiredAIEngineer() > 0) {
requiredWorkers.add("AI");
previewTitle = previewTitle + "/AI(" + summary.getRequiredAIEngineer() + ")";
}
previewTitle = previewTitle + "] " + summary.getTitle();

previewDTO.setPreviewTitle(previewTitle);

previewDTO.setRequiredWorkers(requiredWorkers);

// deadlineDate 설정: createdAt에서 30일을 더한 날짜
LocalDate deadlineDate = summary.getCreatedAt().toLocalDate().plusDays(30);
previewDTO.setDeadlineDate(deadlineDate);

// ProjectPreviewDTO 리스트에 추가
projectPreviewDTOList.add(previewDTO);
}

return new ProjectSummaryPagingResponseDTO(projectPreviewDTOList, projectSummaryPage.getTotalPages(), projectRepository.count());
}

public ProjectSummaryPagingResponseDTO findAllProjectPreviewInHome() {
Pageable pageable = PageRequest.of(0, 5, Sort.by("createdAt").descending());
Page<ProjectSummary> projectSummaryPage = projectRepository.findAllBy(pageable);
List<ProjectPreviewDTO> projectPreviewDTOList = new ArrayList<>();

for (ProjectSummary summary : projectSummaryPage.getContent()) {
ProjectPreviewDTO previewDTO = new ProjectPreviewDTO();

previewDTO.setProjectId(summary.getProjectId());

// workType 설정
previewDTO.setWorkType(summary.getWorkType());
previewDTO.setProgressClassification(summary.getProgressClassification());

// previewTitle 생성: workType + (StartDateTime과 EndDateTime의 월 차이) + title
long monthsDifference = ChronoUnit.MONTHS.between(summary.getStartDateTime(), summary.getEndDateTime());
String previewTitle = "[";
if(summary.getWorkType().equals("both"))
previewTitle += "상주, 원격";
else if (summary.getWorkType().equals("local"))
previewTitle += "상주";
else if (summary.getWorkType().equals("remote"))
previewTitle += "원격";
previewTitle = previewTitle + "] [" + monthsDifference + "개월";

// requiredWorkers 설정
List<String> requiredWorkers = new ArrayList<>();
if (summary.getRequiredClient() != null && summary.getRequiredClient() > 0) {
requiredWorkers.add("클라이언트");
previewTitle = previewTitle + "/클라이언트(" + summary.getRequiredClient() + ")";
}
if (summary.getRequiredServer() != null && summary.getRequiredServer() > 0) {
requiredWorkers.add("서버");
previewTitle = previewTitle + "/서버(" + summary.getRequiredServer() + ")";
}
if (summary.getRequiredDesign() != null && summary.getRequiredDesign() > 0) {
requiredWorkers.add("디자인");
previewTitle = previewTitle + "/디자인(" + summary.getRequiredDesign() + ")";
}
if (summary.getRequiredPlanner() != null && summary.getRequiredPlanner() > 0) {
requiredWorkers.add("기획");
previewTitle = previewTitle + "/기획(" + summary.getRequiredPlanner() + ")";
}
if (summary.getRequiredAIEngineer() != null && summary.getRequiredAIEngineer() > 0) {
requiredWorkers.add("AI");
previewTitle = previewTitle + "/AI(" + summary.getRequiredAIEngineer() + ")";
}
previewTitle = previewTitle + "] " + summary.getTitle();

previewDTO.setPreviewTitle(previewTitle);

previewDTO.setRequiredWorkers(requiredWorkers);

// deadlineDate 설정: createdAt에서 30일을 더한 날짜
LocalDate deadlineDate = summary.getCreatedAt().toLocalDate().plusDays(30);
previewDTO.setDeadlineDate(deadlineDate);

// ProjectPreviewDTO 리스트에 추가
projectPreviewDTOList.add(previewDTO);
}

return new ProjectSummaryPagingResponseDTO(projectPreviewDTOList, projectSummaryPage.getTotalPages(), projectRepository.count());
}

public ProjectDetailResponseDTO findProjectDetailByProjectId(Long projectId) {
ProjectIdAndContent projectIdAndContents = projectRepository.findProjectIdAndContentByProjectId(projectId);
List<Comment> commentList = commentRepository.findCommentIdsByProjectId(projectId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public ProjectService(ProjectRepository projectRepository) {
@Transactional
public ProjectSingleResponseDTO registProject(ProjectRegistRequestDTO projectRegistRequestDTO, String accountId) {
return new ProjectSingleResponseDTO(projectRepository.save(new Project(
projectRegistRequestDTO.getWorkScope(),
projectRegistRequestDTO.getWorkType(),
projectRegistRequestDTO.getProgressClassification(),
projectRegistRequestDTO.getCompanyName(),
Expand Down Expand Up @@ -61,12 +60,6 @@ public ProjectPagingResponseDTO findProjectsByAccountIdWithPaging(int page, Stri
return new ProjectPagingResponseDTO(projectPage.getContent(), projectPage.getTotalPages());
}

public ProjectPagingResponseDTO findProjectsByWorkScopeWithPaging(int page, String workScope) {
Pageable pageable = PageRequest.of(page, pageSize, Sort.by("createdAt").descending());
Page<Project> projectPage = projectRepository.findProjectsByWorkScope(workScope, pageable);
return new ProjectPagingResponseDTO(projectPage.getContent(), projectPage.getTotalPages());
}

public ProjectPagingResponseDTO findProjectsByWorkTypeWithPaging(int page, String workType) {
Pageable pageable = PageRequest.of(page, pageSize, Sort.by("createdAt").descending());
Page<Project> projectPage = projectRepository.findProjectsByWorkType(workType, pageable);
Expand Down Expand Up @@ -116,7 +109,6 @@ public ProjectSingleResponseDTO updateProject(ProjectUpdateRequestDTO projectUpd
if (request.isPresent()) {
Project foundProject = request.get();
if(foundProject.getAccountId().equals(accountId)) {
foundProject.setWorkScope(projectUpdateRequestDTO.getWorkScope());
foundProject.setWorkType(projectUpdateRequestDTO.getWorkType());
foundProject.setProgressClassification(projectUpdateRequestDTO.getProgressClassification());
foundProject.setTitle(projectUpdateRequestDTO.getTitle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ public TeamController(TeamService teamService, JwtUtil jwtUtil) {
})
@PostMapping
public ResponseEntity<TeamSingleReponseDTO> registTeam(
@RequestBody TeamRegistRequestDTO teamRegistRequestDTO, @RequestParam String accountId) {
@RequestBody TeamRegistRequestDTO teamRegistRequestDTO, @RequestHeader(name = "Authorization") String authorizationHeader) throws Exception {

String accountId = jwtUtil.getSubjectFromAuthHeaderWithoutAuth(authorizationHeader);
TeamSingleReponseDTO team = teamService.registTeam(teamRegistRequestDTO, accountId);
return new ResponseEntity<>(team, HttpStatus.CREATED);
}
Expand Down Expand Up @@ -104,7 +105,9 @@ public ResponseEntity<TeamListResponseDTO> getTeamsByMemberIdContaining(
@PatchMapping
public ResponseEntity<TeamSingleReponseDTO> updateTeam(
@RequestBody TeamUpdateRequestDTO teamUpdateRequestDTO,
@RequestParam String accountId) {
@RequestHeader(name = "Authorization") String authorizationHeader) throws Exception {

String accountId = jwtUtil.getSubjectFromAuthHeaderWithoutAuth(authorizationHeader);

try {
TeamSingleReponseDTO updatedTeam = teamService.updateTeam(teamUpdateRequestDTO, accountId);
Expand All @@ -126,6 +129,7 @@ public TeamSingleReponseDTO addMemberToTeam(
@RequestHeader(name = "Authorization") String authorizationHeader) throws Exception {

String accountId = jwtUtil.getSubjectFromAuthHeaderWithoutAuth(authorizationHeader);
System.out.println(teamMemberModifyRequestDTO);
return teamService.addMemberToTeam(teamMemberModifyRequestDTO, accountId);
}

Expand Down