diff --git a/src/hoj-springboot/.gitignore b/src/hoj-springboot/.gitignore
deleted file mode 100644
index 24cbb6d..0000000
--- a/src/hoj-springboot/.gitignore
+++ /dev/null
@@ -1,36 +0,0 @@
-*.classpath
-
-# Package Files
-*.jar
-*.war
-*.ear
-*.log
-*.iml
-
-.DS_Store
-node_modules
-dist/
-target/
-out/
-.idea/
-.classpath
-.project
-
-# local env files
-.env.local
-.env.*.local
-
-# Log files
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
-pnpm-debug.log*
-
-# Editor directories and files
-.idea
-.vscode
-*.suo
-*.ntvs*
-*.njsproj
-*.sln
-*.sw?
diff --git a/src/hoj-springboot/DataBackup/pom.xml b/src/hoj-springboot/DataBackup/pom.xml
deleted file mode 100644
index 1a0f0a4..0000000
--- a/src/hoj-springboot/DataBackup/pom.xml
+++ /dev/null
@@ -1,208 +0,0 @@
-
-
-
- hoj-springboot
- top.hcode
- 1.0-SNAPSHOT
-
- 4.0.0
- DataBackup
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- top.hcode.hoj.DataBackupApplication
- ZIP
-
-
-
-
- repackage
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
- 8
- 8
-
-
-
-
-
- src/main/resources
-
-
- src/main/java
-
- **/*.xml
-
-
-
-
-
-
- top.hcode
- api
- 1.0-SNAPSHOT
-
-
-
- org.springframework.boot
- spring-boot-starter-mail
-
-
-
- org.springframework.retry
- spring-retry
-
-
-
- com.alibaba.cloud
- spring-cloud-starter-alibaba-nacos-config
-
-
-
- com.alibaba.nacos
- nacos-client
-
-
-
-
- com.alibaba.nacos
- nacos-client
- 1.4.2
-
-
-
- com.alibaba.cloud
- spring-cloud-starter-alibaba-nacos-discovery
-
-
- org.projectlombok
- lombok
- true
-
-
- com.alibaba
- druid
-
-
- com.alibaba
- easyexcel
- 2.2.7
-
-
- com.baomidou
- mybatis-plus-boot-starter
-
-
- org.crazycake
- shiro-redis-spring-boot-starter
-
-
- org.crazycake
- shiro-redis
-
-
-
-
- org.crazycake
- shiro-redis
- 3.3.1
-
-
- mysql
- mysql-connector-java
-
-
-
- cn.hutool
- hutool-all
- 5.7.22
-
-
-
- com.github.oshi
- oshi-core
- 5.6.1
-
-
-
- com.vdurmont
- emoji-java
- 5.1.1
-
-
-
-
- org.springframework.boot
- spring-boot-starter-data-redis
-
-
- io.lettuce
- lettuce-core
-
-
-
-
-
-
- io.jsonwebtoken
- jjwt
- 0.9.1
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-actuator
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-thymeleaf
-
-
-
- com.github.whvcse
- easy-captcha
- 1.6.2
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.junit.vintage
- junit-vintage-engine
-
-
-
-
-
- org.jsoup
- jsoup
- 1.13.1
-
-
-
-
-
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java b/src/hoj-springboot/DataBackup/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java
deleted file mode 100644
index 663da0b..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java
+++ /dev/null
@@ -1,2118 +0,0 @@
-//
-// Source code recreated from a .class file by IntelliJ IDEA
-// (powered by Fernflower decompiler)
-//
-
-package com.alibaba.druid.pool;
-
-import com.alibaba.druid.DruidRuntimeException;
-import com.alibaba.druid.filter.Filter;
-import com.alibaba.druid.filter.FilterChainImpl;
-import com.alibaba.druid.filter.FilterManager;
-import com.alibaba.druid.pool.vendor.NullExceptionSorter;
-import com.alibaba.druid.proxy.jdbc.DataSourceProxy;
-import com.alibaba.druid.proxy.jdbc.TransactionInfo;
-import com.alibaba.druid.stat.JdbcDataSourceStat;
-import com.alibaba.druid.stat.JdbcSqlStat;
-import com.alibaba.druid.stat.JdbcStatManager;
-import com.alibaba.druid.support.logging.Log;
-import com.alibaba.druid.support.logging.LogFactory;
-import com.alibaba.druid.util.DruidPasswordCallback;
-import com.alibaba.druid.util.Histogram;
-import com.alibaba.druid.util.JdbcUtils;
-import com.alibaba.druid.util.MySqlUtils;
-import com.alibaba.druid.util.StringUtils;
-import com.alibaba.druid.util.Utils;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.SQLFeatureNotSupportedException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
-import java.util.concurrent.atomic.AtomicLongFieldUpdater;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.logging.Logger;
-import javax.management.JMException;
-import javax.management.ObjectName;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.sql.DataSource;
-
-public abstract class DruidAbstractDataSource extends WrapperAdapter implements DruidAbstractDataSourceMBean, DataSource, DataSourceProxy, Serializable {
- private static final long serialVersionUID = 1L;
- private static final Log LOG = LogFactory.getLog(DruidAbstractDataSource.class);
- public static final int DEFAULT_INITIAL_SIZE = 0;
- public static final int DEFAULT_MAX_ACTIVE_SIZE = 8;
- public static final int DEFAULT_MAX_IDLE = 8;
- public static final int DEFAULT_MIN_IDLE = 0;
- public static final int DEFAULT_MAX_WAIT = -1;
- public static final String DEFAULT_VALIDATION_QUERY = null;
- public static final boolean DEFAULT_TEST_ON_BORROW = false;
- public static final boolean DEFAULT_TEST_ON_RETURN = false;
- public static final boolean DEFAULT_WHILE_IDLE = true;
- public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 60000L;
- public static final long DEFAULT_TIME_BETWEEN_CONNECT_ERROR_MILLIS = 500L;
- public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN = 3;
- public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS = 1800000L;
- public static final long DEFAULT_MAX_EVICTABLE_IDLE_TIME_MILLIS = 25200000L;
- public static final long DEFAULT_PHY_TIMEOUT_MILLIS = -1L;
- protected volatile boolean defaultAutoCommit = true;
- protected volatile Boolean defaultReadOnly;
- protected volatile Integer defaultTransactionIsolation;
- protected volatile String defaultCatalog = null;
- protected String name;
- protected volatile String username;
- protected volatile String password;
- protected volatile String jdbcUrl;
- protected volatile String driverClass;
- protected volatile ClassLoader driverClassLoader;
- protected volatile Properties connectProperties = new Properties();
- protected volatile PasswordCallback passwordCallback;
- protected volatile NameCallback userCallback;
- protected volatile int initialSize = 0;
- protected volatile int maxActive = 8;
- protected volatile int minIdle = 0;
- protected volatile int maxIdle = 8;
- protected volatile long maxWait = -1L;
- protected int notFullTimeoutRetryCount = 0;
- protected volatile String validationQuery;
- protected volatile int validationQueryTimeout;
- protected volatile boolean testOnBorrow;
- protected volatile boolean testOnReturn;
- protected volatile boolean testWhileIdle;
- protected volatile boolean poolPreparedStatements;
- protected volatile boolean sharePreparedStatements;
- protected volatile int maxPoolPreparedStatementPerConnectionSize;
- protected volatile boolean inited;
- protected volatile boolean initExceptionThrow;
- protected PrintWriter logWriter;
- protected List filters;
- private boolean clearFiltersEnable;
- protected volatile ExceptionSorter exceptionSorter;
- protected Driver driver;
- protected volatile int queryTimeout;
- protected volatile int transactionQueryTimeout;
- protected long createTimespan;
- protected volatile int maxWaitThreadCount;
- protected volatile boolean accessToUnderlyingConnectionAllowed;
- protected volatile long timeBetweenEvictionRunsMillis;
- protected volatile int numTestsPerEvictionRun;
- protected volatile long minEvictableIdleTimeMillis;
- protected volatile long maxEvictableIdleTimeMillis;
- protected volatile long keepAliveBetweenTimeMillis;
- protected volatile long phyTimeoutMillis;
- protected volatile long phyMaxUseCount;
- protected volatile boolean removeAbandoned;
- protected volatile long removeAbandonedTimeoutMillis;
- protected volatile boolean logAbandoned;
- protected volatile int maxOpenPreparedStatements;
- protected volatile List connectionInitSqls;
- protected volatile String dbType;
- protected volatile long timeBetweenConnectErrorMillis;
- protected volatile ValidConnectionChecker validConnectionChecker;
- protected final Map activeConnections;
- protected static final Object PRESENT = new Object();
- protected long id;
- protected int connectionErrorRetryAttempts;
- protected boolean breakAfterAcquireFailure;
- protected long transactionThresholdMillis;
- protected final Date createdTime;
- protected Date initedTime;
- protected volatile long errorCount;
- protected volatile long dupCloseCount;
- protected volatile long startTransactionCount;
- protected volatile long commitCount;
- protected volatile long rollbackCount;
- protected volatile long cachedPreparedStatementHitCount;
- protected volatile long preparedStatementCount;
- protected volatile long closedPreparedStatementCount;
- protected volatile long cachedPreparedStatementCount;
- protected volatile long cachedPreparedStatementDeleteCount;
- protected volatile long cachedPreparedStatementMissCount;
- static final AtomicLongFieldUpdater errorCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "errorCount");
- static final AtomicLongFieldUpdater dupCloseCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "dupCloseCount");
- static final AtomicLongFieldUpdater startTransactionCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "startTransactionCount");
- static final AtomicLongFieldUpdater commitCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "commitCount");
- static final AtomicLongFieldUpdater rollbackCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "rollbackCount");
- static final AtomicLongFieldUpdater cachedPreparedStatementHitCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "cachedPreparedStatementHitCount");
- static final AtomicLongFieldUpdater preparedStatementCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "preparedStatementCount");
- static final AtomicLongFieldUpdater closedPreparedStatementCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "closedPreparedStatementCount");
- static final AtomicLongFieldUpdater cachedPreparedStatementCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "cachedPreparedStatementCount");
- static final AtomicLongFieldUpdater cachedPreparedStatementDeleteCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "cachedPreparedStatementDeleteCount");
- static final AtomicLongFieldUpdater cachedPreparedStatementMissCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "cachedPreparedStatementMissCount");
- protected final Histogram transactionHistogram;
- private boolean dupCloseLogEnable;
- private ObjectName objectName;
- protected volatile long executeCount;
- protected volatile long executeQueryCount;
- protected volatile long executeUpdateCount;
- protected volatile long executeBatchCount;
- static final AtomicLongFieldUpdater executeQueryCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "executeQueryCount");
- static final AtomicLongFieldUpdater executeUpdateCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "executeUpdateCount");
- static final AtomicLongFieldUpdater executeBatchCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "executeBatchCount");
- static final AtomicLongFieldUpdater executeCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "executeCount");
- protected volatile Throwable createError;
- protected volatile Throwable lastError;
- protected volatile long lastErrorTimeMillis;
- protected volatile Throwable lastCreateError;
- protected volatile long lastCreateErrorTimeMillis;
- protected volatile long lastCreateStartTimeMillis;
- protected boolean isOracle;
- protected boolean isMySql;
- protected boolean useOracleImplicitCache;
- protected ReentrantLock lock;
- protected Condition notEmpty;
- protected Condition empty;
- protected ReentrantLock activeConnectionLock;
- protected volatile int createErrorCount;
- protected volatile int creatingCount;
- protected volatile int directCreateCount;
- protected volatile long createCount;
- protected volatile long destroyCount;
- protected volatile long createStartNanos;
- static final AtomicIntegerFieldUpdater createErrorCountUpdater = AtomicIntegerFieldUpdater.newUpdater(DruidAbstractDataSource.class, "createErrorCount");
- static final AtomicIntegerFieldUpdater creatingCountUpdater = AtomicIntegerFieldUpdater.newUpdater(DruidAbstractDataSource.class, "creatingCount");
- static final AtomicIntegerFieldUpdater directCreateCountUpdater = AtomicIntegerFieldUpdater.newUpdater(DruidAbstractDataSource.class, "directCreateCount");
- static final AtomicLongFieldUpdater createCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "createCount");
- static final AtomicLongFieldUpdater destroyCountUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "destroyCount");
- static final AtomicLongFieldUpdater createStartNanosUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "createStartNanos");
- private Boolean useUnfairLock;
- private boolean useLocalSessionState;
- protected long timeBetweenLogStatsMillis;
- protected DruidDataSourceStatLogger statLogger;
- private boolean asyncCloseConnectionEnable;
- protected int maxCreateTaskCount;
- protected boolean failFast;
- protected volatile int failContinuous;
- protected volatile long failContinuousTimeMillis;
- protected ScheduledExecutorService destroyScheduler;
- protected ScheduledExecutorService createScheduler;
- static final AtomicLongFieldUpdater failContinuousTimeMillisUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "failContinuousTimeMillis");
- static final AtomicIntegerFieldUpdater failContinuousUpdater = AtomicIntegerFieldUpdater.newUpdater(DruidAbstractDataSource.class, "failContinuous");
- protected boolean initVariants;
- protected boolean initGlobalVariants;
- protected volatile boolean onFatalError;
- protected volatile int onFatalErrorMaxActive;
- protected volatile int fatalErrorCount;
- protected volatile int fatalErrorCountLastShrink;
- protected volatile long lastFatalErrorTimeMillis;
- protected volatile String lastFatalErrorSql;
- protected volatile Throwable lastFatalError;
- protected volatile long connectionIdSeed;
- protected volatile long statementIdSeed;
- protected volatile long resultSetIdSeed;
- protected volatile long transactionIdSeed;
- protected volatile long metaDataIdSeed;
- static final AtomicLongFieldUpdater connectionIdSeedUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "connectionIdSeed");
- static final AtomicLongFieldUpdater statementIdSeedUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "statementIdSeed");
- static final AtomicLongFieldUpdater resultSetIdSeedUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "resultSetIdSeed");
- static final AtomicLongFieldUpdater transactionIdSeedUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "transactionIdSeed");
- static final AtomicLongFieldUpdater metaDataIdSeedUpdater = AtomicLongFieldUpdater.newUpdater(DruidAbstractDataSource.class, "metaDataIdSeed");
-
- public DruidAbstractDataSource(boolean lockFair) {
- this.validationQuery = DEFAULT_VALIDATION_QUERY;
- this.validationQueryTimeout = -1;
- this.testOnBorrow = false;
- this.testOnReturn = false;
- this.testWhileIdle = true;
- this.poolPreparedStatements = false;
- this.sharePreparedStatements = false;
- this.maxPoolPreparedStatementPerConnectionSize = 10;
- this.inited = false;
- this.initExceptionThrow = true;
- this.logWriter = new PrintWriter(System.out);
- this.filters = new CopyOnWriteArrayList();
- this.clearFiltersEnable = true;
- this.exceptionSorter = null;
- this.maxWaitThreadCount = -1;
- this.accessToUnderlyingConnectionAllowed = true;
- this.timeBetweenEvictionRunsMillis = 60000L;
- this.numTestsPerEvictionRun = 3;
- this.minEvictableIdleTimeMillis = 1800000L;
- this.maxEvictableIdleTimeMillis = 25200000L;
- this.keepAliveBetweenTimeMillis = 120000L;
- this.phyTimeoutMillis = -1L;
- this.phyMaxUseCount = -1L;
- this.removeAbandonedTimeoutMillis = 300000L;
- this.maxOpenPreparedStatements = -1;
- this.timeBetweenConnectErrorMillis = 500L;
- this.validConnectionChecker = null;
- this.activeConnections = new IdentityHashMap();
- this.connectionErrorRetryAttempts = 1;
- this.breakAfterAcquireFailure = false;
- this.transactionThresholdMillis = 0L;
- this.createdTime = new Date();
- this.errorCount = 0L;
- this.dupCloseCount = 0L;
- this.startTransactionCount = 0L;
- this.commitCount = 0L;
- this.rollbackCount = 0L;
- this.cachedPreparedStatementHitCount = 0L;
- this.preparedStatementCount = 0L;
- this.closedPreparedStatementCount = 0L;
- this.cachedPreparedStatementCount = 0L;
- this.cachedPreparedStatementDeleteCount = 0L;
- this.cachedPreparedStatementMissCount = 0L;
- this.transactionHistogram = new Histogram(new long[]{1L, 10L, 100L, 1000L, 10000L, 100000L});
- this.dupCloseLogEnable = false;
- this.executeCount = 0L;
- this.executeQueryCount = 0L;
- this.executeUpdateCount = 0L;
- this.executeBatchCount = 0L;
- this.isOracle = false;
- this.isMySql = false;
- this.useOracleImplicitCache = true;
- this.activeConnectionLock = new ReentrantLock();
- this.createErrorCount = 0;
- this.creatingCount = 0;
- this.directCreateCount = 0;
- this.createCount = 0L;
- this.destroyCount = 0L;
- this.createStartNanos = 0L;
- this.useUnfairLock = null;
- this.useLocalSessionState = true;
- this.statLogger = new DruidDataSourceStatLoggerImpl();
- this.asyncCloseConnectionEnable = false;
- this.maxCreateTaskCount = 3;
- this.failFast = false;
- this.failContinuous = 0;
- this.failContinuousTimeMillis = 0L;
- this.initVariants = false;
- this.initGlobalVariants = false;
- this.onFatalError = false;
- this.onFatalErrorMaxActive = 0;
- this.fatalErrorCount = 0;
- this.fatalErrorCountLastShrink = 0;
- this.lastFatalErrorTimeMillis = 0L;
- this.lastFatalErrorSql = null;
- this.lastFatalError = null;
- this.connectionIdSeed = 10000L;
- this.statementIdSeed = 20000L;
- this.resultSetIdSeed = 50000L;
- this.transactionIdSeed = 60000L;
- this.metaDataIdSeed = 80000L;
- this.lock = new ReentrantLock(lockFair);
- this.notEmpty = this.lock.newCondition();
- this.empty = this.lock.newCondition();
- }
-
- public boolean isUseLocalSessionState() {
- return this.useLocalSessionState;
- }
-
- public void setUseLocalSessionState(boolean useLocalSessionState) {
- this.useLocalSessionState = useLocalSessionState;
- }
-
- public DruidDataSourceStatLogger getStatLogger() {
- return this.statLogger;
- }
-
- public void setStatLoggerClassName(String className) {
- try {
- Class> clazz = Class.forName(className);
- DruidDataSourceStatLogger statLogger = (DruidDataSourceStatLogger)clazz.newInstance();
- this.setStatLogger(statLogger);
- } catch (Exception var4) {
- throw new IllegalArgumentException(className, var4);
- }
- }
-
- public void setStatLogger(DruidDataSourceStatLogger statLogger) {
- this.statLogger = statLogger;
- }
-
- public long getTimeBetweenLogStatsMillis() {
- return this.timeBetweenLogStatsMillis;
- }
-
- public void setTimeBetweenLogStatsMillis(long timeBetweenLogStatsMillis) {
- this.timeBetweenLogStatsMillis = timeBetweenLogStatsMillis;
- }
-
- public boolean isOracle() {
- return this.isOracle;
- }
-
- public void setOracle(boolean isOracle) {
- if (this.inited) {
- throw new IllegalStateException();
- } else {
- this.isOracle = isOracle;
- }
- }
-
- public boolean isUseUnfairLock() {
- return this.lock.isFair();
- }
-
- public void setUseUnfairLock(boolean useUnfairLock) {
- if (this.lock.isFair() != !useUnfairLock) {
- if (!this.inited) {
- ReentrantLock lock = this.lock;
- lock.lock();
-
- try {
- if (!this.inited) {
- this.lock = new ReentrantLock(!useUnfairLock);
- this.notEmpty = this.lock.newCondition();
- this.empty = this.lock.newCondition();
- this.useUnfairLock = useUnfairLock;
- }
- } finally {
- lock.unlock();
- }
- }
-
- }
- }
-
- public boolean isUseOracleImplicitCache() {
- return this.useOracleImplicitCache;
- }
-
- public void setUseOracleImplicitCache(boolean useOracleImplicitCache) {
- if (this.useOracleImplicitCache != useOracleImplicitCache) {
- this.useOracleImplicitCache = useOracleImplicitCache;
- boolean isOracleDriver10 = this.isOracle() && this.driver != null && this.driver.getMajorVersion() == 10;
- if (isOracleDriver10 && useOracleImplicitCache) {
- this.getConnectProperties().setProperty("oracle.jdbc.FreeMemoryOnEnterImplicitCache", "true");
- } else {
- this.getConnectProperties().remove("oracle.jdbc.FreeMemoryOnEnterImplicitCache");
- }
- }
-
- }
-
- public Throwable getLastCreateError() {
- return this.lastCreateError;
- }
-
- public Throwable getLastError() {
- return this.lastError;
- }
-
- public long getLastErrorTimeMillis() {
- return this.lastErrorTimeMillis;
- }
-
- public Date getLastErrorTime() {
- return this.lastErrorTimeMillis <= 0L ? null : new Date(this.lastErrorTimeMillis);
- }
-
- public long getLastCreateErrorTimeMillis() {
- return this.lastCreateErrorTimeMillis;
- }
-
- public Date getLastCreateErrorTime() {
- return this.lastCreateErrorTimeMillis <= 0L ? null : new Date(this.lastCreateErrorTimeMillis);
- }
-
- public int getTransactionQueryTimeout() {
- return this.transactionQueryTimeout <= 0 ? this.queryTimeout : this.transactionQueryTimeout;
- }
-
- public void setTransactionQueryTimeout(int transactionQueryTimeout) {
- this.transactionQueryTimeout = transactionQueryTimeout;
- }
-
- public long getExecuteCount() {
- return this.executeCount + this.executeQueryCount + this.executeUpdateCount + this.executeBatchCount;
- }
-
- public long getExecuteUpdateCount() {
- return this.executeUpdateCount;
- }
-
- public long getExecuteQueryCount() {
- return this.executeQueryCount;
- }
-
- public long getExecuteBatchCount() {
- return this.executeBatchCount;
- }
-
- public long getAndResetExecuteCount() {
- return executeCountUpdater.getAndSet(this, 0L) + executeQueryCountUpdater.getAndSet(this, 0L) + executeUpdateCountUpdater.getAndSet(this, 0L) + executeBatchCountUpdater.getAndSet(this, 0L);
- }
-
- public long getExecuteCount2() {
- return this.executeCount;
- }
-
- public void incrementExecuteCount() {
- executeCountUpdater.incrementAndGet(this);
- }
-
- public void incrementExecuteUpdateCount() {
- ++this.executeUpdateCount;
- }
-
- public void incrementExecuteQueryCount() {
- ++this.executeQueryCount;
- }
-
- public void incrementExecuteBatchCount() {
- ++this.executeBatchCount;
- }
-
- public boolean isDupCloseLogEnable() {
- return this.dupCloseLogEnable;
- }
-
- public void setDupCloseLogEnable(boolean dupCloseLogEnable) {
- this.dupCloseLogEnable = dupCloseLogEnable;
- }
-
- public ObjectName getObjectName() {
- return this.objectName;
- }
-
- public void setObjectName(ObjectName objectName) {
- this.objectName = objectName;
- }
-
- public Histogram getTransactionHistogram() {
- return this.transactionHistogram;
- }
-
- public void incrementCachedPreparedStatementCount() {
- cachedPreparedStatementCountUpdater.incrementAndGet(this);
- }
-
- public void decrementCachedPreparedStatementCount() {
- cachedPreparedStatementCountUpdater.decrementAndGet(this);
- }
-
- public void incrementCachedPreparedStatementDeleteCount() {
- cachedPreparedStatementDeleteCountUpdater.incrementAndGet(this);
- }
-
- public void incrementCachedPreparedStatementMissCount() {
- cachedPreparedStatementMissCountUpdater.incrementAndGet(this);
- }
-
- public long getCachedPreparedStatementMissCount() {
- return this.cachedPreparedStatementMissCount;
- }
-
- public long getCachedPreparedStatementAccessCount() {
- return this.cachedPreparedStatementMissCount + this.cachedPreparedStatementHitCount;
- }
-
- public long getCachedPreparedStatementDeleteCount() {
- return this.cachedPreparedStatementDeleteCount;
- }
-
- public long getCachedPreparedStatementCount() {
- return this.cachedPreparedStatementCount;
- }
-
- public void incrementClosedPreparedStatementCount() {
- closedPreparedStatementCountUpdater.incrementAndGet(this);
- }
-
- public long getClosedPreparedStatementCount() {
- return this.closedPreparedStatementCount;
- }
-
- public void incrementPreparedStatementCount() {
- preparedStatementCountUpdater.incrementAndGet(this);
- }
-
- public long getPreparedStatementCount() {
- return this.preparedStatementCount;
- }
-
- public void incrementCachedPreparedStatementHitCount() {
- cachedPreparedStatementHitCountUpdater.incrementAndGet(this);
- }
-
- public long getCachedPreparedStatementHitCount() {
- return this.cachedPreparedStatementHitCount;
- }
-
- public long getTransactionThresholdMillis() {
- return this.transactionThresholdMillis;
- }
-
- public void setTransactionThresholdMillis(long transactionThresholdMillis) {
- this.transactionThresholdMillis = transactionThresholdMillis;
- }
-
- public abstract void logTransaction(TransactionInfo var1);
-
- public long[] getTransactionHistogramValues() {
- return this.transactionHistogram.toArray();
- }
-
- public long[] getTransactionHistogramRanges() {
- return this.transactionHistogram.getRanges();
- }
-
- public long getCommitCount() {
- return this.commitCount;
- }
-
- public void incrementCommitCount() {
- commitCountUpdater.incrementAndGet(this);
- }
-
- public long getRollbackCount() {
- return this.rollbackCount;
- }
-
- public void incrementRollbackCount() {
- rollbackCountUpdater.incrementAndGet(this);
- }
-
- public long getStartTransactionCount() {
- return this.startTransactionCount;
- }
-
- public void incrementStartTransactionCount() {
- startTransactionCountUpdater.incrementAndGet(this);
- }
-
- public boolean isBreakAfterAcquireFailure() {
- return this.breakAfterAcquireFailure;
- }
-
- public void setBreakAfterAcquireFailure(boolean breakAfterAcquireFailure) {
- this.breakAfterAcquireFailure = breakAfterAcquireFailure;
- }
-
- public int getConnectionErrorRetryAttempts() {
- return this.connectionErrorRetryAttempts;
- }
-
- public void setConnectionErrorRetryAttempts(int connectionErrorRetryAttempts) {
- this.connectionErrorRetryAttempts = connectionErrorRetryAttempts;
- }
-
- public long getDupCloseCount() {
- return this.dupCloseCount;
- }
-
- public int getMaxPoolPreparedStatementPerConnectionSize() {
- return this.maxPoolPreparedStatementPerConnectionSize;
- }
-
- public void setMaxPoolPreparedStatementPerConnectionSize(int maxPoolPreparedStatementPerConnectionSize) {
- if (maxPoolPreparedStatementPerConnectionSize > 0) {
- this.poolPreparedStatements = true;
- } else {
- this.poolPreparedStatements = false;
- }
-
- this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize;
- }
-
- public boolean isSharePreparedStatements() {
- return this.sharePreparedStatements;
- }
-
- public void setSharePreparedStatements(boolean sharePreparedStatements) {
- this.sharePreparedStatements = sharePreparedStatements;
- }
-
- public void incrementDupCloseCount() {
- dupCloseCountUpdater.incrementAndGet(this);
- }
-
- public ValidConnectionChecker getValidConnectionChecker() {
- return this.validConnectionChecker;
- }
-
- public void setValidConnectionChecker(ValidConnectionChecker validConnectionChecker) {
- this.validConnectionChecker = validConnectionChecker;
- }
-
- public String getValidConnectionCheckerClassName() {
- return this.validConnectionChecker == null ? null : this.validConnectionChecker.getClass().getName();
- }
-
- public void setValidConnectionCheckerClassName(String validConnectionCheckerClass) throws Exception {
- Class> clazz = Utils.loadClass(validConnectionCheckerClass);
- ValidConnectionChecker validConnectionChecker = null;
- if (clazz != null) {
- validConnectionChecker = (ValidConnectionChecker)clazz.newInstance();
- this.validConnectionChecker = validConnectionChecker;
- } else {
- LOG.error("load validConnectionCheckerClass error : " + validConnectionCheckerClass);
- }
-
- }
-
- public String getDbType() {
- return this.dbType;
- }
-
- public void setDbType(String dbType) {
- this.dbType = dbType;
- }
-
- public void addConnectionProperty(String name, String value) {
- if (!StringUtils.equals(this.connectProperties.getProperty(name), value)) {
- if (this.inited) {
- throw new UnsupportedOperationException();
- } else {
- this.connectProperties.put(name, value);
- }
- }
- }
-
- public Collection getConnectionInitSqls() {
- Collection result = this.connectionInitSqls;
- return result == null ? Collections.emptyList() : result;
- }
-
- public void setConnectionInitSqls(Collection extends Object> connectionInitSqls) {
- if (connectionInitSqls != null && connectionInitSqls.size() > 0) {
- ArrayList newVal = null;
- Iterator var3 = connectionInitSqls.iterator();
-
- while(var3.hasNext()) {
- Object o = var3.next();
- if (o != null) {
- String s = o.toString();
- s = s.trim();
- if (s.length() != 0) {
- if (newVal == null) {
- newVal = new ArrayList();
- }
-
- newVal.add(s);
- }
- }
- }
-
- this.connectionInitSqls = newVal;
- } else {
- this.connectionInitSqls = null;
- }
-
- }
-
- public long getTimeBetweenConnectErrorMillis() {
- return this.timeBetweenConnectErrorMillis;
- }
-
- public void setTimeBetweenConnectErrorMillis(long timeBetweenConnectErrorMillis) {
- this.timeBetweenConnectErrorMillis = timeBetweenConnectErrorMillis;
- }
-
- public int getMaxOpenPreparedStatements() {
- return this.maxPoolPreparedStatementPerConnectionSize;
- }
-
- public void setMaxOpenPreparedStatements(int maxOpenPreparedStatements) {
- this.setMaxPoolPreparedStatementPerConnectionSize(maxOpenPreparedStatements);
- }
-
- public boolean isLogAbandoned() {
- return this.logAbandoned;
- }
-
- public void setLogAbandoned(boolean logAbandoned) {
- this.logAbandoned = logAbandoned;
- }
-
- public int getRemoveAbandonedTimeout() {
- return (int)(this.removeAbandonedTimeoutMillis / 1000L);
- }
-
- public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
- this.removeAbandonedTimeoutMillis = (long)removeAbandonedTimeout * 1000L;
- }
-
- public void setRemoveAbandonedTimeoutMillis(long removeAbandonedTimeoutMillis) {
- this.removeAbandonedTimeoutMillis = removeAbandonedTimeoutMillis;
- }
-
- public long getRemoveAbandonedTimeoutMillis() {
- return this.removeAbandonedTimeoutMillis;
- }
-
- public boolean isRemoveAbandoned() {
- return this.removeAbandoned;
- }
-
- public void setRemoveAbandoned(boolean removeAbandoned) {
- this.removeAbandoned = removeAbandoned;
- }
-
- public long getMinEvictableIdleTimeMillis() {
- return this.minEvictableIdleTimeMillis;
- }
-
- public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) {
- if (minEvictableIdleTimeMillis < 30000L) {
- LOG.error("minEvictableIdleTimeMillis should be greater than 30000");
- }
-
- this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
- }
-
- public long getKeepAliveBetweenTimeMillis() {
- return this.keepAliveBetweenTimeMillis;
- }
-
- public void setKeepAliveBetweenTimeMillis(long keepAliveBetweenTimeMillis) {
- if (keepAliveBetweenTimeMillis < 30000L) {
- LOG.error("keepAliveBetweenTimeMillis should be greater than 30000");
- }
-
- this.keepAliveBetweenTimeMillis = keepAliveBetweenTimeMillis;
- }
-
- public long getMaxEvictableIdleTimeMillis() {
- return this.maxEvictableIdleTimeMillis;
- }
-
- public void setMaxEvictableIdleTimeMillis(long maxEvictableIdleTimeMillis) {
- if (maxEvictableIdleTimeMillis < 30000L) {
- LOG.error("maxEvictableIdleTimeMillis should be greater than 30000");
- }
-
- if (maxEvictableIdleTimeMillis < this.minEvictableIdleTimeMillis) {
- throw new IllegalArgumentException("maxEvictableIdleTimeMillis must be grater than minEvictableIdleTimeMillis");
- } else {
- this.maxEvictableIdleTimeMillis = maxEvictableIdleTimeMillis;
- }
- }
-
- public long getPhyTimeoutMillis() {
- return this.phyTimeoutMillis;
- }
-
- public void setPhyTimeoutMillis(long phyTimeoutMillis) {
- this.phyTimeoutMillis = phyTimeoutMillis;
- }
-
- public long getPhyMaxUseCount() {
- return this.phyMaxUseCount;
- }
-
- public void setPhyMaxUseCount(long phyMaxUseCount) {
- this.phyMaxUseCount = phyMaxUseCount;
- }
-
- public int getNumTestsPerEvictionRun() {
- return this.numTestsPerEvictionRun;
- }
-
- /** @deprecated */
- @Deprecated
- public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
- this.numTestsPerEvictionRun = numTestsPerEvictionRun;
- }
-
- public long getTimeBetweenEvictionRunsMillis() {
- return this.timeBetweenEvictionRunsMillis;
- }
-
- public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {
- this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
- }
-
- public int getMaxWaitThreadCount() {
- return this.maxWaitThreadCount;
- }
-
- public void setMaxWaitThreadCount(int maxWaithThreadCount) {
- this.maxWaitThreadCount = maxWaithThreadCount;
- }
-
- public String getValidationQuery() {
- return this.validationQuery;
- }
-
- public void setValidationQuery(String validationQuery) {
- this.validationQuery = validationQuery;
- }
-
- public int getValidationQueryTimeout() {
- return this.validationQueryTimeout;
- }
-
- public void setValidationQueryTimeout(int validationQueryTimeout) {
- if (validationQueryTimeout < 0 && "sqlserver".equals(this.dbType)) {
- LOG.error("validationQueryTimeout should be >= 0");
- }
-
- this.validationQueryTimeout = validationQueryTimeout;
- }
-
- public boolean isAccessToUnderlyingConnectionAllowed() {
- return this.accessToUnderlyingConnectionAllowed;
- }
-
- public void setAccessToUnderlyingConnectionAllowed(boolean accessToUnderlyingConnectionAllowed) {
- this.accessToUnderlyingConnectionAllowed = accessToUnderlyingConnectionAllowed;
- }
-
- public boolean isTestOnBorrow() {
- return this.testOnBorrow;
- }
-
- public void setTestOnBorrow(boolean testOnBorrow) {
- this.testOnBorrow = testOnBorrow;
- }
-
- public boolean isTestOnReturn() {
- return this.testOnReturn;
- }
-
- public void setTestOnReturn(boolean testOnReturn) {
- this.testOnReturn = testOnReturn;
- }
-
- public boolean isTestWhileIdle() {
- return this.testWhileIdle;
- }
-
- public void setTestWhileIdle(boolean testWhileIdle) {
- this.testWhileIdle = testWhileIdle;
- }
-
- public boolean isDefaultAutoCommit() {
- return this.defaultAutoCommit;
- }
-
- public void setDefaultAutoCommit(boolean defaultAutoCommit) {
- this.defaultAutoCommit = defaultAutoCommit;
- }
-
- public Boolean getDefaultReadOnly() {
- return this.defaultReadOnly;
- }
-
- public void setDefaultReadOnly(Boolean defaultReadOnly) {
- this.defaultReadOnly = defaultReadOnly;
- }
-
- public Integer getDefaultTransactionIsolation() {
- return this.defaultTransactionIsolation;
- }
-
- public void setDefaultTransactionIsolation(Integer defaultTransactionIsolation) {
- this.defaultTransactionIsolation = defaultTransactionIsolation;
- }
-
- public String getDefaultCatalog() {
- return this.defaultCatalog;
- }
-
- public void setDefaultCatalog(String defaultCatalog) {
- this.defaultCatalog = defaultCatalog;
- }
-
- public PasswordCallback getPasswordCallback() {
- return this.passwordCallback;
- }
-
- public void setPasswordCallback(PasswordCallback passwordCallback) {
- this.passwordCallback = passwordCallback;
- }
-
- public void setPasswordCallbackClassName(String passwordCallbackClassName) throws Exception {
- Class> clazz = Utils.loadClass(passwordCallbackClassName);
- if (clazz != null) {
- this.passwordCallback = (PasswordCallback)clazz.newInstance();
- } else {
- LOG.error("load passwordCallback error : " + passwordCallbackClassName);
- this.passwordCallback = null;
- }
-
- }
-
- public NameCallback getUserCallback() {
- return this.userCallback;
- }
-
- public void setUserCallback(NameCallback userCallback) {
- this.userCallback = userCallback;
- }
-
- public boolean isInitVariants() {
- return this.initVariants;
- }
-
- public void setInitVariants(boolean initVariants) {
- this.initVariants = initVariants;
- }
-
- public boolean isInitGlobalVariants() {
- return this.initGlobalVariants;
- }
-
- public void setInitGlobalVariants(boolean initGlobalVariants) {
- this.initGlobalVariants = initGlobalVariants;
- }
-
- public int getQueryTimeout() {
- return this.queryTimeout;
- }
-
- public void setQueryTimeout(int seconds) {
- this.queryTimeout = seconds;
- }
-
- public String getName() {
- return this.name != null ? this.name : "DataSource-" + System.identityHashCode(this);
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public boolean isPoolPreparedStatements() {
- return this.poolPreparedStatements;
- }
-
- public abstract void setPoolPreparedStatements(boolean var1);
-
- public long getMaxWait() {
- return this.maxWait;
- }
-
- public void setMaxWait(long maxWaitMillis) {
- if (maxWaitMillis != this.maxWait) {
- if (maxWaitMillis > 0L && this.useUnfairLock == null && !this.inited) {
- ReentrantLock lock = this.lock;
- lock.lock();
-
- try {
- if (!this.inited && !lock.isFair()) {
- this.lock = new ReentrantLock(true);
- this.notEmpty = this.lock.newCondition();
- this.empty = this.lock.newCondition();
- }
- } finally {
- lock.unlock();
- }
- }
-
- if (this.inited) {
- LOG.error("maxWait changed : " + this.maxWait + " -> " + maxWaitMillis);
- }
-
- this.maxWait = maxWaitMillis;
- }
- }
-
- public int getNotFullTimeoutRetryCount() {
- return this.notFullTimeoutRetryCount;
- }
-
- public void setNotFullTimeoutRetryCount(int notFullTimeoutRetryCount) {
- this.notFullTimeoutRetryCount = notFullTimeoutRetryCount;
- }
-
- public int getMinIdle() {
- return this.minIdle;
- }
-
- public void setMinIdle(int value) {
- if (value != this.minIdle) {
- if (this.inited && value > this.maxActive) {
- throw new IllegalArgumentException("minIdle greater than maxActive, " + this.maxActive + " < " + this.minIdle);
- } else if (this.minIdle < 0) {
- throw new IllegalArgumentException("minIdle must > 0");
- } else {
- this.minIdle = value;
- }
- }
- }
-
- public int getMaxIdle() {
- return this.maxIdle;
- }
-
- /** @deprecated */
- @Deprecated
- public void setMaxIdle(int maxIdle) {
- LOG.error("maxIdle is deprecated");
- this.maxIdle = maxIdle;
- }
-
- public int getInitialSize() {
- return this.initialSize;
- }
-
- public void setInitialSize(int initialSize) {
- if (this.initialSize != initialSize) {
- if (this.inited) {
- throw new UnsupportedOperationException();
- } else {
- this.initialSize = initialSize;
- }
- }
- }
-
- public long getCreateErrorCount() {
- return (long)this.createErrorCount;
- }
-
- public int getMaxActive() {
- return this.maxActive;
- }
-
- public abstract void setMaxActive(int var1);
-
- public String getUsername() {
- return this.username;
- }
-
- public void setUsername(String username) {
- if (!StringUtils.equals(this.username, username)) {
-// if (this.inited) {
-// throw new UnsupportedOperationException();
-// } else {
- this.username = username;
-// }
- }
- }
-
- public String getPassword() {
- return this.password;
- }
-
- public void setPassword(String password) {
- if (!StringUtils.equals(this.password, password)) {
- if (this.inited) {
- LOG.info("password changed");
- }
-
- this.password = password;
- }
- }
-
- public Properties getConnectProperties() {
- return this.connectProperties;
- }
-
- public abstract void setConnectProperties(Properties var1);
-
- public void setConnectionProperties(String connectionProperties) {
- if (connectionProperties != null && connectionProperties.trim().length() != 0) {
- String[] entries = connectionProperties.split(";");
- Properties properties = new Properties();
-
- for(int i = 0; i < entries.length; ++i) {
- String entry = entries[i];
- if (entry.length() > 0) {
- int index = entry.indexOf(61);
- if (index > 0) {
- String name = entry.substring(0, index);
- String value = entry.substring(index + 1);
- properties.setProperty(name, value);
- } else {
- properties.setProperty(entry, "");
- }
- }
- }
-
- this.setConnectProperties(properties);
- } else {
- this.setConnectProperties((Properties)null);
- }
- }
-
- public String getUrl() {
- return this.jdbcUrl;
- }
-
- public String getRawJdbcUrl() {
- return this.jdbcUrl;
- }
-
- public void setUrl(String jdbcUrl) {
- if (!StringUtils.equals(this.jdbcUrl, jdbcUrl)) {
-// if (this.inited) {
-// throw new UnsupportedOperationException();
-// } else {
- if (jdbcUrl != null) {
- jdbcUrl = jdbcUrl.trim();
- }
-
- this.jdbcUrl = jdbcUrl;
-// }
- }
- }
-
- public String getDriverClassName() {
- return this.driverClass;
- }
-
- public void setDriverClassName(String driverClass) {
- if (driverClass != null && driverClass.length() > 256) {
- throw new IllegalArgumentException("driverClassName length > 256.");
- } else {
- if ("oracle.jdbc.driver.OracleDriver".equalsIgnoreCase(driverClass)) {
- driverClass = "oracle.jdbc.OracleDriver";
- LOG.warn("oracle.jdbc.driver.OracleDriver is deprecated.Having use oracle.jdbc.OracleDriver.");
- }
-
- if (this.inited) {
- if (!StringUtils.equals(this.driverClass, driverClass)) {
- throw new UnsupportedOperationException();
- }
- } else {
- this.driverClass = driverClass;
- }
- }
- }
-
- public ClassLoader getDriverClassLoader() {
- return this.driverClassLoader;
- }
-
- public void setDriverClassLoader(ClassLoader driverClassLoader) {
- this.driverClassLoader = driverClassLoader;
- }
-
- public PrintWriter getLogWriter() {
- return this.logWriter;
- }
-
- public void setLogWriter(PrintWriter out) throws SQLException {
- this.logWriter = out;
- }
-
- public void setLoginTimeout(int seconds) {
- DriverManager.setLoginTimeout(seconds);
- }
-
- public int getLoginTimeout() {
- return DriverManager.getLoginTimeout();
- }
-
- public Driver getDriver() {
- return this.driver;
- }
-
- public void setDriver(Driver driver) {
- this.driver = driver;
- }
-
- public int getDriverMajorVersion() {
- return this.driver == null ? -1 : this.driver.getMajorVersion();
- }
-
- public int getDriverMinorVersion() {
- return this.driver == null ? -1 : this.driver.getMinorVersion();
- }
-
- public ExceptionSorter getExceptionSorter() {
- return this.exceptionSorter;
- }
-
- public String getExceptionSorterClassName() {
- return this.exceptionSorter == null ? null : this.exceptionSorter.getClass().getName();
- }
-
- public void setExceptionSorter(ExceptionSorter exceptionSoter) {
- this.exceptionSorter = exceptionSoter;
- }
-
- public void setExceptionSorterClassName(String exceptionSorter) throws Exception {
- this.setExceptionSorter(exceptionSorter);
- }
-
- public void setExceptionSorter(String exceptionSorter) throws SQLException {
- if (exceptionSorter == null) {
- this.exceptionSorter = NullExceptionSorter.getInstance();
- } else {
- exceptionSorter = exceptionSorter.trim();
- if (exceptionSorter.length() == 0) {
- this.exceptionSorter = NullExceptionSorter.getInstance();
- } else {
- Class> clazz = Utils.loadClass(exceptionSorter);
- if (clazz == null) {
- LOG.error("load exceptionSorter error : " + exceptionSorter);
- } else {
- try {
- this.exceptionSorter = (ExceptionSorter)clazz.newInstance();
- } catch (Exception var4) {
- throw new SQLException("create exceptionSorter error", var4);
- }
- }
-
- }
- }
- }
-
- public List getProxyFilters() {
- return this.filters;
- }
-
- public void setProxyFilters(List filters) {
- if (filters != null) {
- this.filters.addAll(filters);
- }
-
- }
-
- public String[] getFilterClasses() {
- List filterConfigList = this.getProxyFilters();
- List classes = new ArrayList();
- Iterator var3 = filterConfigList.iterator();
-
- while(var3.hasNext()) {
- Filter filter = (Filter)var3.next();
- classes.add(filter.getClass().getName());
- }
-
- return (String[])classes.toArray(new String[classes.size()]);
- }
-
- public void setFilters(String filters) throws SQLException {
- if (filters != null && filters.startsWith("!")) {
- filters = filters.substring(1);
- this.clearFilters();
- }
-
- this.addFilters(filters);
- }
-
- public void addFilters(String filters) throws SQLException {
- if (filters != null && filters.length() != 0) {
- String[] filterArray = filters.split("\\,");
- String[] var3 = filterArray;
- int var4 = filterArray.length;
-
- for(int var5 = 0; var5 < var4; ++var5) {
- String item = var3[var5];
- FilterManager.loadFilter(this.filters, item.trim());
- }
-
- }
- }
-
- public void clearFilters() {
- if (this.isClearFiltersEnable()) {
- this.filters.clear();
- }
- }
-
- public void validateConnection(Connection conn) throws SQLException {
- String query = this.getValidationQuery();
- if (conn.isClosed()) {
- throw new SQLException("validateConnection: connection closed");
- } else if (this.validConnectionChecker != null) {
- boolean result = true;
- Exception error = null;
-
- try {
- result = this.validConnectionChecker.isValidConnection(conn, this.validationQuery, this.validationQueryTimeout);
- if (result && this.onFatalError) {
- this.lock.lock();
-
- try {
- if (this.onFatalError) {
- this.onFatalError = false;
- }
- } finally {
- this.lock.unlock();
- }
- }
- } catch (SQLException var24) {
- throw var24;
- } catch (Exception var25) {
- error = var25;
- }
-
- if (!result) {
- SQLException sqlError = error != null ? new SQLException("validateConnection false", error) : new SQLException("validateConnection false");
- throw sqlError;
- }
- } else {
- if (null != query) {
- Statement stmt = null;
- ResultSet rs = null;
-
- try {
- stmt = conn.createStatement();
- if (this.getValidationQueryTimeout() > 0) {
- stmt.setQueryTimeout(this.getValidationQueryTimeout());
- }
-
- rs = stmt.executeQuery(query);
- if (!rs.next()) {
- throw new SQLException("validationQuery didn't return a row");
- }
-
- if (this.onFatalError) {
- this.lock.lock();
-
- try {
- if (this.onFatalError) {
- this.onFatalError = false;
- }
- } finally {
- this.lock.unlock();
- }
- }
- } finally {
- JdbcUtils.close(rs);
- JdbcUtils.close(stmt);
- }
- }
-
- }
- }
-
- /** @deprecated */
- protected boolean testConnectionInternal(Connection conn) {
- return this.testConnectionInternal((DruidConnectionHolder)null, conn);
- }
-
- protected boolean testConnectionInternal(DruidConnectionHolder holder, Connection conn) {
- String sqlFile = JdbcSqlStat.getContextSqlFile();
- String sqlName = JdbcSqlStat.getContextSqlName();
- if (sqlFile != null) {
- JdbcSqlStat.setContextSqlFile((String)null);
- }
-
- if (sqlName != null) {
- JdbcSqlStat.setContextSqlName((String)null);
- }
-
- try {
- boolean valid;
- if (this.validConnectionChecker == null) {
- if (conn.isClosed()) {
- valid = false;
- return valid;
- } else if (null == this.validationQuery) {
- valid = true;
- return valid;
- } else {
- Statement stmt = null;
- ResultSet rset = null;
-
- boolean var7;
- try {
- stmt = conn.createStatement();
- if (this.getValidationQueryTimeout() > 0) {
- stmt.setQueryTimeout(this.validationQueryTimeout);
- }
-
- rset = stmt.executeQuery(this.validationQuery);
- if (!rset.next()) {
- var7 = false;
- return var7;
- }
- } finally {
- JdbcUtils.close(rset);
- JdbcUtils.close(stmt);
- }
-
- if (this.onFatalError) {
- this.lock.lock();
-
- try {
- if (this.onFatalError) {
- this.onFatalError = false;
- }
- } finally {
- this.lock.unlock();
- }
- }
-
- var7 = true;
- return var7;
- }
- } else {
- valid = this.validConnectionChecker.isValidConnection(conn, this.validationQuery, this.validationQueryTimeout);
- long currentTimeMillis = System.currentTimeMillis();
- if (holder != null) {
- holder.lastValidTimeMillis = currentTimeMillis;
- }
-
- if (valid && this.isMySql) {
- long lastPacketReceivedTimeMs = MySqlUtils.getLastPacketReceivedTimeMs(conn);
- if (lastPacketReceivedTimeMs > 0L) {
- long mysqlIdleMillis = currentTimeMillis - lastPacketReceivedTimeMs;
- if (lastPacketReceivedTimeMs > 0L && mysqlIdleMillis >= this.timeBetweenEvictionRunsMillis) {
- this.discardConnection(conn);
- String errorMsg = "discard long time none received connection. , jdbcUrl : " + this.jdbcUrl + ", jdbcUrl : " + this.jdbcUrl + ", lastPacketReceivedIdleMillis : " + mysqlIdleMillis;
- LOG.error(errorMsg);
- boolean var13 = false;
- return var13;
- }
- }
- }
-
- if (valid && this.onFatalError) {
- this.lock.lock();
-
- try {
- if (this.onFatalError) {
- this.onFatalError = false;
- }
- } finally {
- this.lock.unlock();
- }
- }
-
- boolean var46 = valid;
- return var46;
- }
- } catch (Throwable var41) {
- boolean var6 = false;
- return var6;
- } finally {
- if (sqlFile != null) {
- JdbcSqlStat.setContextSqlFile(sqlFile);
- }
-
- if (sqlName != null) {
- JdbcSqlStat.setContextSqlName(sqlName);
- }
-
- }
- }
-
- public Set getActiveConnections() {
- this.activeConnectionLock.lock();
-
- HashSet var1;
- try {
- var1 = new HashSet(this.activeConnections.keySet());
- } finally {
- this.activeConnectionLock.unlock();
- }
-
- return var1;
- }
-
- public List getActiveConnectionStackTrace() {
- List list = new ArrayList();
- Iterator var2 = this.getActiveConnections().iterator();
-
- while(var2.hasNext()) {
- DruidPooledConnection conn = (DruidPooledConnection)var2.next();
- list.add(Utils.toString(conn.getConnectStackTrace()));
- }
-
- return list;
- }
-
- public long getCreateTimespanNano() {
- return this.createTimespan;
- }
-
- public long getCreateTimespanMillis() {
- return this.createTimespan / 1000000L;
- }
-
- public Driver getRawDriver() {
- return this.driver;
- }
-
- public boolean isClearFiltersEnable() {
- return this.clearFiltersEnable;
- }
-
- public void setClearFiltersEnable(boolean clearFiltersEnable) {
- this.clearFiltersEnable = clearFiltersEnable;
- }
-
- public long createConnectionId() {
- return connectionIdSeedUpdater.incrementAndGet(this);
- }
-
- public long createStatementId() {
- return statementIdSeedUpdater.getAndIncrement(this);
- }
-
- public long createMetaDataId() {
- return metaDataIdSeedUpdater.getAndIncrement(this);
- }
-
- public long createResultSetId() {
- return resultSetIdSeedUpdater.getAndIncrement(this);
- }
-
- public long createTransactionId() {
- return transactionIdSeedUpdater.getAndIncrement(this);
- }
-
- void initStatement(DruidPooledConnection conn, Statement stmt) throws SQLException {
- boolean transaction = !conn.getConnectionHolder().underlyingAutoCommit;
- int queryTimeout = transaction ? this.getTransactionQueryTimeout() : this.getQueryTimeout();
- if (queryTimeout > 0) {
- stmt.setQueryTimeout(queryTimeout);
- }
-
- }
-
- public void handleConnectionException(DruidPooledConnection conn, Throwable t) throws SQLException {
- this.handleConnectionException(conn, t, (String)null);
- }
-
- public abstract void handleConnectionException(DruidPooledConnection var1, Throwable var2, String var3) throws SQLException;
-
- protected abstract void recycle(DruidPooledConnection var1) throws SQLException;
-
- public Connection createPhysicalConnection(String url, Properties info) throws SQLException {
- Object conn;
- if (this.getProxyFilters().size() == 0) {
- conn = this.getDriver().connect(url, info);
- } else {
- conn = (new FilterChainImpl(this)).connection_connect(info);
- }
-
- createCountUpdater.incrementAndGet(this);
- return (Connection)conn;
- }
-
- public DruidAbstractDataSource.PhysicalConnectionInfo createPhysicalConnection() throws SQLException {
- String url = this.getUrl();
- Properties connectProperties = this.getConnectProperties();
- String user;
- if (this.getUserCallback() != null) {
- user = this.getUserCallback().getName();
- } else {
- user = this.getUsername();
- }
-
- String password = this.getPassword();
- PasswordCallback passwordCallback = this.getPasswordCallback();
- if (passwordCallback != null) {
- if (passwordCallback instanceof DruidPasswordCallback) {
- DruidPasswordCallback druidPasswordCallback = (DruidPasswordCallback)passwordCallback;
- druidPasswordCallback.setUrl(url);
- druidPasswordCallback.setProperties(connectProperties);
- }
-
- char[] chars = passwordCallback.getPassword();
- if (chars != null) {
- password = new String(chars);
- }
- }
-
- Properties physicalConnectProperties = new Properties();
- if (connectProperties != null) {
- physicalConnectProperties.putAll(connectProperties);
- }
-
- if (user != null && user.length() != 0) {
- physicalConnectProperties.put("user", user);
- }
-
- if (password != null && password.length() != 0) {
- physicalConnectProperties.put("password", password);
- }
-
- Connection conn = null;
- long connectStartNanos = System.nanoTime();
- Map variables = this.initVariants ? new HashMap() : null;
- Map globalVariables = this.initGlobalVariants ? new HashMap() : null;
- createStartNanosUpdater.set(this, connectStartNanos);
- creatingCountUpdater.incrementAndGet(this);
- boolean var27 = false;
-
- long connectedNanos;
- long initedNanos;
- long validatedNanos;
- try {
- var27 = true;
- conn = this.createPhysicalConnection(url, physicalConnectProperties);
- connectedNanos = System.nanoTime();
- if (conn == null) {
- throw new SQLException("connect error, url " + url + ", driverClass " + this.driverClass);
- }
-
- this.initPhysicalConnection(conn, variables, globalVariables);
- initedNanos = System.nanoTime();
- this.validateConnection(conn);
- validatedNanos = System.nanoTime();
- this.setFailContinuous(false);
- this.setCreateError((Throwable)null);
- var27 = false;
- } catch (SQLException var28) {
- this.setCreateError(var28);
- JdbcUtils.close(conn);
- throw var28;
- } catch (RuntimeException var29) {
- this.setCreateError(var29);
- JdbcUtils.close(conn);
- throw var29;
- } catch (Error var30) {
- createErrorCountUpdater.incrementAndGet(this);
- this.setCreateError(var30);
- JdbcUtils.close(conn);
- throw var30;
- } finally {
- if (var27) {
- long nano = System.nanoTime() - connectStartNanos;
- this.createTimespan += nano;
- creatingCountUpdater.decrementAndGet(this);
- }
- }
-
- long nano = System.nanoTime() - connectStartNanos;
- this.createTimespan += nano;
- creatingCountUpdater.decrementAndGet(this);
- return new DruidAbstractDataSource.PhysicalConnectionInfo(conn, connectStartNanos, connectedNanos, initedNanos, validatedNanos, variables, globalVariables);
- }
-
- protected void setCreateError(Throwable ex) {
- if (ex == null) {
- this.lock.lock();
-
- try {
- if (this.createError != null) {
- this.createError = null;
- }
- } finally {
- this.lock.unlock();
- }
-
- } else {
- createErrorCountUpdater.incrementAndGet(this);
- long now = System.currentTimeMillis();
- this.lock.lock();
-
- try {
- this.createError = ex;
- this.lastCreateError = ex;
- this.lastCreateErrorTimeMillis = now;
- } finally {
- this.lock.unlock();
- }
-
- }
- }
-
- public boolean isFailContinuous() {
- return failContinuousUpdater.get(this) == 1;
- }
-
- protected void setFailContinuous(boolean fail) {
- if (fail) {
- failContinuousTimeMillisUpdater.set(this, System.currentTimeMillis());
- } else {
- failContinuousTimeMillisUpdater.set(this, 0L);
- }
-
- boolean currentState = failContinuousUpdater.get(this) == 1;
- if (currentState != fail) {
- if (fail) {
- failContinuousUpdater.set(this, 1);
- if (LOG.isInfoEnabled()) {
- LOG.info("{dataSource-" + this.getID() + "} failContinuous is true");
- }
- } else {
- failContinuousUpdater.set(this, 0);
- if (LOG.isInfoEnabled()) {
- LOG.info("{dataSource-" + this.getID() + "} failContinuous is false");
- }
- }
-
- }
- }
-
- public void initPhysicalConnection(Connection conn) throws SQLException {
- this.initPhysicalConnection(conn, (Map)null, (Map)null);
- }
-
- public void initPhysicalConnection(Connection conn, Map variables, Map globalVariables) throws SQLException {
- if (conn.getAutoCommit() != this.defaultAutoCommit) {
- conn.setAutoCommit(this.defaultAutoCommit);
- }
-
- if (this.defaultReadOnly != null && conn.isReadOnly() != this.defaultReadOnly) {
- conn.setReadOnly(this.defaultReadOnly);
- }
-
- if (this.getDefaultTransactionIsolation() != null && conn.getTransactionIsolation() != this.getDefaultTransactionIsolation()) {
- conn.setTransactionIsolation(this.getDefaultTransactionIsolation());
- }
-
- if (this.getDefaultCatalog() != null && this.getDefaultCatalog().length() != 0) {
- conn.setCatalog(this.getDefaultCatalog());
- }
-
- Collection initSqls = this.getConnectionInitSqls();
- if (initSqls.size() != 0 || variables != null || globalVariables != null) {
- Statement stmt = null;
-
- try {
- stmt = conn.createStatement();
- Iterator var6 = initSqls.iterator();
-
- String name;
- while(var6.hasNext()) {
- name = (String)var6.next();
- if (name != null) {
- stmt.execute(name);
- }
- }
-
- if ("mysql".equals(this.dbType) || "aliyun_ads".equals(this.dbType)) {
- ResultSet rs;
- Object value;
- if (variables != null) {
- rs = null;
-
- try {
- rs = stmt.executeQuery("show variables");
-
- while(rs.next()) {
- name = rs.getString(1);
- value = rs.getObject(2);
- variables.put(name, value);
- }
- } finally {
- JdbcUtils.close(rs);
- }
- }
-
- if (globalVariables != null) {
- rs = null;
-
- try {
- rs = stmt.executeQuery("show global variables");
-
- while(rs.next()) {
- name = rs.getString(1);
- value = rs.getObject(2);
- globalVariables.put(name, value);
- }
- } finally {
- JdbcUtils.close(rs);
- }
- }
- }
- } finally {
- JdbcUtils.close(stmt);
- }
-
- }
- }
-
- public abstract int getActivePeak();
-
- public CompositeDataSupport getCompositeData() throws JMException {
- JdbcDataSourceStat stat = this.getDataSourceStat();
- Map map = new HashMap();
- map.put("ID", this.getID());
- map.put("URL", this.getUrl());
- map.put("Name", this.getName());
- map.put("FilterClasses", this.getFilterClasses());
- map.put("CreatedTime", this.getCreatedTime());
- map.put("RawDriverClassName", this.getDriverClassName());
- map.put("RawUrl", this.getUrl());
- map.put("RawDriverMajorVersion", this.getRawDriverMajorVersion());
- map.put("RawDriverMinorVersion", this.getRawDriverMinorVersion());
- map.put("Properties", this.getProperties());
- map.put("ConnectionActiveCount", (long)this.getActiveCount());
- map.put("ConnectionActiveCountMax", this.getActivePeak());
- map.put("ConnectionCloseCount", this.getCloseCount());
- map.put("ConnectionCommitCount", this.getCommitCount());
- map.put("ConnectionRollbackCount", this.getRollbackCount());
- map.put("ConnectionConnectLastTime", stat.getConnectionStat().getConnectLastTime());
- map.put("ConnectionConnectErrorCount", this.getCreateCount());
- if (this.createError != null) {
- map.put("ConnectionConnectErrorLastTime", this.getLastCreateErrorTime());
- map.put("ConnectionConnectErrorLastMessage", this.createError.getMessage());
- map.put("ConnectionConnectErrorLastStackTrace", Utils.getStackTrace(this.createError));
- } else {
- map.put("ConnectionConnectErrorLastTime", (Object)null);
- map.put("ConnectionConnectErrorLastMessage", (Object)null);
- map.put("ConnectionConnectErrorLastStackTrace", (Object)null);
- }
-
- map.put("StatementCreateCount", stat.getStatementStat().getCreateCount());
- map.put("StatementPrepareCount", stat.getStatementStat().getPrepareCount());
- map.put("StatementPreCallCount", stat.getStatementStat().getPrepareCallCount());
- map.put("StatementExecuteCount", stat.getStatementStat().getExecuteCount());
- map.put("StatementRunningCount", stat.getStatementStat().getRunningCount());
- map.put("StatementConcurrentMax", stat.getStatementStat().getConcurrentMax());
- map.put("StatementCloseCount", stat.getStatementStat().getCloseCount());
- map.put("StatementErrorCount", stat.getStatementStat().getErrorCount());
- map.put("StatementLastErrorTime", (Object)null);
- map.put("StatementLastErrorMessage", (Object)null);
- map.put("StatementLastErrorStackTrace", (Object)null);
- map.put("StatementExecuteMillisTotal", stat.getStatementStat().getMillisTotal());
- map.put("StatementExecuteLastTime", stat.getStatementStat().getExecuteLastTime());
- map.put("ConnectionConnectingCount", stat.getConnectionStat().getConnectingCount());
- map.put("ResultSetCloseCount", stat.getResultSetStat().getCloseCount());
- map.put("ResultSetOpenCount", stat.getResultSetStat().getOpenCount());
- map.put("ResultSetOpenningCount", stat.getResultSetStat().getOpeningCount());
- map.put("ResultSetOpenningMax", stat.getResultSetStat().getOpeningMax());
- map.put("ResultSetFetchRowCount", stat.getResultSetStat().getFetchRowCount());
- map.put("ResultSetLastOpenTime", stat.getResultSetStat().getLastOpenTime());
- map.put("ResultSetErrorCount", stat.getResultSetStat().getErrorCount());
- map.put("ResultSetOpenningMillisTotal", stat.getResultSetStat().getAliveMillisTotal());
- map.put("ResultSetLastErrorTime", stat.getResultSetStat().getLastErrorTime());
- map.put("ResultSetLastErrorMessage", (Object)null);
- map.put("ResultSetLastErrorStackTrace", (Object)null);
- map.put("ConnectionConnectCount", this.getConnectCount());
- if (this.createError != null) {
- map.put("ConnectionErrorLastMessage", this.createError.getMessage());
- map.put("ConnectionErrorLastStackTrace", Utils.getStackTrace(this.createError));
- } else {
- map.put("ConnectionErrorLastMessage", (Object)null);
- map.put("ConnectionErrorLastStackTrace", (Object)null);
- }
-
- map.put("ConnectionConnectMillisTotal", stat.getConnectionStat().getConnectMillis());
- map.put("ConnectionConnectingCountMax", stat.getConnectionStat().getConnectingMax());
- map.put("ConnectionConnectMillisMax", stat.getConnectionStat().getConnectMillisMax());
- map.put("ConnectionErrorLastTime", stat.getConnectionStat().getErrorLastTime());
- map.put("ConnectionAliveMillisMax", stat.getConnectionConnectAliveMillisMax());
- map.put("ConnectionAliveMillisMin", stat.getConnectionConnectAliveMillisMin());
- map.put("ConnectionHistogram", stat.getConnectionHistogramValues());
- map.put("StatementHistogram", stat.getStatementStat().getHistogramValues());
- return new CompositeDataSupport(JdbcStatManager.getDataSourceCompositeType(), map);
- }
-
- public long getID() {
- return this.id;
- }
-
- public Date getCreatedTime() {
- return this.createdTime;
- }
-
- public abstract int getRawDriverMajorVersion();
-
- public abstract int getRawDriverMinorVersion();
-
- public abstract String getProperties();
-
- public Logger getParentLogger() throws SQLFeatureNotSupportedException {
- throw new SQLFeatureNotSupportedException();
- }
-
- public void closePreapredStatement(PreparedStatementHolder stmtHolder) {
- if (stmtHolder != null) {
- closedPreparedStatementCountUpdater.incrementAndGet(this);
- this.decrementCachedPreparedStatementCount();
- this.incrementCachedPreparedStatementDeleteCount();
- JdbcUtils.close(stmtHolder.statement);
- }
- }
-
- protected void cloneTo(DruidAbstractDataSource to) {
- to.defaultAutoCommit = this.defaultAutoCommit;
- to.defaultReadOnly = this.defaultReadOnly;
- to.defaultTransactionIsolation = this.defaultTransactionIsolation;
- to.defaultCatalog = this.defaultCatalog;
- to.name = this.name;
- to.username = this.username;
- to.password = this.password;
- to.jdbcUrl = this.jdbcUrl;
- to.driverClass = this.driverClass;
- to.connectProperties = this.connectProperties;
- to.passwordCallback = this.passwordCallback;
- to.userCallback = this.userCallback;
- to.initialSize = this.initialSize;
- to.maxActive = this.maxActive;
- to.minIdle = this.minIdle;
- to.maxIdle = this.maxIdle;
- to.maxWait = this.maxWait;
- to.validationQuery = this.validationQuery;
- to.validationQueryTimeout = this.validationQueryTimeout;
- to.testOnBorrow = this.testOnBorrow;
- to.testOnReturn = this.testOnReturn;
- to.testWhileIdle = this.testWhileIdle;
- to.poolPreparedStatements = this.poolPreparedStatements;
- to.sharePreparedStatements = this.sharePreparedStatements;
- to.maxPoolPreparedStatementPerConnectionSize = this.maxPoolPreparedStatementPerConnectionSize;
- to.logWriter = this.logWriter;
- if (this.filters != null) {
- to.filters = new ArrayList(this.filters);
- }
-
- to.exceptionSorter = this.exceptionSorter;
- to.driver = this.driver;
- to.queryTimeout = this.queryTimeout;
- to.transactionQueryTimeout = this.transactionQueryTimeout;
- to.accessToUnderlyingConnectionAllowed = this.accessToUnderlyingConnectionAllowed;
- to.timeBetweenEvictionRunsMillis = this.timeBetweenEvictionRunsMillis;
- to.numTestsPerEvictionRun = this.numTestsPerEvictionRun;
- to.minEvictableIdleTimeMillis = this.minEvictableIdleTimeMillis;
- to.removeAbandoned = this.removeAbandoned;
- to.removeAbandonedTimeoutMillis = this.removeAbandonedTimeoutMillis;
- to.logAbandoned = this.logAbandoned;
- to.maxOpenPreparedStatements = this.maxOpenPreparedStatements;
- if (this.connectionInitSqls != null) {
- to.connectionInitSqls = new ArrayList(this.connectionInitSqls);
- }
-
- to.dbType = this.dbType;
- to.timeBetweenConnectErrorMillis = this.timeBetweenConnectErrorMillis;
- to.validConnectionChecker = this.validConnectionChecker;
- to.connectionErrorRetryAttempts = this.connectionErrorRetryAttempts;
- to.breakAfterAcquireFailure = this.breakAfterAcquireFailure;
- to.transactionThresholdMillis = this.transactionThresholdMillis;
- to.dupCloseLogEnable = this.dupCloseLogEnable;
- to.isOracle = this.isOracle;
- to.useOracleImplicitCache = this.useOracleImplicitCache;
- to.asyncCloseConnectionEnable = this.asyncCloseConnectionEnable;
- to.createScheduler = this.createScheduler;
- to.destroyScheduler = this.destroyScheduler;
- }
-
- public abstract void discardConnection(Connection var1);
-
- public boolean isAsyncCloseConnectionEnable() {
- return this.isRemoveAbandoned() ? true : this.asyncCloseConnectionEnable;
- }
-
- public void setAsyncCloseConnectionEnable(boolean asyncCloseConnectionEnable) {
- this.asyncCloseConnectionEnable = asyncCloseConnectionEnable;
- }
-
- public ScheduledExecutorService getCreateScheduler() {
- return this.createScheduler;
- }
-
- public void setCreateScheduler(ScheduledExecutorService createScheduler) {
- if (this.isInited()) {
- throw new DruidRuntimeException("dataSource inited.");
- } else {
- this.createScheduler = createScheduler;
- }
- }
-
- public ScheduledExecutorService getDestroyScheduler() {
- return this.destroyScheduler;
- }
-
- public void setDestroyScheduler(ScheduledExecutorService destroyScheduler) {
- if (this.isInited()) {
- throw new DruidRuntimeException("dataSource inited.");
- } else {
- this.destroyScheduler = destroyScheduler;
- }
- }
-
- public boolean isInited() {
- return this.inited;
- }
-
- public int getMaxCreateTaskCount() {
- return this.maxCreateTaskCount;
- }
-
- public void setMaxCreateTaskCount(int maxCreateTaskCount) {
- if (maxCreateTaskCount < 1) {
- throw new IllegalArgumentException();
- } else {
- this.maxCreateTaskCount = maxCreateTaskCount;
- }
- }
-
- public boolean isFailFast() {
- return this.failFast;
- }
-
- public void setFailFast(boolean failFast) {
- this.failFast = failFast;
- }
-
- public int getOnFatalErrorMaxActive() {
- return this.onFatalErrorMaxActive;
- }
-
- public void setOnFatalErrorMaxActive(int onFatalErrorMaxActive) {
- this.onFatalErrorMaxActive = onFatalErrorMaxActive;
- }
-
- public boolean isOnFatalError() {
- return this.onFatalError;
- }
-
- public boolean isInitExceptionThrow() {
- return this.initExceptionThrow;
- }
-
- public void setInitExceptionThrow(boolean initExceptionThrow) {
- this.initExceptionThrow = initExceptionThrow;
- }
-
- public static class PhysicalConnectionInfo {
- private Connection connection;
- private long connectStartNanos;
- private long connectedNanos;
- private long initedNanos;
- private long validatedNanos;
- private Map vairiables;
- private Map globalVairiables;
- long createTaskId;
-
- public PhysicalConnectionInfo(Connection connection, long connectStartNanos, long connectedNanos, long initedNanos, long validatedNanos) {
- this(connection, connectStartNanos, connectedNanos, initedNanos, validatedNanos, (Map)null, (Map)null);
- }
-
- public PhysicalConnectionInfo(Connection connection, long connectStartNanos, long connectedNanos, long initedNanos, long validatedNanos, Map vairiables, Map globalVairiables) {
- this.connection = connection;
- this.connectStartNanos = connectStartNanos;
- this.connectedNanos = connectedNanos;
- this.initedNanos = initedNanos;
- this.validatedNanos = validatedNanos;
- this.vairiables = vairiables;
- this.globalVairiables = globalVairiables;
- }
-
- public Connection getPhysicalConnection() {
- return this.connection;
- }
-
- public long getConnectStartNanos() {
- return this.connectStartNanos;
- }
-
- public long getConnectedNanos() {
- return this.connectedNanos;
- }
-
- public long getInitedNanos() {
- return this.initedNanos;
- }
-
- public long getValidatedNanos() {
- return this.validatedNanos;
- }
-
- public long getConnectNanoSpan() {
- return this.connectedNanos - this.connectStartNanos;
- }
-
- public Map getVairiables() {
- return this.vairiables;
- }
-
- public Map getGlobalVairiables() {
- return this.globalVairiables;
- }
- }
-}
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/DataBackupApplication.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/DataBackupApplication.java
deleted file mode 100644
index 3279af5..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/DataBackupApplication.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package top.hcode.hoj;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.retry.annotation.EnableRetry;
-import org.springframework.scheduling.annotation.EnableAsync;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2020/10/22 23:25
- * @Description:
- */
-@EnableRetry
-@EnableScheduling // 开启定时任务
-@EnableDiscoveryClient // 开启注册发现
-@SpringBootApplication
-@EnableAsync(proxyTargetClass=true) //开启异步注解
-@EnableTransactionManagement
-public class DataBackupApplication {
- public static void main(String[] args) {
- SpringApplication.run(DataBackupApplication.class,args);
- }
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/advice/GlobalExceptionAdvice.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/advice/GlobalExceptionAdvice.java
deleted file mode 100644
index d2a7850..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/advice/GlobalExceptionAdvice.java
+++ /dev/null
@@ -1,299 +0,0 @@
-package top.hcode.hoj.advice;
-
-
-import com.google.protobuf.ServiceException;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.ibatis.exceptions.PersistenceException;
-import org.apache.shiro.ShiroException;
-import org.apache.shiro.authc.AuthenticationException;
-import org.apache.shiro.authz.AuthorizationException;
-import org.apache.shiro.authz.UnauthenticatedException;
-import org.springframework.dao.DataIntegrityViolationException;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.converter.HttpMessageNotReadableException;
-import org.springframework.validation.BindException;
-import org.springframework.validation.BindingResult;
-import org.springframework.validation.FieldError;
-import org.springframework.validation.ObjectError;
-import org.springframework.web.HttpMediaTypeNotSupportedException;
-import org.springframework.web.HttpRequestMethodNotSupportedException;
-import org.springframework.web.bind.MethodArgumentNotValidException;
-import org.springframework.web.bind.MissingServletRequestParameterException;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.bind.annotation.RestControllerAdvice;
-import top.hcode.hoj.common.exception.*;
-import top.hcode.hoj.common.result.CommonResult;
-import top.hcode.hoj.common.result.ResultStatus;
-import top.hcode.hoj.exception.AccessException;
-
-import javax.mail.MessagingException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.validation.ConstraintViolation;
-import javax.validation.ConstraintViolationException;
-import javax.validation.ValidationException;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.sql.SQLException;
-import java.util.Set;
-
-/**
- * 全局异常处理
- */
-@Slf4j(topic = "hoj")
-@RestControllerAdvice
-public class GlobalExceptionAdvice {
-
-
- /**
- * 400 - Internal Server Error 自定义通用异常
- */
- @ResponseStatus(HttpStatus.BAD_REQUEST)
- @ExceptionHandler(value = {StatusForbiddenException.class,
- StatusAccessDeniedException.class,
- StatusFailException.class,
- StatusNotFoundException.class,
- StatusSystemErrorException.class})
- public CommonResult handleCustomException(Exception e) {
- return CommonResult.errorResponse(e.getMessage(), ResultStatus.FAIL);
- }
-
-
- /**
- * 401 -UnAuthorized 处理AuthenticationException,token相关异常 即是认证出错 可能无法处理!
- */
- @ResponseStatus(HttpStatus.UNAUTHORIZED)
- @ExceptionHandler(value = AuthenticationException.class)
- public CommonResult handleAuthenticationException(AuthenticationException e,
- HttpServletRequest httpRequest,
- HttpServletResponse httpResponse) {
- httpResponse.setHeader("Url-Type", httpRequest.getHeader("Url-Type")); // 为了前端能区别请求来源
- return CommonResult.errorResponse(e.getMessage(), ResultStatus.ACCESS_DENIED);
- }
-
- /**
- * 401 -UnAuthorized UnauthenticatedException,token相关异常 即是认证出错 可能无法处理!
- * 没有登录(没有token),访问有@RequiresAuthentication的请求路径会报这个异常
- */
- @ResponseStatus(HttpStatus.UNAUTHORIZED)
- @ExceptionHandler(value = UnauthenticatedException.class)
- public CommonResult handleUnauthenticatedException(UnauthenticatedException e,
- HttpServletRequest httpRequest,
- HttpServletResponse httpResponse) {
- httpResponse.setHeader("Url-Type", httpRequest.getHeader("Url-Type")); // 为了前端能区别请求来源
- return CommonResult.errorResponse("请您先登录!", ResultStatus.ACCESS_DENIED);
- }
-
- /**
- * 403 -FORBIDDEN AuthorizationException异常 即是授权认证出错 可能无法处理!
- */
- @ResponseStatus(HttpStatus.FORBIDDEN)
- @ExceptionHandler(value = AuthorizationException.class)
- public CommonResult handleAuthenticationException(AuthorizationException e,
- HttpServletRequest httpRequest,
- HttpServletResponse httpResponse) {
- httpResponse.setHeader("Url-Type", httpRequest.getHeader("Url-Type")); // 为了前端能区别请求来源
- return CommonResult.errorResponse("对不起,您无权限进行此操作!", ResultStatus.FORBIDDEN);
- }
-
- /**
- * 403 -FORBIDDEN 处理shiro的异常 无法处理! 未能走到controller层
- */
- @ResponseStatus(HttpStatus.FORBIDDEN)
- @ExceptionHandler(value = ShiroException.class)
- public CommonResult handleShiroException(ShiroException e,
- HttpServletRequest httpRequest,
- HttpServletResponse httpResponse) {
- httpResponse.setHeader("Url-Type", httpRequest.getHeader("Url-Type")); // 为了前端能区别请求来源
- return CommonResult.errorResponse("对不起,您无权限进行此操作,请先登录进行授权认证", ResultStatus.FORBIDDEN);
- }
-
- /**
- * 403 -FORBIDDEN 处理访问api能力被禁止的异常
- */
- @ResponseStatus(HttpStatus.FORBIDDEN)
- @ExceptionHandler(value = AccessException.class)
- public CommonResult handleAccessException(AccessException e) {
- return CommonResult.errorResponse(e.getMessage(), ResultStatus.FORBIDDEN);
- }
-
- /**
- * 400 - Bad Request 处理Assert的异常 断言的异常!
- */
- @ResponseStatus(HttpStatus.BAD_REQUEST)
- @ExceptionHandler(value = IllegalArgumentException.class)
- public CommonResult handler(IllegalArgumentException e) {
- return CommonResult.errorResponse(e.getMessage(), ResultStatus.FAIL);
- }
-
- /**
- * 400 - Bad Request @Validated 校验错误异常处理
- */
- @ResponseStatus(HttpStatus.BAD_REQUEST)
- @ExceptionHandler(value = MethodArgumentNotValidException.class)
- public CommonResult handlerMethodArgumentNotValidException(MethodArgumentNotValidException e) throws IOException {
- BindingResult bindingResult = e.getBindingResult();
- ObjectError objectError = bindingResult.getAllErrors().stream().findFirst().get();
- return CommonResult.errorResponse(objectError.getDefaultMessage(), ResultStatus.FAIL);
- }
-
-
- /**
- * 400 - Bad Request 处理缺少请求参数
- */
- @ResponseStatus(HttpStatus.BAD_REQUEST)
- @ExceptionHandler(MissingServletRequestParameterException.class)
- public CommonResult handleMissingServletRequestParameterException(
- MissingServletRequestParameterException e) {
- return CommonResult.errorResponse("The required request parameters are missing:" + e.getMessage(), ResultStatus.FAIL);
- }
-
- /**
- * 400 - Bad Request 参数解析失败
- */
- @ResponseStatus(HttpStatus.BAD_REQUEST)
- @ExceptionHandler(HttpMessageNotReadableException.class)
- public CommonResult handleHttpMessageNotReadableException(
- HttpMessageNotReadableException e) {
- return CommonResult.errorResponse("Failed to parse parameter format!", ResultStatus.FAIL);
- }
-
-
- /**
- * 400 - Bad Request 参数绑定失败
- */
- @ResponseStatus(HttpStatus.BAD_REQUEST)
- @ExceptionHandler(BindException.class)
- public CommonResult handleBindException(BindException e) {
- BindingResult result = e.getBindingResult();
- FieldError error = result.getFieldError();
- String field = error.getField();
- String code = error.getDefaultMessage();
- String message = String.format("%s:%s", field, code);
- return CommonResult.errorResponse(message, ResultStatus.FAIL);
- }
-
- /**
- * 400 - Bad Request 参数验证失败
- */
- @ResponseStatus(HttpStatus.BAD_REQUEST)
- @ExceptionHandler(ConstraintViolationException.class)
- public CommonResult handleServiceException(ConstraintViolationException e) {
- Set> violations = e.getConstraintViolations();
- ConstraintViolation> violation = violations.iterator().next();
- String message = violation.getMessage();
- return CommonResult.errorResponse("[参数验证失败]parameter:" + message, ResultStatus.FAIL);
- }
-
- /**
- * 400 - Bad Request 实体校验失败
- */
- @ResponseStatus(HttpStatus.BAD_REQUEST)
- @ExceptionHandler(ValidationException.class)
- public CommonResult handleValidationException(ValidationException e) {
- return CommonResult.errorResponse("Entity verification failed. The request parameters are incorrect!", ResultStatus.FAIL);
- }
-
- /**
- * 405 - Method Not Allowed 不支持当前请求方法
- */
- @ResponseStatus(HttpStatus.METHOD_NOT_ALLOWED)
- @ExceptionHandler(HttpRequestMethodNotSupportedException.class)
- public CommonResult handleHttpRequestMethodNotSupportedException(
- HttpRequestMethodNotSupportedException e) {
- return CommonResult.errorResponse("The request method is not supported!", ResultStatus.FAIL);
- }
-
- /**
- * 415 - Unsupported Media Type 不支持当前媒体类型
- */
- @ResponseStatus(HttpStatus.UNSUPPORTED_MEDIA_TYPE)
- @ExceptionHandler(HttpMediaTypeNotSupportedException.class)
- public CommonResult handleHttpMediaTypeNotSupportedException(Exception e) {
- return CommonResult.errorResponse("The media type is not supported!", ResultStatus.FAIL);
- }
-
-
- /**
- * 500 - Internal Server Error 处理邮件发送出现的异常
- */
- @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
- @ExceptionHandler(value = MessagingException.class)
- public CommonResult handler(MessagingException e) {
- log.error("邮箱系统异常-------------->{}", getMessage(e));
- return CommonResult.errorResponse("Server Error! Please try Again later!", ResultStatus.SYSTEM_ERROR);
- }
-
- /**
- * 500 - Internal Server Error 业务逻辑异常
- */
- @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
- @ExceptionHandler(ServiceException.class)
- public CommonResult handleServiceException(ServiceException e) {
- log.error("业务逻辑异常-------------->{}", getMessage(e));
- return CommonResult.errorResponse("Server Error! Please try Again later!", ResultStatus.SYSTEM_ERROR);
- }
-
- /**
- * 500 - Internal Server Error 操作数据库出现异常:名称重复,外键关联
- */
- @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
- @ExceptionHandler(DataIntegrityViolationException.class)
- public CommonResult handleDataIntegrityViolationException(DataIntegrityViolationException e) {
- log.error("操作数据库出现异常-------------->{}", getMessage(e));
- return CommonResult.errorResponse("Server Error! Please try Again later!", ResultStatus.SYSTEM_ERROR);
- }
-
-
- /**
- * 500 - Internal Server Error 操作数据库出现异常
- */
- @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
- @ExceptionHandler(SQLException.class)
- public CommonResult handleSQLException(SQLException e) {
- log.error("操作数据库出现异常-------------->{}", getMessage(e));
- return CommonResult.errorResponse("Operation failed! Error message: " + e.getMessage(), ResultStatus.SYSTEM_ERROR);
- }
-
- /**
- * 500 - Internal Server Error 批量操作数据库出现异常:名称重复,外键关联
- */
- @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
- @ExceptionHandler(PersistenceException.class)
- public CommonResult handleBatchUpdateException(PersistenceException e) {
- log.error("操作数据库出现异常-------------->{}", getMessage(e));
- return CommonResult.errorResponse("请检查数据是否准确!可能原因:数据库中已有相同的数据导致重复冲突!", ResultStatus.SYSTEM_ERROR);
- }
-
-
- /**
- * 500 - Internal Server Error 系统通用异常
- */
- @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
- @ExceptionHandler(Exception.class)
- public CommonResult handleException(Exception e) {
- log.error("系统通用异常-------------->{}", getMessage(e));
- return CommonResult.errorResponse("Server Error!", ResultStatus.SYSTEM_ERROR);
- }
-
-
- /**
- * 打印异常信息
- */
- public static String getMessage(Exception e) {
- String swStr = null;
- try (StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw)) {
- e.printStackTrace(pw);
- pw.flush();
- sw.flush();
- swStr = sw.toString();
- } catch (IOException ex) {
- ex.printStackTrace();
- log.error(ex.getMessage());
- }
- return swStr;
- }
-}
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/annotation/HOJAccess.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/annotation/HOJAccess.java
deleted file mode 100644
index 90a8976..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/annotation/HOJAccess.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package top.hcode.hoj.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @Author Himit_ZH
- * @Date 2022/5/9
- */
-@Target({ElementType.TYPE, ElementType.METHOD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface HOJAccess {
- HOJAccessEnum[] value() default {};
-}
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/annotation/HOJAccessEnum.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/annotation/HOJAccessEnum.java
deleted file mode 100644
index b35385e..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/annotation/HOJAccessEnum.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package top.hcode.hoj.annotation;
-
-/**
- * @Author Himit_ZH
- * @Date 2022/5/9
- */
-public enum HOJAccessEnum {
- /**
- * 公共讨论区
- */
- PUBLIC_DISCUSSION,
-
- /**
- * 团队讨论区
- */
- GROUP_DISCUSSION,
-
- /**
- * 比赛评论
- */
- CONTEST_COMMENT,
-
- /**
- * 公共评测
- */
- PUBLIC_JUDGE,
-
- /**
- * 团队评测
- */
- GROUP_JUDGE,
-
- /**
- * 比赛评测
- */
- CONTEST_JUDGE,
-
- /**
- * 隐藏非比赛提交详情的代码
- */
- HIDE_NON_CONTEST_SUBMISSION_CODE
-}
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusAccessDeniedException.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusAccessDeniedException.java
deleted file mode 100644
index 624f5af..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusAccessDeniedException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package top.hcode.hoj.common.exception;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2022/3/9 10:30
- * @Description:
- */
-public class StatusAccessDeniedException extends Exception {
-
- public StatusAccessDeniedException() {
- }
-
- public StatusAccessDeniedException(String message) {
- super(message);
- }
-
- public StatusAccessDeniedException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public StatusAccessDeniedException(Throwable cause) {
- super(cause);
- }
-
- public StatusAccessDeniedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusFailException.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusFailException.java
deleted file mode 100644
index 7be8fff..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusFailException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package top.hcode.hoj.common.exception;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2022/3/9 10:27
- * @Description:
- */
-public class StatusFailException extends Exception{
- public StatusFailException() {
- }
-
- public StatusFailException(String message) {
- super(message);
- }
-
- public StatusFailException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public StatusFailException(Throwable cause) {
- super(cause);
- }
-
- public StatusFailException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusForbiddenException.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusForbiddenException.java
deleted file mode 100644
index c2814c7..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusForbiddenException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package top.hcode.hoj.common.exception;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2022/3/9 10:29
- * @Description:
- */
-public class StatusForbiddenException extends Exception{
-
- public StatusForbiddenException() {
- }
-
- public StatusForbiddenException(String message) {
- super(message);
- }
-
- public StatusForbiddenException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public StatusForbiddenException(Throwable cause) {
- super(cause);
- }
-
- public StatusForbiddenException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusNotFoundException.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusNotFoundException.java
deleted file mode 100644
index 5c80059..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusNotFoundException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package top.hcode.hoj.common.exception;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2022/3/9 10:30
- * @Description:
- */
-public class StatusNotFoundException extends Exception{
-
- public StatusNotFoundException() {
- }
-
- public StatusNotFoundException(String message) {
- super(message);
- }
-
- public StatusNotFoundException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public StatusNotFoundException(Throwable cause) {
- super(cause);
- }
-
- public StatusNotFoundException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusSystemErrorException.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusSystemErrorException.java
deleted file mode 100644
index 88f000d..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/exception/StatusSystemErrorException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package top.hcode.hoj.common.exception;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2022/3/10 14:33
- * @Description:
- */
-public class StatusSystemErrorException extends Exception {
-
- public StatusSystemErrorException() {
- }
-
- public StatusSystemErrorException(String message) {
- super(message);
- }
-
- public StatusSystemErrorException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public StatusSystemErrorException(Throwable cause) {
- super(cause);
- }
-
- public StatusSystemErrorException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/result/CommonResult.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/result/CommonResult.java
deleted file mode 100644
index 880c928..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/result/CommonResult.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package top.hcode.hoj.common.result;
-
-import lombok.Data;
-
-@Data
-public class CommonResult{
-
- private final Integer status; // 状态码
-
- private final T data; // 返回的数据
-
- private final String msg; // 自定义信息
-
-
- /**
- * 成功的结果
- *
- * @param data 返回结果
- * @param msg 返回信息
- */
- public static CommonResult successResponse(T data, String msg) {
- return new CommonResult<>(ResultStatus.SUCCESS.getStatus(), data, msg);
- }
-
-
- /**
- * 成功的结果
- *
- * @param data 返回结果
- */
- public static CommonResult successResponse(T data) {
- return new CommonResult(ResultStatus.SUCCESS.getStatus(), data, "success");
- }
-
- /**
- * 成功的结果
- *
- * @param msg 返回信息
- */
- public static CommonResult successResponse(String msg) {
- return new CommonResult(ResultStatus.SUCCESS.getStatus(), null, msg);
- }
-
- /**
- * 成功的结果
- */
- public static CommonResult successResponse() {
- return new CommonResult(ResultStatus.SUCCESS.getStatus(), null, "success");
- }
-
-
- /**
- * 失败的结果,无异常
- *
- * @param msg 返回信息
- */
- public static CommonResult errorResponse(String msg) {
- return new CommonResult(ResultStatus.FAIL.getStatus(), null, msg);
- }
-
- public static CommonResult errorResponse(ResultStatus resultStatus) {
- return new CommonResult(resultStatus.getStatus(), null, resultStatus.getDescription());
- }
-
- public static CommonResult errorResponse(String msg, ResultStatus resultStatus) {
- return new CommonResult(resultStatus.getStatus(), null, msg);
- }
-
- public static CommonResult errorResponse(String msg, Integer status) {
- return new CommonResult(status, null, msg);
- }
-
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/result/ResultStatus.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/result/ResultStatus.java
deleted file mode 100644
index 9e71faa..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/common/result/ResultStatus.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package top.hcode.hoj.common.result;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2022/3/9 15:17
- * @Description:
- */
-@Getter
-@AllArgsConstructor
-public enum ResultStatus {
-
- SUCCESS(200,"成功"),
-
- FAIL(400,"失败"),
-
- ACCESS_DENIED(401,"访问受限"),
-
- FORBIDDEN(403,"拒绝访问"),
-
- NOT_FOUND(404,"数据不存在"),
-
- SYSTEM_ERROR(500,"系统错误");
-
-
- private int status;
-
- private String description;
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/AsyncTaskConfig.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/AsyncTaskConfig.java
deleted file mode 100644
index 7cc62f2..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/AsyncTaskConfig.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package top.hcode.hoj.config;
-
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.annotation.AsyncConfigurer;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-
-import java.lang.reflect.Method;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ThreadPoolExecutor;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2020/11/6 23:36
- * @Description: 通用异步线程池
- */
-@Configuration
-@Slf4j(topic = "hoj")
-public class AsyncTaskConfig implements AsyncConfigurer {
- @Override
- public Executor getAsyncExecutor() {
- ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
- // 线程池维护线程的最少数量
- taskExecutor.setCorePoolSize(10);
- // 线程池维护线程的最大数量
- taskExecutor.setMaxPoolSize(20);
- // 缓存队列
- taskExecutor.setQueueCapacity(200);
- //活跃时间
- taskExecutor.setKeepAliveSeconds(3);
- // 对拒绝task的处理策略
- //(1) 默认的ThreadPoolExecutor.AbortPolicy 处理程序遭到拒绝将抛出运行时RejectedExecutionException;
- //(2) ThreadPoolExecutor.CallerRunsPolicy 线程调用运行该任务的 execute 本身。此策略提供简单的反馈控制机制,能够减缓新任务的提交速度
- //(3) ThreadPoolExecutor.DiscardPolicy 不能执行的任务将被删除;
- //(4) ThreadPoolExecutor.DiscardOldestPolicy 如果执行程序尚未关闭,则位于工作队列头部的任务将被删除,然后重试执行程序(如果再次失败,则重复此过程)
- taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
- // 线程名前缀,方便排查问题
- taskExecutor.setThreadNamePrefix("CommonThread-");
- // 注意一定要初始化
- taskExecutor.initialize();
-
- return taskExecutor;
-
- }
-
- /**
- * 异步任务中异常处理
- * @return
- */
- @Override
- public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
- return new AsyncUncaughtExceptionHandler() {
-
- @Override
- public void handleUncaughtException(Throwable arg0, Method arg1, Object... arg2) {
- log.error("==========================" + arg0.getMessage() + "=======================", arg0);
- log.error("exception method:" + arg1.getName());
- }
- };
- }
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/DataSourceConfigure.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/DataSourceConfigure.java
deleted file mode 100644
index d9fe45c..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/DataSourceConfigure.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package top.hcode.hoj.config;
-
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.cloud.context.config.annotation.RefreshScope;
-import org.springframework.stereotype.Component;
-
-/**
- * @Author Himit_ZH
- * @Date 2022/6/15
- */
-@Component
-@RefreshScope
-@ConfigurationProperties(prefix = "hoj.db")
-@Data
-public class DataSourceConfigure {
-
- private String username;
-
- private String password;
-
- private String host;
-
- private Integer port;
-
- private String name;
-}
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/DruidConfigure.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/DruidConfigure.java
deleted file mode 100644
index 654c18c..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/DruidConfigure.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package top.hcode.hoj.config;
-
-import com.alibaba.druid.pool.DruidDataSource;
-import lombok.Data;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.cloud.context.config.annotation.RefreshScope;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import java.util.Optional;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2021/5/21 17:57
- * @Description:
- */
-@Configuration
-@RefreshScope
-@Data
-@Slf4j(topic = "hoj")
-public class DruidConfigure {
-
- @Value("${mysql-username}")
- private String username;
-
- @Value("${mysql-password}")
- private String password;
-
- @Value("${mysql-host}")
- private String host;
-
- @Value("${mysql-port}")
- private Integer port;
-
- @Value("${mysql-name}")
- private String name;
-
- @Value("${spring.datasource.driver-class-name}")
- private String driverClassName;
-
- @Value("${spring.datasource.type}")
- private String type;
-
- @Value("${spring.datasource.initial-size}")
- private Integer initialSize;
-
- @Value("${spring.datasource.poolPreparedStatements:true}")
- private Boolean poolPreparedStatements;
-
- @Value("${spring.datasource.maxPoolPreparedStatementPerConnectionSize:20}")
- private Integer maxPoolPreparedStatementPerConnectionSize;
-
- @Value("${spring.datasource.timeBetweenEvictionRunsMillis:60000}")
- private Integer timeBetweenEvictionRunsMillis;
-
- @Value("${spring.datasource.minEvictableIdleTimeMillis:300000}")
- private Integer minEvictableIdleTimeMillis;
-
- @Value("${spring.datasource.validationQuery}")
- private String validationQuery;
-
- @Value("${spring.datasource.testWhileIdle:true}")
- private Boolean testWhileIdle;
-
- @Value("${spring.datasource.testOnBorrow:false}")
- private Boolean testOnBorrow;
-
- @Value("${spring.datasource.testOnReturn:false}")
- private Boolean testOnReturn;
-
- @Value("${spring.datasource.connectionErrorRetryAttempts:3}")
- private Integer connectionErrorRetryAttempts;
-
- @Value("${spring.datasource.breakAfterAcquireFailure:true}")
- private Boolean breakAfterAcquireFailure;
-
- @Value("${spring.datasource.timeBetweenConnectErrorMillis:300000}")
- private Integer timeBetweenConnectErrorMillis;
-
- @Value("${spring.datasource.min-idle}")
- private Integer minIdle;
-
- @Value("${spring.datasource.maxActive}")
- private Integer maxActive;
-
- @Value("${spring.datasource.maxWait}")
- private Integer maxWait;
-
- @Autowired
- private DataSourceConfigure dataSourceConfigure;
-
- @Bean(name = "datasource")
- @RefreshScope
- public DruidDataSource dataSource(){
-
- String mysqlHost = Optional.ofNullable(dataSourceConfigure.getHost()).orElseGet(() -> host);
- Integer mysqlPort = Optional.ofNullable(dataSourceConfigure.getPort()).orElseGet(() -> port);
- String mysqlName = Optional.ofNullable(dataSourceConfigure.getName()).orElseGet(() -> name);
- String mysqlUsername = Optional.ofNullable(dataSourceConfigure.getUsername()).orElseGet(() -> username);
- String mysqlUserPassword = Optional.ofNullable(dataSourceConfigure.getPassword()).orElseGet(() -> password);
-
- log.warn("[MySQL] [Config Change] name:[{}], host:[{}], port:[{}], username:[{}], password:[{}]", mysqlName, mysqlHost, mysqlPort, mysqlUsername, mysqlUserPassword);
-
- DruidDataSource datasource = new DruidDataSource();
- String url = "jdbc:mysql://" + mysqlHost + ":" + mysqlPort + "/" + mysqlName + "?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&rewriteBatchedStatements=true";
- datasource.setUrl(url);
- datasource.setUsername(mysqlUsername);
- datasource.setPassword(mysqlUserPassword);
- datasource.setDriverClassName(driverClassName);
- datasource.setDbType(type);
- datasource.setMaxActive(maxActive);
- datasource.setInitialSize(initialSize);
- datasource.setMinIdle(minIdle);
- datasource.setMaxWait(maxWait);
- datasource.setPoolPreparedStatements(poolPreparedStatements);
- datasource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
- datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
- datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
- datasource.setValidationQuery(validationQuery);
- datasource.setTestWhileIdle(testWhileIdle);
- datasource.setTestOnReturn(testOnReturn);
- datasource.setTestOnBorrow(testOnBorrow);
- datasource.setConnectionErrorRetryAttempts(connectionErrorRetryAttempts);
- datasource.setBreakAfterAcquireFailure(breakAfterAcquireFailure);
- datasource.setTimeBetweenConnectErrorMillis(timeBetweenConnectErrorMillis);
- return datasource;
- }
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/JedisPoolConfigure.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/JedisPoolConfigure.java
deleted file mode 100644
index 055ced8..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/JedisPoolConfigure.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package top.hcode.hoj.config;
-
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.cloud.context.config.annotation.RefreshScope;
-import org.springframework.stereotype.Component;
-
-/**
- * @Author Himit_ZH
- * @Date 2022/6/15
- */
-@Component
-@RefreshScope
-@ConfigurationProperties(prefix = "hoj.redis")
-@Data
-public class JedisPoolConfigure {
- private String host;
-
- private Integer port;
-
- private String password;
-}
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/JudgeAsyncTaskConfig.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/JudgeAsyncTaskConfig.java
deleted file mode 100644
index 96b8294..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/JudgeAsyncTaskConfig.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package top.hcode.hoj.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.annotation.EnableAsync;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-
-import java.util.concurrent.Executor;
-import java.util.concurrent.ThreadPoolExecutor;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2021/5/24 16:54
- * @Description: 专用于判题的异步线程池
- */
-@Configuration
-@EnableAsync
-public class JudgeAsyncTaskConfig {
- @Bean
- public Executor judgeTaskAsyncPool() {
- ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
- //核心线程池大小
- executor.setCorePoolSize(2);
- //最大线程数
- executor.setMaxPoolSize(10);
- //队列容量
- executor.setQueueCapacity(500);
- //活跃时间
- executor.setKeepAliveSeconds(3);
- //线程名字前缀
- executor.setThreadNamePrefix("JudgeExecutor-");
-
- // setRejectedExecutionHandler:当pool已经达到max size的时候,如何处理新任务
- // CallerRunsPolicy:不在新线程中执行任务,而是由调用者所在的线程来执行
- executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
- executor.initialize();
- return executor;
- }
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/MyMetaObjectConfig.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/MyMetaObjectConfig.java
deleted file mode 100644
index a407eff..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/MyMetaObjectConfig.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package top.hcode.hoj.config;
-
-import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
-import org.apache.ibatis.reflection.MetaObject;
-import org.springframework.stereotype.Component;
-
-import java.util.Date;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2020/12/4 14:14
- * @Description: 处理mybatis-plus自动填充时间
- */
-@Component
-public class MyMetaObjectConfig implements MetaObjectHandler {
- @Override
- public void insertFill(MetaObject metaObject) {
- this.setFieldValByName("gmtCreate",new Date(),metaObject);
- this.setFieldValByName("gmtModified",new Date(),metaObject);
- }
-
- @Override
- public void updateFill(MetaObject metaObject) {
- this.setFieldValByName("gmtModified", new Date(), metaObject);
- }
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/MybatisPlusConfig.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/MybatisPlusConfig.java
deleted file mode 100644
index f5c4ffd..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/MybatisPlusConfig.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package top.hcode.hoj.config;
-import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
-import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2020/7/19 21:04
- * @Description:
- */
-@Configuration
-@EnableTransactionManagement
-@MapperScan("top.hcode.hoj.mapper")
-public class MybatisPlusConfig {
-
- // 注册乐观锁插件
- @Bean
- public OptimisticLockerInterceptor optimisticLockerInterceptor() {
- return new OptimisticLockerInterceptor();
- }
-
- // 分页插件
- @Bean
- public PaginationInterceptor paginationInterceptor() {
- return new PaginationInterceptor();
- }
-
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/RedisAutoConfig.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/RedisAutoConfig.java
deleted file mode 100644
index e4c2307..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/RedisAutoConfig.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package top.hcode.hoj.config;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.cloud.context.config.annotation.RefreshScope;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.connection.RedisPassword;
-import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
-import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
-import redis.clients.jedis.JedisPoolConfig;
-
-import java.util.Optional;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2021/5/21 15:53
- * @Description:
- */
-@Configuration
-public class RedisAutoConfig {
-
- @Value("${spring.redis.jedis.pool.max-active:200}")
- private Integer maxActive;
- @Value("${spring.redis.jedis.pool.max-idle:50}")
- private Integer maxIdle;
- @Value("${spring.redis.jedis.pool.max-wait:-1}")
- private Long maxWait;
- @Value("${spring.redis.jedis.pool.min-idle:10}")
- private Integer minIdle;
-
- @Value("${redis-host}")
- private String redisHost;
- @Value("${redis-port}")
- private Integer redisPort;
- @Value("${redis-password}")
- private String redisPassword;
-
- @Autowired
- private JedisPoolConfigure jedisPoolConfigure;
-
-
- @Bean
- public RedisConnectionFactory redisConnectionFactory(JedisPoolConfig jedisPool,
- RedisStandaloneConfiguration jedisConfig) {
- JedisConnectionFactory connectionFactory = new JedisConnectionFactory(jedisConfig);
- connectionFactory.setPoolConfig(jedisPool);
- return connectionFactory;
- }
-
- @Bean
- public JedisPoolConfig jedisPool() {
- JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
- jedisPoolConfig.setMaxIdle(maxIdle);
- jedisPoolConfig.setMaxWaitMillis(maxWait);
- jedisPoolConfig.setMaxTotal(maxActive);
- jedisPoolConfig.setMinIdle(minIdle);
- return jedisPoolConfig;
- }
-
- @Bean
- @RefreshScope
- public RedisStandaloneConfiguration jedisConfig() {
- RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
- config.setHostName(Optional.ofNullable(jedisPoolConfigure.getHost()).orElseGet(() -> redisHost));
- config.setPort(Optional.ofNullable(jedisPoolConfigure.getPort()).orElseGet(() -> redisPort));
- config.setPassword(RedisPassword.of(Optional.ofNullable(jedisPoolConfigure.getPassword()).orElseGet(() -> redisPassword)));
- return config;
- }
-
-}
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/RedisConfig.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/RedisConfig.java
deleted file mode 100644
index c8948e7..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/RedisConfig.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package top.hcode.hoj.config;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2020/10/23 23:47
- * @Description:
- */
-@Configuration
-public class RedisConfig {
- // 自己定义了一个 RedisTemplate
- @Bean(name = "redisTemplate")
- @SuppressWarnings("all")
- public RedisTemplate redisTemplate(RedisConnectionFactory factory) {
- // 我们为了自己开发方便,一般直接使用
- RedisTemplate template = new RedisTemplate();
- template.setConnectionFactory(factory);
-
- // Json序列化配置
- Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
- ObjectMapper om = new ObjectMapper();
- om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
- om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
- jackson2JsonRedisSerializer.setObjectMapper(om);
- // String 的序列化
- StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
-
- // key采用String的序列化方式
- template.setKeySerializer(stringRedisSerializer);
- // hash的key也采用String的序列化方式
- template.setHashKeySerializer(stringRedisSerializer);
- // value序列化方式采用jackson
- template.setValueSerializer(jackson2JsonRedisSerializer);
- // hash的value序列化方式采用jackson
- template.setHashValueSerializer(jackson2JsonRedisSerializer);
- template.afterPropertiesSet();
-
- return template;
- }
-
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/RestTemplateConfig.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/RestTemplateConfig.java
deleted file mode 100644
index 5dc8336..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/RestTemplateConfig.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package top.hcode.hoj.config;
-
-import org.springframework.cloud.client.loadbalancer.LoadBalanced;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.client.ClientHttpRequestFactory;
-import org.springframework.http.client.SimpleClientHttpRequestFactory;
-import org.springframework.web.client.RestTemplate;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2020/5/19 22:47
- * @Description:
- */
-@Configuration
-public class RestTemplateConfig {
- @Bean
- public RestTemplate restTemplate(ClientHttpRequestFactory factory)
- {
- return new RestTemplate(factory);
- }
-
- @Bean
- public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
- SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
- factory.setReadTimeout(600000);//单位为ms
- factory.setConnectTimeout(50000);//单位为ms
- return factory;
- }
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/ShiroConfig.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/ShiroConfig.java
deleted file mode 100644
index 6bf509c..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/ShiroConfig.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package top.hcode.hoj.config;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2020/7/19 22:53
- * @Description:
- */
-
-import org.apache.shiro.mgt.DefaultSessionStorageEvaluator;
-import org.apache.shiro.mgt.DefaultSubjectDAO;
-import org.apache.shiro.mgt.SecurityManager;
-import org.apache.shiro.session.mgt.SessionManager;
-import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
-import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
-import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition;
-import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition;
-import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
-import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;
-import org.crazycake.shiro.RedisCacheManager;
-import org.crazycake.shiro.RedisSessionDAO;
-import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import top.hcode.hoj.shiro.AccountRealm;
-import top.hcode.hoj.shiro.JwtFilter;
-
-
-import javax.servlet.Filter;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * shiro启用注解拦截控制器
- */
-@Configuration
-public class ShiroConfig {
- @Autowired
- JwtFilter jwtFilter;
-
- @Bean
- public SessionManager sessionManager(RedisSessionDAO redisSessionDAO) {
- DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
- sessionManager.setSessionDAO(redisSessionDAO);
- return sessionManager;
- }
-
-
- @Bean
- public DefaultWebSecurityManager securityManager(AccountRealm accountRealm,
- SessionManager sessionManager,
- RedisCacheManager redisCacheManager) {
- DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(accountRealm);
- securityManager.setSessionManager(sessionManager);
- securityManager.setCacheManager(redisCacheManager);
- /*
- * 关闭shiro自带的session,详情见文档
- */
- DefaultSubjectDAO subjectDAO = new DefaultSubjectDAO();
- DefaultSessionStorageEvaluator defaultSessionStorageEvaluator = new DefaultSessionStorageEvaluator();
- defaultSessionStorageEvaluator.setSessionStorageEnabled(false);
- subjectDAO.setSessionStorageEvaluator(defaultSessionStorageEvaluator);
- securityManager.setSubjectDAO(subjectDAO);
- return securityManager;
- }
- @Bean
- public ShiroFilterChainDefinition shiroFilterChainDefinition() {
- DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
- Map filterMap = new LinkedHashMap<>();
- filterMap.put("/**", "jwt"); // 主要通过注解方式校验权限
- chainDefinition.addPathDefinitions(filterMap);
- return chainDefinition;
- }
- @Bean("shiroFilterFactoryBean")
- public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager,
- ShiroFilterChainDefinition shiroFilterChainDefinition) {
- ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean();
- shiroFilter.setSecurityManager(securityManager);
- Map filters = new HashMap<>();
- filters.put("jwt", jwtFilter);
- shiroFilter.setFilters(filters);
- Map filterMap = shiroFilterChainDefinition.getFilterChainMap();
- shiroFilter.setFilterChainDefinitionMap(filterMap);
- return shiroFilter;
- }
-
- //开启注解代理(默认好像已经开启,可以不要)
- @Bean
- public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager){
- AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
- authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
- return authorizationAttributeSourceAdvisor;
- }
- @Bean
- public static DefaultAdvisorAutoProxyCreator getDefaultAdvisorAutoProxyCreator() {
- DefaultAdvisorAutoProxyCreator creator = new DefaultAdvisorAutoProxyCreator();
- creator.setProxyTargetClass(true);
- return creator;
- }
-}
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/StartupRunner.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/StartupRunner.java
deleted file mode 100644
index 5e58cfa..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/StartupRunner.java
+++ /dev/null
@@ -1,448 +0,0 @@
-package top.hcode.hoj.config;
-
-import cn.hutool.core.util.IdUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
-import lombok.extern.slf4j.Slf4j;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.CommandLineRunner;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-import top.hcode.hoj.crawler.language.LanguageContext;
-import top.hcode.hoj.dao.judge.RemoteJudgeAccountEntityService;
-import top.hcode.hoj.dao.problem.LanguageEntityService;
-import top.hcode.hoj.manager.admin.system.ConfigManager;
-import top.hcode.hoj.pojo.entity.judge.RemoteJudgeAccount;
-import top.hcode.hoj.pojo.entity.problem.Language;
-import top.hcode.hoj.pojo.vo.ConfigVo;
-import top.hcode.hoj.utils.Constants;
-
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2021/2/19 22:11
- * @Description:项目启动后,初始化运行该run方法
- */
-@Component
-@Slf4j(topic = "hoj")
-public class StartupRunner implements CommandLineRunner {
-
- @Autowired
- private ConfigVo configVo;
-
- @Autowired
- private ConfigManager configManager;
-
- @Autowired
- private RemoteJudgeAccountEntityService remoteJudgeAccountEntityService;
-
- @Autowired
- private LanguageEntityService languageEntityService;
-
- @Value("${open-remote-judge}")
- private String openRemoteJudge;
-
- // jwt配置
- @Value("${jwt-token-secret}")
- private String tokenSecret;
-
- @Value("${jwt-token-expire}")
- private String tokenExpire;
-
- @Value("${jwt-token-fresh-expire}")
- private String checkRefreshExpire;
-
- // 数据库配置
- @Value("${mysql-username}")
- private String mysqlUsername;
-
- @Value("${mysql-password}")
- private String mysqlPassword;
-
- @Value("${mysql-name}")
- private String mysqlDBName;
-
- @Value("${mysql-host}")
- private String mysqlHost;
-
- @Value("${mysql-public-host}")
- private String mysqlPublicHost;
-
- @Value("${mysql-port}")
- private Integer mysqlPort;
-
- @Value("${mysql-public-port}")
- private Integer mysqlPublicPort;
-
- // 缓存配置
- @Value("${redis-host}")
- private String redisHost;
-
- @Value("${redis-port}")
- private Integer redisPort;
-
- @Value("${redis-password}")
- private String redisPassword;
- // 判题服务token
- @Value("${judge-token}")
- private String judgeToken;
-
- // 邮箱配置
- @Value("${email-username}")
- private String emailUsername;
-
- @Value("${email-password}")
- private String emailPassword;
-
- @Value("${email-host}")
- private String emailHost;
-
- @Value("${email-port}")
- private Integer emailPort;
-
- @Value("${hdu-username-list}")
- private List hduUsernameList;
-
- @Value("${hdu-password-list}")
- private List hduPasswordList;
-
- @Value("${cf-username-list}")
- private List cfUsernameList;
-
- @Value("${cf-password-list}")
- private List cfPasswordList;
-
- @Value("${poj-username-list}")
- private List pojUsernameList;
-
- @Value("${poj-password-list}")
- private List pojPasswordList;
-
- @Value("${atcoder-username-list}")
- private List atcoderUsernameList;
-
- @Value("${atcoder-password-list}")
- private List atcoderPasswordList;
-
- @Value("${spoj-username-list}")
- private List spojUsernameList;
-
- @Value("${spoj-password-list}")
- private List spojPasswordList;
-
- @Value("${forced-update-remote-judge-account}")
- private Boolean forcedUpdateRemoteJudgeAccount;
-
- @Override
- public void run(String... args) throws Exception {
-
- // 动态修改nacos上的配置文件
- if (judgeToken.equals("default")) {
- configVo.setJudgeToken(IdUtil.fastSimpleUUID());
- } else {
- configVo.setJudgeToken(judgeToken);
- }
-
- if (tokenSecret.equals("default")) {
- configVo.setTokenSecret(IdUtil.fastSimpleUUID());
- } else {
- configVo.setTokenSecret(tokenSecret);
- }
- configVo.setTokenExpire(tokenExpire);
- configVo.setCheckRefreshExpire(checkRefreshExpire);
-
- configVo.setMysqlUsername(mysqlUsername);
- configVo.setMysqlPassword(mysqlPassword);
- configVo.setMysqlHost(mysqlHost);
- configVo.setMysqlPublicHost(mysqlPublicHost);
- configVo.setMysqlPort(mysqlPort);
- configVo.setMysqlPublicPort(mysqlPublicPort);
- configVo.setMysqlDBName(mysqlDBName);
-
- configVo.setRedisHost(redisHost);
- configVo.setRedisPort(redisPort);
- configVo.setRedisPassword(redisPassword);
-
- if (configVo.getEmailHost() == null || !"your_email_host".equals(emailHost)) {
- configVo.setEmailHost(emailHost);
- }
- if (configVo.getEmailPort() == null || emailPort != 456) {
- configVo.setEmailPort(emailPort);
- }
- if (configVo.getEmailUsername() == null || !"your_email_username".equals(emailUsername)) {
- configVo.setEmailUsername(emailUsername);
- }
- if (configVo.getEmailPassword() == null || !"your_email_password".equals(emailPassword)) {
- configVo.setEmailPassword(emailPassword);
- }
-
- if (CollectionUtils.isEmpty(configVo.getHduUsernameList()) || forcedUpdateRemoteJudgeAccount) {
- configVo.setHduUsernameList(hduUsernameList);
- }else {
- hduUsernameList = configVo.getHduUsernameList();
- }
-
- if (CollectionUtils.isEmpty(configVo.getHduPasswordList()) || forcedUpdateRemoteJudgeAccount) {
- configVo.setHduPasswordList(hduPasswordList);
- }else {
- hduPasswordList = configVo.getHduPasswordList();
- }
-
- if (CollectionUtils.isEmpty(configVo.getCfUsernameList()) || forcedUpdateRemoteJudgeAccount) {
- configVo.setCfUsernameList(cfUsernameList);
- }else {
- cfUsernameList = configVo.getCfUsernameList();
- }
-
- if (CollectionUtils.isEmpty(configVo.getCfPasswordList()) || forcedUpdateRemoteJudgeAccount) {
- configVo.setCfPasswordList(cfPasswordList);
- }else {
- cfPasswordList = configVo.getCfPasswordList();
- }
-
- if (CollectionUtils.isEmpty(configVo.getPojUsernameList()) || forcedUpdateRemoteJudgeAccount) {
- configVo.setPojUsernameList(pojUsernameList);
- }else {
- pojUsernameList = configVo.getPojUsernameList();
- }
-
- if (CollectionUtils.isEmpty(configVo.getPojPasswordList()) || forcedUpdateRemoteJudgeAccount) {
- configVo.setPojPasswordList(pojPasswordList);
- }else {
- pojPasswordList = configVo.getPojPasswordList();
- }
-
- if (CollectionUtils.isEmpty(configVo.getAtcoderUsernameList()) || forcedUpdateRemoteJudgeAccount) {
- configVo.setAtcoderUsernameList(atcoderUsernameList);
- }else {
- atcoderUsernameList = configVo.getAtcoderUsernameList();
- }
-
- if (CollectionUtils.isEmpty(configVo.getAtcoderPasswordList()) || forcedUpdateRemoteJudgeAccount) {
- configVo.setAtcoderPasswordList(atcoderPasswordList);
- }else {
- atcoderPasswordList = configVo.getAtcoderPasswordList();
- }
-
- if (CollectionUtils.isEmpty(configVo.getSpojUsernameList()) || forcedUpdateRemoteJudgeAccount) {
- configVo.setSpojUsernameList(spojUsernameList);
- }else {
- spojUsernameList = configVo.getSpojUsernameList();
- }
-
- if (CollectionUtils.isEmpty(configVo.getSpojPasswordList()) || forcedUpdateRemoteJudgeAccount) {
- configVo.setSpojPasswordList(spojPasswordList);
- }else {
- spojPasswordList = configVo.getSpojPasswordList();
- }
-
- configManager.sendNewConfigToNacos();
-
- upsertHOJLanguage("PHP", "PyPy2", "PyPy3", "JavaScript Node", "JavaScript V8");
-
- checkAllLanguageUpdate();
-
- if (openRemoteJudge.equals("true")) {
- // 初始化清空表
- remoteJudgeAccountEntityService.remove(new QueryWrapper<>());
- addRemoteJudgeAccountToMySQL(Constants.RemoteOJ.HDU.getName(), hduUsernameList, hduPasswordList);
- addRemoteJudgeAccountToMySQL(Constants.RemoteOJ.POJ.getName(), pojUsernameList, pojPasswordList);
- addRemoteJudgeAccountToMySQL(Constants.RemoteOJ.CODEFORCES.getName(), cfUsernameList, cfPasswordList);
- addRemoteJudgeAccountToMySQL(Constants.RemoteOJ.SPOJ.getName(), spojUsernameList, spojPasswordList);
- addRemoteJudgeAccountToMySQL(Constants.RemoteOJ.ATCODER.getName(), atcoderUsernameList, atcoderPasswordList);
-
- checkRemoteOJLanguage(Constants.RemoteOJ.SPOJ, Constants.RemoteOJ.ATCODER);
- }
-
- }
-
- /**
- * @param oj
- * @param usernameList
- * @param passwordList
- * @MethodName addRemoteJudgeAccountToRedis
- * @Description 将传入的对应oj账号写入到mysql
- * @Return
- * @Since 2021/5/18
- */
- private void addRemoteJudgeAccountToMySQL(String oj, List usernameList, List passwordList) {
-
-
- if (CollectionUtils.isEmpty(usernameList) || CollectionUtils.isEmpty(passwordList) || usernameList.size() != passwordList.size()) {
- log.error("[Init System Config] [{}]: There is no account or password configured for remote judge, " +
- "username list:{}, password list:{}", oj, Arrays.toString(usernameList.toArray()),
- Arrays.toString(passwordList.toArray()));
- }
-
- List remoteAccountList = new LinkedList<>();
- for (int i = 0; i < usernameList.size(); i++) {
-
- remoteAccountList.add(new RemoteJudgeAccount()
- .setUsername(usernameList.get(i))
- .setPassword(passwordList.get(i))
- .setStatus(true)
- .setVersion(0L)
- .setOj(oj));
-
- }
-
- if (remoteAccountList.size() > 0) {
- boolean addOk = remoteJudgeAccountEntityService.saveOrUpdateBatch(remoteAccountList);
- if (!addOk) {
- log.error("[Init System Config] Remote judge initialization failed. Failed to add account for: [{}]. Please check the configuration file and restart!", oj);
- }
- }
- }
-
-
- private void upsertHOJLanguage(String... languageList) {
- /**
- * 2022.02.25 新增js、pypy、php语言
- */
- for (String language : languageList) {
- QueryWrapper languageQueryWrapper = new QueryWrapper<>();
- languageQueryWrapper.eq("oj", "ME")
- .eq("name", language);
- int count = languageEntityService.count(languageQueryWrapper);
- if (count == 0) {
- Language newLanguage = buildHOJLanguage(language);
- boolean isOk = languageEntityService.save(newLanguage);
- if (!isOk) {
- log.error("[Init System Config] [HOJ] Failed to add new language [{}]! Please check whether the language table corresponding to the database has the language!", language);
- }
- }
- }
- }
-
- private void checkAllLanguageUpdate() {
-
- /**
- * 2022.02.25 更新原有的python3.6.9为python3.7.5
- */
- UpdateWrapper languageUpdateWrapper = new UpdateWrapper<>();
- languageUpdateWrapper.eq("oj", "ME")
- .eq("name", "Python3")
- .set("description", "Python 3.7.5");
- languageEntityService.update(languageUpdateWrapper);
-
- /**
- * 2022.02.25 删除cf的Microsoft Visual C++ 2010
- */
- UpdateWrapper deleteWrapper = new UpdateWrapper<>();
- deleteWrapper.eq("name", "Microsoft Visual C++ 2010")
- .eq("oj", "CF");
- languageEntityService.remove(deleteWrapper);
- }
-
- private void checkRemoteOJLanguage(Constants.RemoteOJ... remoteOJList) {
- for (Constants.RemoteOJ remoteOJ : remoteOJList) {
- QueryWrapper languageQueryWrapper = new QueryWrapper<>();
- languageQueryWrapper.eq("oj", remoteOJ.getName());
- int count = languageEntityService.count(languageQueryWrapper);
- if (count == 0) {
- List languageList = new LanguageContext(remoteOJ).buildLanguageList();
- boolean isOk = languageEntityService.saveBatch(languageList);
- if (!isOk) {
- log.error("[Init System Config] [{}] Failed to initialize language list! Please check whether the language table corresponding to the database has the OJ language!", remoteOJ.getName());
- }
- }
- }
- }
-
-
- private Language buildHOJLanguage(String lang) {
- Language language = new Language();
- switch (lang) {
- case "PHP":
- language.setName("PHP")
- .setCompileCommand("/usr/bin/php {src_path}")
- .setContentType("text/x-php")
- .setDescription("PHP 7.3.33")
- .setTemplate("=array_sum(fscanf(STDIN, \"%d %d\"));")
- .setIsSpj(false)
- .setOj("ME");
- return language;
- case "JavaScript Node":
- language.setName("JavaScript Node")
- .setCompileCommand("/usr/bin/node {src_path}")
- .setContentType("text/javascript")
- .setDescription("Node.js 14.19.0")
- .setTemplate("var readline = require('readline');\n" +
- "const rl = readline.createInterface({\n" +
- " input: process.stdin,\n" +
- " output: process.stdout\n" +
- "});\n" +
- "rl.on('line', function(line){\n" +
- " var tokens = line.split(' ');\n" +
- " console.log(parseInt(tokens[0]) + parseInt(tokens[1]));\n" +
- "});")
- .setIsSpj(false)
- .setOj("ME");
- return language;
- case "JavaScript V8":
- language.setName("JavaScript V8")
- .setCompileCommand("/usr/bin/jsv8/d8 {src_path}")
- .setContentType("text/javascript")
- .setDescription("JavaScript V8 8.4.109")
- .setTemplate("const [a, b] = readline().split(' ').map(n => parseInt(n, 10));\n" +
- "print((a + b).toString());")
- .setIsSpj(false)
- .setOj("ME");
- return language;
- case "PyPy2":
- language.setName("PyPy2")
- .setContentType("text/x-python")
- .setCompileCommand("/usr/bin/pypy -m py_compile {src_path}")
- .setDescription("PyPy 2.7.18 (7.3.8)")
- .setTemplate("print sum(int(x) for x in raw_input().split(' '))")
- .setCodeTemplate("//PREPEND BEGIN\n" +
- "//PREPEND END\n" +
- "\n" +
- "//TEMPLATE BEGIN\n" +
- "def add(a, b):\n" +
- " return a + b\n" +
- "//TEMPLATE END\n" +
- "\n" +
- "\n" +
- "if __name__ == '__main__': \n" +
- " //APPEND BEGIN\n" +
- " a, b = 1, 1\n" +
- " print add(a, b)\n" +
- " //APPEND END")
- .setIsSpj(false)
- .setOj("ME");
- return language;
- case "PyPy3":
- language.setName("PyPy3")
- .setContentType("text/x-python")
- .setDescription("PyPy 3.8.12 (7.3.8)")
- .setCompileCommand("/usr/bin/pypy3 -m py_compile {src_path}")
- .setTemplate("print(sum(int(x) for x in input().split(' ')))")
- .setCodeTemplate("//PREPEND BEGIN\n" +
- "//PREPEND END\n" +
- "\n" +
- "//TEMPLATE BEGIN\n" +
- "def add(a, b):\n" +
- " return a + b\n" +
- "//TEMPLATE END\n" +
- "\n" +
- "\n" +
- "if __name__ == '__main__': \n" +
- " //APPEND BEGIN\n" +
- " a, b = 1, 1\n" +
- " print(add(a, b))\n" +
- " //APPEND END")
- .setIsSpj(false)
- .setOj("ME");
- return language;
- }
- return null;
- }
-
-}
-
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/SwaggerConfig.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/SwaggerConfig.java
deleted file mode 100644
index f0af785..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/SwaggerConfig.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package top.hcode.hoj.config;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.env.Environment;
-import org.springframework.core.env.Profiles;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.service.ApiInfo;
-import springfox.documentation.service.Contact;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
-
-import java.util.ArrayList;
-
-/**
- * @Author: Himit_ZH
- * @Date: 2020/5/29 22:28
- * @Description:
- */
-//@Configuration
-//@EnableSwagger2 //开启swagger2
-public class SwaggerConfig {
- @Bean //配置swagger的docket的bean势力
- public Docket docket(Environment environment){
- //设置要显示的swagger环境
- Profiles profiles = Profiles.of("dev","test"); //线下环境
- //通过环境判断是否在自己所设定的环境当中
- boolean flag = environment.acceptsProfiles(profiles);
- return new Docket(DocumentationType.SWAGGER_2)
- .apiInfo(apiInfo())
- .groupName("Himit_ZH") //分组
- .enable(flag) //开启
- .select()
- //RequestHandlerSelectors扫描方式
- //any()全部
- //none 都不扫描
- //path 过滤什么路径
- .apis(RequestHandlerSelectors.basePackage("top.hcode"))
- .build();
- }
- //配置swagger信息
- private ApiInfo apiInfo(){
- //作者信息
- Contact contact = new Contact("Himit_ZH", "https://blog.csdn.net/weixin_43853097", "372347736@qq.com");
- return new ApiInfo(
- "Himit_ZH的swaggerAPI文档",
- "网站作者是个大帅哥!",
- "v1.0",
- "https://blog.csdn.net/weixin_43853097",
- contact,
- "Apache 2.0",
- "http://www.apache.org/licenses/LICENSE-2.0",
- new ArrayList());
- }
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/TomcatConfig.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/TomcatConfig.java
deleted file mode 100644
index ba24d93..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/TomcatConfig.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package top.hcode.hoj.config;
-
-import org.apache.catalina.connector.Connector;
-import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
-import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * @Author Himit_ZH
- * @Date 2022/6/11
- * 允许请求路径出现[] \ 等特殊字符
- */
-@Configuration
-public class TomcatConfig {
-
- @Bean
- public TomcatServletWebServerFactory webServerFactory() {
- TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
- factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
- @Override
- public void customize(Connector connector) {
- connector.setProperty("relaxedPathChars", "\"<>[\\]^`{|}");
- connector.setProperty("relaxedQueryChars", "\"<>[\\]^`{|}");
- connector.setProperty("rejectIllegalHeader", "false");
- }
- });
- return factory;
- }
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/WebMvcConfig.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/WebMvcConfig.java
deleted file mode 100644
index a97c8a4..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/config/WebMvcConfig.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package top.hcode.hoj.config;
-
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.config.annotation.CorsRegistry;
-import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
-import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-import top.hcode.hoj.interceptor.AccessInterceptor;
-import top.hcode.hoj.utils.Constants;
-
-import java.io.File;
-
-/**
- * 解决跨域问题以及增加注解拦截类
- */
-@Configuration
-public class WebMvcConfig implements WebMvcConfigurer {
-
- private static final String[] EXCLUDE_PATH_PATTERNS = new String[]{
- "/api/admin/**", "/api/file/**", "/api/msg/**", "/api/public/**"
- };
-
- @Autowired
- private AccessInterceptor accessInterceptor;
-
- @Override
- public void addCorsMappings(CorsRegistry registry) {
- registry.addMapping("/**")
- .allowedOrigins("*")
- .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
- .allowCredentials(true)
- .maxAge(3600)
- .allowedHeaders("*");
- }
-
- // 前端直接通过/public/img/图片名称即可拿到
- @Override
- public void addResourceHandlers(ResourceHandlerRegistry registry) {
- // /api/public/img/** /api/public/file/**
- registry.addResourceHandler(Constants.File.IMG_API.getPath() + "**", Constants.File.FILE_API.getPath() + "**")
- .addResourceLocations("file:" + Constants.File.USER_AVATAR_FOLDER.getPath() + File.separator,
- "file:" + Constants.File.GROUP_AVATAR_FOLDER.getPath() + File.separator,
- "file:" + Constants.File.MARKDOWN_FILE_FOLDER.getPath() + File.separator,
- "file:" + Constants.File.HOME_CAROUSEL_FOLDER.getPath() + File.separator,
- "file:" + Constants.File.PROBLEM_FILE_FOLDER.getPath() + File.separator);
- }
-
- @Override
- public void addInterceptors(InterceptorRegistry registry) {
- registry.addInterceptor(accessInterceptor)
- .addPathPatterns("/api/**")
- .excludePathPatterns(EXCLUDE_PATH_PATTERNS);
- }
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminAccountController.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminAccountController.java
deleted file mode 100644
index 50b3a56..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminAccountController.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package top.hcode.hoj.controller.admin;
-
-import org.apache.shiro.authz.annotation.Logical;
-import org.apache.shiro.authz.annotation.RequiresAuthentication;
-import org.apache.shiro.authz.annotation.RequiresRoles;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
-import top.hcode.hoj.common.result.CommonResult;
-
-import top.hcode.hoj.pojo.dto.LoginDto;
-
-import top.hcode.hoj.pojo.vo.UserInfoVo;
-import top.hcode.hoj.service.admin.account.AdminAccountService;
-
-
-
-/**
- * @Author: Himit_ZH
- * @Date: 2020/12/2 21:23
- * @Description:
- */
-@RestController
-@RequestMapping("/api/admin")
-public class AdminAccountController {
-
- @Autowired
- private AdminAccountService adminAccountService;
-
- @PostMapping("/login")
- public CommonResult login(@Validated @RequestBody LoginDto loginDto){
- return adminAccountService.login(loginDto);
- }
-
- @GetMapping("/logout")
- @RequiresAuthentication
- @RequiresRoles(value = {"root","admin","problem_admin"},logical = Logical.OR)
- public CommonResult logout() {
- return adminAccountService.logout();
- }
-
-}
\ No newline at end of file
diff --git a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminContestController.java b/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminContestController.java
deleted file mode 100644
index 00c4346..0000000
--- a/src/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/controller/admin/AdminContestController.java
+++ /dev/null
@@ -1,236 +0,0 @@
-package top.hcode.hoj.controller.admin;
-
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-
-import org.apache.shiro.authz.annotation.Logical;
-import org.apache.shiro.authz.annotation.RequiresAuthentication;
-import org.apache.shiro.authz.annotation.RequiresRoles;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.*;
-import top.hcode.hoj.common.result.CommonResult;
-import top.hcode.hoj.pojo.dto.AnnouncementDto;
-import top.hcode.hoj.pojo.dto.ContestProblemDto;
-import top.hcode.hoj.pojo.dto.ProblemDto;
-import top.hcode.hoj.pojo.entity.contest.Contest;
-import top.hcode.hoj.pojo.entity.contest.ContestProblem;
-
-import top.hcode.hoj.pojo.entity.problem.Problem;
-import top.hcode.hoj.pojo.vo.AdminContestVo;
-import top.hcode.hoj.pojo.vo.AnnouncementVo;
-
-import top.hcode.hoj.service.admin.contest.AdminContestAnnouncementService;
-import top.hcode.hoj.service.admin.contest.AdminContestProblemService;
-import top.hcode.hoj.service.admin.contest.AdminContestService;
-
-import javax.servlet.http.HttpServletRequest;
-import java.util.*;
-
-
-/**
- * @Author: Himit_ZH
- * @Date: 2020/12/19 22:28
- * @Description:
- */
-@RestController
-@RequestMapping("/api/admin/contest")
-public class AdminContestController {
-
-
- @Autowired
- private AdminContestService adminContestService;
-
- @Autowired
- private AdminContestProblemService adminContestProblemService;
-
- @Autowired
- private AdminContestAnnouncementService adminContestAnnouncementService;
-
- @GetMapping("/get-contest-list")
- @RequiresAuthentication
- @RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
- public CommonResult> getContestList(@RequestParam(value = "limit", required = false) Integer limit,
- @RequestParam(value = "currentPage", required = false) Integer currentPage,
- @RequestParam(value = "keyword", required = false) String keyword) {
-
- return adminContestService.getContestList(limit, currentPage, keyword);
- }
-
- @GetMapping("")
- @RequiresAuthentication
- @RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
- public CommonResult getContest(@RequestParam("cid") Long cid) {
-
- return adminContestService.getContest(cid);
- }
-
- @DeleteMapping("")
- @RequiresAuthentication
- @RequiresRoles(value = "root") // 只有超级管理员能删除比赛
- public CommonResult deleteContest(@RequestParam("cid") Long cid) {
-
- return adminContestService.deleteContest(cid);
- }
-
- @PostMapping("")
- @RequiresAuthentication
- @RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
- public CommonResult addContest(@RequestBody AdminContestVo adminContestVo) {
-
- return adminContestService.addContest(adminContestVo);
- }
-
- @GetMapping("/clone")
- @RequiresAuthentication
- @RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
- public CommonResult cloneContest(@RequestParam("cid") Long cid) {
- return adminContestService.cloneContest(cid);
- }
-
- @PutMapping("")
- @RequiresAuthentication
- @RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
- @Transactional(rollbackFor = Exception.class)
- public CommonResult updateContest(@RequestBody AdminContestVo adminContestVo) {
-
- return adminContestService.updateContest(adminContestVo);
- }
-
- @PutMapping("/change-contest-visible")
- @RequiresAuthentication
- @RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
- public CommonResult changeContestVisible(@RequestParam(value = "cid", required = true) Long cid,
- @RequestParam(value = "uid", required = true) String uid,
- @RequestParam(value = "visible", required = true) Boolean visible) {
-
- return adminContestService.changeContestVisible(cid, uid, visible);
- }
-
- /**
- * 以下为比赛的题目的增删改查操作接口
- */
-
- @GetMapping("/get-problem-list")
- @RequiresAuthentication
- @RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
- @Transactional(rollbackFor = Exception.class)
- public CommonResult> getProblemList(@RequestParam(value = "limit", required = false) Integer limit,
- @RequestParam(value = "currentPage", required = false) Integer currentPage,
- @RequestParam(value = "keyword", required = false) String keyword,
- @RequestParam(value = "cid", required = true) Long cid,
- @RequestParam(value = "problemType", required = false) Integer problemType,
- @RequestParam(value = "oj", required = false) String oj) {
-
- return adminContestProblemService.getProblemList(limit, currentPage, keyword, cid, problemType, oj);
- }
-
- @GetMapping("/problem")
- @RequiresAuthentication
- @RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
- public CommonResult getProblem(@RequestParam("pid") Long pid, HttpServletRequest request) {
- return adminContestProblemService.getProblem(pid);
- }
-
- @DeleteMapping("/problem")
- @RequiresAuthentication
- @RequiresRoles(value = {"root", "problem_admin"}, logical = Logical.OR)
- @Transactional(rollbackFor = Exception.class)
- public CommonResult deleteProblem(@RequestParam("pid") Long pid,
- @RequestParam(value = "cid", required = false) Long cid) {
- return adminContestProblemService.deleteProblem(pid, cid);
- }
-
- @PostMapping("/problem")
- @RequiresAuthentication
- @RequiresRoles(value = {"root", "admin", "problem_admin"}, logical = Logical.OR)
- @Transactional(rollbackFor = Exception.class)
- public CommonResult