Skip to content

Commit

Permalink
Merge pull request #71 from Kernel360/feature/admin-project#63
Browse files Browse the repository at this point in the history
Feature/admin project#63
  • Loading branch information
taekminKwon authored Jan 10, 2025
2 parents f44d677 + 1cd434f commit 90dc5c4
Show file tree
Hide file tree
Showing 36 changed files with 521 additions and 114 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.seveneleven.devlens.domain.admin.common;

import com.seveneleven.devlens.domain.admin.db.CompanyRepository;
import com.seveneleven.devlens.domain.admin.exception.CompanyDuplicatedException;
import com.seveneleven.devlens.domain.admin.exception.CompanyNotFoundException;
import com.seveneleven.devlens.domain.admin.repository.CompanyRepository;
import com.seveneleven.devlens.domain.member.constant.YN;
import com.seveneleven.devlens.domain.member.entity.Company;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.seveneleven.devlens.domain.admin.common;

import com.seveneleven.devlens.domain.admin.db.AdminProjectRepository;
import com.seveneleven.devlens.domain.admin.exception.ProjectNameDuplicatedException;
import com.seveneleven.devlens.domain.admin.repository.AdminProjectRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.seveneleven.devlens.domain.admin.controller;

import com.seveneleven.devlens.domain.admin.dto.GetProject;
import com.seveneleven.devlens.domain.admin.dto.PaginatedResponse;
import com.seveneleven.devlens.domain.admin.dto.PostProject;
import com.seveneleven.devlens.domain.admin.dto.ReadProjectHistory;
import com.seveneleven.devlens.domain.admin.dto.*;
import com.seveneleven.devlens.domain.admin.service.ProjectCreateService;
import com.seveneleven.devlens.domain.admin.service.ProjectHistoryService;
import com.seveneleven.devlens.domain.admin.service.ProjectReadService;
import com.seveneleven.devlens.domain.admin.service.ProjectUpdateService;
import com.seveneleven.devlens.global.response.APIResponse;
import com.seveneleven.devlens.global.response.SuccessCode;
import lombok.RequiredArgsConstructor;
Expand All @@ -20,12 +18,13 @@ public class AdminProjectController {
private final ProjectCreateService projectCreateService;
private final ProjectReadService projectReadService;
private final ProjectHistoryService projectHistoryService;
private final ProjectUpdateService projectUpdateService;

/*
함수명 : newProject
함수 목적 : 프로젝트 생성
*/
@PostMapping("/new")
@PostMapping("")
public ResponseEntity<APIResponse<PostProject.Response>> newProject(
@RequestBody PostProject.Request request
) {
Expand All @@ -39,7 +38,7 @@ public ResponseEntity<APIResponse<PostProject.Response>> newProject(
함수명 : readProject
함수 목적 : 프로젝트 조회
*/
@GetMapping("/list/{id}")
@GetMapping("/{id}")
public ResponseEntity<APIResponse<GetProject.Response>> readProject(
@PathVariable Long id
) {
Expand All @@ -53,7 +52,7 @@ public ResponseEntity<APIResponse<GetProject.Response>> readProject(
함수명 : getListOfProjects
함수 목적 : 프로젝트 목록 조회
*/
@GetMapping("/list")
@GetMapping("")
public ResponseEntity<APIResponse<PaginatedResponse<GetProject.Response>>> getListOfProjects(
@RequestParam(value = "page", required = true) Integer page
) {
Expand All @@ -67,7 +66,7 @@ public ResponseEntity<APIResponse<PaginatedResponse<GetProject.Response>>> getLi
함수명 : getListOfProjectHistory
함수 목적 : 프로젝트 이력 목록 조회
*/
@GetMapping("/history/list")
@GetMapping("/histories")
public ResponseEntity<APIResponse<PaginatedResponse<ReadProjectHistory.Response>>> getListOfProjectHistory(
@RequestParam(value = "page") Integer page
) {
Expand All @@ -81,12 +80,39 @@ public ResponseEntity<APIResponse<PaginatedResponse<ReadProjectHistory.Response>
함수명 : getProjectHistory
함수 목적 : 프로젝트 이력 조회
*/
@GetMapping("/history/list/{id}")
@GetMapping("/histories/{id}")
public ResponseEntity<APIResponse<ReadProjectHistory.Response>> getProjectHistory(
@PathVariable Long id
) {
return ResponseEntity
.status(SuccessCode.OK.getStatus())
.body(APIResponse.success(SuccessCode.OK, projectHistoryService.getProjectHistory(id)));
}
/*
함수명 : updateProject
함수 목적 : 프로젝트 이력 조회
*/
@PutMapping("/{id}")
public ResponseEntity<APIResponse<PutProject.Response>> updateProject(
@PathVariable Long id,
@RequestBody PutProject.Request request
){
return ResponseEntity
.status(SuccessCode.OK.getStatus())
.body(APIResponse.success(SuccessCode.OK,projectUpdateService.updateProject(id, request)));
}

/*
함수명 : deleteProject
함수 목적 : 프로젝트 삭제
*/
@DeleteMapping("/{id}")
public ResponseEntity<APIResponse<Void>> deleteProject(
@PathVariable Long id
){
projectUpdateService.deleteProject(id);
return ResponseEntity
.status(SuccessCode.DELETED.getStatus())
.body(APIResponse.success(SuccessCode.DELETED));
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.seveneleven.devlens.domain.admin.controller;

import com.seveneleven.devlens.domain.admin.dto.CompanyDto;
import com.seveneleven.devlens.domain.admin.dto.GetCompany;
import com.seveneleven.devlens.domain.admin.dto.PaginatedResponse;
import com.seveneleven.devlens.domain.admin.service.CompanyCreateService;
import com.seveneleven.devlens.domain.admin.service.CompanyReadService;
Expand All @@ -16,7 +17,7 @@
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/company")
@RequestMapping("/companies")
public class CompanyController {
private final CompanyCreateService companyCreateService;
private final CompanyReadService companyReadService;
Expand All @@ -26,7 +27,7 @@ public class CompanyController {
함수명 : createCompany
목적 : 회사 생성하여 db에 저장
*/
@PostMapping("/new")
@PostMapping("")
public ResponseEntity<APIResponse<CompanyDto.CompanyResponse>> createCompany(
@Valid @RequestBody CompanyDto.CompanyRequest companyRequest
) {
Expand All @@ -40,11 +41,12 @@ public ResponseEntity<APIResponse<CompanyDto.CompanyResponse>> createCompany(
함수명 : readCompany
목적 : 회사 상세 정보 조회
*/
@GetMapping("/list/{companyId}")
public ResponseEntity<APIResponse<CompanyDto.CompanyResponse>> readCompany(
@PathVariable Long companyId
@GetMapping("/{id}")
public ResponseEntity<APIResponse<GetCompany.Response>> readCompany(
@PathVariable Long id,
@RequestParam(value = "page", required = true) Integer page
) {
var company = companyReadService.getCompanyResponse(companyId);
var company = companyReadService.getCompanyResponse(id, page);
return ResponseEntity
.status(SuccessCode.OK.getStatus())
.body(APIResponse.success(SuccessCode.OK, company));
Expand All @@ -54,7 +56,7 @@ public ResponseEntity<APIResponse<CompanyDto.CompanyResponse>> readCompany(
함수명 : readCompanyList
목적 : 회사 목록 조회
*/
@GetMapping("/list")
@GetMapping("")
public ResponseEntity<APIResponse<PaginatedResponse<CompanyDto.CompanyResponse>>> readCompanyList(
@RequestParam(value = "page", required = true) Integer page
) {
Expand All @@ -68,7 +70,7 @@ public ResponseEntity<APIResponse<PaginatedResponse<CompanyDto.CompanyResponse>>
함수명 : updateCompany
목적 : 회사 상세 정보 수정
*/
@PutMapping("/list/{id}")
@PutMapping("/{id}")
public ResponseEntity<APIResponse<CompanyDto.CompanyResponse>> updateCompany(
@PathVariable Long id,
@RequestBody CompanyDto.CompanyRequest companyRequest
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public static class CompanyRequest {
private String address;
private BusinessType businessType;
private String businessRegistrationNumber;
private YN representativeImageExists;
private YN isActive;

public CompanyRequest(
Expand All @@ -30,7 +29,6 @@ public CompanyRequest(
String address,
BusinessType businessType,
String businessRegistrationNumber,
YN representativeImageExists,
YN activeStatus
) {
this.id = id;
Expand All @@ -41,7 +39,6 @@ public CompanyRequest(
this.address = address;
this.businessType = businessType;
this.businessRegistrationNumber = businessRegistrationNumber;
this.representativeImageExists = representativeImageExists;
this.isActive = activeStatus;
}
}
Expand All @@ -56,7 +53,6 @@ public static class CompanyResponse {
private String address;
private BusinessType businessType;
private String businessRegistrationNumber;
private YN representativeImageExists;
private YN isActive;

public CompanyResponse(
Expand All @@ -68,7 +64,6 @@ public CompanyResponse(
String address,
BusinessType businessType,
String businessRegistrationNumber,
YN representativeImageExists,
YN activeStatus
) {
this.id = id;
Expand All @@ -79,7 +74,6 @@ public CompanyResponse(
this.address = address;
this.businessType = businessType;
this.businessRegistrationNumber = businessRegistrationNumber;
this.representativeImageExists = representativeImageExists;
this.isActive = activeStatus;
}
}
Expand Down
104 changes: 104 additions & 0 deletions src/main/java/com/seveneleven/devlens/domain/admin/dto/GetCompany.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.seveneleven.devlens.domain.admin.dto;

import com.seveneleven.devlens.domain.member.constant.BusinessType;
import com.seveneleven.devlens.domain.member.constant.YN;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class GetCompany {
@Getter
public static class Request {
private Long id;
private String companyName;
private String representativeName;
private String representativeContact;
private String representativeEmail;
private String address;
private BusinessType businessType;
private String businessRegistrationNumber;
private YN representativeImageExists;
private YN isActive;

public Request(
Long id,
String companyName,
String representativeName,
String representativeContact,
String representativeEmail,
String address,
BusinessType businessType,
String businessRegistrationNumber,
YN representativeImageExists,
YN activeStatus
) {
this.id = id;
this.companyName = companyName;
this.representativeName = representativeName;
this.representativeContact = representativeContact;
this.representativeEmail = representativeEmail;
this.address = address;
this.businessType = businessType;
this.businessRegistrationNumber = businessRegistrationNumber;
this.representativeImageExists = representativeImageExists;
this.isActive = activeStatus;
}
}

@Getter
public static class Response {
private Long id;
private String companyName;
private String representativeName;
private String representativeContact;
private String representativeEmail;
private String address;
private BusinessType businessType;
private String businessRegistrationNumber;
private YN isActive;
private PaginatedResponse<GetProject.Response> projects;

public Response(
Long id,
String companyName,
String representativeName,
String representativeContact,
String representativeEmail,
String address,
BusinessType businessType,
String businessRegistrationNumber,
YN activeStatus,
PaginatedResponse<GetProject.Response> projects
) {
this.id = id;
this.companyName = companyName;
this.representativeName = representativeName;
this.representativeContact = representativeContact;
this.representativeEmail = representativeEmail;
this.address = address;
this.businessType = businessType;
this.businessRegistrationNumber = businessRegistrationNumber;
this.isActive = activeStatus;
this.projects = projects;
}

public Response addProjectList(
Response response,
PaginatedResponse<GetProject.Response> projects
) {
return new Response(
response.getId(),
response.getCompanyName(),
response.getRepresentativeName(),
response.getRepresentativeContact(),
response.getRepresentativeEmail(),
response.getAddress(),
response.getBusinessType(),
response.getBusinessRegistrationNumber(),
response.getIsActive(),
projects
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import com.seveneleven.devlens.domain.project.entity.Project;
import com.seveneleven.devlens.global.entity.YesNo;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@NoArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class GetProject {
@Getter
public static class Request {
Expand Down
Loading

0 comments on commit 90dc5c4

Please sign in to comment.