Skip to content

Commit

Permalink
Merge pull request #53 from Integradorl-UdeA/feat/add-user-ldap
Browse files Browse the repository at this point in the history
Feat/add user ldap
  • Loading branch information
superpollo2 authored May 24, 2024
2 parents 6627ead + 4835efb commit 8524d94
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/consola/lis/model/enums/ItemState.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.consola.lis.model.enums;

import com.consola.lis.util.deserializer.ItemStateDeserializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

import java.util.ArrayList;
import java.util.List;

@JsonDeserialize(using = ItemStateDeserializer.class)
public enum ItemState {
AVAILABLE("Disponible"),
BROKEN("Averiado"),
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/consola/lis/model/enums/LoanState.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.consola.lis.model.enums;

import com.consola.lis.util.deserializer.LoanStateDeserializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

import java.util.ArrayList;
import java.util.List;

@JsonDeserialize(using = LoanStateDeserializer.class)
public enum LoanState {
ACTIVE ("Activo"),
RETURNED("Devuelto"),
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/consola/lis/model/enums/LoanType.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.consola.lis.model.enums;

import com.consola.lis.util.deserializer.LoanTypeDeserializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

import java.util.ArrayList;
import java.util.List;

@JsonDeserialize(using = LoanTypeDeserializer.class)
public enum LoanType {
GENERAL("General"),
BOOK ("Libro"),
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/consola/lis/model/enums/UserRole.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.consola.lis.model.enums;


import com.consola.lis.util.deserializer.UserRoleDeserializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

import java.util.ArrayList;
import java.util.List;

@JsonDeserialize(using = UserRoleDeserializer.class)
public enum UserRole {
ADMIN ("Administrador"),
AUXPROG ("Auxiliar de Programación"),
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/consola/lis/model/enums/WalletOwners.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.consola.lis.model.enums;


import com.consola.lis.util.deserializer.WalletOwnersDeserializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

import java.util.ArrayList;
import java.util.List;

@JsonDeserialize(using = WalletOwnersDeserializer.class)
public enum WalletOwners {
DIEGO_ALEJANDRO_BOTIA ("Diego Alejandro Botia"),
ANDRES_MARIN("Andres Marin"),
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/com/consola/lis/service/LoanService.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.consola.lis.model.repository.LoanRepository;
import com.consola.lis.util.exception.AlreadyExistsException;
import com.consola.lis.util.exception.IllegalParameterInRequest;
import com.consola.lis.util.exception.IsEmptyException;
import com.consola.lis.util.exception.NotExistingException;
import com.consola.lis.util.mapper.LoanMapper;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -100,11 +99,7 @@ public boolean existLoan(int loanId){
}

public List<Loan> getAllLoans() {
List<Loan> allLoans = loanRepository.findAll();
if(allLoans.isEmpty()){
throw new IsEmptyException("403", HttpStatus.FORBIDDEN, "No exists loans");
}
return allLoans;
return loanRepository.findAll();
}


Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/consola/lis/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ public UserLis getUser(String username) {


public AuthResponseDTO changeUserRole(String username, UserRole newRole) {

System.out.println("holi"+newRole.name());
UserLis user = userLisRepository.findByUsername(username).orElseThrow(()-> new NotExistingException("404", HttpStatus.NOT_FOUND, "the category whit id " + username + " not exist "));

user.setRole(newRole);
userLisRepository.save(user);

Expand Down

0 comments on commit 8524d94

Please sign in to comment.