This is an easy actix-web project.Just lottery hero for HOK. And same logic project clean architecture
I have kotlin SpringBoot project as some logic hok-lottery
See the API documentation pages for more info.
See lottery sql info for more sql info
-
Create database and tables, you can see it by lottery sql. this can be done in the terminal, then input your mysql root password four times.:
./sql/import_databases.sh
If you don't want to test sql and use the shell script, you can create mysql database and use:
mysql -u root -p lottery < ./sql/lottery.sql
-
Create a
.env
file in this directory:SERVER_ADDR=127.0.0.1:8034 DATABASE_URL=mysql://<username>:<password>@localhost:3306/lottery DATABASE_URL_TEST=mysql://<username>:<password>@localhost:3306/lottery_test
or use shell script:
echo "SERVER_ADDR=127.0.0.1:8034" >> .env echo "DATABASE_URL=mysql://<username>:<password>@localhost:3306/lottery" >> .env echo "DATABASE_URL_TEST=mysql://<username>:<password>@localhost:3306/lottery_test" >> .env
Maybe you shouldn't use test db, then you can delete the test db shell script and env content.
-
Run the server
cargo run
my actix The Layered Architecture
:
src
├── app_state.rs
├── controller
│ ├── mod.rs
│ ├── pick.rs
│ └── reset.rs
├── creat_app.rs
├── lib.rs
├── main.rs
├── model
│ ├── hero.rs
│ ├── log.rs
│ ├── mod.rs
│ ├── my_result.rs
│ ├── post_param.rs
│ ├── team.rs
│ └── team_query.rs
├── repository
│ ├── hero.rs
│ ├── log.rs
│ ├── mod.rs
│ └── team.rs
├── service
│ ├── mod.rs
│ ├── pick.rs
│ └── reset.rs
└── test
├── mod.rs
├── test_pick_controller.rs
└── test_team_repository.rs
To run the tests, you can go src/test
and use the following command:
cargo test