Public Education Example - TheOpenCloudEngine/uEngine-cloud GitHub Wiki

Sample Project download

https://github.com/uengine-oss ์œผ๋กœ ๋“ค์–ด๊ฐ€์„œ
https://github.com/uengine-oss/msa-tutorial-class-management-monolith ๋ฅผ git clone ํ•œ๋‹ค

(๋˜ ๋‹ค๋ฅธ ์˜ˆ์ œ: ๋ณดํ—˜์‚ฌ ์˜ˆ์ œ - https://github.com/jinyoung/sw-modeling-example-msa)

$ git clone https://github.com/uengine-oss/msa-tutorial-class-management-monolith.git
$ cd msa-tutorial-class-management-monolith
$ mvn spring-boot:run

ํ•ด๋‹น ํ”„๋กœ์ ํŠธ๋ฅผ ๋‹ค์šด๋ฐ›๊ณ  intellij๋กœ ์—ด์—ˆ์„๋•Œ, ์•„๋ž˜์™€ ๊ฐ™์ด ํ”„๋กœ์ ํŠธ ๊ตฌ์กฐ๊ฐ€ ๋‚˜์˜จ๋‹ค.
ํ˜„์žฌ ํ”„๋กœ์ ํŠธ๋Š” eureka ๊ฐ€ ์žˆ๋‹ค๋Š” ๊ฐ€์ •ํ•˜์— ๋งŒ๋“ค์–ด์ง„ ์ฝ”๋“œ์ด๊ธฐ์—, application.yml ํŒŒ์ผ์„ ์—ด์–ด์„œ eureka.client.enabled : false ๋กœ ์„ค์ •ํ•˜์—ฌ ์ค€๋‹ค.

eureka:
  client:
    enabled: false


์ด์ œ ํ•ด๋‹น ํ”„๋กœ์ ํŠธ์˜ ๊ตฌ์กฐ๋ฅผ ์‚ดํŽด๋ณด์ž
HATEOAS ๊ฐ€ ์ ์šฉ๋œ ์„œ๋น„์Šค๋Š” ์ง„์ž…์ ์—์„œ ์กฐํšŒ๋ฅผ ํ•˜์˜€์„๋•Œ ๋ชจ๋“  ์„ค๋ช…์ด ๋‹ค ๋‚˜์˜จ๋‹ค

$http localhost:8080

{
    "_links": {
        "clazzDays": {
            "href": "http://localhost:8080/clazzDays{?page,size,sort}",
            "templated": true
        },
        "clazzes": {
            "href": "http://localhost:8080/clazzes{?page,size,sort}",
            "templated": true
        },
        "courses": {
            "href": "http://localhost:8080/courses{?page,size,sort}",
            "templated": true
        },
        "customers": {
            "href": "http://localhost:8080/customers{?page,size,sort}",
            "templated": true
        },
        "enrollments": {
            "href": "http://localhost:8080/enrollments{?page,size,sort}",
            "templated": true
        },
        "instructors": {
            "href": "http://localhost:8080/instructors{?page,size,sort}",
            "templated": true
        },
        "profile": {
            "href": "http://localhost:8080/profile"
        }
    }
}

ํŒŒ์ผ ๊ตฌ์กฐ๋ฅผ ์„ค๋ช…ํ•˜์ž๋ฉด

  • Clazz ๊ฐ•์˜
  • ClazzDay ๊ฐ•์˜ ๋‚ ์ž
  • Course ๊ต์œก ์ฝ”์Šค
  • Customer ์ˆ˜๊ฐ•์ƒ
  • Enrollment ์ˆ˜๊ฐ•์ƒ์˜ ์ˆ˜๊ฐ•์ƒํƒœ
  • Instructor ๊ต์œก ๊ฐ•์‚ฌ
    ์œ„์™€๊ฐ™์€ ํด๋ ˆ์Šค ๋“ค์ด ์žˆ๊ณ , ํ•ด๋‹น ํด๋ž˜์Šค๋“ค์„ Repository๋กœ ๋ฌถ์–ด์„œ ๊ตฌ์„ฑ๋œ ํ”„๋กœ์ ํŠธ์ด๋‹ค.

Sample project ๊ตฌ๋™ํ•˜๊ธฐ

๊ณผ์ •(course)๋“ฑ๋ก

## ๊ณผ์ •๋“ฑ๋ก
$ http localhost:8080/courses title="software modeling lecture" duration=5 maxEnrollment=5 minEnrollment=1
## ๋ชจ๋“  ์ •๋ณด์‹œ์Šคํ…œ์€ ์ ์ฐจ ๋ฐ์ดํ„ฐ๊ฐ€ ์ฑ„์›Œ์ง€๋ฉด์„œ ํ”„๋กœ์„ธ์Šค๊ฐ€ ํ˜๋Ÿฌ๊ฐ„๋‹ค.  
## ๋ฐ์ดํ„ฐ๋ฅผ ์ดˆ๋ฐ˜์— ๋„ฃ์ง€ ์•Š์•˜๋”๋ผ๋„, PATCH๋ฅผ ํ†ตํ•ด ์ ์ฐจ ๋ฐ์ดํ„ฐ๋ฅผ ๋„ฃ์–ด์ค€๋‹ค.  
$ http PATCH "http://localhost:8080/courses/1" description="MSA ๊ต์šฑ๊ณผ์ •์ž…๋‹ˆ๋‹ค"

{
    "_links": {
        "clazzes": {
            "href": "http://localhost:8080/courses/1/clazzes"
        },
        "course": {
            "href": "http://localhost:8080/courses/1"
        },
        "self": {
            "href": "http://localhost:8080/courses/1"
        }
    },
    "courseId": null,
    "description": "MSA ๊ต์šฑ๊ณผ์ •์ž…๋‹ˆ๋‹ค",
    "duration": 5,
    "maxEnrollment": 5,
    "minEnrollment": 1,
    "title": "software modeling lecture",
    "unitPrice": null
}

๊ฐ•์˜(clazz) ๋“ฑ๋ก

## ํด๋ž˜์Šค 1 ๋“ฑ๋ก - ์—๋Ÿฌ ๋ฐœ์ƒ
$ http localhost:8080/clazzes course="http://localhost:8080/courses" id="1"
## ํด๋ž˜์Šค 1 ๋“ฑ๋ก - ์ •์ƒ ์ž‘๋™  
## "http://localhost:8080/courses/1" ์ด๊ฒƒ์ด ๋ฌธ์ž์—ด์ฒ˜๋Ÿผ ๋„˜์–ด๊ฐ€์ง€๋งŒ HATEOAS์—์„œ๋Š” ๋ฌธ์ž์—ด์ด ์•„๋‹ˆ๊ณ , ๋ฆฌ์†Œ์Šค๋ฅผ ์ง€์นญํ•˜๋Š” ์˜๋ฏธ๋ฅผ ๊ฐ€์ง„๋‹ค
$ http localhost:8080/clazzes course="http://localhost:8080/courses/1"

{
    "_links": {
        "clazz": {
            "href": "http://localhost:8080/clazzes/2"
        },
        "clazzDays": {
            "href": "http://localhost:8080/clazzes/2/clazzDays"
        },
        "course": {
            "href": "http://localhost:8080/clazzes/2/course"
        },
        "instructor": {
            "href": "http://localhost:8080/clazzes/2/instructor"
        },
        "self": {
            "href": "http://localhost:8080/clazzes/2"
        }
    },
    "evaluationRate": 0,
    "states": null
}

์ด ๊ฐ•์˜์˜ ์œ ์ผํ•œ ํ‚ค๋Š” 2๋ฒˆ์ด๊ณ , 2๋ฒˆ ๊ฐ•์˜์˜ ๊ณผ์ •์€ http "http://localhost:8080/clazzes/2/course" ์„ ํ˜ธ์ถœํ•˜์—ฌ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ๋‹ค.
http://localhost:8080/courses/1 ๊ณผ ๊ฐ™์€ ๊ฒฐ๊ณผ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๊ฒƒ์ด ํ™•์ธ ๊ฐ€๋Šฅํ•˜๋‹ค.

์ด ๋‘๊ฐœ์˜ API๋Š” URL๋งํฌ๋กœ relation์ด ๋ฌถ์—ฌ ์žˆ๋‹ค.
API ์ˆ˜์ค€์—์„œ๋Š” ๋ถ„๋ฆฌ๊ฐ€ ๋˜์–ด์žˆ๊ธฐ๋•Œ๋ฌธ์—, ๋‚˜์ค‘์— ์„œ๋น„์Šค๋ฅผ ๋ถ„๋ฆฌํ•˜๋”๋ผ๋„, API๋Š” ๋ณ€ํ™”๊ฐ€ ์—†๊ธฐ๋•Œ๋ฌธ์— frontend์—์„œ ์ˆ˜์ •์—†์ด ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

โš ๏ธ **GitHub.com Fallback** โš ๏ธ