Lightweight Spring Boot backend for a smart door lock mobile app. This project exposes HTTP APIs used by the mobile client to register/login users, query and change user/device state, request door operations, and handle messages.
- Main class:
spring.restapi.RestapiApplication - Controller example:
spring.restapi.controller.DoorController(routes listed below) - Config file:
src/main/resources/application.yml - Java: 8 (see
pom.xml) - Build tool: Maven (wrapper included:
mvnw,mvnw.cmd)
- Java 8 JDK installed and JAVA_HOME set.
- MySQL server (or adjust
spring.datasource.url) and a database configured for the app. - Redis server if you rely on socket/notification features (defaults shown below).
Edit src/main/resources/application.yml to change runtime configuration. Relevant defaults found in the repository:
- server.port: 8081
- spring.datasource.url:
jdbc:mysql://localhost:3306/smartiot?useSSL=false - spring.datasource.username/password:
smartiot/smartiot - redis.host:
localhost, redis.port:6379
Also present under config:
socket_timeoutandbluetooth_timeout(ms)
From the repository root (Windows):
.\mvnw.cmd -DskipTests package
.\mvnw.cmd spring-boot:runOr run the produced jar:
.\mvnw.cmd -DskipTests package
java -jar target\SmartHomeServer-0.0.1.jarRun tests:
.\mvnw.cmd testBase path used by controllers: /smart_app/ (see DoorController). All endpoints are POST and expect JSON bodies.
Common endpoints implemented in DoorController:
POST /smart_app/login— user login, acceptsLoginRequestDto(cid, password)POST /smart_app/check_register— check if CID is availablePOST /smart_app/register— register new userPOST /smart_app/search_district— search district dataPOST /smart_app/get_business_list— fetch business listPOST /smart_app/change_userinfo— change user infoPOST /smart_app/change_password— change passwordPOST /smart_app/request_admin_auth— request admin authorizationPOST /smart_app/user_manage_list— admin: get user manage listPOST /smart_app/user_manage_process— admin: process user (change role/state)POST /smart_app/check_door_states— check device/socket/bluetooth/batteryPOST /smart_app/open_door_request— request open door (network->bluetooth bridging)POST /smart_app/history— get door open historyPOST /smart_app/message_list— get messages/feedbackPOST /smart_app/message_send— send feedback message
Request/response shapes are defined under src/main/java/spring/restapi/resquest_dto and src/main/java/spring/restapi/response_dto.
spring.restapi.controller— REST controllersspring.restapi.service— service layer (DoorService)spring.restapi.repository— Spring Data JPA repositoriesspring.restapi.model— JPA entity modelsspring.restapi.resquest_dtoand...response_dto— DTOs
- The project uses Spring Boot 2.2.6 and targets Java 8 (see
pom.xml). - Default DB/Redis credentials in
application.ymlare development defaults — change them before running in production. - If you enable Redis-based features, ensure Redis is reachable at the configured host/port.
- Add a
.envor externalized configuration to avoid committing secrets. - Add integration tests that start an in-memory DB (H2) and mock Redis for CI runs.
If you'd like, I can also:
- generate an example Postman collection for the listed endpoints,
- add a short
docker-compose.ymlto bring up MySQL + Redis for local testing, - or create a simple
READMEbadge section with build status once CI is added.