Git Product home page Git Product logo

spring-lv2's Introduction

Spring LV2 과제

도서관 서버 만들기

📌 TODO

  1. 404 Error Status code 나오게 하기

  2. 회원 등록 실패 시 memberId 1 증가하는 문제 해결하기

    JPA에서 MySQL과 연동해서 @GeneratedValue를 쓸 때 주로 사용하는 IDENTITY 전략은 기본 키 생성을 DB에 위임한다. JPA 영속성 컨텍스트에서 Entity를 관리하기 위해서는 PK값이 있어야하는데, MySQL AUTO_INCREMENT 기능으로 생성하는 PK를 영속성 컨텍스트 1차 캐시의 key 값으로 사용하여 관리하는 방식이다.

    그런데 JPA 입장에서는 DB에 query를 실행하기 전에는 AUTO_INCREMENT되는 값을 알 수 가 없다. 따라서 IDENTITY 전략을 사용할 떄는 em.persist() 가 호출되는 시점에 insert query가 실행되어 PK 값을 조회한다.

    entityTransaction.commit()이 실행되기 전에 오류가 발생해서 transaction이 rollback이 된다고 해도 DB에서 AUTO_INCREMENT한 값은 그대로 유지된다. 따라서 다음 번에 호출한 query에서도 PK가 증가한 상태가 된다.

Use case diagram

use case diagram

ERD

book의 language의 경우 ISO 639-1 codes를 사용

ERD

API Spec

API Spec

POST /api/books

Request

{
  "title": "string",
  "author": "string",
  "language": "string",
  "publisher": "string"
}

Response 201 400

Status: 201

{
  "id": "integer",
  "title": "string",
  "author": "string",
  "language": "string",
  "publisher": "string",
  "registeredAt": {
    "type": "string",
    "format": "date-time"
  },
  "available": "boolean"
}

Status: 400

{
  "code": "string",
  "error type": "string",
  "message": "string"
}
POST /api/members

Request

{
  "name": "string",
  "gender": "string",
  "rrn": "string",
  "phoneNumber": "string",
  "address": "string"
}

Response 201 400

Status: 201

{
  "id": "integer",
  "name": "string",
  "gender": "string",
  "phoneNumber": "string",
  "address": "string"
}

Status: 400

{
  "code": "string",
  "error type": "string",
  "message": "string"
}
GET /api/books

Response 200 404

Status: 200

{
  "type": "array",
  "items": {
    "id": "integer",
    "title": "string",
    "author": "string",
    "language": "string",
    "publisher": "string",
    "registeredAt": {
      "type": "string",
      "format": "date-time"
    },
    "available": "boolean"
  }
}

Status: 404

{
  "code": "string",
  "error type": "string",
  "message": "string"
}
GET /api/books/{bookId}

Response 200 404

Status: 200

{
  "id": "integer",
  "title": "string",
  "author": "string",
  "language": "string",
  "publisher": "string",
  "registeredAt": {
    "type": "string",
    "format": "date-time"
  },
  "available": "boolean"
}

Status: 404

{
  "code": "string",
  "error type": "string",
  "message": "string"
}
GET /api/records

Response 200 400 404

Status: 200

{
  "type": "array",
  "items": {
    "id": "integer",
    "name": "string",
    "phoneNumber": "string",
    "title": "string",
    "author": "string",
    "borrowedAt": {
      "type": "string",
      "format": "date-time"
    },
    "returnStatus": "boolean"
  }
}

Status: 400, 404

{
  "code": "string",
  "error type": "string",
  "message": "string"
}
POST /api/books/{bookId}

Response 201 400

Status: 201

{
  "message": "string"
}

Status: 400

{
  "code": "string",
  "error type": "string",
  "message": "string"
}
PUT /api/books/{bookId}

Response 200 400

Status: 200

{
  "message": "string"
}

Status: 400

{
  "code": "string",
  "error type": "string",
  "message": "string"
}

spring-lv2's People

Contributors

hjunyoung avatar

Watchers

 avatar

spring-lv2's Issues

lv2 페어 리뷰

  1. RecordService의 line 33에서 mapper 메서드 만드신 것도 좋은데 Member와 Book을 BorrowRecordDto의 생성자 매개변수로 넘기는 방법도 좋을 것 같습니다.
  2. 페널티 처리하는 방식이 저보다 훨씬 명료하네요~!
  3. @DynamicInsert는 몰랐던 Annotation인데 덕분에 알게 되었습니다.
    전반적으로 잘 짜여진 구성과 명료한 로직에 감탄하고 갑니다.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.