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

Fe/#98 chatGPT 퍼블리싱 및 반응형 #121

Merged
merged 40 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d442531
feat: 고도화 버튼
mineii May 8, 2023
5118856
design: gpt아이콘 변경
mineii May 8, 2023
93f76df
feat: 모달창
mineii May 11, 2023
59b2d0e
feat: 아이콘 추가
mineii May 11, 2023
fab4029
feat: stepper
mineii May 11, 2023
36dbe2e
design: 모달창 위치
mineii May 11, 2023
23e3e17
feat: 기술 선택
mineii May 11, 2023
53c3c23
feat: 모달창 전체
mineii May 11, 2023
93d5d40
feat: 화면별 코드
mineii May 12, 2023
8a15fa6
feat: 모달창 내 화면 전환
mineii May 12, 2023
4d19fb1
design: 디자인 세부 수정
mineii May 12, 2023
bbff1db
design: 모달창 크기 조정
mineii May 12, 2023
fb65088
design: stepper
mineii May 12, 2023
5637097
feat: 재사용 컴포넌트
mineii May 17, 2023
03b3afd
feat: input창 글자수 제한
mineii May 18, 2023
fac8405
design: 위치 세부 수정
mineii May 22, 2023
fcb1ae9
design: 버튼 효과
mineii May 22, 2023
e7c3832
design: 반응형
mineii May 22, 2023
cec655d
Merge branch 'feature' into FE/#98
mineii May 22, 2023
4f2595a
Merge branch 'FE/#116' into FE/#98
mineii May 22, 2023
e070f24
feat: 모든 창 반응형
mineii May 25, 2023
cf9dc85
design: 반응형 수정
mineii May 25, 2023
59ca416
design: 모달창 위치 수정
mineii May 25, 2023
6e4df1b
Merge branch 'feature' into FE/#98
Mayreeel May 25, 2023
720d50d
docs: 주석 해제
mineii Jun 3, 2023
9d3d042
fix:CI 오류 해결
youKeon Jun 12, 2023
d26a571
fix:CI 수정
youKeon Jun 12, 2023
b635544
fix:ci수정
youKeon Jun 12, 2023
6b97ded
fix:ci수정
youKeon Jun 12, 2023
098a818
fix:CI수정
youKeon Jun 12, 2023
c33c5e9
fix:환경변수 설정
youKeon Jun 12, 2023
c9942a2
fix:환경변수 설정
youKeon Jun 12, 2023
51ed9cb
fix:CI 수정
youKeon Jun 12, 2023
9943474
fix:ci수정
youKeon Jun 12, 2023
67e4976
fix:CI.yml 수정
youKeon Jun 12, 2023
e5b61c4
fix:CI.yml 수정
youKeon Jun 12, 2023
8228cb1
fix:CI.yml 수정
youKeon Jun 12, 2023
16cb9ec
fix : eslint error 해결
Mayreeel Jun 15, 2023
49ab82c
fix : readingPage eslint error 해결
Mayreeel Jun 15, 2023
97546a6
Merge remote-tracking branch 'origin/BE/#131' into FE/#98
Mayreeel Jun 15, 2023
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
7 changes: 7 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ jobs:
- name: Grant Execute Permission For Gradlew
run: chmod +x backend/gradlew

- name: Make properties
run: |
cd backend/src/main/resources
touch ./application-local.yml
echo "${{ secrets.TEST_PROPERTIES }}" > ./application-local.yml
shell: bash

- name: Test with Gradle
run: |
cd backend
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
.DS_Store
.env
backend/src/test/resources/application-test.yml
backend/src/main/resources/application-local.yml
backend/src/main/resources/application-docker.yml
backend/src/main/resources/application-dbconfig.yml
backend/gradle.properties
Expand All @@ -14,3 +12,6 @@ logs/
*.log

logs/

backend/src/main/resources/application-local.yml

6 changes: 4 additions & 2 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ dependencies {

// test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'com.h2database:h2'

//rest-docs
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
Expand Down Expand Up @@ -133,11 +134,12 @@ jacocoTestReport {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"**/Q*",
"**/*Dto*",
'**/dto/**',
"**/*Application*",
"**/mapper/**",
"**/util/**",
"**/global/**",
"**/com/graphy/backend/domain/job/domain/**",
"**/com/graphy/backend/domain/job/service/**"
])
}))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class Job {
@Column(nullable = false)
private LocalDateTime expirationDate;

@Builder
public Job(Long id,
String companyName,
String title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.graphy.backend.domain.job.domain.Job;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

Expand All @@ -20,12 +21,14 @@ public static class CreateJobInfoRequest {

private LocalDateTime expirationDate;

public static Job toJob(Long id,
String companyName,
String title,
String url,
LocalDateTime expirationDate) {
return new Job(id, companyName, title, url, expirationDate);
public Job toEntity() {
return Job.builder()
.id(id)
.companyName(companyName)
.title(title)
.url(url)
.expirationDate(expirationDate)
.build();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.graphy.backend.domain.job.service;

import com.graphy.backend.domain.job.domain.Job;
import com.graphy.backend.domain.job.dto.JobDto;
import com.graphy.backend.domain.job.repository.JobRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -18,7 +19,6 @@
import java.time.LocalDateTime;
import java.time.ZoneId;

import static com.graphy.backend.domain.job.dto.JobDto.CreateJobInfoRequest.*;

@Service
@Transactional
Expand Down Expand Up @@ -59,6 +59,7 @@ public void save() {
}

saveJobInfo(response.toString());
System.out.println(response);
}

private void saveJobInfo(String response) {
Expand All @@ -72,7 +73,6 @@ private void saveJobInfo(String response) {

// 공고 ID
Long jobId = jobObject.getLong("id");
// if (jobRepository.findById(jobId) != null) break;

// 회사 이름
String companyName = jobObject.getJSONObject("company")
Expand All @@ -94,8 +94,8 @@ private void saveJobInfo(String response) {
Instant.ofEpochSecond(expirationTimestampLong),
ZoneId.systemDefault());

Job job = toJob(jobId, companyName, jobTitle, companyInfoURL, expirationTimestamp);
jobRepository.save(job);
JobDto.CreateJobInfoRequest dto = new JobDto.CreateJobInfoRequest(jobId, companyName, jobTitle, companyInfoURL, expirationTimestamp);
jobRepository.save(dto.toEntity());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ public class ProjectService {

private final GPTChatRestService gptChatRestService;

@PostConstruct
public void initTag() throws IOException {
if (tagRepository.existsById(1L))
return;
ClassPathResource resource = new ClassPathResource("tag.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()));
String s;

while ((s = br.readLine()) != null) {
Tag tag = Tag.builder().tech(s).build();
tagRepository.save(tag);
}
br.close();
}
// @PostConstruct
// public void initTag() throws IOException {
// if (tagRepository.existsById(1L))
// return;
// ClassPathResource resource = new ClassPathResource("tag.txt");
// BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream()));
// String s;
//
// while ((s = br.readLine()) != null) {
// Tag tag = Tag.builder().tech(s).build();
// tagRepository.save(tag);
// }
// br.close();
// }

public CreateProjectResponse createProject(CreateProjectRequest dto) {
Project entity = mapper.toEntity(dto);
Expand Down Expand Up @@ -96,12 +96,6 @@ public UpdateProjectResponse updateProject(Long projectId, UpdateProjectRequest
return mapper.toUpdateProjectDto(project);
}

public List<GetProjectResponse> getProjects(Pageable pageable) {

Page<Project> projects = projectRepository.findAll(pageable);
return mapper.toDtoList(projects).getContent();
}

public GetProjectDetailResponse getProjectById(Long projectId) {
Project project = projectRepository.findById(projectId)
.orElseThrow(() -> new EmptyResultException(ErrorCode.PROJECT_DELETED_OR_NOT_EXIST));
Expand All @@ -112,7 +106,7 @@ public GetProjectDetailResponse getProjectById(Long projectId) {
}

public Tags getTagsWithName(List<String> techStacks) {
List<Tag> foundTags = techStacks.stream().map(tagRepository::findTagByTech)
List<Tag> foundTags = techStacks.stream().map(tagRepository::findTagByTech)
.collect(Collectors.toList());
return new Tags(foundTags);
}
Expand All @@ -124,7 +118,7 @@ public List<GetProjectResponse> getProjects(GetProjectsRequest dto, Pageable pag

@Async
public CompletableFuture<String> getProjectPlanAsync(String prompt) {
GptCompletionRequest dto = new GptCompletionDto.GptCompletionRequest();
GptCompletionRequest dto = new GptCompletionRequest();
CompletableFuture<String> response = new CompletableFuture<>();

dto.setPrompt(prompt);
Expand Down
4 changes: 2 additions & 2 deletions backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ spring:
matching-strategy: ant_path_matcher
async:
request-timeout: 60000
profiles:
active: local
profiles:
active: local

jpa:
database: mysql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.time.LocalDateTime;
Expand All @@ -36,5 +38,4 @@ public void saveTest() throws Exception {

verify(jobRepository, times(1)).deleteAllExpiredSince(any(LocalDateTime.class));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.graphy.backend.domain.comment.dto.CommentWithMaskingDto;
import com.graphy.backend.domain.comment.service.CommentService;
import com.graphy.backend.domain.project.dto.ProjectDto;
import com.graphy.backend.domain.project.service.ProjectService;
import com.graphy.backend.global.common.PageRequest;
import com.graphy.backend.test.MockApiTest;
Expand All @@ -23,14 +22,21 @@
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;

import static com.graphy.backend.domain.project.dto.ProjectDto.*;
import static com.graphy.backend.domain.project.dto.ProjectDto.GetProjectDetailResponse;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.BDDMockito.given;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.*;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@WebMvcTest(ProjectController.class)
Expand Down Expand Up @@ -94,22 +100,63 @@ public LocalDateTime getCreatedAt() {
result.andExpect(status().isOk());
}

@Test
@DisplayName("프로젝트 생성 테스트")
public void createProject() throws Exception {
//given
CreateProjectRequest request = CreateProjectRequest.builder()
.projectName("projectName")
.description("description")
.content("content")
.build();

CreateProjectResponse response = CreateProjectResponse.builder().projectId(1L).build();

//when
when(projectService.createProject(request)).thenReturn(response);

//then
mvc.perform(post(baseUrl)
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(request)))
.andExpect(status().isOk())
.andDo(document("project-create",
preprocessResponse(prettyPrint()))
);
}

@Test
@DisplayName("프로젝트 삭제 테스트")
public void deleteProject() throws Exception {
//given
Long projectId = 1L;

doNothing().when(projectService).deleteProject(anyLong());

mvc.perform(delete(baseUrl + "/{projectId}", 1L)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andDo(document("project-delete",
preprocessResponse(prettyPrint()))
);
}

@Test
@DisplayName("프로젝트 이름/내용/전체 검색한다")
void searchProjectsWithName() throws Exception {

// given
String projectName = "검색이름";

ProjectDto.GetProjectsRequest request = ProjectDto.GetProjectsRequest.builder()
GetProjectsRequest request = GetProjectsRequest.builder()
.projectName(projectName).build();

com.graphy.backend.global.common.PageRequest pageRequest = new PageRequest();
List<ProjectDto.GetProjectResponse> result = new ArrayList<ProjectDto.GetProjectResponse>();
PageRequest pageRequest = new PageRequest();
List<GetProjectResponse> result = new ArrayList<GetProjectResponse>();

for (int i = 0; i < 5; i++) {
ProjectDto.GetProjectResponse response =
ProjectDto.GetProjectResponse.builder().id((long) i).projectName("검색이름" + i)
GetProjectResponse response =
GetProjectResponse.builder().id((long) i).projectName("검색이름" + i)
.description("프로젝트 설명" + i).createdAt(LocalDateTime.now()).build();
result.add(response);
}
Expand All @@ -135,7 +182,7 @@ void getProjectPlan() throws Exception {
List<String> plans = new ArrayList<>(Arrays.asList("Spring Security", "Docker"));
String topic = "간단한 게시판";

ProjectDto.GetPlanRequest request = new ProjectDto.GetPlanRequest(topic, features, techStacks, plans);
GetPlanRequest request = new GetPlanRequest(topic, features, techStacks, plans);

String apiResult = "API 결과";
CompletableFuture<String> result = CompletableFuture.completedFuture(apiResult);
Expand All @@ -149,4 +196,26 @@ void getProjectPlan() throws Exception {
// then
resultActions.andExpect((status().isOk()));
}

@Test
@DisplayName("프로젝트 조회 시 프로젝트가 존재하지 않으면 예외가 발생한다")
public void EmptyResultTest() throws Exception {

// given
GetProjectsRequest request = GetProjectsRequest.builder().build();
PageRequest pageRequest = new PageRequest();
Pageable pageable = pageRequest.of();

// when
when(projectService.getProjects(any(GetProjectsRequest.class), any(Pageable.class)))
.thenReturn(Collections.emptyList());

// then
mvc.perform(get(baseUrl + "/search") // "/project/search" should be replaced with the actual URL
.param("page", String.valueOf(pageable.getPageNumber()))
.param("size", String.valueOf(pageable.getPageSize()))
.contentType(MediaType.APPLICATION_JSON)
.content(objectMapper.writeValueAsString(request)))
.andExpect(status().is4xxClientError()); // adjust based on the actual error code you're using
}
}
Loading
Loading