Skip to content
Open
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
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
# DevitUser
Devit User Domain
# Devit
<p align="center">
<img src = 'https://user-images.githubusercontent.com/84092014/177942862-e4755aa7-f87b-4eaa-8eae-07bcaeb3932e.png' style='width:300px;'/>
</p>
경험이 많고 실력 있는 개발자에게 도움을 받기 위한 플랫폼입니다. <br/>
기업 또는 개인에게 알맞는 개발자의 스펙과 원하는 직무를 등록하여 구인하고 개발자는 확인 후 지원서를 넣어 서로가 만족하는 상황이 되었을 때 계약이 진행될 수 있도록 중개하는 웹 사이트입니다. <br/>


## Devit User Service
Devit 유저 서비스입니다. <br>
유저의 회원가입 로직을 인증 서버와 RabbitMQ 비동기 이벤트로 처리합니다. <br>
유저 프로필, 이력서를 관리합니다.<br>
이력서로는, 카테고리 직종, 학적, 경력, 수상 등이 있습니다.<br>
개발 중에 있습니다.<br>
이력서에 관한 API 완성되면, ERD API 명세서 업로드 예정입니다.<br>

## API List


# link to another repo

- eureka server : https://github.com/ekgpgdi/devit-eureka-server
- gateway : https://github.com/ekgpgdi/devit-gateway
- certification service : https://github.com/ekgpgdi/devit-certification-service
- board : https://github.com/kimziaco/devit-board
- user : https://github.com/eet43/devit-user
- chat : https://github.com/eet43/devit-chat
18 changes: 18 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 0.0
os: linux
files:
- source: /
destination: /home/ubuntu/app/
overwrite: yes

permissions:
- object: /
pattern: "**"
owner: ubuntu
group: ubuntu

hooks:
ApplicationStart:
- location: deploy.sh
timeout: 60
runas: ubuntu
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dependencies {
// https://mvnrepository.com/artifact/org.json/json
implementation group: 'org.json', name: 'json', version: '20160810'


implementation 'com.fasterxml.jackson.core:jackson-databind'

}
Expand Down
31 changes: 31 additions & 0 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

REPOSITORY=/home/ubuntu/app

echo "> 현재 구동 중인 애플리케이션 pid 확인"

CURRENT_PID=$(pgrep -fla java | grep hayan | awk '{print $1}')

echo "현재 구동 중인 애플리케이션 pid: $CURRENT_PID"

if [ -z "$CURRENT_PID" ]; then
echo "현재 구동 중인 애플리케이션이 없으므로 종료하지 않습니다."
else
echo "> kill -15 $CURRENT_PID"
kill -15 $CURRENT_PID
sleep 5
fi

echo "> 새 애플리케이션 배포"

JAR_NAME=$(ls -tr $REPOSITORY/*SNAPSHOT.jar | tail -n 1)

echo "> JAR NAME: $JAR_NAME"

echo "> $JAR_NAME 에 실행권한 추가"

chmod +x $JAR_NAME

echo "> $JAR_NAME 실행"

nohup java -jar -Duser.timezone=Asia/Seoul $JAR_NAME >> $REPOSITORY/nohup.out 2>&1 &
27 changes: 23 additions & 4 deletions src/main/java/com/devit/user/controller/CategoryController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import com.devit.user.entity.Category;
import com.devit.user.exception.NoResourceException;
import com.devit.user.service.CategoryService;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

Expand All @@ -19,26 +21,34 @@
* 1. 부모 카테고리 등록
* 2. 자식 카테고리 등록
* 3. 자식 카테고리들 조회
* 4. 특정 카테고리 객체 조회
*/
@RestController
@RequiredArgsConstructor
@Slf4j
public class CategoryController {
private final CategoryService categoryService;

@PostMapping("api/users/categories/parent") //1
@PostMapping("/categories/parent") //1
@ApiOperation(value = "부모 카테고리 등록", notes = "부모 카테고리를 등록합니다.")
public ResponseEntity<?> saveParentCategory(@RequestBody CreateParentCategoryRequest request) throws NoResourceException {
log.info("category : {} 부모 카테고리를 저장합니다.", request.getName());

Category category = new Category();
category.setName(request.getName());
category.setDepth(1L);

Long saveCategoryId = categoryService.saveCategory(category);

log.info("category : {} 부모 카테고리 Id 를 반환합니다.", saveCategoryId);


return ResponseEntity.ok().body(saveCategoryId);
}

@PostMapping("api/users/categories/children") //2
@PostMapping("/categories/children") //2
@ApiOperation(value = "자식 카테고리 등록", notes = "자식 카테고리를 등록합니다.")
public ResponseEntity<?> saveChildCategory(@RequestBody CreateChildCategoryRequest request) throws NoResourceException {
log.info("category : {} 자식 카테고리를 저장합니다.", request.getName());

Category findParent = categoryService.findCategoryByName(request.getParentName());

Expand All @@ -47,14 +57,23 @@ public ResponseEntity<?> saveChildCategory(@RequestBody CreateChildCategoryReque
category.setDepth(2L);
category.addParent(findParent);

log.info("category : 부모와 자식 카테고리를 연결합니다.");


Long saveCategoryId = categoryService.saveCategory(category);

log.info("category : {} 자식 카테고리 id를 반환합니다.", saveCategoryId);


return ResponseEntity.ok().body(saveCategoryId);
}

@GetMapping("api/users/categories") //3
@GetMapping("/categories") //3
@ApiOperation(value = "카테고리 조회", notes = "자식 카테고리를 조회합니다.")
public ResponseEntity<?> getCategories() {

log.info("category : 카테고리를 조회합니다.");

List<Category> findParents = categoryService.findParentCategoires();
List<GetCategoryResponse> collect = findParents.stream()
.map(c -> new GetCategoryResponse(c.getId(), c.getName(), c.getChildren()))
Expand Down
108 changes: 76 additions & 32 deletions src/main/java/com/devit/user/controller/ResumeController.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
package com.devit.user.controller;

import com.devit.user.dto.EditResumeRequest;
import com.devit.user.entity.Category;
import com.devit.user.entity.Education;
import com.devit.user.entity.User;
import com.devit.user.dto.ResumeDto;
import com.devit.user.dto.SendResumeMessage;
import com.devit.user.dto.response.ResponseDetails;
import com.devit.user.dto.SendResumeRequest;
import com.devit.user.entity.Resume;
import com.devit.user.exception.NoResourceException;
import com.devit.user.message.RabbitMqSender;
import com.devit.user.service.CategoryService;
import com.devit.user.service.ResumeService;
import com.devit.user.service.UserService;
import com.devit.user.util.HttpStatusChangeInt;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONObject;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.Null;
import java.util.Base64;
import java.util.List;
import java.util.Date;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;


/**
Expand All @@ -38,28 +39,71 @@ public class ResumeController {
private final ResumeService resumeService;
private final CategoryService categoryService;
private final UserService userService;
private final RabbitMqSender rabbitMqSender;

@PutMapping("/resumes") //수정되야함
@ApiOperation(value = "이력서 수정", notes = "이력서를 수정합니다.")
public ResponseEntity<?> editResume(@RequestHeader("Authorization") String data, @RequestBody EditResumeRequest request) throws NoResourceException {

log.info("resume : 이력서를 수정합니다. ex) 자기소개 : {}", request.getIntroduce());

String[] chunks = data.split("\\.");
Base64.Decoder decoder = Base64.getDecoder();
String payload = new String(decoder.decode(chunks[1]));

JSONObject jsonObject = new JSONObject(payload);
String sample = jsonObject.getString("uuid");
UUID uuid = UUID.fromString(sample); //토큰 복호화 완료

// Category findCategory = categoryService.findCategoryByName(request.getCategoryName()); //카테고리 찾아오기


Resume editResume = resumeService.save(request, uuid);

log.info("resume : 이력서 수정 왼료 {}", editResume);

int httpStatus = HttpStatusChangeInt.ChangeStatusCode("OK");
String path = "api/users/resumes";

ResponseDetails responseDetails = new ResponseDetails(new Date(), editResume, httpStatus, path);
return new ResponseEntity<>(responseDetails, HttpStatus.CREATED);
}

@PostMapping("/resumes")
@ApiOperation(value = "이력서 전송", notes = "이력서를 전송합니다.")
public ResponseEntity<?> sendResume(@RequestHeader("Authorization") String data, @RequestBody Map<String, String> requestObject) {
String[] chunks = data.split("\\.");
Base64.Decoder decoder = Base64.getDecoder();
String payload = new String(decoder.decode(chunks[1]));

JSONObject jsonObject = new JSONObject(payload);
String sample = jsonObject.getString("uuid");
UUID uuid = UUID.fromString(sample); //토큰 복호화 완료

String nickName; //조건문 변수 처리를 못 하는거 떄문에 일단 선언

if (!jsonObject.has("nickName")) {
Object obj = userService.findUserName(uuid);
nickName = String.valueOf(obj);
}
else {
nickName = jsonObject.getString("nickName"); // 키 값이 없으면 null 값이면 nullPointException
}


ResumeDto resumeDto = new ResumeDto(uuid, nickName, UUID.fromString(requestObject.get("boardId")));
log.info("resume : 이력서를 전송합니다. {}", resumeDto);
String message = rabbitMqSender.send(resumeDto);

log.info("resume : 이력서 전송 결과를 반환합니다. : {}", message);

int httpStatus = HttpStatusChangeInt.ChangeStatusCode("OK");
String path = "api/users/resumes";


ResponseDetails responseDetails = new ResponseDetails(new Date(), message, httpStatus, path);
return new ResponseEntity<>(responseDetails, HttpStatus.CREATED);
}

// @PostMapping("/api/users/resumes")
// public ResponseEntity<?> editResume(@RequestHeader("Authorization") String data, @RequestBody @Valid EditResumeRequest request) throws NoResourceException {
//
// String[] chunks = data.split("\\.");
// Base64.Decoder decoder = Base64.getDecoder();
// String payload = new String(decoder.decode(chunks[1]));
//
// JSONObject jsonObject = new JSONObject(payload);
// String sample = jsonObject.getString("uuid");
// UUID uuid = UUID.fromString(sample);
//
// User findUser = userService.findUser(uuid);
//
//// request.getEducations().stream()
//// .filter(e->e!=null)
//// .map(e->{Education.createEducation(e.)})
//
// Category findCategory = categoryService.findCategoryByName(request.getCategoryName()); //카테고리 찾아오기
//
// int httpStatus = HttpStatusChangeInt.ChangeStatusCode("Edited");
// String path = "api/users/resumes";
// }

}
30 changes: 25 additions & 5 deletions src/main/java/com/devit/user/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
public class UserController {
private final UserService userService;
private final ResumeService resumeService;
/*
토큰 파싱해야함.

/**
* 1. 유저 프로필 조회 (url : /api/users/)
* 2. 특정 유저 조회
*/

@GetMapping("/api/users")
@GetMapping("/")
public ResponseEntity<?> getProfile(@RequestHeader("Authorization") String data) throws NoResourceException {

String[] chunks = data.split("\\.");
Expand All @@ -46,13 +48,31 @@ public ResponseEntity<?> getProfile(@RequestHeader("Authorization") String data)
UUID uuid = UUID.fromString(sample);

User findUser = userService.findUser(uuid);
Resume findResume = resumeService.findByUser(findUser);

log.info("User : 프로필을 조회합니다. {}", findUser);


int httpStatus = HttpStatusChangeInt.ChangeStatusCode("OK");
String path = "api/users/";


ResponseProfileDetails responseDetails = new ResponseProfileDetails(new Date(), findUser, findResume, httpStatus, path);
ResponseDetails responseDetails = new ResponseDetails(new Date(), findUser, httpStatus, path);
return new ResponseEntity<>(responseDetails, HttpStatus.CREATED);
}

@GetMapping("/{uuid}")
public ResponseEntity<?> getProfile(@PathVariable("uuid") UUID userId) throws NoResourceException {


User findUser = userService.findUser(userId);

log.info("User : 해당 이력서를 조회합니다. {}", findUser);

int httpStatus = HttpStatusChangeInt.ChangeStatusCode("OK");
String path = "api/users/{uuid}";


ResponseDetails responseDetails = new ResponseDetails(new Date(), findUser, httpStatus, path);
return new ResponseEntity<>(responseDetails, HttpStatus.CREATED);
}
}
28 changes: 28 additions & 0 deletions src/main/java/com/devit/user/dto/EditAwardDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.devit.user.dto;

import com.devit.user.entity.Status;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import java.time.LocalDate;
@Getter
@AllArgsConstructor
public class EditAwardDto {
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate startDate; //시작 날짜

@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate endDate; //종료 날짜

private String competition; //대회 이름 최대 15글자

private String awards; //수상 내용 최대 10글자

private String content; //추가 자기소개

public EditAwardDto() {

}
}
Loading