diff --git a/service/src/main/java/com/hzya/frame/sysnew/application/api/dao/ISysApplicationApiDao.java b/service/src/main/java/com/hzya/frame/sysnew/application/api/dao/ISysApplicationApiDao.java index ab5ddcde..2ce1c113 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/application/api/dao/ISysApplicationApiDao.java +++ b/service/src/main/java/com/hzya/frame/sysnew/application/api/dao/ISysApplicationApiDao.java @@ -20,5 +20,8 @@ public interface ISysApplicationApiDao extends IBaseDao queryBaseName(SysApplicationApiEntity entity); + } diff --git a/service/src/main/java/com/hzya/frame/sysnew/application/api/dao/impl/SysApplicationApiDaoImpl.java b/service/src/main/java/com/hzya/frame/sysnew/application/api/dao/impl/SysApplicationApiDaoImpl.java index dc62c166..d9bdc7d7 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/application/api/dao/impl/SysApplicationApiDaoImpl.java +++ b/service/src/main/java/com/hzya/frame/sysnew/application/api/dao/impl/SysApplicationApiDaoImpl.java @@ -24,6 +24,12 @@ public class SysApplicationApiDaoImpl extends MybatisGenericDao queryBaseName(SysApplicationApiEntity entity) { + List o = (List) super.selectList(getSqlIdPrifx() + "queryBaseName", entity); + return o; + + } // 查询符合条件的数量 diff --git a/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiDto.java b/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiDto.java index 4de0d23b..f44126cd 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiDto.java +++ b/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiDto.java @@ -23,6 +23,12 @@ public class SysApplicationApiDto { private Long apiCode; /** Api接口地址(固定系统内部外放接口地址) */ private String apiPath; + /** bean名称 */ + private String beanName; + /** 方法名称 */ + private String funName; + /** 是否扩展api */ + private String extensionApi; public String getAppId() { return appId; } @@ -86,5 +92,29 @@ public class SysApplicationApiDto { public void setApiPath(String apiPath) { this.apiPath = apiPath; } + + public String getBeanName() { + return beanName; + } + + public void setBeanName(String beanName) { + this.beanName = beanName; + } + + public String getFunName() { + return funName; + } + + public void setFunName(String funName) { + this.funName = funName; + } + + public String getExtensionApi() { + return extensionApi; + } + + public void setExtensionApi(String extensionApi) { + this.extensionApi = extensionApi; + } } diff --git a/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiEntity.java b/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiEntity.java index bb861f1e..a027f07c 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiEntity.java +++ b/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiEntity.java @@ -54,6 +54,12 @@ public class SysApplicationApiEntity extends BaseEntity { private String bodyIn; /** Body 出参 JSON */ private String bodyOut; + /** bean名称 */ + private String beanName; + /** 方法名称 */ + private String funName; + /** 是否扩展api 1、启用 2、停用*/ + private String extensionApi; public String getApiStatus() { @@ -231,5 +237,29 @@ public class SysApplicationApiEntity extends BaseEntity { public void setApiPath(String apiPath) { this.apiPath = apiPath; } + + public String getBeanName() { + return beanName; + } + + public void setBeanName(String beanName) { + this.beanName = beanName; + } + + public String getFunName() { + return funName; + } + + public void setFunName(String funName) { + this.funName = funName; + } + + public String getExtensionApi() { + return extensionApi; + } + + public void setExtensionApi(String extensionApi) { + this.extensionApi = extensionApi; + } } diff --git a/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiEntity.xml b/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiEntity.xml index 53e163fe..9ddf15c8 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiEntity.xml +++ b/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiEntity.xml @@ -27,6 +27,9 @@ + + + @@ -58,7 +61,10 @@ ,body_in_type ,body_in ,body_out - ,sorts + ,bean_name + ,fun_name + ,extension_api + ,sorts ,create_user_id ,create_time ,modify_user_id @@ -92,6 +98,9 @@ a.body_in_type, a.body_in, a.body_out, + a.bean_name, + a.fun_name, + a.extension_api, a.sorts, a.create_user_id, a.create_time, @@ -143,6 +152,9 @@ WHERE and body_in_type = #{bodyInType} and body_in = #{bodyIn} and body_out = #{bodyOut} + and bean_name = #{beanName} + and fun_name = #{funName} + and extension_api = #{extensionApi} and sorts = #{sorts} and create_user_id = #{create_user_id} and create_time = #{create_time} @@ -188,6 +200,9 @@ WHERE and body_in_type = #{bodyInType} and body_in = #{bodyIn} and body_out = #{bodyOut} + and bean_name = #{beanName} + and fun_name = #{funName} + and extension_api = #{extensionApi} and sorts = #{sorts} and create_user_id = #{create_user_id} and create_time = #{create_time} @@ -244,6 +259,9 @@ WHERE and body_in_type like concat('%',#{bodyInType},'%') and body_in like concat('%',#{bodyIn},'%') and body_out like concat('%',#{bodyOut},'%') + and bean_name like concat('%',#{beanName},'%') + and fun_name like concat('%',#{funName},'%') + and extension_api like concat('%',#{extensionApi},'%') and sorts like concat('%',#{sorts},'%') and create_user_id like concat('%',#{create_user_id},'%') @@ -295,6 +313,9 @@ WHERE or body_in_type = #{bodyInType} or body_in = #{bodyIn} or body_out = #{bodyOut} + or bean_name = #{beanName} + or fun_name = #{funName} + or extension_api = #{extensionApi} or sorts = #{sorts} or create_user_id = #{create_user_id} or create_time = #{create_time} @@ -335,6 +356,9 @@ WHERE body_in_type , body_in , body_out , + bean_name , + fun_name , + extension_api , sorts , create_user_id , create_time , @@ -371,6 +395,9 @@ WHERE #{bodyInType} , #{bodyIn} , #{bodyOut} , + #{beanName} , + #{funName} , + #{extensionApi} , #{sorts} , #{create_user_id} , #{create_time} , @@ -389,11 +416,11 @@ WHERE insert into sys_application_api(api_status,api_code,api_path, app_id, catalogue_id, api_name, api_remark, need_Login, authentication_port, parameter_passing_mode, destination_address, request_coding, request_method, - timeout_period, current_limiting, header_in, query_in, body_in_type, body_in, body_out, sorts, create_user_id, + timeout_period, current_limiting, header_in, query_in, body_in_type, body_in, body_out, bean_name, fun_name, extension_api, sorts, create_user_id, create_time, modify_user_id, modify_time, sts, org_id, sts) values - (#{entity.apiStatus},#{entity.apiCode},#{entity.apiPath},#{entity.appId},#{entity.catalogueId},#{entity.apiName},#{entity.apiRemark},#{entity.needLogin},#{entity.authenticationPort},#{entity.parameterPassingMode},#{entity.destinationAddress},#{entity.requestCoding},#{entity.requestMethod},#{entity.timeoutPeriod},#{entity.currentLimiting},#{entity.headerIn},#{entity.queryIn},#{entity.bodyInType},#{entity.bodyIn},#{entity.bodyOut},#{entity.sorts},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id}, + (#{entity.apiStatus},#{entity.apiCode},#{entity.apiPath},#{entity.appId},#{entity.catalogueId},#{entity.apiName},#{entity.apiRemark},#{entity.needLogin},#{entity.authenticationPort},#{entity.parameterPassingMode},#{entity.destinationAddress},#{entity.requestCoding},#{entity.requestMethod},#{entity.timeoutPeriod},#{entity.currentLimiting},#{entity.headerIn},#{entity.queryIn},#{entity.bodyInType},#{entity.bodyIn},#{entity.bodyOut},#{entity.beanName},#{entity.funName},#{entity.extensionApi},#{entity.sorts},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id}, 'Y') @@ -401,11 +428,11 @@ WHERE insert into sys_application_api(api_status,api_code,api_path, app_id, catalogue_id, api_name, api_remark, need_Login, authentication_port, parameter_passing_mode, destination_address, request_coding, request_method, - timeout_period, current_limiting, header_in, query_in, body_in_type, body_in, body_out, sorts, create_user_id, + timeout_period, current_limiting, header_in, query_in, body_in_type, body_in, body_out,bean_name,fun_name,extension_api, sorts, create_user_id, create_time, modify_user_id, modify_time, sts, org_id) values - (#{entity.apiStatus},#{entity.apiCode},#{entity.apiPath},#{entity.appId},#{entity.catalogueId},#{entity.apiName},#{entity.apiRemark},#{entity.needLogin},#{entity.authenticationPort},#{entity.parameterPassingMode},#{entity.destinationAddress},#{entity.requestCoding},#{entity.requestMethod},#{entity.timeoutPeriod},#{entity.currentLimiting},#{entity.headerIn},#{entity.queryIn},#{entity.bodyInType},#{entity.bodyIn},#{entity.bodyOut},#{entity.sorts},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id}) + (#{entity.apiStatus},#{entity.apiCode},#{entity.apiPath},#{entity.appId},#{entity.catalogueId},#{entity.apiName},#{entity.apiRemark},#{entity.needLogin},#{entity.authenticationPort},#{entity.parameterPassingMode},#{entity.destinationAddress},#{entity.requestCoding},#{entity.requestMethod},#{entity.timeoutPeriod},#{entity.currentLimiting},#{entity.headerIn},#{entity.queryIn},#{entity.bodyInType},#{entity.bodyIn},#{entity.bodyOut},#{entity.beanName},#{entity.funName},#{entity.extensionApi},#{entity.sorts},#{entity.create_user_id},#{entity.create_time},#{entity.modify_user_id},#{entity.modify_time},#{entity.sts},#{entity.org_id}) on duplicate key update api_status = values(api_status), @@ -427,7 +454,10 @@ WHERE query_in = values(query_in), body_in_type = values(body_in_type), body_in = values(body_in), - body_out = values(body_out), + body_out = values(extension_api), + bean_name = values(bean_name), + fun_name = values(fun_name), + extension_api = values(extension_api), sorts = values(sorts), create_user_id = values(create_user_id), create_time = values(create_time), @@ -466,6 +496,9 @@ WHERE body_in_type = #{bodyInType}, body_in = #{bodyIn}, body_out = #{bodyOut}, + bean_name = #{beanName}, + fun_name = #{funName}, + extension_api = #{extensionApi}, sorts = #{sorts}, create_user_id = #{create_user_id}, create_time = #{create_time}, @@ -513,6 +546,9 @@ where id = #{id} and body_in_type = #{bodyInType} and body_in = #{bodyIn} and body_out = #{bodyOut} + and bean_name = #{beanName} + and fun_name = #{funName} + and extension_api = #{extensionApi} and sorts = #{sorts} and sts = #{sts} and sts='Y' @@ -673,6 +709,57 @@ where id = #{id} order by a.sorts asc + + - - SELECT count(*) from sys_application_api WHERE diff --git a/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiVo.java b/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiVo.java index a910d527..12009690 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiVo.java +++ b/service/src/main/java/com/hzya/frame/sysnew/application/api/entity/SysApplicationApiVo.java @@ -33,7 +33,12 @@ public class SysApplicationApiVo { private Long apiCode; /** Api接口地址(固定系统内部外放接口地址) */ private String apiPath; - + /** bean名称 */ + private String beanName; + /** 方法名称 */ + private String funName; + /** 是否扩展api */ + private String extensionApi; public Long getApiCode() { return apiCode; } @@ -129,5 +134,29 @@ public class SysApplicationApiVo { public void setApiStatus(String apiStatus) { this.apiStatus = apiStatus; } + + public String getBeanName() { + return beanName; + } + + public void setBeanName(String beanName) { + this.beanName = beanName; + } + + public String getFunName() { + return funName; + } + + public void setFunName(String funName) { + this.funName = funName; + } + + public String getExtensionApi() { + return extensionApi; + } + + public void setExtensionApi(String extensionApi) { + this.extensionApi = extensionApi; + } } diff --git a/service/src/main/java/com/hzya/frame/sysnew/application/entity/SysExtensionApiEntity.java b/service/src/main/java/com/hzya/frame/sysnew/application/entity/SysExtensionApiEntity.java new file mode 100644 index 00000000..90c7ed64 --- /dev/null +++ b/service/src/main/java/com/hzya/frame/sysnew/application/entity/SysExtensionApiEntity.java @@ -0,0 +1,39 @@ +package com.hzya.frame.sysnew.application.entity; + + +import java.util.Map; + +public class SysExtensionApiEntity { + + /** head */ + private Map headers; + /** query */ + private String querys; + /** body */ + private String bodys; + + public Map getHeaders() { + return headers; + } + + public void setHeaders(Map headers) { + this.headers = headers; + } + + public String getQuerys() { + return querys; + } + + public void setQuerys(String querys) { + this.querys = querys; + } + + public String getBodys() { + return bodys; + } + + public void setBodys(String bodys) { + this.bodys = bodys; + } +} + diff --git a/service/src/main/java/com/hzya/frame/sysnew/application/service/ISysApplicationService.java b/service/src/main/java/com/hzya/frame/sysnew/application/service/ISysApplicationService.java index a588a995..707622b3 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/application/service/ISysApplicationService.java +++ b/service/src/main/java/com/hzya/frame/sysnew/application/service/ISysApplicationService.java @@ -305,4 +305,39 @@ public interface ISysApplicationService extends IBaseService ids = sysMessageManageLogDao.querySysMessageManageLogIds(entity); PageInfo pageInfo = new PageInfo(ids); List sysMessageManageLogEntities = new ArrayList<>(); - if(ids != null && ids.size() > 0){ + if (ids != null && ids.size() > 0) { entity.setIds(ids); sysMessageManageLogEntities = sysMessageManageLogDao.queryListByErrorPageVo(entity); } @@ -1603,14 +1614,9 @@ public class SysApplicationServiceImpl extends BaseService headerMap = ServletUtil.getHeaderMap(request); - String querys = request.getQueryString(); + String oldbodys = ServletUtil.getBody(servletRequest); + Map oldheaderMap = ServletUtil.getHeaderMap(request); + String oldquerys = request.getQueryString(); //应用key String publicKey = request.getHeader("publicKey"); //应用密钥 @@ -1636,106 +1642,91 @@ public class SysApplicationServiceImpl extends BaseService sysApplicationEntities = sysApplicationDao.queryBase(sendApp); - //if (sysApplicationEntities == null || sysApplicationEntities.size() != 1) { - // return BaseResult.getFailureMessageEntity("系统错误请联系中台管理员,应用配置错误"); - //} - //sendApp = sysApplicationEntities.get(0); - SysApplicationEntity sendApp = getAppByPublicKeySecretKey(publicKey,secretKey); - if(sendApp == null ){ - return BaseResult.getFailureMessageEntity("系统错误请联系中台管理员,应用配置错误"); + + SysApplicationEntity sendApp = getAppByPublicKeySecretKey(publicKey, secretKey); + if (sendApp == null) { + return BaseResult.getFailureMessageEntity("系统错误请联系中台管理员,请联系管理员"); } //判断应用是否启用 if (sendApp.getAppStatus() == null || !"1".equals(sendApp.getAppStatus())) { - return BaseResult.getFailureMessageEntity("发送方应用未启用,请联系中台管理员"); + return BaseResult.getFailureMessageEntity(sendApp.getName()+"应用未启用,请联系管理员"); } - //判断应用接口是否启用 - //if(sendApp.getInterfaceStatus() == null || !"1".equals(sendApp.getInterfaceStatus())){ - // return BaseResult.getFailureMessageEntity("发送方应用接口未启用,请联系中台管理员"); - //} - //估计请求的appID和接口编码 查询具体发送的那个应用那个接口 - //SysApplicationEntity receiveApp = new SysApplicationEntity(); - //receiveApp.setSts("Y"); - //receiveApp.setAppId(Integer.valueOf(appId)); - //List receiveAppList = sysApplicationDao.queryBase(receiveApp); - //if (receiveAppList == null || receiveAppList.size() != 1) { - // return BaseResult.getFailureMessageEntity("系统错误请联系中台管理员,应用配置错误"); - //} - //receiveApp = receiveAppList.get(0); + + SysApplicationEntity receiveApp = getAppByAppId(appId); - if(receiveApp == null ){ - return BaseResult.getFailureMessageEntity("系统错误请联系中台管理员,应用配置错误"); + if (receiveApp == null) { + return BaseResult.getFailureMessageEntity("根据appId:"+appId+"未匹配到应用,请联系管理员"); } //判断应用是否启用 if (receiveApp.getAppStatus() == null || !"1".equals(receiveApp.getAppStatus())) { - return BaseResult.getFailureMessageEntity("接收方应用未启用,请联系中台管理员"); + return BaseResult.getFailureMessageEntity(receiveApp.getName()+"应用未启用,请联系管理员"); } //判断应用接口是否启用 if (receiveApp.getInterfaceStatus() == null || !"1".equals(receiveApp.getInterfaceStatus())) { - return BaseResult.getFailureMessageEntity("接收方应用接口未启用,请联系中台管理员"); + return BaseResult.getFailureMessageEntity(receiveApp.getName()+"应用接口环境未启用,请联系管理员"); } - //SysApplicationApiEntity receiveApi = new SysApplicationApiEntity(); - //receiveApi.setSts("Y"); - //receiveApi.setAppId(receiveApp.getId()); - //receiveApi.setApiCode(Long.parseLong(apiCode)); - //List receiveApiList = sysApplicationApiDao.queryBase(receiveApi); - //if (receiveApiList == null || receiveApiList.size() != 1) { - // return BaseResult.getFailureMessageEntity(receiveApp.getName() + ":" + apiCode + "未启用或者未创建"); - //} - //receiveApi = receiveApiList.get(0); - - SysApplicationApiEntity receiveApi = getApiByAppIdApiCode(receiveApp.getId(),apiCode); - if(receiveApi == null ){ - return BaseResult.getFailureMessageEntity(receiveApp.getName() + ":" + apiCode + "未启用或者未创建"); + SysApplicationApiEntity receiveApi = getApiByAppIdApiCode(receiveApp.getId(), apiCode); + if (receiveApi == null) { + return BaseResult.getFailureMessageEntity(receiveApp.getName() + ":" + apiCode + "未启用或者未创建"); } - //获取A应用请求过来的IP,校验B应用设置三方的ip白名单是否一致 - //SysApplicationApiAuthEntity sysApplicationApiAuthEntity = new SysApplicationApiAuthEntity(); - //sysApplicationApiAuthEntity.setSts("Y"); - //sysApplicationApiAuthEntity.setName(sendApp.getId()); - //sysApplicationApiAuthEntity.setAppId(receiveApp.getId()); - //sysApplicationApiAuthEntity.setSystemStatus("1"); - //List sysApplicationApiAuthEntities = sysApplicationApiAuthDao.queryByLike(sysApplicationApiAuthEntity); - //if (sysApplicationApiAuthEntities == null || sysApplicationApiAuthEntities.size() == 0) { - // return BaseResult.getFailureMessageEntity("接收方应用权限配置错误"); - //} - //for (int i = 0; i < sysApplicationApiAuthEntities.size(); i++) { - // if (sysApplicationApiAuthEntities.get(i).getSystemAddress() != null && !"".equals(sysApplicationApiAuthEntities.get(i).getSystemAddress()) - // && !sysApplicationApiAuthEntities.get(i).getSystemAddress().contains(ip)) { - // logger.error("发送方应用ip配置错误,ip为:" + ip); - // return BaseResult.getFailureMessageEntity("发送方应用ip配置错误"); - // } - //} - SysApplicationApiAuthEntity sysApplicationApiAuthEntity = getApiAuthByNameAppId(sendApp.getId(),receiveApp.getId()); - if(sysApplicationApiAuthEntity == null ){ - return BaseResult.getFailureMessageEntity("接收方应用权限配置错误"); + + SysApplicationApiAuthEntity sysApplicationApiAuthEntity = getApiAuthByNameAppId(sendApp.getId(), receiveApp.getId()); + if (sysApplicationApiAuthEntity == null) { + return BaseResult.getFailureMessageEntity(receiveApp.getName()+"应用权限配置错误"); } if (sysApplicationApiAuthEntity.getSystemAddress() != null && !"".equals(sysApplicationApiAuthEntity.getSystemAddress()) - && !sysApplicationApiAuthEntity.getSystemAddress().contains(ip)) { - logger.error("发送方应用ip配置错误,ip为:" + ip); - return BaseResult.getFailureMessageEntity("发送方应用ip配置错误"); + && !sysApplicationApiAuthEntity.getSystemAddress().contains(ip)) { + return BaseResult.getFailureMessageEntity(receiveApp.getName()+"发送应用"+receiveApp.getName()+"的ip白名单配置错误"); } - //判断接口是否授权第三方 - //SysApplicationApiAuthDetailEntity sysApplicationApiAuthDetailEntity = new SysApplicationApiAuthDetailEntity(); - //sysApplicationApiAuthDetailEntity.setSts("Y"); - //sysApplicationApiAuthDetailEntity.setAppId(receiveApp.getId()); - //sysApplicationApiAuthDetailEntity.setApiId(receiveApi.getId()); - //sysApplicationApiAuthDetailEntity.setStatusType("2"); - //sysApplicationApiAuthDetailEntity.setTripartiteSystemId(sysApplicationApiAuthEntities.get(0).getId()); - //List sysApplicationApiAuthDetailEntities = sysApplicationApiAuthDetailDao.queryBase(sysApplicationApiAuthDetailEntity); - //if (sysApplicationApiAuthDetailEntities == null || sysApplicationApiAuthDetailEntities.size() == 0) { - // return BaseResult.getFailureMessageEntity("发送方未关联应用方"); - //} - SysApplicationApiAuthDetailEntity sysApplicationApiAuthDetailEntity = getApiAuthDetailByAppIdApiIdTripartiteSystemId(receiveApp.getId(),receiveApi.getId(),sysApplicationApiAuthEntity.getId()); - if(sysApplicationApiAuthDetailEntity == null ){ - return BaseResult.getFailureMessageEntity("发送方未关联应用方"); + SysApplicationApiAuthDetailEntity sysApplicationApiAuthDetailEntity = getApiAuthDetailByAppIdApiIdTripartiteSystemId(receiveApp.getId(), receiveApi.getId(), sysApplicationApiAuthEntity.getId()); + if (sysApplicationApiAuthDetailEntity == null) { + saveLog(sendApp, receiveApp, receiveApi, oldbodys,null, oldheaderMap,null, null, oldquerys,null, null, jrff, fsqsj, fshsj,false); + return BaseResult.getFailureMessageEntity(receiveApi.getApiName()+"未授权给"+sendApp.getName()+",请联系管理员"); } + SysExtensionApiEntity sysExtensionApiEntity = new SysExtensionApiEntity(); + sysExtensionApiEntity.setHeaders(oldheaderMap); + sysExtensionApiEntity.setQuerys(oldquerys); + sysExtensionApiEntity.setBodys(oldbodys); + + //TODO 判断是否有内部api 是否扩展api 1、启用 2、停用 + if (receiveApi.getExtensionApi() != null && "1".equals(receiveApi.getExtensionApi()) + && receiveApi.getBeanName() != null && !"".equals(receiveApi.getBeanName()) + && receiveApi.getFunName() != null && !"".equals(receiveApi.getFunName()) + ) { + //获取类 + Object object = null; + try { + object = ApplicationContextUtil.getBeanByName(receiveApi.getBeanName()); + } catch (SecurityException e) { + + } + //获取类下面的方法 + Method[] methods = object.getClass().getMethods(); + if (methods == null || methods.length == 0) { + return BaseResult.getFailureMessageEntity("未找到内部方法,请联系管理员"); + } + for (Method m : methods) { + if (null != m) { + if (m.getName().equals(receiveApi.getFunName().trim())) { + try { + logger.info("invoke开始>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + sysExtensionApiEntity = (SysExtensionApiEntity) m.invoke(object, sysExtensionApiEntity); + logger.info("invoke结束>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); + } catch (Exception e) { + logger.error("invokeException{}", e.getMessage()); + return BaseResult.getFailureMessageEntity("内部方法执行错误,请联系管理员"); + } + } + } + } + + } + //TODO 判断是否有内部api + Map headerMap = sysExtensionApiEntity.getHeaders(); + String querys = sysExtensionApiEntity.getQuerys(); + String bodys = sysExtensionApiEntity.getBodys(); //设置参数获取参数 StringBuffer url = new StringBuffer(); url.append(receiveApp.getInterfaceAddress()); @@ -1769,7 +1760,7 @@ public class SysApplicationServiceImpl extends BaseService 0) { @@ -1799,7 +1790,7 @@ public class SysApplicationServiceImpl extends BaseService 0) { for (String key : headers.keySet()) { @@ -1860,7 +1851,7 @@ public class SysApplicationServiceImpl extends BaseService headerMap, Map headers, String querys, String body, long jrff, long fsqsj, long fshsj) { + private void saveLog(SysApplicationEntity sendApp, SysApplicationEntity receiveApp, SysApplicationApiEntity receiveApi, + String oldbodys,String bodys, + Map oldheaderMap,Map headerMap, + Map headers, + String oldquerys,String querys, + String body, long jrff, long fsqsj, long fshsj,boolean flag) { SysMessageManageLogEntity sysMessageManageLogEntity = new SysMessageManageLogEntity(); //messageManageId 消息主表主键 //theme 消息主题 @@ -1956,9 +1952,9 @@ public class SysApplicationServiceImpl extends BaseService st = Arrays.asList(new String[]{"8000060000"}); //{"orderNo":"DB1003108862178","ErrorCode":"","ResultString":"success","ResultInt":0} List rs = Arrays.asList(new String[]{"8000080005", "8000080000", "8000080002", "8000080004"}); //{"status":"success","data":"[{\\"pk_corp\\":\\"1015\\",\\"unitcode\\":\\"3401\\",\\"unitname\\":\\"hjx建设银行有限公司\\",\\"createdate\\":\\"2023-01-01\\",\\"deptattr\\":\\"1\\",\\"deptname\\":\\"API新增部门02\\",\\"deptcode\\":\\"DEV02\\",\\"pk_deptdoc\\":\\"1015A210000000001QJ7\\"}]","taskNumber":"202309110119"} - List ss = Arrays.asList(new String[]{"8000160014", "8000160015", "8000160016", "8000160017", "8000160021" , "8000160022" , "8000160023" , "8000160018", "8000160019","8000160020","8000160025","8000160026","8000160027","8000160029","8000160030"}); + List ss = Arrays.asList(new String[]{"8000160014", "8000160015", "8000160016", "8000160017", "8000160021", "8000160022", "8000160023", "8000160018", "8000160019", "8000160020", "8000160025", "8000160026", "8000160027", "8000160029", "8000160030"}); sysMessageManageLogEntity.setStatus("4");//返回信息 - - if(st.contains(receiveApi.getApiCode().toString())){ - if(JSONUtil.isTypeJSON(body)){ + sysMessageManageLogEntity.setRemark("转发失败");//返回信息 + if(!flag){ + sysMessageManageLogEntity.setStatus("4");//返回信息 + sysMessageManageLogEntity.setRemark("API未授权,请联系管理员");//返回信息 + }else if (st.contains(receiveApi.getApiCode().toString())) { + if (JSONUtil.isTypeJSON(body)) { JSONObject cheackdatas = JSONObject.parseObject(body); String checkdata = cheackdatas.getString("Success"); - if("true".equals(checkdata)){ + if ("true".equals(checkdata)) { sysMessageManageLogEntity.setStatus("3");//返回信息 + sysMessageManageLogEntity.setRemark("转发成功");//返回信息 + } } - }else if(rs.contains(receiveApi.getApiCode().toString())){ - if(JSONUtil.isTypeJSON(body)){ + } else if (rs.contains(receiveApi.getApiCode().toString())) { + if (JSONUtil.isTypeJSON(body)) { JSONObject cheackdatas = JSONObject.parseObject(body); String checkdata = cheackdatas.getString("ResultString"); - if("success".equals(checkdata)){ + if ("success".equals(checkdata)) { sysMessageManageLogEntity.setStatus("3");//返回信息 + sysMessageManageLogEntity.setRemark("转发成功");//返回信息 + } } - }else if(ss.contains(receiveApi.getApiCode().toString())){ - if(JSONUtil.isTypeJSON(body)){ + } else if (ss.contains(receiveApi.getApiCode().toString())) { + if (JSONUtil.isTypeJSON(body)) { JSONObject cheackdatas = JSONObject.parseObject(body); String checkdata = cheackdatas.getString("status"); - if("success".equals(checkdata)){ + if ("success".equals(checkdata)) { sysMessageManageLogEntity.setStatus("3");//返回信息 + sysMessageManageLogEntity.setRemark("转发成功");//返回信息 + } } - }else { + } else { sysMessageManageLogEntity.setStatus("3");//返回信息 + sysMessageManageLogEntity.setRemark("转发成功");//返回信息 + } //remark 备注 - long s1 = jrff - fsqsj; - long s2 = fsqsj - fshsj; - sysMessageManageLogEntity.setRemark("转发成功,发送前时间:" + s1 + "ms,发送时间:" + s2 + "ms");//返回信息 sysMessageManageLogEntity.setErrorStatus("2");//返回信息 sysMessageManageLogEntity.setId(UUIDUtils.getUUID()); sysMessageManageLogEntity.setCreate_user_id("c796fd9ba4c9f5ff3cc2fa41a040e443"); @@ -2027,4 +2031,88 @@ public class SysApplicationServiceImpl extends BaseService sysApplicationVos = sysApplicationDao.queryApp(entity); + PageInfo pageInfo = new PageInfo(sysApplicationVos); + return BaseResult.getSuccessMessageEntity("查询数据成功", pageInfo); + } + + /** + * @param object + * @return + * @Author lvleigang + * @Description 应用列表查询接口 多字段模糊查询,枚举类型字段转换 + * @Date 2:06 下午 2023/9/23 + **/ + @Override + public JsonResultEntity thirdInterfacequeryAppAll(JSONObject object) { + SysApplicationDto entity = getData("jsonStr", object, SysApplicationDto.class); + List sysApplicationVos = sysApplicationDao.queryApp(entity); + return BaseResult.getSuccessMessageEntity("查询数据成功", sysApplicationVos); + } + + /** + * @param object + * @return + * @Author lvleigang + * @Description 查询接口日志 查询接口发送错误,以及不发送的数据 + * @Date 2:08 下午 2023/9/23 + **/ + @Override + public JsonResultEntity thirdInterfacequeryAppApiLog(JSONObject object) { + SysMessageManageLogEntity entity = getData("jsonStr", object, SysMessageManageLogEntity.class); + //判断分页 + if (entity == null || entity.getPageNum() == null || entity.getPageSize() == null) { + return BaseResult.getFailureMessageEntity("分页查询参数不存在"); + } + //日期转换 + if (entity.getCreateTimeStart() != null) { + DateTime beginOfDay = DateUtil.beginOfDay(entity.getCreateTimeStart()); + entity.setCreateTimeStart(beginOfDay); + } + //日期转换 + if (entity.getCreateTimeEnd() != null) { + DateTime endOfDay = DateUtil.endOfDay(entity.getCreateTimeEnd()); + entity.setCreateTimeEnd(endOfDay); + } + PageHelper.startPage(entity.getPageNum(), entity.getPageSize()); + List ids = sysMessageManageLogDao.querySysMessageManageLogIds(entity); + PageInfo pageInfo = new PageInfo(ids); + List sysMessageManageLogEntities = new ArrayList<>(); + if (ids != null && ids.size() > 0) { + entity.setIds(ids); + sysMessageManageLogEntities = sysMessageManageLogDao.queryListByErrorPageVo(entity); + } + pageInfo.setList(sysMessageManageLogEntities); + return BaseResult.getSuccessMessageEntity("查询数据成功", pageInfo); + } + + /** + * @param object + * @return + * @Author lvleigang + * @Description 查询接口 + * @Date 2:08 下午 2023/9/23 + **/ + @Override + public JsonResultEntity thirdInterfacequeryAppApi(JSONObject object) { + SysApplicationApiEntity entity = getData("jsonStr", object, SysApplicationApiEntity.class); + List ids = sysApplicationApiDao.queryBaseName(entity); + return BaseResult.getSuccessMessageEntity("查询数据成功", ids); + } + } diff --git a/service/src/main/java/com/hzya/frame/sysnew/messageManageLog/service/ISysMessageManageLogService.java b/service/src/main/java/com/hzya/frame/sysnew/messageManageLog/service/ISysMessageManageLogService.java index 4e24697e..ac8ce4d9 100644 --- a/service/src/main/java/com/hzya/frame/sysnew/messageManageLog/service/ISysMessageManageLogService.java +++ b/service/src/main/java/com/hzya/frame/sysnew/messageManageLog/service/ISysMessageManageLogService.java @@ -58,4 +58,13 @@ public interface ISysMessageManageLogService extends IBaseService implement private final String bmApiCodexg = "8000160016";//部门档案修改 private final String bmApiCodesc = "8000160017";//部门档案删除 - private final String chApiCodexz = "8000160021";//存货对照新增 - private final String chApiCodexg = "8000160022";//存货对照修改 - private final String chApiCodesc = "8000160023";//存货对照删除 + private final String chApiCodexz = "8000160025";//存货对照新增 + private final String chApiCodexg = "8000160026";//存货对照修改 + private final String chApiCodesc = "8000160027";//存货对照删除 private final String ksApiCodexz = "8000160018";//客商辅助核算新增 private final String ksApiCodexg = "8000160019";//客商辅助核算修改