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); + } }