|
|
|
|
@ -1,24 +1,24 @@
|
|
|
|
|
package com.interplug.qcast.biz.login;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.http.HttpMethod;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.interplug.qcast.biz.login.dto.JoinUser;
|
|
|
|
|
import com.interplug.qcast.biz.login.dto.LoginUser;
|
|
|
|
|
import com.interplug.qcast.biz.login.dto.UserLoginResponse;
|
|
|
|
|
import com.interplug.qcast.biz.login.dto.UserPassword;
|
|
|
|
|
import com.interplug.qcast.biz.login.dto.UserResponse;
|
|
|
|
|
import com.interplug.qcast.config.Exception.ErrorCode;
|
|
|
|
|
import com.interplug.qcast.config.Exception.QcastException;
|
|
|
|
|
import com.interplug.qcast.config.message.Messages;
|
|
|
|
|
import com.interplug.qcast.util.DefaultResponse;
|
|
|
|
|
import com.interplug.qcast.util.InterfaceQsp;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.http.HttpMethod;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.interplug.qcast.biz.login.dto.JoinUser;
|
|
|
|
|
import com.interplug.qcast.biz.login.dto.LoginUser;
|
|
|
|
|
import com.interplug.qcast.biz.login.dto.UserLoginResponse;
|
|
|
|
|
import com.interplug.qcast.biz.login.dto.UserPassword;
|
|
|
|
|
import com.interplug.qcast.biz.login.dto.UserResponse;
|
|
|
|
|
import com.interplug.qcast.config.Exception.ErrorCode;
|
|
|
|
|
import com.interplug.qcast.config.Exception.QcastException;
|
|
|
|
|
import com.interplug.qcast.config.message.Messages;
|
|
|
|
|
import com.interplug.qcast.util.DefaultResponse;
|
|
|
|
|
import com.interplug.qcast.util.InterfaceQsp;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
@ -50,6 +50,12 @@ public class LoginService {
|
|
|
|
|
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
|
|
|
|
|
message.getMessage("common.message.required.data", "Password"));
|
|
|
|
|
|
|
|
|
|
loginUser.setAccsSiteCd("DESIGN");
|
|
|
|
|
loginUser.setActLog("LOGIN");
|
|
|
|
|
|
|
|
|
|
String sessionId = UUID.randomUUID().toString();
|
|
|
|
|
loginUser.setRequestId(sessionId);
|
|
|
|
|
|
|
|
|
|
UserLoginResponse userLoginResponse = null;
|
|
|
|
|
|
|
|
|
|
// QSP API Call..
|
|
|
|
|
@ -58,20 +64,51 @@ public class LoginService {
|
|
|
|
|
// /api/user/login
|
|
|
|
|
String strResponse =
|
|
|
|
|
interfaceQsp.callApi(HttpMethod.POST, qspUrl + "/api/user/login", loginUser);
|
|
|
|
|
if (!"".equals(strResponse)) {
|
|
|
|
|
ObjectMapper om =
|
|
|
|
|
new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
|
|
|
userLoginResponse = om.readValue(strResponse, UserLoginResponse.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (userLoginResponse != null
|
|
|
|
|
&& userLoginResponse.getResult() != null
|
|
|
|
|
&& "S".equalsIgnoreCase(userLoginResponse.getResult().getResultCode())) {
|
|
|
|
|
userLoginResponse.setSessionId(UUID.randomUUID().toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return userLoginResponse;
|
|
|
|
|
}
|
|
|
|
|
if (!"".equals(strResponse)) {
|
|
|
|
|
ObjectMapper om =
|
|
|
|
|
new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
|
|
|
userLoginResponse = om.readValue(strResponse, UserLoginResponse.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (userLoginResponse != null
|
|
|
|
|
&& userLoginResponse.getResult() != null
|
|
|
|
|
&& "S".equalsIgnoreCase(userLoginResponse.getResult().getResultCode())) {
|
|
|
|
|
userLoginResponse.setSessionId(sessionId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return userLoginResponse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 로그아웃 처리
|
|
|
|
|
*
|
|
|
|
|
* @param loginUser LoginUser
|
|
|
|
|
* @return DefaultResponse
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public DefaultResponse getLogout(LoginUser loginUser) throws Exception {
|
|
|
|
|
if (loginUser.getLoginId() == null || "".equals(loginUser.getLoginId()))
|
|
|
|
|
throw new QcastException(ErrorCode.INVALID_INPUT_VALUE,
|
|
|
|
|
message.getMessage("common.message.required.data", "Login Id"));
|
|
|
|
|
|
|
|
|
|
loginUser.setAccsSiteCd("DESIGN");
|
|
|
|
|
loginUser.setActLog("LOGOUT");
|
|
|
|
|
|
|
|
|
|
// QSP API Call..
|
|
|
|
|
// Q.CAST 로그아웃
|
|
|
|
|
// post
|
|
|
|
|
// /api/user/logout
|
|
|
|
|
DefaultResponse defaultResponse = null;
|
|
|
|
|
String strResponse =
|
|
|
|
|
interfaceQsp.callApi(HttpMethod.POST, qspUrl + "/api/user/logout", loginUser);
|
|
|
|
|
if (!"".equals(strResponse)) {
|
|
|
|
|
ObjectMapper om =
|
|
|
|
|
new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|
|
|
|
defaultResponse = om.readValue(strResponse, DefaultResponse.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return defaultResponse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UserResponse getUser(LoginUser loginUser) {
|
|
|
|
|
return loginMapper.getUser(loginUser);
|
|
|
|
|
|