|
|
|
@ -4,6 +4,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import com.mfsys.aconnect.client.dto.ThirdPartyUserDTO;
|
|
|
|
import com.mfsys.aconnect.client.dto.ThirdPartyUserDTO;
|
|
|
|
import com.mfsys.aconnect.configuration.config.WebClientConfig;
|
|
|
|
import com.mfsys.aconnect.configuration.config.WebClientConfig;
|
|
|
|
import com.mfsys.aconnect.usermanagement.dto.UserDTOs;
|
|
|
|
import com.mfsys.aconnect.usermanagement.dto.UserDTOs;
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.usermanagement.exceptions.EmailAlreadyExistException;
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.usermanagement.exceptions.UsernameAlreadyExistException;
|
|
|
|
|
|
|
|
import com.mfsys.aconnect.usermanagement.repository.UserRepository;
|
|
|
|
import com.mfsys.aconnect.usermanagement.model.Role;
|
|
|
|
import com.mfsys.aconnect.usermanagement.model.Role;
|
|
|
|
import com.mfsys.aconnect.usermanagement.service.UserService;
|
|
|
|
import com.mfsys.aconnect.usermanagement.service.UserService;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
@ -23,16 +26,25 @@ public class ThirdPartyUserService {
|
|
|
|
private final WebClientConfig webClientConfig;
|
|
|
|
private final WebClientConfig webClientConfig;
|
|
|
|
private final UserService userService;
|
|
|
|
private final UserService userService;
|
|
|
|
private final ObjectMapper objectMapper;
|
|
|
|
private final ObjectMapper objectMapper;
|
|
|
|
|
|
|
|
private final UserRepository userRepository;
|
|
|
|
|
|
|
|
|
|
|
|
public ThirdPartyUserService(WebClientConfig webClientConfig, UserService userService, ObjectMapper objectMapper){
|
|
|
|
public ThirdPartyUserService(WebClientConfig webClientConfig, UserService userService, ObjectMapper objectMapper, UserRepository userRepository){
|
|
|
|
this.webClientConfig = webClientConfig;
|
|
|
|
this.webClientConfig = webClientConfig;
|
|
|
|
this.userService = userService;
|
|
|
|
this.userService = userService;
|
|
|
|
this.objectMapper = objectMapper;
|
|
|
|
this.objectMapper = objectMapper;
|
|
|
|
|
|
|
|
this.userRepository = userRepository;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Object createThirdPartyUser(ThirdPartyUserDTO request, String token){
|
|
|
|
public Object createThirdPartyUser(ThirdPartyUserDTO request, String token){
|
|
|
|
String porOrgacode = request.getPorOrgacode();
|
|
|
|
String porOrgacode = request.getPorOrgacode();
|
|
|
|
String url = securityURI + "/security/user";
|
|
|
|
String url = securityURI + "/security/thirdParty/user";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (userRepository.existsByUserId(request.getSusUsercode())) {
|
|
|
|
|
|
|
|
throw new UsernameAlreadyExistException(porOrgacode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (userRepository.existsByEmail(request.getSusEmail())) {
|
|
|
|
|
|
|
|
throw new EmailAlreadyExistException(porOrgacode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> payloadMap = buildPayload(request);
|
|
|
|
Map<String, Object> payloadMap = buildPayload(request);
|
|
|
|
Map<String, Object> ciihiveRequest = buildCiihiveRequest(request, payloadMap);
|
|
|
|
Map<String, Object> ciihiveRequest = buildCiihiveRequest(request, payloadMap);
|
|
|
|
|