An open API service indexing awesome lists of open source software.

https://github.com/simplydemo/userservice-demo

Backend Demo application combines components such as kotlin, spring-boot, jpa, webmvc, junit, mockk
https://github.com/simplydemo/userservice-demo

jpa junit5 kotlin maven rest-api spring-webflux-functional

Last synced: 2 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# user-crud-demo-backend
Backend combines components such as kotlin, spring-boot, jpa, webmvc, junit, mockk

## Build
프로젝트 build 및 run 을 위해 먼저 jdk-17 버전을 준비합니다.
```shell
java -version

# sdk 패키지 매니저를 이용 한다면 현재 java 버전 확인 및 버전 변경을 할 수 있습니다.
sdk current java
# 17 버전이 없다면 설치 가능
# sdk install java
sdk default java
```

```
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:

* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.5.6/maven-plugin/reference/html/)
* [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.5.6/maven-plugin/reference/html/#build-image)
* [Rest Repositories](https://docs.spring.io/spring-boot/docs/2.5.6/reference/htmlsingle/#howto-use-exposing-spring-data-repositories-rest-endpoint)
* [Spring Web](https://docs.spring.io/spring-boot/docs/2.5.6/reference/htmlsingle/#boot-features-developing-web-applications)
* [Spring Data JPA](https://docs.spring.io/spring-boot/docs/2.5.6/reference/htmlsingle/#boot-features-jpa-and-spring-data)

### Guides
The following guides illustrate how to use some features concretely:

* [Accessing JPA Data with REST](https://spring.io/guides/gs/accessing-data-rest/)
* [Accessing Neo4j Data with REST](https://spring.io/guides/gs/accessing-neo4j-data-rest/)
* [Accessing MongoDB Data with REST](https://spring.io/guides/gs/accessing-mongodb-data-rest/)
* [Building a RESTful Web Service](https://spring.io/guides/gs/rest-service/)
* [Serving Web Content with Spring MVC](https://spring.io/guides/gs/serving-web-content/)
* [Building REST services with Spring](https://spring.io/guides/tutorials/bookmarks/)
* [Accessing Data with JPA](https://spring.io/guides/gs/accessing-data-jpa/)