Skip to content

Backend Demo application combines components such as kotlin, spring-boot, jpa, webmvc, junit, mockk

Notifications You must be signed in to change notification settings

simplydemo/userservice-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

user-crud-demo-backend

Backend combines components such as kotlin, spring-boot, jpa, webmvc, junit, mockk

Build

프로젝트 build 및 run 을 위해 먼저 jdk-17 버전을 준비합니다.

java -version

# sdk 패키지 매니저를 이용 한다면 현재 java 버전 확인 및 버전 변경을 할 수 있습니다.
sdk current java 
# 17 버전이 없다면 설치 가능
# sdk install java <JDK_17_Version>
sdk default java <JDK_17_Version>  
mvn clean package -DskipTests=true

Run

mvn spring-boot:run -DskipTests=true

Check APIs

query

curl -v -L -X GET http://localhost:8080/api/v1/users/query

users-add

curl -v -L  -X POST 'http://localhost:8080/api/v1/users' \
-H 'Content-Type: application/json' -H 'Authorization: Bearer {token}' \
--data-raw '{
    "firstName": "scott2",
    "lastName": "pines",
    "email": "scott2@pines.io",
    "role": "Manager",
    "title": "MR",
    "usercode": "scott21234"
}' 

users-find-all

curl -v -L -X GET 'http://localhost:8080/api/v1/users' \
 -H 'Content-Type: application/json' -H 'Authorization: Bearer {token}' 

users-find-by-id

curl -v -L -X GET 'http://localhost:8080/api/v1/users/1' \
 -H 'Content-Type: application/json' -H 'Authorization: Bearer {token}' 

users-modify

curl -v -L -X PUT 'http://localhost:8080/api/v1/users/3' \
 -H 'Content-Type: application/json' -H 'Authorization: Bearer {token}' \
 --data-raw '{
    "id": 3,
    "firstName": "Banana",
    "lastName": "Fruit",
    "email": "banana.fruit@farm.io",
    "role": "Admin",
    "title": "Mr",
    "usercode": "banana1234"
}' 

users-find-by-query

curl -v -L -X GET 'http://localhost:8080/api/v1/users/query?lastName=Fruit&title=mr&email=farm&role=manager' \
-H 'Content-Type: application/json' -H 'Authorization: Bearer {token}'

users-delete

curl -v -L -X DELETE 'http://localhost:8080/api/v1/users/4' \
-H 'Content-Type: application/json' -H 'Authorization: Bearer {token}'

Appendix

Docker Mysql UP

docker-compose -f ./cicd/docker/docker-compose-mysql.yaml up -d

# Listen port 확인 (by netcat)
# nc -vc localhost 53306

Docker H2 UP

docker-compose -f ./cicd/docker/docker-compose-h2.yaml up -d

# Listen port 확인 (by netcat)
# nc -vc localhost 1521

Build Docker Image

mvn clean package -DskipTests=true

docker build -t symplesims/user-service:loc-1.0 -f ./cicd/docker/Dockerfile .

### Docker Service UP
docker-compose -f ./cicd/docker/docker-compose.yaml up -d

# with profile
# docker-compose -f ./cicd/docker/docker-compose.yaml run user-service -e SPRING_PROFILE=dev

# Down
# docker-compose -f ./cicd/docker/docker-compose.yaml down

Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use some features concretely: