parent
4932096ba3
commit
046cfe6f7c
@ -0,0 +1,85 @@
|
||||
package com.jiuyv.sptccc.agile.business.service.impl;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
import com.jcraft.jsch.SftpException;
|
||||
import com.jiuyv.sptccc.agile.common.utils.sftp.SFTPChannel;
|
||||
import com.jiuyv.sptccc.agile.common.utils.sftp.SshClientPool;
|
||||
|
||||
/**
|
||||
* 处理sftp文件
|
||||
*/
|
||||
@Component
|
||||
public class SftpFileServer {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SftpFileServer.class);
|
||||
|
||||
|
||||
/** 下载文件 */
|
||||
public boolean downloadSjztLinePassengerNonrtimeOfSftp(SshClientPool hostPool,SFTPChannel channel
|
||||
,HttpServletResponse response,String src) {
|
||||
try {
|
||||
ChannelSftp chSftp = channel.getChannelNew(hostPool.getSession());
|
||||
Long size = checkFileExistOfSftp(chSftp, src);
|
||||
if(size==null) {
|
||||
return false;
|
||||
}
|
||||
response.setHeader(HttpHeaders.CONTENT_LENGTH, size+"");
|
||||
chSftp.get(src, response.getOutputStream());
|
||||
chSftp.quit();
|
||||
return true;
|
||||
}catch(Exception e) {
|
||||
LOGGER.info("从sftp下载失败>>src={}",src, e);
|
||||
return false;
|
||||
}finally {
|
||||
channel.closeInnerChannel();
|
||||
hostPool.returnSession(channel.getSession());//不再关闭,直接返还连接
|
||||
}
|
||||
}
|
||||
private Long checkFileExistOfSftp(ChannelSftp chSftp,String src) {
|
||||
try {
|
||||
return chSftp.stat(src).getSize();
|
||||
} catch (SftpException e) {
|
||||
return null;//不存在忽略错误
|
||||
}
|
||||
}
|
||||
|
||||
/** 上传文件 */
|
||||
@Async
|
||||
public void uploadSjztLinePassengerNonrtimeOfSftp(SshClientPool hostPool,SFTPChannel channel
|
||||
,HttpServletResponse response,String src,File file) {
|
||||
try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(file))) {
|
||||
ChannelSftp chSftp = channel.getChannelNew(hostPool.getSession());
|
||||
autoMkdir(channel, src);//创建目录
|
||||
chSftp.put(in, src);
|
||||
chSftp.quit();
|
||||
}catch(Exception e) {
|
||||
LOGGER.info("上传到sftp失败>>src={}",src,e);
|
||||
}finally {
|
||||
channel.closeInnerChannel();
|
||||
hostPool.returnSession(channel.getSession());//不再关闭,直接返还连接
|
||||
file.deleteOnExit();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 自动创建目录
|
||||
* @param chSftp
|
||||
* @param dst
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void autoMkdir(SFTPChannel channel,String dst) throws Exception {
|
||||
//linux斜杠必须是 “/”
|
||||
channel.commitCurrShellCmd("mkdir -p '"+new File(dst).getParent().replace("\\", "/")+"/'");
|
||||
}
|
||||
}
|
6
sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/common/core/BaseManagerUtils.java → sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/common/BaseManagerUtils.java
6
sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/common/core/BaseManagerUtils.java → sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/common/BaseManagerUtils.java
2
sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/common/core/domain/BaseTime.java → sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/common/model/BaseTime.java
2
sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/common/core/domain/BaseTime.java → sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/common/model/BaseTime.java
@ -1,4 +1,4 @@
|
||||
package com.jiuyv.sptccc.agile.common.core.domain;
|
||||
package com.jiuyv.sptccc.agile.common.model;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
@ -0,0 +1,48 @@
|
||||
package com.jiuyv.sptccc.agile.common.utils.sftp;
|
||||
|
||||
import org.apache.commons.pool2.impl.GenericObjectPool;
|
||||
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
||||
|
||||
import com.jcraft.jsch.Session;
|
||||
import com.jiuyv.sptccc.agile.common.utils.sftp.model.SFTPConfig;
|
||||
|
||||
/**
|
||||
* ssh连接对象池
|
||||
*/
|
||||
public class SshClientPool {
|
||||
private GenericObjectPool<Session> pool;
|
||||
|
||||
public SshClientPool(SFTPConfig sshClientConfig){
|
||||
init(sshClientConfig);
|
||||
}
|
||||
|
||||
public void init(SFTPConfig sshClientConfig){
|
||||
SshClientFactory factory = new SshClientFactory(sshClientConfig);
|
||||
GenericObjectPoolConfig<Session> poolConfig = sshClientConfig.getPoolConfig();
|
||||
pool = new GenericObjectPool<>(factory, poolConfig!=null?poolConfig:new GenericObjectPoolConfig<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取会话
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public Session getSession() throws Exception{
|
||||
return pool.borrowObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* 归还会话
|
||||
* @param session
|
||||
*/
|
||||
public void returnSession(Session session){
|
||||
try {
|
||||
if (session != null){
|
||||
pool.returnObject(session);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//无需错误
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
package com.jiuyv.sptccc.agile.common.utils.sftp.model;
|
||||
|
||||
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
||||
|
||||
import com.jcraft.jsch.Session;
|
||||
|
||||
/**
|
||||
* sftp配置类
|
||||
* @author zhouliang
|
||||
*
|
||||
*/
|
||||
public class SFTPConfig implements java.io.Serializable{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主机ip
|
||||
*/
|
||||
private String host;
|
||||
/**
|
||||
* 端口
|
||||
*/
|
||||
private int port=22;
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* location
|
||||
*/
|
||||
private int location;
|
||||
|
||||
/** 连接池配置*/
|
||||
private transient GenericObjectPoolConfig<Session> poolConfig;
|
||||
|
||||
/**
|
||||
* @return the host
|
||||
*/
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param host the host to set
|
||||
*/
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the port
|
||||
*/
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param port the port to set
|
||||
*/
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the username
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param username the username to set
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the password
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param password the password to set
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the location
|
||||
*/
|
||||
public int getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param location the location to set
|
||||
*/
|
||||
public void setLocation(int location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the poolConfig
|
||||
*/
|
||||
public GenericObjectPoolConfig<Session> getPoolConfig() {
|
||||
return poolConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param poolConfig the poolConfig to set
|
||||
*/
|
||||
public void setPoolConfig(GenericObjectPoolConfig<Session> poolConfig) {
|
||||
this.poolConfig = poolConfig;
|
||||
}
|
||||
}
|
2
sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/common/utils/spring/SpringUtils.java → sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/framework/SpringUtils.java
2
sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/common/utils/spring/SpringUtils.java → sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/framework/SpringUtils.java
@ -1,4 +1,4 @@
|
||||
package com.jiuyv.sptccc.agile.common.utils.spring;
|
||||
package com.jiuyv.sptccc.agile.framework;
|
||||
|
||||
import org.springframework.aop.framework.AopContext;
|
||||
import org.springframework.beans.BeansException;
|
2
sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/common/config/ConsoleConfig.java → sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/framework/config/ConsoleConfig.java
2
sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/common/config/ConsoleConfig.java → sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-service/src/main/java/com/jiuyv/sptccc/agile/framework/config/ConsoleConfig.java
@ -1,4 +1,4 @@
|
||||
package com.jiuyv.sptccc.agile.common.config;
|
||||
package com.jiuyv.sptccc.agile.framework.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
@ -0,0 +1,55 @@
|
||||
package com.jiuyv.sptccc.agile.business.service.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.jiuyv.sptccc.agile.api.fegin.constants.WaringType;
|
||||
import com.jiuyv.sptccc.agile.api.fegin.dto.publicPhoneMsgLog.ReqSendWaringPhoneMsgDTO;
|
||||
import com.jiuyv.sptccc.agile.business.entity.vo.TblDatacenterTaskStatusVO;
|
||||
import com.jiuyv.sptccc.agile.common.core.domain.R;
|
||||
import com.jiuyv.sptccc.agile.fegin.PublicPhoneMsgLogFeignApix;
|
||||
|
||||
/**
|
||||
* 发送消息
|
||||
*/
|
||||
@Component
|
||||
public class SendSmsServer {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SendSmsServer.class);
|
||||
|
||||
|
||||
/** 数据中心同步任务失败消息模板 */
|
||||
public static final String CODE_SJZT_SYNC_TASK_ERROR_PHONE = "sjzt_sync_task_error_phone";
|
||||
|
||||
@Autowired
|
||||
private PublicPhoneMsgLogFeignApix publicPhoneMsgLogFeignApix;
|
||||
|
||||
/** 发送短信,异步忽略错误 */
|
||||
@Async
|
||||
public void sendMsgAsync(TblDatacenterTaskStatusVO taskStatus) {
|
||||
try {
|
||||
Map<String, String> msgMapParams = new HashMap<>();
|
||||
msgMapParams.put("taskNo", taskStatus.getTaskNo());
|
||||
msgMapParams.put("taskConditions", taskStatus.getTaskConditions());
|
||||
msgMapParams.put("taskTitle", taskStatus.getDatacenterTask().getTaskTitle());
|
||||
|
||||
ReqSendWaringPhoneMsgDTO msgvo = new ReqSendWaringPhoneMsgDTO();
|
||||
msgvo.setWaringType(WaringType.DS.getCode());
|
||||
msgvo.setMsgTemplateCode(CODE_SJZT_SYNC_TASK_ERROR_PHONE);
|
||||
msgvo.setMsgMapParams(msgMapParams );
|
||||
msgvo.setSysType("console");//portal/console
|
||||
R<Long> res = publicPhoneMsgLogFeignApix.sendWarningPhoneMsgLog(msgvo);
|
||||
if(!res.isSuccess()) {
|
||||
LOGGER.info("sms error>>{}",res.getMsg());//直接输出
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//忽略短信错误
|
||||
}
|
||||
}
|
||||
}
|
2
sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-sync/src/main/java/com/jiuyv/sptccc/agile/common/utils/SpringUtils.java → sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-sync/src/main/java/com/jiuyv/sptccc/agile/framework/SpringUtils.java
2
sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-sync/src/main/java/com/jiuyv/sptccc/agile/common/utils/SpringUtils.java → sptcc_agile_etl/src/agile-datacenter/src/trunk/agile-datacenter/agile-datacenter-sync/src/main/java/com/jiuyv/sptccc/agile/framework/SpringUtils.java
@ -1,4 +1,4 @@
|
||||
package com.jiuyv.sptccc.agile.common.utils;
|
||||
package com.jiuyv.sptccc.agile.framework;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
@ -0,0 +1,101 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<artifactId>agile-dms</artifactId>
|
||||
<groupId>com.jiuyv.sptcc.agile</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<artifactId>agile-dms-api</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.jiuyv.sptcc.agile</groupId>
|
||||
<artifactId>agile-common</artifactId>
|
||||
<version>${agile-common.version}</version>
|
||||
</dependency>
|
||||
<!-- SpringWeb模块 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 自定义验证注解 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--常用工具类 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- excel工具 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/easyexcel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>3.1.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-prepare-agent</id>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>default-report</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,51 @@
|
||||
//package com.jiuyv.sptcc.agile.api.data;
|
||||
//
|
||||
//
|
||||
//import com.jiuyv.sptcc.agile.dms.data.domain.dto.SqlConsoleDto;
|
||||
//import com.jiuyv.sptcc.agile.dms.data.domain.vo.SqlConsoleConnNumVo;
|
||||
//import com.jiuyv.sptcc.agile.dms.data.domain.vo.SqlConsoleResVo;
|
||||
//import com.jiuyv.sptccc.agile.common.core.domain.R;
|
||||
//import org.springframework.validation.annotation.Validated;
|
||||
//import org.springframework.web.bind.annotation.GetMapping;
|
||||
//import org.springframework.web.bind.annotation.PostMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestBody;
|
||||
//
|
||||
//public interface SqlConsoleApi {
|
||||
//
|
||||
// String PREFIX_PATH = "/public/agile-data";
|
||||
//
|
||||
// /**
|
||||
// * 运行SQL
|
||||
// *
|
||||
// * @param sqlConsoleDto
|
||||
// * @return
|
||||
// */
|
||||
// @PostMapping(PREFIX_PATH+"/run")
|
||||
// R<SqlConsoleResVo> sqlRun(@RequestBody @Validated SqlConsoleDto sqlConsoleDto);
|
||||
//
|
||||
// /**
|
||||
// * 停止SQL执行
|
||||
// *
|
||||
// * @param sqlConsoleDto SQL停止参数
|
||||
// * @return 成功响应的R对象
|
||||
// */
|
||||
// @PostMapping("/stop")
|
||||
// R<Object> stopSql(@RequestBody SqlConsoleDto sqlConsoleDto);
|
||||
//
|
||||
// /**
|
||||
// * 导出SQL查询结果
|
||||
// *
|
||||
// * @param sqlConsoleDto 导出参数
|
||||
// * @return 成功响应的R对象
|
||||
// */
|
||||
// @PostMapping("/export")
|
||||
// R<Object> exportQueryResult(@Validated @RequestBody SqlConsoleDto sqlConsoleDto);
|
||||
//
|
||||
// /**
|
||||
// * 获取数据库连接池连接数
|
||||
// *
|
||||
// * @return 包含连接数信息的R对象
|
||||
// */
|
||||
// @GetMapping("/connectNum")
|
||||
// R<SqlConsoleConnNumVo> getConnectNum();
|
||||
//}
|
@ -0,0 +1,134 @@
|
||||
package com.jiuyv.sptcc.agile.dms.common.core.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Entity基类
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public class BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 创建者姓名 */
|
||||
private String createByName;
|
||||
|
||||
/** 创建时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
/** 创建者id(或账户) */
|
||||
private String createBy;
|
||||
|
||||
/** 更新者姓名 */
|
||||
private String updateByName;
|
||||
|
||||
/** 更新者id(或账户) */
|
||||
private String updateBy;
|
||||
|
||||
/** 更新时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
/** 搜索值 */
|
||||
private String searchValue;
|
||||
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 请求参数 */
|
||||
private Map<String, Object> params;
|
||||
|
||||
/**
|
||||
* @return the createByName
|
||||
*/
|
||||
public String getCreateByName() {
|
||||
return createByName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param createByName the createByName to set
|
||||
*/
|
||||
public void setCreateByName(String createByName) {
|
||||
this.createByName = createByName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the updateByName
|
||||
*/
|
||||
public String getUpdateByName() {
|
||||
return updateByName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param updateByName the updateByName to set
|
||||
*/
|
||||
public void setUpdateByName(String updateByName) {
|
||||
this.updateByName = updateByName;
|
||||
}
|
||||
|
||||
public String getSearchValue() {
|
||||
return searchValue == null ? "" : searchValue;
|
||||
}
|
||||
|
||||
public void setSearchValue(String searchValue) {
|
||||
this.searchValue = searchValue;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
return createBy == null ? "" : createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
return updateBy == null ? "" : updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public Date getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(Date updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark == null ? "" : remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public Map<String, Object> getParams() {
|
||||
if (params == null) {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(Map<String, Object> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.jiuyv.sptcc.agile.dms;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration;
|
||||
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
* 启动程序
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@EnableFeignClients
|
||||
@EnableEurekaClient
|
||||
@EnableScheduling
|
||||
@EnableTransactionManagement
|
||||
@SpringBootApplication(exclude = {GroovyTemplateAutoConfiguration.class})
|
||||
@ImportResource({ "classpath:spring/applicationContext.xml" })//事务控制
|
||||
public class SptccConsoleApplication {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SptccConsoleApplication.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SptccConsoleApplication.class, args);
|
||||
LOGGER.info("(♥◠‿◠)ノ゙ 模块启动成功゙ \n"+
|
||||
" ___ ___ ___ \n"+
|
||||
" |\\ \\ |\\ \\ / /| \n"+
|
||||
" \\ \\ \\ \\ \\ \\/ / / \n"+
|
||||
" __ \\ \\ \\ \\ \\ / / \n"+
|
||||
" |\\ \\\\_\\ \\ \\/ / / \n"+
|
||||
" \\ \\________\\ __/ / / \n"+
|
||||
" \\|________| |\\___/ / \n"+
|
||||
" \\|___|/ \n"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
package com.jiuyv.sptcc.agile.dms;
|
||||
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
/**
|
||||
* web容器中进行部署
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public class SptccConsoleServletInitializer extends SpringBootServletInitializer {
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(SptccConsoleApplication.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.jiuyv.sptcc.agile.dms.common.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 匿名访问不鉴权注解
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Target({ ElementType.METHOD, ElementType.TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Anonymous
|
||||
{
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.jiuyv.sptcc.agile.dms.common.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 数据权限过滤注解
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface DataScope
|
||||
{
|
||||
/**
|
||||
* 部门表的别名
|
||||
*/
|
||||
String deptAlias() default "";
|
||||
|
||||
/**
|
||||
* 用户表的别名
|
||||
*/
|
||||
String userAlias() default "";
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.jiuyv.sptcc.agile.dms.common.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Excel注解集
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Excels
|
||||
{
|
||||
Excel[] value();
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.jiuyv.sptcc.agile.dms.common.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.jiuyv.sptcc.agile.dms.common.enums.BusinessType;
|
||||
import com.jiuyv.sptcc.agile.dms.common.enums.OperatorType;
|
||||
|
||||
/**
|
||||
* 自定义操作日志记录注解
|
||||
*
|
||||
* @author admin
|
||||
*
|
||||
*/
|
||||
@Target({ ElementType.PARAMETER, ElementType.METHOD })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Log
|
||||
{
|
||||
/**
|
||||
* 模块
|
||||
*/
|
||||
String title() default "";
|
||||
|
||||
/**
|
||||
* 功能
|
||||
*/
|
||||
BusinessType businessType() default BusinessType.OTHER;
|
||||
|
||||
/**
|
||||
* 操作人类别
|
||||
*/
|
||||
OperatorType operatorType() default OperatorType.MANAGE;
|
||||
|
||||
/**
|
||||
* 是否保存请求的参数
|
||||
*/
|
||||
boolean isSaveRequestData() default true;
|
||||
|
||||
/**
|
||||
* 是否保存响应的参数
|
||||
*/
|
||||
boolean isSaveResponseData() default true;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.jiuyv.sptcc.agile.dms.common.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
/**
|
||||
* 方法不需要输出日志时使用
|
||||
* @author zhouliang
|
||||
*
|
||||
*/
|
||||
@Target({ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface LogIgnore {
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.jiuyv.sptcc.agile.dms.common.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 忽略连续提交限制
|
||||
*
|
||||
* @author admin
|
||||
*
|
||||
*/
|
||||
@Inherited
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface NoRepeatSubmit
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.jiuyv.sptcc.agile.dms.common.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.jiuyv.sptcc.agile.dms.common.constant.CacheConstants;
|
||||
import com.jiuyv.sptcc.agile.dms.common.enums.LimitType;
|
||||
|
||||
/**
|
||||
* 限流注解
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface RateLimiter
|
||||
{
|
||||
/**
|
||||
* 限流key
|
||||
*/
|
||||
String key() default CacheConstants.RATE_LIMIT_KEY;
|
||||
|
||||
/**
|
||||
* 限流时间,单位秒
|
||||
*/
|
||||
int time() default 60;
|
||||
|
||||
/**
|
||||
* 限流次数
|
||||
*/
|
||||
int count() default 100;
|
||||
|
||||
/**
|
||||
* 限流类型
|
||||
*/
|
||||
LimitType limitType() default LimitType.DEFAULT;
|
||||
}
|
@ -0,0 +1,265 @@
|
||||
package com.jiuyv.sptcc.agile.dms.common.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 读取项目相关配置
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "console")
|
||||
public class ConsoleConfig {
|
||||
/** 项目名称 */
|
||||
private String name;
|
||||
|
||||
/** 版本 */
|
||||
private String version;
|
||||
|
||||
/** 版权年份 */
|
||||
private String copyrightYear;
|
||||
|
||||
/** 实例演示开关 */
|
||||
private boolean demoEnabled;
|
||||
|
||||
/** 上传路径 */
|
||||
private static String profile;
|
||||
|
||||
/** 获取地址开关 */
|
||||
private static boolean addressEnabled;
|
||||
|
||||
/** 验证码类型 */
|
||||
private static String captchaType;
|
||||
|
||||
private static String encryptKey;
|
||||
|
||||
private static String encryptIv;
|
||||
|
||||
private static String encryptDbIv;
|
||||
|
||||
/** 测试类标志,为了屏蔽一些远程结果 */
|
||||
private static boolean testFlag=false;
|
||||
|
||||
//密码过期时间,登陆前修改密码
|
||||
private static int passwordExpireDays=90;
|
||||
//密码快期天数提醒
|
||||
private static int passwordExpireReminderDays=7;
|
||||
//密码过期后,修改错误次数
|
||||
private static int passwordErrorNum=3;
|
||||
//登陆错误/密码修改错误锁定时间(分)
|
||||
private static int loginErrorLockTime=30;
|
||||
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getCopyrightYear() {
|
||||
return copyrightYear;
|
||||
}
|
||||
|
||||
public void setCopyrightYear(String copyrightYear) {
|
||||
this.copyrightYear = copyrightYear;
|
||||
}
|
||||
|
||||
public boolean isDemoEnabled() {
|
||||
return demoEnabled;
|
||||
}
|
||||
|
||||
public void setDemoEnabled(boolean demoEnabled) {
|
||||
this.demoEnabled = demoEnabled;
|
||||
}
|
||||
|
||||
public static String getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(String profile) {
|
||||
setProfile2(profile);
|
||||
}
|
||||
|
||||
public static void setProfile2(String profile) {
|
||||
ConsoleConfig.profile = profile;
|
||||
}
|
||||
|
||||
public static boolean isAddressEnabled() {
|
||||
return addressEnabled;
|
||||
}
|
||||
|
||||
public void setAddressEnabled(boolean addressEnabled) {
|
||||
setAddressEnabled2(addressEnabled);
|
||||
}
|
||||
|
||||
public static void setAddressEnabled2(boolean addressEnabled) {
|
||||
ConsoleConfig.addressEnabled = addressEnabled;
|
||||
}
|
||||
|
||||
public static String getCaptchaType() {
|
||||
return captchaType;
|
||||
}
|
||||
|
||||
public void setCaptchaType(String captchaType) {
|
||||
setCaptchaType2(captchaType);
|
||||
}
|
||||
|
||||
public static void setCaptchaType2(String captchaType) {
|
||||
ConsoleConfig.captchaType = captchaType;
|
||||
}
|
||||
|
||||
public static String getEncryptKey() {
|
||||
return encryptKey;
|
||||
}
|
||||
|
||||
public void setEncryptKey(String encryptKey) {
|
||||
setEncryptKey2(encryptKey);
|
||||
}
|
||||
|
||||
public static void setEncryptKey2(String encryptKey) {
|
||||
ConsoleConfig.encryptKey = encryptKey;
|
||||
}
|
||||
|
||||
public static String getEncryptIv() {
|
||||
return encryptIv;
|
||||
}
|
||||
|
||||
public void setEncryptIv(String encryptIv) {
|
||||
setEncryptIv2(encryptIv);
|
||||
}
|
||||
|
||||
public static void setEncryptIv2(String encryptIv) {
|
||||
ConsoleConfig.encryptIv = encryptIv;
|
||||
}
|
||||
|
||||
public static String getEncryptDbIv() {
|
||||
return encryptDbIv;
|
||||
}
|
||||
|
||||
public void setEncryptDbIv(String encryptDbIv) {
|
||||
setEncryptDbIv2(encryptDbIv);
|
||||
}
|
||||
public static void setEncryptDbIv2(String encryptDbIv) {
|
||||
ConsoleConfig.encryptDbIv = encryptDbIv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导入上传路径
|
||||
*/
|
||||
public static String getImportPath() {
|
||||
return getProfile() + "/import";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下载路径
|
||||
*/
|
||||
public static String getDownloadPath() {
|
||||
return getProfile() + "/download/";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传路径
|
||||
*/
|
||||
public static String getUploadPath() {
|
||||
return getProfile() + "/upload";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取随附文件上传路径
|
||||
*/
|
||||
public static String getUploadPath2() {
|
||||
return getProfile();
|
||||
}
|
||||
|
||||
|
||||
public static boolean getTestFlag() {
|
||||
return testFlag;
|
||||
}
|
||||
|
||||
public void setTestFlag(boolean testFlag) {
|
||||
setTestFlag2(testFlag);
|
||||
}
|
||||
public static void setTestFlag2(boolean testFlag) {
|
||||
ConsoleConfig.testFlag = testFlag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the passwordExpireDays
|
||||
*/
|
||||
public static int getPasswordExpireDays() {
|
||||
return passwordExpireDays;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param passwordExpireDays the passwordExpireDays to set
|
||||
*/
|
||||
public static void setPasswordExpireDays(int passwordExpireDays) {
|
||||
setPasswordExpireDays2(passwordExpireDays);
|
||||
}
|
||||
public static void setPasswordExpireDays2(int passwordExpireDays) {
|
||||
ConsoleConfig.passwordExpireDays = passwordExpireDays;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the passwordErrorNum
|
||||
*/
|
||||
public static int getPasswordErrorNum() {
|
||||
return passwordErrorNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param passwordErrorNum the passwordErrorNum to set
|
||||
*/
|
||||
public static void setPasswordErrorNum(int passwordErrorNum) {
|
||||
setPasswordErrorNum2(passwordErrorNum);
|
||||
}
|
||||
public static void setPasswordErrorNum2(int passwordErrorNum) {
|
||||
ConsoleConfig.passwordErrorNum = passwordErrorNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loginErrorLockTime
|
||||
*/
|
||||
public static int getLoginErrorLockTime() {
|
||||
return loginErrorLockTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param loginErrorLockTime the loginErrorLockTime to set
|
||||
*/
|
||||
public static void setLoginErrorLockTime(int loginErrorLockTime) {
|
||||
setLoginErrorLockTime2(loginErrorLockTime);
|
||||
}
|
||||
public static void setLoginErrorLockTime2(int loginErrorLockTime) {
|
||||
ConsoleConfig.loginErrorLockTime = loginErrorLockTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the passwordExpireReminderDays
|
||||
*/
|
||||
public static int getPasswordExpireReminderDays() {
|
||||
return passwordExpireReminderDays;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param passwordExpireReminderDays the passwordExpireReminderDays to set
|
||||
*/
|
||||
public static void setPasswordExpireReminderDays(int passwordExpireReminderDays) {
|
||||
setPasswordExpireReminderDays2(passwordExpireReminderDays);
|
||||
}
|
||||
public static void setPasswordExpireReminderDays2(int passwordExpireReminderDays) {
|
||||
ConsoleConfig.passwordExpireReminderDays = passwordExpireReminderDays;
|
||||
}
|
||||
}
|
@ -0,0 +1,169 @@
|
||||
package com.jiuyv.sptcc.agile.dms.common.config;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
import com.jiuyv.sptcc.agile.dms.common.utils.sm4.Sm4Util;
|
||||
import com.jiuyv.sptcc.agile.dms.common.utils.uuid.IdUtils;
|
||||
import com.jiuyv.sptcc.agile.dms.framework.security.model.OperationTokenSet;
|
||||
import com.jiuyv.sptcc.agile.dms.framework.security.model.TokenNode;
|
||||
|
||||
/**
|
||||
* 读取项目自定义相关配置,方便多处使用
|
||||
* @author Administrator
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "operationtoken")
|
||||
public class ConsoleOprTokenProperties {
|
||||
|
||||
/** 操作令牌标识(放具体值) */
|
||||
private String headerVal="tokenSet";
|
||||
|
||||
/** 操作令牌标识 */
|
||||
private String header="operationToken";
|
||||
|
||||
/** 操作令牌标识 */
|
||||
private String headerKey="operationTokenKey";
|
||||
|
||||
/** 操作令牌次数 */
|
||||
private Integer tokenTimes=100;
|
||||
|
||||
/** 操作令牌跳过的url */
|
||||
private List<String> skipUrls;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
Assert.notNull(tokenTimes, "openrationtToken times null");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the headerVal
|
||||
*/
|
||||
public String getHeaderVal() {
|
||||
return headerVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param headerVal the headerVal to set
|
||||
*/
|
||||
public void setHeaderVal(String headerVal) {
|
||||
this.headerVal = headerVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the header
|
||||
*/
|
||||
public String getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param header the header to set
|
||||
*/
|
||||
public void setHeader(String header) {
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the headerKey
|
||||
*/
|
||||
public String getHeaderKey() {
|
||||
return headerKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param headerKey the headerKey to set
|
||||
*/
|
||||
public void setHeaderKey(String headerKey) {
|
||||
this.headerKey = headerKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tokenTimes
|
||||
*/
|
||||
public Integer getTokenTimes() {
|
||||
return tokenTimes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tokenTimes the tokenTimes to set
|
||||
*/
|
||||
public void setTokenTimes(Integer tokenTimes) {
|
||||
this.tokenTimes = tokenTimes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the skipUrls
|
||||
*/
|
||||
public List<String> getSkipUrls() {
|
||||
return skipUrls;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param skipUrls the skipUrls to set
|
||||
*/
|
||||
public void setSkipUrls(List<String> skipUrls) {
|
||||
this.skipUrls = skipUrls;
|
||||
}
|
||||
|
||||
|
||||
//加密token
|
||||
public String encryptToken(String token, String sm4Key) throws Exception {
|
||||
return Base64.encodeBase64String(Sm4Util.encrypt_ECB_Padding(sm4Key.getBytes(Charsets.UTF_8), token.getBytes(Charsets.UTF_8)));
|
||||
}
|
||||
|
||||
//解密token
|
||||
public String decryptToken(String token, String sm4Key) throws Exception {
|
||||
return Base64.encodeBase64String(Sm4Util.decrypt_ECB_Padding(Hex.decodeHex(sm4Key), Base64.decodeBase64(token)));
|
||||
}
|
||||
|
||||
public ImmutablePair<TokenNode, String> calculateNewToken(HttpServletRequest request) throws Exception {
|
||||
//
|
||||
String sm4key = IdUtils.fastSimpleUUID().substring(0, 16);
|
||||
String hexSm4Key = Hex.encodeHexString(sm4key.getBytes(Charsets.UTF_8));
|
||||
//token
|
||||
String newToken = IdUtils.fastSimpleUUID().substring(0, 16);
|
||||
String encryptToken = this.encryptToken(newToken, sm4key);
|
||||
TokenNode newNode = new TokenNode(encryptToken, newToken, hexSm4Key, sm4key, tokenTimes);
|
||||
|
||||
// String tokenSetStr = String.valueOf(request.getSession().getAttribute(this.headerVal));
|
||||
// OperationTokenSet set = JsonUtil.json2Bean(tokenSetStr, OperationTokenSet.class);
|
||||
OperationTokenSet set = (OperationTokenSet) request.getSession().getAttribute(this.headerVal);
|
||||
if (null == set) {
|
||||
set = new OperationTokenSet(newNode, sm4key);
|
||||
// request.getSession().setAttribute(this.headerVal, JsonUtil.toJSONString(set));
|
||||
request.getSession().setAttribute(this.headerVal, set);
|
||||
} else {
|
||||
set.getCurNode().setTimes(set.getCurNode().getTimes() - 1);
|
||||
//当前node节点 放入 旧node map
|
||||
Map<String, TokenNode> oldNodeMap = set.getTokenNodeMap();
|
||||
if (null == oldNodeMap) {
|
||||
oldNodeMap = new ConcurrentHashMap<>();
|
||||
}
|
||||
oldNodeMap.put(set.getCurNode().getEncryptToken(), set.getCurNode());
|
||||
set.setTokenNodeMap(oldNodeMap);
|
||||
//新node 替换
|
||||
set.setCurNode(newNode);
|
||||
//request.getSession().setAttribute(this.headerVal, JsonUtil.toJSONString(set));
|
||||
request.getSession().setAttribute(this.headerVal, set);
|
||||
}
|
||||
return ImmutablePair.of(newNode, set.getCurNode().getHexSM4Key());
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.jiuyv.sptcc.agile.dms.common.constant;
|
||||
|
||||
public class DataConstant {
|
||||
|
||||
/**
|
||||
* 通用的是否
|
||||
*/
|
||||
public enum TrueOrFalse {
|
||||
FALSE("0",false),
|
||||
TRUE("1",true);
|
||||
|
||||
TrueOrFalse(String key, boolean val){
|
||||
this.key = key;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
private final String key;
|
||||
private final boolean val;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public boolean getVal() {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用的启用禁用状态
|
||||
*/
|
||||
public enum EnableState {
|
||||
DISABLE("1","禁用"),
|
||||
ENABLE("0","启用");
|
||||
|
||||
EnableState(String key, String val){
|
||||
this.key = key;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
private final String key;
|
||||
private final String val;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getVal() {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue