로그인, 로그아웃 추적
This commit is contained in:
parent
709b1f1f15
commit
60b84191c1
@ -59,6 +59,20 @@ public class LoginController {
|
||||
return loginService.getLogin(loginUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Q.CAST III에서 로그아웃한다.
|
||||
*
|
||||
* @param loginUser LoginUser
|
||||
* @return DefaultResponse
|
||||
* @throws Exception
|
||||
*/
|
||||
@Operation(description = "Q.CAST III에서 로그아웃한다.")
|
||||
@PostMapping("/v1.0/logout")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public DefaultResponse logout(@RequestBody LoginUser loginUser) throws Exception {
|
||||
return loginService.getLogout(loginUser);
|
||||
}
|
||||
|
||||
@PostMapping("/v1.0/user")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public UserResponse getUser(@RequestBody LoginUser loginUser) {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -6,4 +6,7 @@ import lombok.Data;
|
||||
public class LoginUser {
|
||||
private String loginId; // Login Id
|
||||
private String pwd; // Password
|
||||
private String accsSiteCd; // Access Site Code (QSP, QORDER, QMUSUBI_DESIGN, QREAD, QWARRANTY, QPARTNERS)
|
||||
private String actLog; // Action Log (LOGIN, AUTO_LOGIN, LOGOUT)
|
||||
private String requestId; // Request ID <= Unique ID
|
||||
}
|
||||
|
||||
@ -28,4 +28,6 @@ public class UserResponse {
|
||||
private String custNm;
|
||||
//시공사 번호
|
||||
private String builderNo;
|
||||
private String builderNm; // Builder Name
|
||||
private String builderId; // Builder Id
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user