Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ src/main/resources/firebase/
skills/

*.env
*.json
*.json

test/ignored/
AGENTS.md
4 changes: 2 additions & 2 deletions src/main/java/br/com/acta/service/AlertaPrazoService.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void inserir() {
repo.gerarAlertasAtraso();
}

@PreAuthorize("authService.isProprioUsuario(#idUsuario)")
@PreAuthorize("@authService.isProprioUsuario(#idUsuario)")
@Transactional
public AlertaPrazoResponseDTO marcarLido(Long idTarefa, Long idAlerta, Long idUsuario){
authService.configurarUsuarioAtual();
Expand All @@ -61,4 +61,4 @@ public AlertaPrazoResponseDTO marcarLido(Long idTarefa, Long idAlerta, Long idUs
AlertaPrazo salvo = repo.save(alertaPrazo);
return mapper.toResponse(salvo);
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/br/com/acta/service/ColaboradorService.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public ColaboradorResponseDTO inserir(ColaboradorRequestDTO dto) {
return mapper.toResponse(salvo);
}

@PreAuthorize("hasRole('ADMIN') and authService.isColaboradorEmpresa(#id)")
@PreAuthorize("hasRole('ADMIN') and @authService.isColaboradorEmpresa(#id)")
@Override
@Transactional
public ColaboradorResponseDTO patch(Long id, Map<String, Object> campos) {
Expand All @@ -151,7 +151,7 @@ public ColaboradorResponseDTO patch(Long id, Map<String, Object> campos) {
return mapper.toResponse(salvo);
}

@PreAuthorize("hasRole('ADMIN') and authService.isColaboradorEmpresa(#id)")
@PreAuthorize("hasRole('ADMIN') and @authService.isColaboradorEmpresa(#id)")
@Override
@Transactional
public void excluir(Long id) {
Expand All @@ -170,4 +170,4 @@ public Colaborador getEntity(Long id) {
return repo.findByIdAndEmpresaId(id, atual().idEmpresa())
.orElseThrow(() -> new ModelNotFoundException("Colaborador", id));
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/br/com/acta/service/EmailService.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public List<EmailResponseDTO> buscarEmailsEmpresa(Long idEmpresa) {
return emailEmpresaMapper.toResponseList(emails);
}

@PreAuthorize("hasRole('ADMIN') and authService.isUsuarioByIdEmpresa(#idEmpresa)")
@PreAuthorize("hasRole('ADMIN') and @authService.isUsuarioByIdEmpresa(#idEmpresa)")
@Transactional
public EmailResponseDTO inserirEmailEmpresa(Long idEmpresa, EmailRequestDTO dto) {
authService.configurarUsuarioAtual();
Expand All @@ -54,7 +54,7 @@ public EmailResponseDTO inserirEmailEmpresa(Long idEmpresa, EmailRequestDTO dto)
return emailEmpresaMapper.toResponse(salvo);
}

@PreAuthorize("hasRole('ADMIN') and authService.isUsuarioByIdEmpresa(#idEmpresa)")
@PreAuthorize("hasRole('ADMIN') and @authService.isUsuarioByIdEmpresa(#idEmpresa)")
@Transactional
public void excluirEmailEmpresa(Long idEmpresa, Long idEmail) {
authService.configurarUsuarioAtual();
Expand Down Expand Up @@ -105,4 +105,4 @@ private EmailColaborador getEmailColaborador(Long idColaborador, Long idEmail) {
return emailColaboradorRepo.findByColaboradorIdAndId(colaborador.getId(), idEmail)
.orElseThrow(() -> new ModelNotFoundException("Email", idEmail));
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/br/com/acta/service/EmpresaService.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public EmpresaService(EmpresaRepository repo, EmpresaMapper mapper, EmailEmpresa
this.telefoneRepo = telefoneRepo;
}

@PreAuthorize("hasRole('ADMIN') and authService.isUsuarioByIdEmpresa(#id)")
@PreAuthorize("hasRole('ADMIN') and @authService.isUsuarioByIdEmpresa(#id)")
@Override
@Transactional
public EmpresaResponseDTO patch(Long id, Map<String, Object> campos) {
Expand Down Expand Up @@ -86,7 +86,7 @@ public List<EmpresaResponseDTO> buscar(TamanhoEmpresa tamanho){
return mapper.toResponseList(empresas);
}

@PreAuthorize("isAuthenticated() and authService.isUsuarioByIdEmpresa(#id)")
@PreAuthorize("isAuthenticated() and @authService.isUsuarioByIdEmpresa(#id)")
@Transactional(readOnly = true)
@Override
public EmpresaResponseDTO buscar(Long id) {
Expand Down Expand Up @@ -137,4 +137,4 @@ protected void antesInserir(Empresa empresa, EmpresaRequestDTO dto) {
public EmpresaResponseDTO inserir(EmpresaRequestDTO dto) {
return super.inserir(dto);
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/br/com/acta/service/EnderecoEmpresaService.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public List<EnderecoResponseDTO> buscarEndereco(Long idEmpresa) {
return enderecoMapper.toResponseList(enderecos);
}

@PreAuthorize("hasRole('ADMIN') and authService.isUsuarioByIdEmpresa(#idEmpresa)")
@PreAuthorize("hasRole('ADMIN') and @authService.isUsuarioByIdEmpresa(#idEmpresa)")
@Transactional
public EnderecoResponseDTO inserirEndereco(Long idEmpresa, EnderecoRequestDTO dto) {
authService.configurarUsuarioAtual();
Expand All @@ -49,7 +49,7 @@ public EnderecoResponseDTO inserirEndereco(Long idEmpresa, EnderecoRequestDTO dt
return enderecoMapper.toResponse(salvo);
}

@PreAuthorize("hasRole('ADMIN') and authService.isUsuarioByIdEmpresa(#idEmpresa)")
@PreAuthorize("hasRole('ADMIN') and @authService.isUsuarioByIdEmpresa(#idEmpresa)")
@Transactional
public void excluirEndereco(Long idEmpresa, Long idEndereco) {
authService.configurarUsuarioAtual();
Expand All @@ -62,4 +62,4 @@ private Endereco getEndereco(Long idEmpresa, Long idEndereco) {
return enderecoRepo.findByEmpresaAndId(empresa, idEndereco)
.orElseThrow(() -> new ModelNotFoundException("Endereco", idEndereco));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public PriorizacaoProblemaResponseDTO inserir(Long idProblema, PriorizacaoProble
}
}

@PreAuthorize("authService.isProprioUsuario(#idUsuario)")
@PreAuthorize("@authService.isProprioUsuario(#idUsuario)")
@Transactional
public PriorizacaoProblemaResponseDTO patch(Long idProblema, Long idUsuario, Map<String, Object> campos){
authService.configurarUsuarioAtual();
Expand Down Expand Up @@ -129,4 +129,4 @@ public ProblemaResponseDTO aplicarPeso(Long idProblema){
Problema salvo = problemaRepo.save(problema);
return problemaMapper.toResponse(salvo);
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/br/com/acta/service/TelefoneService.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public List<TelefoneResponseDTO> buscarTelefonesEmpresa(Long idEmpresa) {
return telefoneEmpresaMapper.toResponseList(telefones);
}

@PreAuthorize("hasRole('ADMIN') and authService.isUsuarioByIdEmpresa(#idEmpresa)")
@PreAuthorize("hasRole('ADMIN') and @authService.isUsuarioByIdEmpresa(#idEmpresa)")
@Transactional
public TelefoneResponseDTO inserirTelefoneEmpresa(Long idEmpresa, TelefoneRequestDTO dto) {
authService.configurarUsuarioAtual();
Expand All @@ -54,7 +54,7 @@ public TelefoneResponseDTO inserirTelefoneEmpresa(Long idEmpresa, TelefoneReques
return telefoneEmpresaMapper.toResponse(salvo);
}

@PreAuthorize("hasRole('ADMIN') and authService.isUsuarioByIdEmpresa(#idEmpresa)")
@PreAuthorize("hasRole('ADMIN') and @authService.isUsuarioByIdEmpresa(#idEmpresa)")
@Transactional
public void excluirTelefoneEmpresa(Long idEmpresa, Long idTelefone) {
authService.configurarUsuarioAtual();
Expand Down Expand Up @@ -105,4 +105,4 @@ private TelefoneColaborador getTelefoneColaborador(Long idColaborador, Long idTe
return telefoneColaboradorRepo.findByColaboradorIdAndId(colaborador.getId(), idTelefone)
.orElseThrow(() -> new ModelNotFoundException("Telefone", idTelefone));
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/br/com/acta/service/UsuarioCicloService.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public List<UsuarioCicloResponseDTO> buscarPorCiclo(Long idCiclo){
return mapper.toResponseList(usuarios);
}

@PreAuthorize("authService.isProprioUsuario(#idUsuario) or hasAnyRole('ADMIN', 'GESTOR') and authService.isUsuarioEmpresa(#idUsuario)")
@PreAuthorize("@authService.isProprioUsuario(#idUsuario) or hasAnyRole('ADMIN', 'GESTOR') and @authService.isUsuarioEmpresa(#idUsuario)")
@Transactional(readOnly = true)
public List<UsuarioCicloResponseDTO> buscarPorUsuario(Long idUsuario){
Usuario usuario = usuarioService.getEntity(idUsuario);
Expand Down Expand Up @@ -130,4 +130,4 @@ public void excluir(Long idUsuario, Long idCiclo){

repo.delete(usuarioCiclo);
}
}
}
12 changes: 6 additions & 6 deletions src/main/java/br/com/acta/service/UsuarioService.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public UsuarioService(EmpresaService empresaService, UsuarioRepository repo, Usu
this.metaRepo = metaRepo;
}

@PreAuthorize("authService.isProprioUsuario(#id) or hasAnyRole('ADMIN', 'GESTOR')")
@PreAuthorize("@authService.isProprioUsuario(#id) or hasAnyRole('ADMIN', 'GESTOR')")
@Override
@Transactional
public UsuarioResponseDTO patch(Long id, Map<String, Object> campos) {
Expand Down Expand Up @@ -75,7 +75,7 @@ public UsuarioResponseDTO patch(Long id, Map<String, Object> campos) {
return mapper.toResponse(usuario);
}

@PreAuthorize("authService.isProprioUsuario(#id) or hasAnyRole('ADMIN', 'GESTOR')")
@PreAuthorize("@authService.isProprioUsuario(#id) or hasAnyRole('ADMIN', 'GESTOR')")
@Transactional
public UsuarioResponseDTO excluirFoto(Long id) {
configurarUsuarioAtual();
Expand All @@ -89,7 +89,7 @@ public UsuarioResponseDTO excluirFoto(Long id) {
return mapper.toResponse(salvo);
}

@PreAuthorize("hasAnyRole('ADMIN', 'GESTOR') and authService.isUsuarioEmpresa(#idEmpresa)")
@PreAuthorize("hasAnyRole('ADMIN', 'GESTOR') and @authService.isUsuarioEmpresa(#idEmpresa)")
public List<UsuarioResponseDTO> buscar(Long idEmpresa, TipoUsuario tipo) {
List<Usuario> usuarios;

Expand All @@ -99,7 +99,7 @@ public List<UsuarioResponseDTO> buscar(Long idEmpresa, TipoUsuario tipo) {
return mapper.toResponseList(usuarios);
}

@PreAuthorize("authService.isUsuarioEmpresa(#id) and hasRole('ADMIN')")
@PreAuthorize("@authService.isUsuarioEmpresa(#id) and hasRole('ADMIN')")
@Override
@Transactional
public void excluir(Long id) {
Expand Down Expand Up @@ -134,7 +134,7 @@ public void excluir(Long id) {
repo.save(usuario);
}

@PreAuthorize("authService.isProprioUsuario(#id) or hasAnyRole('ADMIN', 'GESTOR')")
@PreAuthorize("@authService.isProprioUsuario(#id) or hasAnyRole('ADMIN', 'GESTOR')")
@Override
public UsuarioResponseDTO buscar(Long id) {
return super.buscar(id);
Expand All @@ -160,4 +160,4 @@ public Usuario getEntity(Long id) {
return repo.findByIdAndEmpresaId(id, atual().idEmpresa())
.orElseThrow(() -> new ModelNotFoundException("Usuário", id));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public UsuarioTreinamentoResponseDTO inserir(Long idTreinamento, UsuarioTreiname
}
}

@PreAuthorize("hasAnyRole('ADMIN', 'GESTOR') or authService.isProprioUsuario(#idUsuario)")
@PreAuthorize("hasAnyRole('ADMIN', 'GESTOR') or @authService.isProprioUsuario(#idUsuario)")
@Transactional
public UsuarioTreinamentoResponseDTO patchStatus(Long idTreinamento, Long idUsuario, StatusTreinamento status){
authService.configurarUsuarioAtual();
Expand Down Expand Up @@ -101,4 +101,4 @@ public void excluir(Long idTreinamento, Long idUsuario){

repo.delete(usuarioTreinamento);
}
}
}
Loading