wangtuohang@126.com 3 тижнів тому
батько
коміт
2d94fd7c15

+ 23 - 7
src/main/java/org/springblade/modules/zf/controller/ZfController.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springblade.common.utils.ParamsConvert;
 import org.springblade.common.utils.ReflectUtil;
@@ -12,8 +13,9 @@ import org.springblade.core.http.util.HttpUtil;
 import org.springblade.core.redis.cache.BladeRedis;
 import org.springblade.modules.application.info.pojo.entity.ApplicationInfoEntity;
 import org.springblade.modules.application.info.service.IApplicationInfoService;
+import org.springblade.modules.log.pojo.entity.LogYysdEntity;
+import org.springblade.modules.log.service.ILogYysdService;
 import org.springblade.modules.zf.pojo.vo.*;
-import org.springblade.modules.zf.pojo.vo.credential.CredentialVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.transaction.annotation.Transactional;
@@ -28,6 +30,7 @@ import java.util.Map;
  * @author BladeX
  * @since 2024-10-15
  */
+@Slf4j
 @RestController
 @AllArgsConstructor
 @RequestMapping("zf")
@@ -41,25 +44,33 @@ public class ZfController extends BladeController {
 
 	private final IApplicationInfoService applicationInfoService;
 
+	private final ILogYysdService logService;
+
 	@PostMapping("/request")
 	public String request(@RequestBody RequestVO requestVO, @RequestHeader Map<String, String> headers) {
 		String activeProfile = env.getActiveProfiles()[0];
-		System.out.println("Active Profiles: " + activeProfile);
 		// 解析固定的请求格式
 		KeyValueVO keyValueVO = requestVO.getParameter().getCondition().getKeyValueList().get(0);
 		RequestCommonVO requestCommonVO = JSONObject.parseObject(keyValueVO.getValue(), RequestCommonVO.class);
 		// 拼装固定的返回格式
-		ResponseVO responseVO = new ResponseVO();
-		responseVO.getData().getDataList().add(new DataListVO());
+//		ResponseVO responseVO = new ResponseVO();
+//		responseVO.getData().getDataList().add(new DataListVO());
 //		FieldValuesVO fieldValuesVO = new FieldValuesVO();
 		if (activeProfile.equals("prod")) {
+//			CredentialVO userCredential = JSONObject.parseObject(headers.get("userCredential"), CredentialVO.class);
 			// 如果当前是三类区,需要验证用户凭证
-			CredentialVO userCredential = requestCommonVO.getUserCredential();
-			String result = HttpUtil.postJson("url", JSONObject.toJSONString(userCredential));
+//			CredentialVO userCredential = requestCommonVO.getUserCredential();
+//			String result = HttpUtil.postJson("url", JSONObject.toJSONString(userCredential));
+//			org.json.JSONObject jsonObject = new org.json.JSONObject(result);
+//			int code = (int) jsonObject.get("code");
+//			if (code != 0) {
+//				return "用户凭证校验失败";
+//			}
+			log.info("三类区判断");
 		}
 		QueryWrapper<ApplicationInfoEntity> queryWrapper = new QueryWrapper<>();
 		if ((requestCommonVO.getAppId() == null || requestCommonVO.getAppId() == -1L) && requestCommonVO.getMethodName().equals("token3")) {
-			queryWrapper.likeLeft("jkdz", ":6543/transpond/request");
+			queryWrapper.likeLeft("jkdz", ":3456/transpond/request");
 			queryWrapper.last("limit 1");
 		} else {
 			queryWrapper.eq("id", requestCommonVO.getAppId());
@@ -68,6 +79,11 @@ public class ZfController extends BladeController {
 		ApplicationInfoEntity appInfoEntity = applicationInfoService.getOne(queryWrapper);
 		// 调用
 		String result = HttpUtil.postJson(appInfoEntity.getJkdz(), headers, JSONObject.toJSONString(requestVO));
+		// 保存日志
+		LogYysdEntity logEntity = new LogYysdEntity();
+		logEntity.setRequestParams(JSONObject.toJSONString(requestCommonVO));
+		logEntity.setResponseBody(result);
+		logService.save(logEntity);
 //		fieldValuesVO.setValue(result);
 		// 返回结果
 //		responseVO.getData().getDataList().get(0).getFieldValues().add(fieldValuesVO);