This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SpringBootApplication | |
public class Application implements CommandLineRunner { | |
// Objeto para escrever no console de log | |
private final Logger logger = LoggerFactory.getLogger(Application.class); | |
// Injeção, instância automática do objeto | |
@Autowired | |
private DummyService dummyService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-data-jpa</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.hsqldb</groupId> | |
<artifactId>hsqldb</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.projectlombok</groupId> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Essa classe insere dois nomes, ao iniciar a aplicação, para fins de teste | |
* @author rodrigo | |
*/ | |
@Configuration | |
@EnableJpaRepositories | |
public class PersistenceConfiguration { | |
// Código para inserir duas pessoas no banco de dados | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface PessoaRepository extends JpaRepository<Pessoa, Long> { | |
List<Pessoa> findByNomeLike(@Param("nome") String nome); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@EnableGlobalMethodSecurity(prePostEnabled = true) | |
@EnableWebSecurity | |
public class SecurityConfiguration extends WebSecurityConfigurerAdapter { | |
@Autowired | |
private FakeUserDetailsService userDetailsService; | |
@Override | |
protected void configure(AuthenticationManagerBuilder auth) throws Exception { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
public class FakeUserDetailsService implements UserDetailsService { | |
@Autowired | |
private PessoaRepository personRepository; | |
@Override | |
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { | |
Pessoa person = personRepository.findByNome(username); | |
if (person == null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface PessoaRepository extends JpaRepository<Pessoa, Long> { | |
@Override | |
@PreAuthorize("hasRole('ROLE_ADMIN')") | |
Page<Pessoa> findAll(Pageable pageable); | |
@Override | |
@PostAuthorize("returnObject.nome == principal.username or hasRole('ROLE_ADMIN')") | |
Pessoa findOne(Long aLong); | |
@PreAuthorize("hasRole('ROLE_ADMIN')") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
@RepositoryEventHandler(Pessoa.class) | |
public class PessoaEventHandler { | |
@PreAuthorize("hasRole('ROLE_ADMIN')") | |
@HandleBeforeSave | |
public void checkPUTAuthority(Pessoa pessoa) { | |
// somente para verificação de segurança | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Bancos de Dados I | |
group: Banco | |
description[[Banco de Dados de exemplo do livro Sistemas de Bancos de Dados de Silberschatz | |
* a relação _emprestimo_ contém informações sobre empréstimos bancários. | |
a relação _tomador_ vincula os clientes aos empréstimos | |
* a relação _conta_ contém as informações sobre contas correntes. | |
a relação _depositante_ vincula os clientes às contas correntes | |
* a relação _cliente_ lista os dados dos clientes | |
]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- this is an example | |
group: tarefa1BD | |
funcionario = { | |
nome_func:string, rua:string, cidade:string | |
Marcos, "Rua A", Joinville | |
Joao, "Rua A", Joinville | |
Ricardo, "Rua C", Joinville |
OlderNewer