Browse Source

UsersResponseDTO.setEduCemadenOrganization AND UsersResponseDTO.setRolesProviderActivationKeys

main
ddangelorb 3 years ago
parent
commit
d0ac050614
  1. 8
      src/main/java/org/waterproofingdata/wpdauth/controller/UsersController.java
  2. 2
      src/main/java/org/waterproofingdata/wpdauth/dto/UsersResponseDTO.java
  3. 4
      src/main/java/org/waterproofingdata/wpdauth/repository/EduCemadenOrganizationsRepository.java
  4. 2
      src/main/java/org/waterproofingdata/wpdauth/service/UsersService.java

8
src/main/java/org/waterproofingdata/wpdauth/controller/UsersController.java

@ -78,8 +78,8 @@ public class UsersController {
@ApiResponse(code = 500, message = "Expired or invalid JWT token")})
public UsersResponseDTO search(@ApiParam("Username") @PathVariable String username) {
UsersResponseDTO urDTO = modelMapper.map(userService.search(username), UsersResponseDTO.class);
//urDTO.setEduCemadenOrganization(userService.findEduCemadenOrganizationById(urDTO.getId()));
//urDTO.setRolesProviderActivationKeys(userService.findRolesproviderActivationKeysById(urDTO.getId()));
urDTO.setEduCemadenOrganization(userService.findEduCemadenOrganizationById(urDTO.getId()));
urDTO.setRolesProviderActivationKeys(userService.findRolesproviderActivationKeysById(urDTO.getId()));
return urDTO;
}
@ -92,8 +92,8 @@ public class UsersController {
@ApiResponse(code = 500, message = "Expired or invalid JWT token")})
public UsersResponseDTO whoami(HttpServletRequest req) {
UsersResponseDTO urDTO = modelMapper.map(userService.whoami(req), UsersResponseDTO.class);
//urDTO.setEduCemadenOrganization(userService.findEduCemadenOrganizationById(urDTO.getId()));
//urDTO.setRolesProviderActivationKeys(userService.findRolesproviderActivationKeysById(urDTO.getId()));
urDTO.setEduCemadenOrganization(userService.findEduCemadenOrganizationById(urDTO.getId()));
urDTO.setRolesProviderActivationKeys(userService.findRolesproviderActivationKeysById(urDTO.getId()));
return urDTO;
}

2
src/main/java/org/waterproofingdata/wpdauth/dto/UsersResponseDTO.java

@ -22,11 +22,9 @@ public class UsersResponseDTO {
@ApiModelProperty(position = 2)
List<Roles> roles;
/*
@ApiModelProperty(position = 3)
EduCemadenOrganizations eduCemadenOrganization;
@ApiModelProperty(position = 4)
List<UsersRolesproviderActivationKey> rolesProviderActivationKeys;
*/
}

4
src/main/java/org/waterproofingdata/wpdauth/repository/EduCemadenOrganizationsRepository.java

@ -10,10 +10,10 @@ import org.waterproofingdata.wpdauth.model.EduCemadenOrganizations;
public interface EduCemadenOrganizationsRepository extends JpaRepository<EduCemadenOrganizations, Integer> {
EduCemadenOrganizations findByPhone(String phone);
@Query(value = "SELECT e.*, ueo.activationkey FROM educemaden_organizations e INNER JOIN users_educemaden_organizations ueo ON e.id = ueo.educemaden_organizations_id WHERE ueo.users_id = ?1;", nativeQuery = true)
@Query(value = "SELECT e.*, ueo.activationkey FROM educemaden_organizations e INNER JOIN users_educemaden_organizations ueo ON e.id = ueo.educemaden_organizations_id WHERE ueo.users_id = ?1", nativeQuery = true)
EduCemadenOrganizations findByUserId(Integer userid);
@Transactional
@Query(value = "INSERT INTO users_educemaden_organizations(id, users_id, educemaden_organizations_id, activationkey) VALUES (DEFAULT, ?1, ?2, ?3);", nativeQuery = true)
@Query(value = "INSERT INTO users_educemaden_organizations(id, users_id, educemaden_organizations_id, activationkey) VALUES (DEFAULT, ?1, ?2, ?3)", nativeQuery = true)
void insertUsersEduCemadenOrganizations(Integer userid, Integer eduCemadenOrganizationsid, String activationkey);
}

2
src/main/java/org/waterproofingdata/wpdauth/service/UsersService.java

@ -85,7 +85,7 @@ public class UsersService {
}
public EduCemadenOrganizations findEduCemadenOrganizationById(Integer userid) {
return eduCemadenOrganizationsRepository.findByUserId(userid);
return eduCemadenOrganizationsRepository.findByUserId(userid);
}
public List<UsersRolesproviderActivationKey> findRolesproviderActivationKeysById(Integer usersid) {

Loading…
Cancel
Save