|
@@ -3,6 +3,7 @@ package com.ozs.controller.upload;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.ozs.common.core.domain.AjaxResult;
|
|
|
import com.ozs.common.core.domain.entity.SysDictData;
|
|
|
import com.ozs.common.utils.ApiTokenUtils;
|
|
|
import com.ozs.common.utils.AppendUtils;
|
|
@@ -160,20 +161,18 @@ public class GeoHazardMonitorTokenController {
|
|
|
@PostMapping("/api/token")
|
|
|
public String getWebToken(@RequestBody SvcAddress svcAddress) {
|
|
|
// 生成令牌
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
+ AjaxResult ajaxResult1=null;
|
|
|
if (ObjectUtils.isEmpty(svcAddress)) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "svcAddress参数不能为空");
|
|
|
- return JSONObject.toJSONString(jsonObject);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "svcAddress参数不能为空");
|
|
|
+ return JSONObject.toJSONString(ajaxResult1);
|
|
|
}
|
|
|
LambdaQueryWrapper<SvcAddress> lw = new LambdaQueryWrapper<SvcAddress>();
|
|
|
if (!ObjectUtils.isEmpty(svcAddress.getClientId())) {
|
|
|
lw.eq(SvcAddress::getClientId, svcAddress.getClientId());
|
|
|
lw.eq(SvcAddress::getEnv, env);
|
|
|
} else {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "客户端编号不能为空");
|
|
|
- return JSONObject.toJSONString(jsonObject);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "客户端编号不能为空");
|
|
|
+ return JSONObject.toJSONString(ajaxResult1);
|
|
|
}
|
|
|
SvcAddress serviceOne = svcAddressService.getOne(lw);
|
|
|
if (!ObjectUtils.isEmpty(serviceOne)) {
|
|
@@ -182,14 +181,12 @@ public class GeoHazardMonitorTokenController {
|
|
|
if (clientSecret.equals(sm4)) {
|
|
|
if (!ObjectUtils.isEmpty(svcAddress.getGrantType())) {
|
|
|
if (!svcAddress.getGrantType().toString().matches(PATTERNS)) {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "授权类型填写错误");
|
|
|
- return JSONObject.toJSONString(jsonObject);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "授权类型填写错误");
|
|
|
+ return JSONObject.toJSONString(ajaxResult1);
|
|
|
}
|
|
|
} else {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "授权类型不能为空");
|
|
|
- return JSONObject.toJSONString(jsonObject);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "授权类型不能为空");
|
|
|
+ return JSONObject.toJSONString(ajaxResult1);
|
|
|
}
|
|
|
ArrayList<String> objects = apiTokenUtils.createGeoHazardMonitorToken(svcAddress.getGrantType().toString(), svcAddress.getClientId(), sm4);
|
|
|
if (objects.size() > 0) {
|
|
@@ -198,24 +195,19 @@ public class GeoHazardMonitorTokenController {
|
|
|
Long l = Long.valueOf(objects.get(0));
|
|
|
respGeoHazardMonitorVo.setExpiresIn(l / 1000);
|
|
|
respGeoHazardMonitorVo.setTokenType("令牌类型");
|
|
|
- jsonObject.put("resultCode", 1);
|
|
|
- jsonObject.put("message", "ok");
|
|
|
- jsonObject.put("data", respGeoHazardMonitorVo);
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(jsonObject), sm4);
|
|
|
+ ajaxResult1 = new AjaxResult(1, "ok",respGeoHazardMonitorVo);
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(ajaxResult1), sm4);
|
|
|
} else {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "生成token失败");
|
|
|
- return JSONObject.toJSONString(jsonObject);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "生成token失败");
|
|
|
+ return JSONObject.toJSONString(ajaxResult1);
|
|
|
}
|
|
|
} else {
|
|
|
- jsonObject.put("resultCode", 2);
|
|
|
- jsonObject.put("message", "客户端密钥错误");
|
|
|
- return JSONObject.toJSONString(jsonObject);
|
|
|
+ ajaxResult1 = new AjaxResult(2, "客户端密钥错误");
|
|
|
+ return JSONObject.toJSONString(ajaxResult1);
|
|
|
}
|
|
|
} else {
|
|
|
- jsonObject.put("resultCode", 0);
|
|
|
- jsonObject.put("message", "参数验证失败");
|
|
|
- return JSONObject.toJSONString(jsonObject);
|
|
|
+ ajaxResult1 = new AjaxResult(0, "参数验证失败");
|
|
|
+ return JSONObject.toJSONString(ajaxResult1);
|
|
|
}
|
|
|
}
|
|
|
|