{"id":20589515,"url":"https://github.com/nankuf/springboot_datafaker","last_synced_at":"2026-04-22T04:02:49.310Z","repository":{"id":236485530,"uuid":"776299363","full_name":"NankuF/springboot_datafaker","owner":"NankuF","description":"Учебный проект для закрепления навыков работы в SpringBoot","archived":false,"fork":false,"pushed_at":"2024-04-27T10:43:48.000Z","size":71,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-06T13:33:41.006Z","etag":null,"topics":["java17-spring-boot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NankuF.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-23T05:44:44.000Z","updated_at":"2024-04-27T10:45:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"ac2faf09-0c64-4375-88a2-28c0a353a313","html_url":"https://github.com/NankuF/springboot_datafaker","commit_stats":null,"previous_names":["nankuf/springboot_datafaker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NankuF/springboot_datafaker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NankuF%2Fspringboot_datafaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NankuF%2Fspringboot_datafaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NankuF%2Fspringboot_datafaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NankuF%2Fspringboot_datafaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NankuF","download_url":"https://codeload.github.com/NankuF/springboot_datafaker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NankuF%2Fspringboot_datafaker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32120402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-22T00:31:26.853Z","status":"online","status_checked_at":"2026-04-22T02:00:05.693Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java17-spring-boot"],"created_at":"2024-11-16T07:29:38.794Z","updated_at":"2026-04-22T04:02:49.279Z","avatar_url":"https://github.com/NankuF.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# springboot_datafaker\nУчебный проект по созданию базового функционала в springboot.\u003cbr\u003e\nВнимание! в `resources/certs/` лежат ключи `*.pem`. В настоящем проекте они должны быть добавлены в `.gitignore`!\u003cbr\u003e\n\n\nСущность - обычно подразумевается класс, отражающий таблицу из БД.\u003cbr\u003e\nDTO - data transfer object. Паттерн, подразумевающий создание классов, инкапсулирующих в себя поля, которые необходимо получить, создать, обновить (create, read, update)\u003cbr\u003e\nMapper - класс, задающий правила автоматического преобразования сущности в DTO и обратно. Использует библиотеку mapstruct.\u003cbr\u003e\n\n1. Создание 100 юзеров при запуске приложения.\u003cbr\u003e\n   Необходимо:\u003cbr\u003e\n   - model: `User` - структура для записи в БД\u003cbr\u003e\n   - repository: `UserRepository` - содержит CRUD для записи в БД\u003cbr\u003e\n   - dto: `UserDTO`, `UserCreateDTO` - указывают, какие поля необходимо заполнить для выполнения create, read, update.\u003cbr\u003e\n   - mapper: `UserMapper` - инкапсулирует код преобразования сущности в DTO и обратно.\u003cbr\u003e\n   - component: опционально. Класс `DataInitializerProperties` нужен для получения переменных из переменных окружения. `DataInitializerProperties.getCount()` Переменная из application.yml, позволет гибко задавать кол-во юзеров для генерации во время запуска приложения.\u003cbr\u003e\n   - component: `DataInitializer` - использует faker для создания юзеров.\u003cbr\u003e\n2. Частичное обновление [PUT вместо PATCH](https://kdrozd-pl.translate.goog/how-to-perform-a-partial-update-patch-with-explicit-null/?_x_tr_sl=auto\u0026_x_tr_tl=ru\u0026_x_tr_hl=ru) - необязательно заполнять все поля для обновления сущности. При передаче поля со значением null - оно будет подставлено. Если же поле не передается, оно будет проигнорировано.\u003cbr\u003e\n    Необходимо:\u003cbr\u003e\n    - install dependency: `implementation(\"org.openapitools:jackson-databind-nullable:0.2.6\")`\u003cbr\u003e\n    - create `UserUpdateDTO` with `JsonNullable` fields.\u003cbr\u003e\n    - create config `JacksonConfig` and write rules for mapping (`UserMapper`, etc).\u003cbr\u003e\n    - create `JsonNullableMapper` and added him to `UserMapper`.\u003cbr\u003e\n    - create simple controllers `UserController` for update `User` model using API.\u003cbr\u003e\n    - create service `UserService` for encapsulation of business logic by separating it from http requests.\u003cbr\u003e\n1. Подключен JPA Audit - автоматическая запись времени создания и обновления записи в БД.\u003cbr\u003e\n    Необходимо:\u003cbr\u003e\n    - set `@EnableJpaAuditing` in class `Application`.\u003cbr\u003e\n    - modify `UserDTO`.\u003cbr\u003e\n    - modify `User` model, added fields `createdAt` and `updatedAt` with `@CreatedDate` and `@LastModifiedDate`.\u003cbr\u003e\n    - set @EntityListeners(AuditingEntityListener.class) on `User` model.\u003cbr\u003e\n2. Перехват ошибок с помощью Advice.\u003cbr\u003e\n    Необходимо:\u003cbr\u003e\n    - create handler `GlobalExceptionHandler`.\u003cbr\u003e\n    - create exception `ResourceNotFoundException`.\u003cbr\u003e\n    - use this exception in controllers or service.\u003cbr\u003e\n3. Поиск юзера по емайлу.\u003cbr\u003e\n   Необходимо:\u003cbr\u003e\n   - add `email` field with `@Email` in `User` model.\u003cbr\u003e\n   - add `findByEmail` method in `UserRepository`.\u003cbr\u003e\n   - add `getUserByEmail` method in `UserService`.\u003cbr\u003e\n   - add email in all user DTO's.\u003cbr\u003e\n   - add new controller.\u003cbr\u003e\n4. Фильтрация и пагинация.\u003cbr\u003e\nBy default `?page=1`\u003cbr\u003e\nПример: http://localhost:8080/api/users?emailCont=is\u0026\u0026updatedAtGt=2024-03-23 20:18:56\u003cbr\u003e\n    Необходимо:\u003cbr\u003e\n    - update `getUsers` in `UserService`.\u003cbr\u003e\n    - update `getUsers` in `UserController`.\u003cbr\u003e\n    - add `JpaSpecificationExecutor\u003cUser\u003e` in `UserRepository`.\u003cbr\u003e\n    - implements filter in `UserSpecification`.\u003cbr\u003e\n    - create `UserParamsDTO` as filter params.\u003cbr\u003e\n1. Авторизация.\u003cbr\u003e\n   Необходимо:\u003cbr\u003e\n   - install dependency.\u003cbr\u003e\n   - update `User` model, implements `UserDetails`.\u003cbr\u003e\n   - create `CustomUserDetailsService` as CRUD for users.\u003cbr\u003e\n   - add `passwordEncoder` bean for hashing password in `EncodersConfig`.\u003cbr\u003e\n   - create `SecurityConfig` where using `passwordEncoder` and `CustomUserDetailsService`.\u003cbr\u003e\n   - create `JWTUtils` for generic jwt token.\u003cbr\u003e\n   - create rsa keys and `RsaKeyProperties`. Dont push `private.pem` to git! This for only example.\u003cbr\u003e\n    ```bash\n    # datafaker/src/main/resources/certs\n    openssl genpkey -out private.pem -algorithm RSA -pkeyopt rsa_keygen_bits:2048 \u0026\u0026\\\n    openssl rsa -in private.pem -pubout -out public.pem\n    ```\n   - create `AuthRequestDTO`\u003cbr\u003e\n   - create `AuthenticationController`.\u003cbr\u003e\n   - add security filter for urls in `SecurityConfig`.\u003cbr\u003e\n   - create `UserUtils` with `getCurrentUser` method for get authenticated user.\u003cbr\u003e\n   - add `passwordDigest` in `UserCreateDTO`.\u003cbr\u003e\n   - add `encryptPassword` method in `UserMapper`.\u003cbr\u003e\n   - check generate token.\u003cbr\u003e\n    ```bash\n    curl -X POST -H \"content-type:application/json\" -d '{\"username\":\"admin@admin.ru\", \"password\": \"123\"}' http://localhost:8080/api/login\n    ```\n    - check get users with token.\u003cbr\u003e\n    ```bash\n    curl -H \"content-type:application/json\" -H \"authorization:bearer \u003ctoken\u003e\" http://localhost:8080/api/users\n    ```\n\n\nOther commands (before create authentication):\u003cbr\u003e\nGet all users\u003cbr\u003e\n```bash\ncurl http://localhost:8080/api/users\n```\nGet user by id\u003cbr\u003e\n```bash\ncurl http://localhost:8080/api/users/1\n```\nCreate User\u003cbr\u003e\n```bash\ncurl -X POST -H \"content-type:application/json\" -d '{\"firstName\":\"Bob\", \"lastName\":\"Marley\"}' http://localhost:8080/api/users\n```\nPartial update user (JsonNullable)\u003cbr\u003e\n```bash\ncurl -X PUT -H 'content-type:application/json' -d '{\"lastName\":\"Hello\"}' http://localhost:8080/api/users/1\n```\nFull update user\u003cbr\u003e\n```bash\ncurl -X PUT -H 'content-type:application/json' -d '{\"firstName\":\"NewFirstName\", \"lastName\":\"NewLastName\"}' http://localhost:8080/api/users/1\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnankuf%2Fspringboot_datafaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnankuf%2Fspringboot_datafaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnankuf%2Fspringboot_datafaker/lists"}