Webservice for collecting pokemon cards. Build with Spring MVC and Thymeleaf.
Java 11, Spring Boot, Spring MVC, Thymeleaf, Spring Security, H2 database, Rest Template.
Thanks to Spring Boot service is ready to deploy. Nothing to corfigurate.
You can register new account, create game avatar, login and logout. Server downloads cards from Pokemon TCG Api and saves them in database. You can view all cards and spend coins for card packs or buy new coins. Card pack contains 5 random cards. Purchased cards will be saved in database and attached to pokemon's trainer.
TrainerService validates comming data structure and if aceptect builds valid trainer object and save it to database.
public void addTrainer(TrainerDTO trainerDTO){
validateUserHasNoTrainer();
validateName(trainerDTO.getName());
Trainer trainer = new Trainer(
trainerDTO.getName(),
trainerDTO.getType(),
loginService.getLoggerUserMail());
trainerRepository.save(trainer);
}
Spring Security configuration. Blocks most of pages if not logget user and shows custom login page.
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
http.headers().disable();
http.authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers("/console").permitAll()
.antMatchers("/register").permitAll()
.antMatchers("/all-cards").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll();
}