lab-3 some configuring p.2

This commit is contained in:
Zakharov_Rostislav 2024-04-17 14:59:46 +04:00
parent addf626c2e
commit 7977bcc9d5
3 changed files with 20 additions and 39 deletions

View File

@ -7,7 +7,7 @@
"cwd": "${workspaceFolder}",
"mainClass": "com.ip.library.LibraryApplication",
"projectName": "library",
"args": "",
"args": "--populate",
"envFile": "${workspaceFolder}/.env"
}
]

View File

@ -41,45 +41,26 @@ public class LibraryApplication implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
// if (args.length > 0 && args[0].equals("--populate")) {
// log.info("Create default types values");
// final var type1 = typeService.create(new TypeEntity("type1"));
// final var type2 = typeService.create(new TypeEntity("type2"));
if (args.length > 0 && args[0].equals("--populate")) {
log.info("Create default types values");
final var type1 = typeService.create(new TypeEntity("type1"));
final var type2 = typeService.create(new TypeEntity("type2"));
// log.info("Create default authors values");
// final var author1 = authorService.create(new AuthorEntity("author1"));
// final var author2 = authorService.create(new AuthorEntity("author2"));
log.info("Create default authors values");
final var author1 = authorService.create(new AuthorEntity("author1"));
final var author2 = authorService.create(new AuthorEntity("author2"));
// log.info("Create default books values");
// final var book1 = bookService.create(new BookEntity("book1", type1, author1));
// final var book2 = bookService.create(new BookEntity("book2", type1, author2));
// final var book3 = bookService.create(new BookEntity("book3", type2, author1));
// final var book4 = bookService.create(new BookEntity("book4", type2, author2));
log.info("Create default books values");
final var book1 = bookService.create(new BookEntity("book1", type1, author1));
final var book2 = bookService.create(new BookEntity("book2", type1, author2));
final var book3 = bookService.create(new BookEntity("book3", type2, author1));
final var book4 = bookService.create(new BookEntity("book4", type2, author2));
// log.info("Create default users values");
// final var user1 = userService.create(new UserEntity("user1", "123"));
// final var user2 = userService.create(new UserEntity("user2", "123"));
// final var admin1 = userService.create(new UserEntity("admin1", "123"));
// userService.giveAdminRole(admin1.getId());
// }
log.info("Create default types values");
final var type1 = typeService.create(new TypeEntity("type1"));
final var type2 = typeService.create(new TypeEntity("type2"));
log.info("Create default authors values");
final var author1 = authorService.create(new AuthorEntity("author1"));
final var author2 = authorService.create(new AuthorEntity("author2"));
log.info("Create default books values");
final var book1 = bookService.create(new BookEntity("book1", type1, author1));
final var book2 = bookService.create(new BookEntity("book2", type1, author2));
final var book3 = bookService.create(new BookEntity("book3", type2, author1));
final var book4 = bookService.create(new BookEntity("book4", type2, author2));
log.info("Create default users values");
final var user1 = userService.create(new UserEntity("user1", "123"));
final var user2 = userService.create(new UserEntity("user2", "123"));
final var admin1 = userService.create(new UserEntity("admin1", "123"));
userService.giveAdminRole(admin1.getId());
log.info("Create default users values");
final var user1 = userService.create(new UserEntity("user1", "123"));
final var user2 = userService.create(new UserEntity("user2", "123"));
final var admin1 = userService.create(new UserEntity("admin1", "123"));
userService.giveAdminRole(admin1.getId());
}
}
}

View File

@ -6,7 +6,7 @@ server.port=8080
# Available levels are: TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF
logging.level.com.example.demo=DEBUG
# Set default orofile
# Set default profile
spring.profiles.default=dev
# Common JPA Settings