resolved conflicts
This commit is contained in:
@@ -106,6 +106,8 @@ public class SecurityConfig {
|
||||
.requestMatchers("/saml2/**").permitAll() // SAML login initiation
|
||||
.requestMatchers("/swagger-ui/**").permitAll() // Swagger docs
|
||||
.requestMatchers("/v1/api-docs/**").permitAll() // API docs
|
||||
.requestMatchers("/v1/user/reset-password/initiate").permitAll()
|
||||
.requestMatchers("/v1/user/reset-password").permitAll()
|
||||
.anyRequest().authenticated())
|
||||
.sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.IF_REQUIRED))
|
||||
.exceptionHandling(exceptionHandling -> exceptionHandling
|
||||
|
||||
@@ -230,6 +230,8 @@ public class GepafinConstant {
|
||||
public static final String ATTEMPT_DATE = "attemptDate";
|
||||
public static final String LOGIN_ATTEMPTED_CREATED_SUCCESSFULLY="login_attempt_successfully_created";
|
||||
public static final String GET_LOGIN_ATTEMPT_MSG="get_login_attempt_se_msg";
|
||||
|
||||
public static final String CANNOT_DELETE_COMPANY_WITH_APPLICATION_SUBMITT = "application.in.submit.status.cannot.delete.company";
|
||||
public static final String GET_USERS_SUCCESS_MSG = "get.users.success.msg";
|
||||
public static final String CANNOT_CREATE_BENEFICIARY_USER="cannot.create.beneficiary.user";
|
||||
}
|
||||
|
||||
|
||||
@@ -2,25 +2,23 @@ package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.*;
|
||||
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
|
||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.FaqRepository;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
||||
import net.gepafin.tendermanagement.model.request.CompanyRequest;
|
||||
import net.gepafin.tendermanagement.model.response.CompanyResponse;
|
||||
import net.gepafin.tendermanagement.repositories.CompanyRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserWithCompanyRepository;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ForbiddenAccessException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@@ -35,13 +33,17 @@ public class CompanyDao {
|
||||
|
||||
@Autowired
|
||||
private UserWithCompanyRepository userWithCompanyRepository;
|
||||
@Autowired
|
||||
private ApplicationRepository applicationRepository;
|
||||
@Autowired
|
||||
private FaqRepository faqRepository;
|
||||
|
||||
|
||||
public CompanyResponse createCompany(UserEntity userEntity, CompanyRequest companyRequest) {
|
||||
CompanyEntity existingCompany = companyRepository.findByVatNumber(companyRequest.getVatNumber());
|
||||
UserWithCompanyEntity userWithCompanyEntity = null;
|
||||
if (existingCompany != null) {
|
||||
UserWithCompanyEntity existingRelation = userWithCompanyRepository.findByUserIdAndCompanyId(userEntity.getId(), existingCompany.getId())
|
||||
UserWithCompanyEntity existingRelation = userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), existingCompany.getId())
|
||||
.orElse(null);
|
||||
if (existingRelation == null) {
|
||||
userWithCompanyEntity = createUserWithCompanyRelation(userEntity, existingCompany, companyRequest.getIsLegalRepresentant());
|
||||
@@ -82,6 +84,7 @@ public class CompanyDao {
|
||||
if (userEntity.getBeneficiary() != null) {
|
||||
userWithCompanyEntity.setBeneficiaryId(userEntity.getBeneficiary().getId());
|
||||
}
|
||||
userWithCompanyEntity.setIsDeleted(Boolean.FALSE);
|
||||
userWithCompanyEntity.setCompanyId(companyEntity.getId());
|
||||
userWithCompanyEntity.setUserId(userEntity.getId());
|
||||
userWithCompanyEntity.setIsLegalRepresentant(isLegalRepresentant);
|
||||
@@ -177,27 +180,49 @@ public class CompanyDao {
|
||||
public void deleteCompany(UserEntity userEntity, Long companyId) {
|
||||
CompanyEntity companyEntity = validateCompany(companyId);
|
||||
companyRepository.delete(companyEntity);
|
||||
userWithCompanyRepository.deleteByCompanyId(companyId);
|
||||
userWithCompanyRepository.deleteByCompanyIdAndIsDeletedFalse(companyId);
|
||||
}
|
||||
|
||||
public List<CompanyResponse> getCompanyByUserId(Long userId) {
|
||||
UserEntity userEntity = userService.validateUser(userId);
|
||||
List<Long> companyIds = userWithCompanyRepository.findCompanyIdByUserId(userEntity.getId());
|
||||
List<CompanyEntity> list = companyRepository.findByIdIn(companyIds);
|
||||
return list.stream().map(companyEntity->{
|
||||
List<Long> activeCompanyIds = userWithCompanyRepository.findActiveCompanyIdsByUserId(userEntity.getId());
|
||||
List<CompanyEntity> companies = companyRepository.findByIdIn(activeCompanyIds);
|
||||
return companies.stream().map(companyEntity -> {
|
||||
UserWithCompanyEntity userWithCompanyEntity = getUserWithCompany(userEntity.getId(), companyEntity.getId());
|
||||
return convertCompanyEntityToCompanyResponse(companyEntity, userWithCompanyEntity);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
public UserWithCompanyEntity validateUserWithCompny(Long userId, Long companyId) {
|
||||
return userWithCompanyRepository.findByUserIdAndCompanyId(userId, companyId).orElseThrow(() -> new ForbiddenAccessException(Status.FORBIDDEN,
|
||||
return userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userId, companyId).orElseThrow(() -> new ForbiddenAccessException(Status.FORBIDDEN,
|
||||
Translator.toLocale(GepafinConstant.PERMISSION_DENIED)));
|
||||
}
|
||||
|
||||
public UserWithCompanyEntity getUserWithCompany(Long userId, Long compnayId) {
|
||||
return userWithCompanyRepository.findByUserIdAndCompanyId(userId, compnayId).orElseThrow(
|
||||
return userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userId, compnayId).orElseThrow(
|
||||
() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.USER_COMPANY_RELATION_NOT_FOUND)));
|
||||
}
|
||||
public void removeCompanyFromList(UserEntity userEntity, Long companyId) {
|
||||
CompanyEntity companyEntity = validateCompany(companyId);
|
||||
UserWithCompanyEntity existingRelation = userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), companyEntity.getId())
|
||||
.orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.USER_ALREADY_CONNECTED_TO_COMPANY)));
|
||||
List<ApplicationEntity> userApplications = applicationRepository.findByCompanyIdAndUserIdAndIsDeletedFalse(companyEntity.getId(), userEntity.getId());
|
||||
List<FaqEntity> faqs = faqRepository.findByCompanyIdAndUserIdAndIsDeletedFalse(companyEntity.getId(), userEntity.getId());
|
||||
for (ApplicationEntity application : userApplications) {
|
||||
if(Boolean.TRUE.equals(application.getStatus().equals(ApplicationStatusTypeEnum.SUBMIT.getValue()))) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST,Translator.toLocale(GepafinConstant.CANNOT_DELETE_COMPANY_WITH_APPLICATION_SUBMITT));
|
||||
}
|
||||
if(Boolean.TRUE.equals(application.getStatus().equals(ApplicationStatusTypeEnum.DRAFT.getValue()))) {
|
||||
application.setIsDeleted(Boolean.TRUE);
|
||||
applicationRepository.save(application);
|
||||
}
|
||||
}
|
||||
for(FaqEntity faq:faqs) {
|
||||
faq.setIsDeleted(Boolean.TRUE);
|
||||
faqRepository.save(faq);
|
||||
}
|
||||
existingRelation.setIsDeleted(Boolean.TRUE);
|
||||
userWithCompanyRepository.save(existingRelation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
import net.gepafin.tendermanagement.repositories.BeneficiaryRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.service.RoleService;
|
||||
import net.gepafin.tendermanagement.service.impl.AuthenticationService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
@@ -33,6 +34,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@@ -56,9 +58,12 @@ public class UserDao {
|
||||
|
||||
@Autowired
|
||||
private BeneficiaryRepository beneficiaryRepository;
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
|
||||
public JWTToken createUser(HttpServletRequest request, String tempToken, UserReq userReq) {
|
||||
|
||||
validateUserRequest(tempToken, userReq);
|
||||
validatePassword(userReq.getPassword(), userReq.getConfPassword(), tempToken);
|
||||
|
||||
@@ -95,6 +100,7 @@ public class UserDao {
|
||||
}
|
||||
|
||||
private void validateUserRequest(String tempToken, UserReq userReq) {
|
||||
RoleEntity role = roleService.validateRole(userReq.getRoleId());
|
||||
if (Boolean.FALSE.equals(Utils.isValidEmail(userReq.getEmail()))) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.VALIDATE_EMAIL));
|
||||
@@ -118,6 +124,10 @@ public class UserDao {
|
||||
if (tempToken != null) {
|
||||
userReq.setRoleId(null);
|
||||
}
|
||||
if(tempToken == null && Boolean.TRUE.equals(RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(role.getRoleType()))){
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.CANNOT_CREATE_BENEFICIARY_USER));
|
||||
}
|
||||
}
|
||||
|
||||
private void validatePassword(String password, String confirmPassword, String tempToken) {
|
||||
@@ -354,5 +364,23 @@ public class UserDao {
|
||||
return authService.validateNewUserToken(token);
|
||||
}
|
||||
|
||||
public List<UserResponseBean> getAllUsers(Long roleId) {
|
||||
List<UserEntity> users;
|
||||
if (roleId != null) {
|
||||
log.info("Fetching users by role ID: {}", roleId);
|
||||
RoleEntity roleEntity=roleService.validateRole(roleId);
|
||||
users = userRepository.findByRoleEntityId(roleEntity.getId());
|
||||
} else {
|
||||
log.info("Fetching all users");
|
||||
users = userRepository.findAll();
|
||||
}
|
||||
List<UserResponseBean> userResponseBeans = users.stream()
|
||||
.map(this::convertUserEntityToUserResponse)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
log.info("Total users found with role ID {}: {}", roleId, userResponseBeans.size());
|
||||
return userResponseBeans;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,4 +22,7 @@ public class UserWithCompanyEntity extends BaseEntity{
|
||||
@Column(name = "IS_LEGAL_REPRESENTANT")
|
||||
private Boolean isLegalRepresentant;
|
||||
|
||||
@Column(name = "IS_DELETED")
|
||||
private Boolean isDeleted = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
|
||||
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.status = 'DRAFT'")
|
||||
Long countDraftApplications();
|
||||
|
||||
List<ApplicationEntity> findByCompanyIdAndUserIdAndIsDeletedFalse(Long companyId,Long userId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -19,5 +19,6 @@ public interface FaqRepository extends JpaRepository<FaqEntity, Long> {
|
||||
List<FaqEntity> findByCallIdAndIsDeletedFalse(Long callId);
|
||||
|
||||
Optional<FaqEntity> findByIdAndCallIdAndIsDeletedFalse(Long id, Long callId);
|
||||
List<FaqEntity> findByCompanyIdAndUserIdAndIsDeletedFalse(Long companyId,Long userId);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
@@ -21,5 +23,5 @@ public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
||||
UserEntity findByBeneficiaryId(Long beneficiaryId);
|
||||
|
||||
Long countByStatusAndRoleEntity_RoleType(String status, String roleName);
|
||||
|
||||
List<UserEntity> findByRoleEntityId(Long roleId);
|
||||
}
|
||||
|
||||
@@ -12,11 +12,13 @@ import net.gepafin.tendermanagement.entities.UserWithCompanyEntity;
|
||||
|
||||
public interface UserWithCompanyRepository extends JpaRepository<UserWithCompanyEntity, Long> {
|
||||
|
||||
void deleteByCompanyId(Long companyId);
|
||||
void deleteByCompanyIdAndIsDeletedFalse(Long companyId);
|
||||
|
||||
@Query("SELECT uwc.companyId FROM UserWithCompanyEntity uwc WHERE uwc.userId = :userId")
|
||||
List<Long> findCompanyIdByUserId(@Param("userId") Long userId);
|
||||
@Query("SELECT u.companyId FROM UserWithCompanyEntity u WHERE u.userId = :userId AND u.isDeleted = false")
|
||||
List<Long> findActiveCompanyIdsByUserId(@Param("userId") Long userId);
|
||||
|
||||
Optional<UserWithCompanyEntity> findByUserIdAndCompanyId(Long userId, Long companyId);
|
||||
|
||||
|
||||
Optional<UserWithCompanyEntity> findByUserIdAndCompanyIdAndIsDeletedFalse(Long userId, Long companyId);
|
||||
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ public interface CompanyService {
|
||||
|
||||
void deleteCompanyDelegation(HttpServletRequest request, Long companyId);
|
||||
UserWithCompanyEntity getUserWithCompanyEntity(Long userId,Long companyId);
|
||||
void removeCompanyFromList(HttpServletRequest request, Long companyId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.RoleEntity;
|
||||
import net.gepafin.tendermanagement.model.request.RoleReq;
|
||||
import net.gepafin.tendermanagement.model.response.RoleResponseBean;
|
||||
|
||||
@@ -15,4 +16,5 @@ public interface RoleService {
|
||||
void deleteRole(Long roleId);
|
||||
|
||||
List<RoleResponseBean> getAllRoles();
|
||||
RoleEntity validateRole(Long roleId);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import net.gepafin.tendermanagement.model.response.UserSamlResponse;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserService {
|
||||
JWTToken createUser(HttpServletRequest request, String tempToken, UserReq userReq);
|
||||
|
||||
@@ -43,5 +45,6 @@ public interface UserService {
|
||||
UserEntity getUserByBeneficiaryId(Long beneficiaryId);
|
||||
|
||||
public UserEntity getUserEntityById(Long userId);
|
||||
List<UserResponseBean> getAllUsers(Long roleId);
|
||||
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class AuthenticationService {
|
||||
|
||||
public JWTToken login(LoginReq loginReq,HttpServletRequest request) {
|
||||
UserEntity user=null;
|
||||
try {
|
||||
|
||||
LoginAttemptEntity loginAttemptEntity = prepareLoginAttemptEntity(loginReq, request);
|
||||
log.info("Attempting login for email: {}", loginReq.getEmail());
|
||||
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(
|
||||
@@ -89,10 +89,6 @@ public class AuthenticationService {
|
||||
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG));
|
||||
}
|
||||
createSuccessLoginAttempt(loginAttemptEntity);
|
||||
} catch (Exception e) {
|
||||
|
||||
|
||||
}
|
||||
return getJWTTokenBean(user, loginReq.getRememberMe());
|
||||
}
|
||||
|
||||
|
||||
@@ -118,4 +118,10 @@ public class CompanyServiceImpl implements CompanyService {
|
||||
public UserWithCompanyEntity getUserWithCompanyEntity(Long userId,Long companyId){
|
||||
return companyDao.getUserWithCompany(userId,companyId);
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeCompanyFromList(HttpServletRequest request, Long companyId) {
|
||||
UserEntity userEntity =validator.validateUser(request);
|
||||
companyDao.removeCompanyFromList(userEntity, companyId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.service.impl;
|
||||
import java.util.List;
|
||||
|
||||
import net.gepafin.tendermanagement.dao.RoleDao;
|
||||
import net.gepafin.tendermanagement.entities.RoleEntity;
|
||||
import net.gepafin.tendermanagement.model.request.RoleReq;
|
||||
import net.gepafin.tendermanagement.model.response.RoleResponseBean;
|
||||
import net.gepafin.tendermanagement.service.RoleService;
|
||||
@@ -46,4 +47,10 @@ public class RoleServiceImpl implements RoleService {
|
||||
return roleDao.getAllRoles();
|
||||
|
||||
}
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public RoleEntity validateRole(Long roleId) {
|
||||
return roleDao.validateRole(roleId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
@@ -124,4 +125,10 @@ public class UserServiceImpl implements UserService {
|
||||
// Calling DAO Function
|
||||
return userDao.validateUser(userId);
|
||||
}
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<UserResponseBean> getAllUsers(Long roleId) {
|
||||
// Calling DAO Function
|
||||
return userDao.getAllUsers(roleId);
|
||||
}
|
||||
}
|
||||
@@ -142,5 +142,15 @@ public interface CompanyApi {
|
||||
@DeleteMapping(value = "{companyId}/delegation", produces = { "application/json" })
|
||||
ResponseEntity<Response<Void>> deleteCompanyDelegation(HttpServletRequest request,
|
||||
@Parameter(description = "The company id", required = true) @PathVariable("companyId") Long companyId);
|
||||
@Operation(summary = "Api to remove a company from user ", responses = { @ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@DeleteMapping(value = "user/{companyId}", produces = { "application/json" })
|
||||
ResponseEntity<Response<Void>> removeCompanyFromList(HttpServletRequest request,
|
||||
@Parameter(description = "The company id", required = true) @PathVariable("companyId") Long companyId);
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Validated
|
||||
public interface UserApi {
|
||||
@@ -219,8 +221,21 @@ public interface UserApi {
|
||||
ResponseEntity<Response<UserSamlResponse>> validateNewUserToken(HttpServletRequest request,
|
||||
@Parameter(description = "The spid token", required = true) @PathVariable("token") String token);
|
||||
|
||||
|
||||
|
||||
@Operation(summary = "Api to get all users",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
||||
@RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.GET)
|
||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||
ResponseEntity<Response<List<UserResponseBean>>> getAllUsers(
|
||||
@Parameter( required = false)@RequestParam(value ="roleId", required = false) Long roleId);
|
||||
|
||||
|
||||
@RequestMapping("favicon.ico")
|
||||
@ResponseBody
|
||||
void returnNoFavicon();
|
||||
|
||||
@@ -128,4 +128,12 @@ public class CompanyApiController implements CompanyApi{
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELEGATION_DELETE_SUCCESS)));
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<Response<Void>> removeCompanyFromList(HttpServletRequest request, Long companyId) {
|
||||
log.info("Api to remove a company from user's list");
|
||||
companyService.removeCompanyFromList(request, companyId);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.COMPANY_DELETE_SUCCESS_MSG)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/user}")
|
||||
@@ -139,7 +141,14 @@ public class UserApiController implements UserApi {
|
||||
UserSamlResponse data = userService.validateNewUserToken(request,token);
|
||||
return ResponseEntity.ok(new Response<>(data, Status.SUCCESS, Translator.toLocale(GepafinConstant.TOKEN_VALIDATE_SUCCESS_MSE)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<List<UserResponseBean>>> getAllUsers(
|
||||
Long roleId) {
|
||||
log.info("Get all Users by Role ID - Role ID: {}", roleId);
|
||||
List<UserResponseBean> users = userService.getAllUsers(roleId);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(users, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_USERS_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void returnNoFavicon() {
|
||||
|
||||
Reference in New Issue
Block a user