1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| package cn.ray.gateway.center.interfaces;
import cn.ray.gateway.center.application.IRegisterManageService; import cn.ray.gateway.center.domain.register.model.vo.ApplicationInterfaceMethodVO; import cn.ray.gateway.center.domain.register.model.vo.ApplicationInterfaceVO; import cn.ray.gateway.center.domain.register.model.vo.ApplicationSystemVO; import cn.ray.gateway.center.infrastructure.common.Constants; import cn.ray.gateway.center.infrastructure.common.ResponseCode; import cn.ray.gateway.center.infrastructure.common.Result; import cn.ray.gateway.center.infrastructure.pojo.ApplicationSystem; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.dao.DuplicateKeyException; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController @RequestMapping("/wg/admin/register") public class RPCRegisterManage {
private Logger logger = LoggerFactory.getLogger(RPCRegisterManage.class);
@Resource private IRegisterManageService registerManageService;
@PostMapping(value = "registerApplication", produces = "application/json;charset=utf-8") public Result<Boolean> registerApplication(@RequestParam String systemId, @RequestParam String systemName, @RequestParam String systemType, @RequestParam String systemRegistry) { try { logger.info("注册应用服务 systemId:{}", systemId); ApplicationSystemVO applicationSystemVO = new ApplicationSystemVO(); applicationSystemVO.setSystemId(systemId); applicationSystemVO.setSystemName(systemName); applicationSystemVO.setSystemType(systemType); applicationSystemVO.setSystemRegistry(systemRegistry); registerManageService.registerApplication(applicationSystemVO); return new Result<>(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getInfo(), true); } catch (DuplicateKeyException e) { logger.warn("注册应用服务重复 systemId:{}", systemId, e); return new Result<>(ResponseCode.INDEX_DUP.getCode(), e.getMessage(), true); } catch (Exception e) { logger.error("注册应用服务失败 systemId:{}", systemId, e); return new Result<>(ResponseCode.UN_ERROR.getCode(), e.getMessage(), false); } }
@PostMapping(value = "registerApplicationInterface", produces = "application/json;charset=utf-8") public Result<Boolean> registerApplicationInterface(@RequestParam String systemId, @RequestParam String interfaceId, @RequestParam String interfaceName, @RequestParam String interfaceVersion) { try { logger.info("注册应用接口 systemId:{} interfaceId:{}", systemId, interfaceId); ApplicationInterfaceVO applicationInterfaceVO = new ApplicationInterfaceVO(); applicationInterfaceVO.setSystemId(systemId); applicationInterfaceVO.setInterfaceId(interfaceId); applicationInterfaceVO.setInterfaceName(interfaceName); applicationInterfaceVO.setInterfaceVersion(interfaceVersion); registerManageService.registerApplicationInterface(applicationInterfaceVO); return new Result<>(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getInfo(), true); } catch (DuplicateKeyException e) { logger.warn("注册应用接口重复 systemId:{} interfaceId:{}", systemId, interfaceId); return new Result<>(ResponseCode.INDEX_DUP.getCode(), e.getMessage(), true); } catch (Exception e) { logger.error("注册应用接口失败 systemId:{} interfaceId:{}", systemId, interfaceId, e); return new Result<>(ResponseCode.UN_ERROR.getCode(), e.getMessage(), false); } }
@PostMapping(value = "registerApplicationInterfaceMethod", produces = "application/json;charset=utf-8") public Result<Boolean> registerApplicationInterfaceMethod(@RequestParam String systemId, @RequestParam String interfaceId, @RequestParam String methodId, @RequestParam String methodName, @RequestParam String parameterType, @RequestParam String uri, @RequestParam String httpCommandType, @RequestParam Integer auth) { try { logger.info("注册应用接口方法 systemId:{} interfaceId:{} methodId:{}", systemId, interfaceId, methodId); ApplicationInterfaceMethodVO applicationInterfaceMethodVO = new ApplicationInterfaceMethodVO(); applicationInterfaceMethodVO.setSystemId(systemId); applicationInterfaceMethodVO.setInterfaceId(interfaceId); applicationInterfaceMethodVO.setMethodId(methodId); applicationInterfaceMethodVO.setMethodName(methodName); applicationInterfaceMethodVO.setParameterType(parameterType); applicationInterfaceMethodVO.setUri(uri); applicationInterfaceMethodVO.setHttpCommandType(httpCommandType); applicationInterfaceMethodVO.setAuth(auth); registerManageService.registerApplicationInterfaceMethod(applicationInterfaceMethodVO); return new Result<>(ResponseCode.SUCCESS.getCode(), ResponseCode.SUCCESS.getInfo(), true); } catch (DuplicateKeyException e) { logger.warn("注册应用接口方法重复 systemId:{} interfaceId:{} methodId:{}", systemId, interfaceId, methodId); return new Result<>(ResponseCode.INDEX_DUP.getCode(), e.getMessage(), true); } catch (Exception e) { logger.error("注册应用接口方法 systemId:{} interfaceId:{} methodId:{}", systemId, interfaceId, methodId, e); return new Result<>(ResponseCode.UN_ERROR.getCode(), e.getMessage(), false); } } }
|