From f23ac75a8effa7a2ebf96174e86f81e4e2968d19 Mon Sep 17 00:00:00 2001 From: x_z Date: Tue, 18 Oct 2022 22:02:56 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E9=AA=8C=E8=AF=81=E5=8C=BB?= =?UTF-8?q?=E9=99=A2=E5=AE=A2=E6=88=B7=E8=B4=A6=E5=8F=B7=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/info/PlatformController.java | 39 +++++++++++++++++++ .../udi/admin/entity/info/PlatformEntity.java | 10 ++++- .../req/info/PlatformUserInfoRequest.java | 27 +++++++++++++ .../admin/service/info/PlatformService.java | 10 +++++ 4 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/glxp/udi/admin/req/info/PlatformUserInfoRequest.java diff --git a/src/main/java/com/glxp/udi/admin/controller/info/PlatformController.java b/src/main/java/com/glxp/udi/admin/controller/info/PlatformController.java index 6206c42..23b039d 100644 --- a/src/main/java/com/glxp/udi/admin/controller/info/PlatformController.java +++ b/src/main/java/com/glxp/udi/admin/controller/info/PlatformController.java @@ -8,6 +8,7 @@ import com.glxp.udi.admin.common.res.BaseResponse; import com.glxp.udi.admin.entity.info.PlatformEntity; import com.glxp.udi.admin.entity.inout.UnitMaintainEntity; import com.glxp.udi.admin.req.info.PlatformLinkRequest; +import com.glxp.udi.admin.req.info.PlatformUserInfoRequest; import com.glxp.udi.admin.res.PageSimpleResponse; import com.glxp.udi.admin.res.info.PlatformLinkResponse; import com.glxp.udi.admin.service.info.PlatformService; @@ -64,6 +65,44 @@ public class PlatformController { return ResultVOUtils.success(pageSimpleResponse); } + /** + * 测试账号连通性 + * + * @return + */ + @AuthRuleAnnotation("") + @PostMapping("/udims/platform/testUserInfo") + public BaseResponse testUserInfo(@RequestBody PlatformUserInfoRequest platformUserInfoRequest, BindingResult bindingResult) { + if (bindingResult.hasErrors()) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); + } + + PlatformEntity platformEntity = platformService.getPlatformById(platformUserInfoRequest.getPlatformId()); + if (null == platformEntity || StrUtil.isBlank(platformEntity.getHost())) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); + } + + String url = platformEntity.getHost() + "/verify"; + Map map = new HashMap<>(); + map.put("username", platformUserInfoRequest.getUsername()); + map.put("password", platformUserInfoRequest.getPassword()); + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON_UTF8); + + HttpEntity request = new HttpEntity<>(JSON.toJSONString(map), headers); + RestTemplate restTemplate = new RestTemplate(); + log.error(url); + + String result = restTemplate.postForObject(url, request, String.class, map); + log.error(result); + Map object = JSON.parseObject(result, Map.class); + if (!String.valueOf(object.get("code")).equals("20000")) { + return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, String.valueOf(object.get("message"))); + } + return ResultVOUtils.success(); + } + @AuthRuleAnnotation("") @PostMapping("/udims/platform/link") public BaseResponse update(@RequestBody UnitMaintainEntity unitMaintainEntity) { diff --git a/src/main/java/com/glxp/udi/admin/entity/info/PlatformEntity.java b/src/main/java/com/glxp/udi/admin/entity/info/PlatformEntity.java index 87f4fb7..baad521 100644 --- a/src/main/java/com/glxp/udi/admin/entity/info/PlatformEntity.java +++ b/src/main/java/com/glxp/udi/admin/entity/info/PlatformEntity.java @@ -11,8 +11,14 @@ public class PlatformEntity { @TableId private String id; - private String name; //平台名称 + /** + * 平台名称 + */ + private String name; - private String host; //平台地址 + /** + * 平台地址 + */ + private String host; } diff --git a/src/main/java/com/glxp/udi/admin/req/info/PlatformUserInfoRequest.java b/src/main/java/com/glxp/udi/admin/req/info/PlatformUserInfoRequest.java new file mode 100644 index 0000000..a3c61dc --- /dev/null +++ b/src/main/java/com/glxp/udi/admin/req/info/PlatformUserInfoRequest.java @@ -0,0 +1,27 @@ +package com.glxp.udi.admin.req.info; + +import lombok.Data; + +/** + * 关联医院客户表单用户信息参数 + */ +@Data +public class PlatformUserInfoRequest { + + /** + * 自助平台地址 + */ + private String platformId; + + /** + * 用户名 + */ + private String username; + + /** + * 密码 + */ + private String password; + + +} diff --git a/src/main/java/com/glxp/udi/admin/service/info/PlatformService.java b/src/main/java/com/glxp/udi/admin/service/info/PlatformService.java index 66620e2..6a9576e 100644 --- a/src/main/java/com/glxp/udi/admin/service/info/PlatformService.java +++ b/src/main/java/com/glxp/udi/admin/service/info/PlatformService.java @@ -208,4 +208,14 @@ public class PlatformService { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); } } + + /** + * 根据ID查询自助平台信息 + * + * @param platformId + * @return + */ + public PlatformEntity getPlatformById(String platformId) { + return platformDao.selectById(platformId); + } }