Commit 0941f6f6 authored by 李成龙's avatar 李成龙

优化特种设备数据对接

parent c6affcf2
......@@ -7,72 +7,13 @@
<version>1.0.0</version>
</parent>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-data-common</artifactId>
<version>1.0.0</version>
<name>amos-boot-data-common</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
......@@ -9,31 +9,46 @@
<version>1.0.0</version>
</parent>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-data-openapi</artifactId>
<version>1.0.0</version>
<name>amos-boot-data-openapi</name>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId>
<version>${amos-biz-boot.version}</version>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-component-event</artifactId>
<artifactId>tyboot-core-foundation</artifactId>
<version>${tyboot-version}</version>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-restful</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-auth</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
......@@ -44,6 +59,17 @@
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-component-event</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-component-opendata</artifactId>
<version>${tyboot-version}</version>
<exclusions>
......@@ -53,11 +79,62 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-systemctl</artifactId>
<version>${amos.version}</version>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-config</artifactId>
<version>${amos.version}</version>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-rdbms</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-component-cache</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-redis</artifactId>
<version>1.4.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>19.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.codehaus.jettison</groupId>
<artifactId>jettison</artifactId>
<version>1.3.7</version>
</dependency>
</dependencies>
<build>
<plugins>
......
//package com.yeejoin.amos.api.openapi.aop;
//
//import javax.servlet.http.HttpServletRequest;
//
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Before;
//import org.aspectj.lang.annotation.Pointcut;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.core.annotation.Order;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//import org.typroject.tyboot.component.cache.Redis;
//import org.typroject.tyboot.core.auth.exception.AuthException;
//import org.typroject.tyboot.core.foundation.context.RequestContext;
//import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
//
//import com.yeejoin.amos.api.openapi.constant.Constant;
//import com.yeejoin.amos.api.openapi.face.model.BizTokenModel;
//import com.yeejoin.amos.component.feign.config.TokenOperation;
//
//@Aspect
//@Component
//@Order(value = 0)
//public class ControllerAop {
//
// @Autowired
// private RedisTemplate redisTemplate;
//
// @Pointcut("(execution(public * com.yeejoin.amos.api.openapi.controller..*(..))) ")
// public void userCache() {
//
// }
//
// @Before("userCache()")
// public void doBefore(JoinPoint joinPoint) {
// ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
// HttpServletRequest request = attributes.getRequest();
// // 不需要添加请求头的接口
// String[] url = new String[]{"/api/user/selectInfo", "/api/user/save/curCompany","/openapi/bizToken/applyToken","/openapi/bizToken/getAppId","/lift/upload","/lift/status","/lift/run","/lift/fault","/lift/video/preview"};
// // 获取请求路径
// for(String uri : url) {
// if(request.getRequestURI().indexOf(uri) != -1) {
// return;
// }
// }
// //TODO tyboot 框架拦截器已缓存数据
// String token = RequestContext.getToken();
// if (ValidationUtil.isEmpty(token)) {
// token = request.getParameterMap().get("access_token")[0];
// }
// if (token != null) {
// fillRequestContext(token);
// }
// boolean validToken = TokenOperation.refresh(token);
// if(!validToken) {
// throw new AuthException("请求未包含认证信息.");
// }
// }
//
//
// private void fillRequestContext(String token) {
// String tokenKey = Redis.genKey(Constant.TOKEN_PREFIX,token);
// BizTokenModel bizTokenModel = (BizTokenModel) redisTemplate.opsForValue().get(tokenKey);
// if(null == bizTokenModel) {
// throw new AuthException("请求未包含认证信息.");
// }
// String product = bizTokenModel.getProduct();
// String appKey = bizTokenModel.getAppKey();
// RequestContext.setToken(token);
// RequestContext.setProduct(product);
// RequestContext.setAppKey(appKey);
// }
//}
package com.yeejoin.amos.api.openapi.aop;
import javax.servlet.http.HttpServletRequest;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.typroject.tyboot.component.cache.Redis;
import org.typroject.tyboot.core.auth.exception.AuthException;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import com.yeejoin.amos.api.openapi.constant.Constant;
import com.yeejoin.amos.api.openapi.face.model.BizTokenModel;
import com.yeejoin.amos.component.feign.config.TokenOperation;
@Aspect
@Component
@Order(value = 0)
public class ControllerAop {
@Autowired
private RedisTemplate redisTemplate;
@Pointcut("(execution(public * com.yeejoin.amos.api.openapi.controller..*(..))) ")
public void userCache() {
}
@Before("userCache()")
public void doBefore(JoinPoint joinPoint) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
// 不需要添加请求头的接口
String[] url = new String[]{"/api/user/selectInfo", "/api/user/save/curCompany","/openapi/bizToken/applyToken","/openapi/bizToken/getAppId","/lift/upload","/lift/status","/lift/run","/lift/fault","/lift/video/preview"};
// 获取请求路径
for(String uri : url) {
if(request.getRequestURI().indexOf(uri) != -1) {
return;
}
}
//TODO tyboot 框架拦截器已缓存数据
String token = RequestContext.getToken();
if (ValidationUtil.isEmpty(token)) {
token = request.getParameterMap().get("access_token")[0];
}
if (token != null) {
fillRequestContext(token);
}
boolean validToken = TokenOperation.refresh(token);
if(!validToken) {
throw new AuthException("请求未包含认证信息.");
}
}
private void fillRequestContext(String token) {
String tokenKey = Redis.genKey(Constant.TOKEN_PREFIX,token);
BizTokenModel bizTokenModel = (BizTokenModel) redisTemplate.opsForValue().get(tokenKey);
if(null == bizTokenModel) {
throw new AuthException("请求未包含认证信息.");
}
String product = bizTokenModel.getProduct();
String appKey = bizTokenModel.getAppKey();
RequestContext.setToken(token);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
}
}
......@@ -57,7 +57,6 @@ import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
@RestController
@TycloudResource(module = "openapi", value = "csei")
@RequestMapping(value = "/csei")
@Api(tags = "csei-检验检测数据对接")
public class CseiController {
......
......@@ -48,7 +48,6 @@ import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
@RestController
@TycloudResource(module = "openapi", value = "cylinder")
@RequestMapping(value = "/cylinder")
@Api(tags = "cylinder-气瓶数据对接")
public class CylinderController {
......
......@@ -26,7 +26,6 @@ import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
@RestController
@TycloudResource(module = "openapi", value = "filestorage")
@RequestMapping(value = "/filestorage")
@Api(tags = "filestorage-上传附件数据对接")
public class FilesController {
......
......@@ -33,7 +33,6 @@ import net.sf.json.JSONObject;
* @version $Id: InspectionController.java, v 0.1 2021年11月8日 下午6:47:54 gwb Exp $
*/
@RestController
@TycloudResource(module = "openapi", value = "inspection")
@RequestMapping(value = "/v1/inspection")
@Api(tags = "inspection-特种设备检验对接")
public class InspectionController
......
......@@ -40,7 +40,6 @@ import net.sf.json.JSONObject;
* @version $Id: ElevatorStatusController.java, v 0.1 2021年9月28日 上午9:11:38 gwb Exp $
*/
@RestController
@TycloudResource(module = "openapi", value = "lift")
@RequestMapping(value = "/lift")
@Api(tags = "lift-电梯物联对接")
public class LiftController
......
......@@ -41,7 +41,6 @@ import net.sf.json.JSONObject;
* @version $Id: InspectionController.java, v 0.1 2021年11月8日 下午6:47:54 gwb Exp $
*/
@RestController
@TycloudResource(module = "openapi", value = "bizToken")
@RequestMapping(value = "/bizToken")
@Api(tags = "bizToken-企业数据对接票据管理")
public class OpenapiBizTokenController
......
spring.application.name=AMOS-API-OPENAPI-CYL
server.servlet.context-path=/openapicyl
spring.application.name=AMOS-API-OPENAPI
server.servlet.context-path=/openapi
server.port=11001
# jdbc_config
spring.datasource.url=jdbc:mysql://113.134.211.174:3308/amos_openapi_cylinder?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&serverTimezone=GMT%2B8
......
......@@ -8,7 +8,6 @@
</parent>
<artifactId>amos-boot-data</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<name>amos-boot-data</name>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment