|
@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
import com.tzld.piaoquan.risk.control.common.base.CommonResponse;
|
|
|
import com.tzld.piaoquan.risk.control.config.QywxConfig;
|
|
|
+import com.tzld.piaoquan.risk.control.model.po.UserBase;
|
|
|
+import com.tzld.piaoquan.risk.control.model.qywx.LoginStatusResultModel;
|
|
|
import com.tzld.piaoquan.risk.control.model.qywx.QwCommonResModel;
|
|
|
import com.tzld.piaoquan.risk.control.model.qywx.QwLoginCheckCode;
|
|
|
import com.tzld.piaoquan.risk.control.model.qywx.QwLoginQRCodeModel;
|
|
@@ -11,6 +13,7 @@ import com.tzld.piaoquan.risk.control.service.QwLoginService;
|
|
|
import com.tzld.piaoquan.risk.control.util.HttpClientUtil;
|
|
|
import com.tzld.piaoquan.risk.control.util.HttpPoolClient;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.http.util.TextUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -51,6 +54,17 @@ public class QwLoginController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/checkLogin")
|
|
|
+ public CommonResponse<String> checkLogin(@RequestBody QwLoginCheckCode checkCode) {
|
|
|
+ int ret = qwLoginService.checkQRCode(checkCode);
|
|
|
+ if(ret == 0) {
|
|
|
+ return CommonResponse.success();
|
|
|
+ } else {
|
|
|
+ LOGGER.error("checkQRCode failed, ret: {}", ret);
|
|
|
+ return CommonResponse.error("failed");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@PostMapping("/automaticLogin")
|
|
|
public CommonResponse<String> automaticLogin(@RequestBody QwLoginCheckCode checkCode) {
|
|
|
String url = qywxConfig.getDomain() + qywxConfig.getPath("login-qrcode");
|
|
@@ -62,26 +76,38 @@ public class QwLoginController {
|
|
|
@PostMapping("/quiteQwLogin")
|
|
|
public CommonResponse<String> quiteQwLogin(@RequestBody String uuid) {
|
|
|
String url = qywxConfig.getDomain() + qywxConfig.getPath("quit-login");
|
|
|
- String response = httpPoolClientDefault.postJson(url, uuid).toString();
|
|
|
- log.info("quiteLogin,response: {}", response);
|
|
|
- QwCommonResModel<QwLoginQRCodeModel> QRCODE = JSON.parseObject(response, new TypeReference<QwCommonResModel<QwLoginQRCodeModel>>() {});
|
|
|
- return CommonResponse.success();
|
|
|
-
|
|
|
+ Optional<String> response = httpPoolClientDefault.postJson(url, uuid);
|
|
|
+ boolean isSuccess = false;
|
|
|
+ if (response.isPresent()) {
|
|
|
+ QwCommonResModel<Object> model = QwCommonResModel.parseResponse(response.get(), Object.class);
|
|
|
+ isSuccess = model.getErrcode() == 0;
|
|
|
+ }
|
|
|
+ if (!isSuccess) {
|
|
|
+ LOGGER.error("quiteQwLogin failed, response: {}", response);
|
|
|
+ return CommonResponse.error("failed");
|
|
|
+ } else {
|
|
|
+ LOGGER.info("quiteQwLogin success, response: {}", response);
|
|
|
+ return CommonResponse.success("success");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@PostMapping("/checkLogin")//前端轮训检测是否登录成功
|
|
|
- public CommonResponse<String> checkLogin(@RequestBody String uuid) {
|
|
|
- if(true) {
|
|
|
- return new CommonResponse<>();
|
|
|
- } else if(false) {
|
|
|
- return CommonResponse.success();
|
|
|
+ public CommonResponse<LoginStatusResultModel> checkLogin(@RequestBody String uuid) {
|
|
|
+ UserBase user = qwLoginService.checkLogin(uuid);
|
|
|
+ LoginStatusResultModel model = new LoginStatusResultModel();
|
|
|
+ if (user != null && !TextUtils.isEmpty(user.getVid()) && user.getLoginStatus() == 1) {
|
|
|
+ model.setLoginStatus(1);
|
|
|
+ model.setMessage("success");
|
|
|
+ return CommonResponse.success(model);
|
|
|
+ } else if (user != null && user.getLoginStatus() == 0) {
|
|
|
+ model.setLoginStatus(1);
|
|
|
+ model.setMessage("processing");
|
|
|
+ return CommonResponse.success(model);
|
|
|
} else {
|
|
|
- return CommonResponse.success();
|
|
|
+ model.setLoginStatus(-1);
|
|
|
+ model.setMessage("failed");
|
|
|
+ return CommonResponse.success(model);
|
|
|
}
|
|
|
-// String url = Constant.QWDOMAIN + Constant.LOGIN_QRCODE_PATH;
|
|
|
-// String response = httpPoolClientDefault.postJson(url, uuid).toString();
|
|
|
-// QwLoginQRCodeModel QRCODE = JSON.parseObject(response, QwLoginQRCodeModel.class);
|
|
|
-// return CommonResponse.success("ok");
|
|
|
}
|
|
|
@PostMapping("/getRunClients")//获取运行中的实例
|
|
|
public CommonResponse<String> getRunClients() {
|