pull/1/head
iamsongpeng 2020-01-16 08:30:12 +08:00
parent bdba9b8584
commit 35fd951877
20 changed files with 323 additions and 290 deletions

View File

@ -10,13 +10,15 @@
</parent>
<groupId>com.songpeng</groupId>
<artifactId>sparchetype</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.0.0</version>
<name>sparchetype</name>
<description>maven 骨架生成所需项目</description>
<packaging>jar</packaging>
<properties>
<java.version>1.8</java.version>
<!-- docker 前缀名,通常用在上传镜像 -->
<docker.image.prefix>sparchetype</docker.image.prefix>
</properties>
<dependencies>
@ -148,6 +150,13 @@
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
</dependency>
<!--logStash-->
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>5.3</version>
</dependency>
</dependencies>
<build>
@ -156,6 +165,29 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- Docker 插件 -->
<plugin>
<!-- 三坐标 -->
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.1.1</version>
<!-- 配置信息 -->
<configuration>
<!-- 镜像名称 -->
<imageName>${docker.image.prefix}/${project.artifactId}:${project.version}</imageName>
<!-- Dockerfile 文件的位置 -->
<dockerDirectory>src/main/docker</dockerDirectory>
<!-- 文件资源 -->
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</build>

View File

@ -0,0 +1,8 @@
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD sparchetype-1.0.0.jar app.jar
RUN bash -c 'touch /app.jar'
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& echo 'Asia/Shanghai' >/etc/timezone
EXPOSE 9090
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

View File

@ -9,67 +9,71 @@ import org.slf4j.LoggerFactory;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* @author SongPeng
*/
public class RedisCacheManager implements CacheManager {
private static final Logger logger = LoggerFactory
.getLogger(RedisCacheManager.class);
private static final Logger logger = LoggerFactory.getLogger(RedisCacheManager.class);
// fast lookup by name map
private final ConcurrentMap<String, Cache> caches = new ConcurrentHashMap<String, Cache>();
/**
* fast lookup by name map
*/
private final ConcurrentMap<String, Cache> caches = new ConcurrentHashMap<>();
private RedisManager redisManager;
private RedisManager redisManager;
/**
* The Redis key prefix for caches
*/
private String keyPrefix = "shiro_redis_cache:";
/**
* The Redis key prefix for caches
*/
private String keyPrefix = "shiro_redis_cache:";
/**
* Returns the Redis session keys
* prefix.
*
* @return The prefix
*/
public String getKeyPrefix() {
return keyPrefix;
}
/**
* Returns the Redis session keys
* prefix.
*
* @return The prefix
*/
public String getKeyPrefix() {
return keyPrefix;
}
/**
* Sets the Redis sessions key
* prefix.
*
* @param keyPrefix The prefix
*/
public void setKeyPrefix(String keyPrefix) {
this.keyPrefix = keyPrefix;
}
/**
* Sets the Redis sessions key
* prefix.
*
* @param keyPrefix The prefix
*/
public void setKeyPrefix(String keyPrefix) {
this.keyPrefix = keyPrefix;
}
@Override
public <K, V> Cache<K, V> getCache(String name) throws CacheException {
logger.debug("获取名称为: " + name + " 的RedisCache实例");
@Override
public <K, V> Cache<K, V> getCache(String name) throws CacheException {
logger.debug("获取名称为: " + name + " 的RedisCache实例");
Cache c = caches.get(name);
Cache c = caches.get(name);
if (c == null) {
if (c == null) {
// initialize the Redis manager instance
redisManager.init();
// initialize the Redis manager instance
redisManager.init();
// create a new cache instance
c = new RedisCache<K, V>(redisManager, keyPrefix);
// create a new cache instance
c = new RedisCache<K, V>(redisManager, keyPrefix);
// add it to the cache collection
caches.put(name, c);
}
return c;
}
// add it to the cache collection
caches.put(name, c);
}
return c;
}
public RedisManager getRedisManager() {
return redisManager;
}
public RedisManager getRedisManager() {
return redisManager;
}
public void setRedisManager(RedisManager redisManager) {
this.redisManager = redisManager;
}
public void setRedisManager(RedisManager redisManager) {
this.redisManager = redisManager;
}
}

View File

@ -12,209 +12,213 @@ import java.util.Set;
*/
public class RedisManager {
@Value("${spring.redis.host}")
private String host = "127.0.0.1";
@Value("${spring.redis.host}")
private String host = "127.0.0.1";
@Value("${spring.redis.port}")
private int port = 6379;
@Value("${spring.redis.port}")
private int port = 6379;
// 0 - never expire
private int expire = 0;
/**
* 0 - never expire
*/
private int expire = 0;
//timeout for jedis try to connect to redis server, not expire time! In milliseconds
/**
* timeout for jedis try to connect to redis server, not expire time! In milliseconds
*/
@Value("${spring.redis.timeout}")
private int timeout = 0;
private int timeout = 0;
@Value("${spring.redis.password}")
private String password = "";
@Value("${spring.redis.password}")
private String password = "";
private static JedisPool jedisPool = null;
private static JedisPool jedisPool = null;
public RedisManager() {
public RedisManager() {
}
}
/**
*
*/
public void init() {
if (jedisPool == null) {
if (password != null && !"".equals(password)) {
jedisPool = new JedisPool(new JedisPoolConfig(), host, port, timeout, password);
} else if (timeout != 0) {
jedisPool = new JedisPool(new JedisPoolConfig(), host, port, timeout);
} else {
jedisPool = new JedisPool(new JedisPoolConfig(), host, port);
}
}
}
/**
*
*/
public void init() {
if (jedisPool == null) {
if (password != null && !"".equals(password)) {
jedisPool = new JedisPool(new JedisPoolConfig(), host, port, timeout, password);
} else if (timeout != 0) {
jedisPool = new JedisPool(new JedisPoolConfig(), host, port, timeout);
} else {
jedisPool = new JedisPool(new JedisPoolConfig(), host, port);
}
}
}
/**
* get value from redis
*
* @param key
* @return
*/
public byte[] get(byte[] key) {
byte[] value = null;
Jedis jedis = jedisPool.getResource();
try {
value = jedis.get(key);
} finally {
if (jedis != null) {
jedis.close();
}
}
return value;
}
/**
* get value from redis
*
* @param key
* @return
*/
public byte[] get(byte[] key) {
byte[] value = null;
Jedis jedis = jedisPool.getResource();
try {
value = jedis.get(key);
} finally {
if (jedis != null) {
jedis.close();
}
}
return value;
}
/**
* set
*
* @param key
* @param value
* @return
*/
public byte[] set(byte[] key, byte[] value) {
Jedis jedis = jedisPool.getResource();
try {
jedis.set(key, value);
if (this.expire != 0) {
jedis.expire(key, this.expire);
}
} finally {
if (jedis != null) {
jedis.close();
}
}
return value;
}
/**
* set
*
* @param key
* @param value
* @return
*/
public byte[] set(byte[] key, byte[] value) {
Jedis jedis = jedisPool.getResource();
try {
jedis.set(key, value);
if (this.expire != 0) {
jedis.expire(key, this.expire);
}
} finally {
if (jedis != null) {
jedis.close();
}
}
return value;
}
/**
* set
*
* @param key
* @param value
* @param expire
* @return
*/
public byte[] set(byte[] key, byte[] value, int expire) {
Jedis jedis = jedisPool.getResource();
try {
jedis.set(key, value);
if (expire != 0) {
jedis.expire(key, expire);
}
} finally {
if (jedis != null) {
jedis.close();
}
}
return value;
}
/**
* set
*
* @param key
* @param value
* @param expire
* @return
*/
public byte[] set(byte[] key, byte[] value, int expire) {
Jedis jedis = jedisPool.getResource();
try {
jedis.set(key, value);
if (expire != 0) {
jedis.expire(key, expire);
}
} finally {
if (jedis != null) {
jedis.close();
}
}
return value;
}
/**
* del
*
* @param key
*/
public void del(byte[] key) {
Jedis jedis = jedisPool.getResource();
try {
jedis.del(key);
} finally {
if (jedis != null) {
jedis.close();
}
}
}
/**
* del
*
* @param key
*/
public void del(byte[] key) {
Jedis jedis = jedisPool.getResource();
try {
jedis.del(key);
} finally {
if (jedis != null) {
jedis.close();
}
}
}
/**
* flush
*/
public void flushDB() {
Jedis jedis = jedisPool.getResource();
try {
jedis.flushDB();
} finally {
if (jedis != null) {
jedis.close();
}
}
}
/**
* flush
*/
public void flushDB() {
Jedis jedis = jedisPool.getResource();
try {
jedis.flushDB();
} finally {
if (jedis != null) {
jedis.close();
}
}
}
/**
* size
*/
public Long dbSize() {
Long dbSize = 0L;
Jedis jedis = jedisPool.getResource();
try {
dbSize = jedis.dbSize();
} finally {
if (jedis != null) {
jedis.close();
}
}
return dbSize;
}
/**
* size
*/
public Long dbSize() {
Long dbSize = 0L;
Jedis jedis = jedisPool.getResource();
try {
dbSize = jedis.dbSize();
} finally {
if (jedis != null) {
jedis.close();
}
}
return dbSize;
}
/**
* keys
*
* @param regex
* @return
*/
public Set<byte[]> keys(String pattern) {
Set<byte[]> keys = null;
Jedis jedis = jedisPool.getResource();
try {
keys = jedis.keys(pattern.getBytes());
} finally {
if (jedis != null) {
jedis.close();
}
}
return keys;
}
/**
* keys
*
* @param regex
* @return
*/
public Set<byte[]> keys(String pattern) {
Set<byte[]> keys = null;
Jedis jedis = jedisPool.getResource();
try {
keys = jedis.keys(pattern.getBytes());
} finally {
if (jedis != null) {
jedis.close();
}
}
return keys;
}
public String getHost() {
return host;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public void setHost(String host) {
this.host = host;
}
public int getPort() {
return port;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public void setPort(int port) {
this.port = port;
}
public int getExpire() {
return expire;
}
public int getExpire() {
return expire;
}
public void setExpire(int expire) {
this.expire = expire;
}
public void setExpire(int expire) {
this.expire = expire;
}
public int getTimeout() {
return timeout;
}
public int getTimeout() {
return timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
public void setTimeout(int timeout) {
this.timeout = timeout;
}
public String getPassword() {
return password;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void setPassword(String password) {
this.password = password;
}
}

View File

@ -21,7 +21,7 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/sparchetype?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong
username: root
password: 123456
password: root
druid:
initial-size: 8
min-idle: 5
@ -50,4 +50,5 @@ spring:
logging:
level:
root: info
com.songpeng: debug
com.songpeng: debug
config: classpath:logback.xml

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration>
<configuration>
<!--应用名称-->
<property name="LOG_NAME" value="/logs"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder charset="UTF-8">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<!--输出到logstash的appender-->
<appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>192.168.137.95:5601</destination>
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>
<appender name="async" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="stash" />
</appender>
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="stash"/>
</root>
</configuration>

View File

@ -7,7 +7,7 @@
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<#--<script src="${request.contextPath}/lib/jquery/jquery-3.4.1.min.js" charset="utf-8"></script>-->
<script src="${request.contextPath}/lib/jquery/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="${request.contextPath}/lib/layui/layui.js?v=v2.5.5" charset="utf-8"></script>
<script src="${request.contextPath}/js/spUtil.js?v=1.0.0" charset="utf-8"></script>
<script src="${request.contextPath}/js/layuimodule/config.js?v=1.0.0" charset="utf-8"></script>

View File

@ -90,9 +90,9 @@
</div>
<script>
layui.use(['element', 'layer', 'layuimini'], function () {
var $ = layui.$,
element = layui.element,
layer = layui.layer;
var element = layui.element,
layer = layui.layer,
layuimini = layui.layuimini;
layuimini.init('${request.contextPath}/json/init.json');
});

View File

@ -61,9 +61,8 @@
</div>
<script src="${request.contextPath}/lib/jq-module/jquery.particleground.min.js" charset="utf-8"></script>
<script>
layui.use(['form'], function () {
var $ = layui.$,
form = layui.form,
layui.use(['form', 'layer'], function () {
var form = layui.form,
layer = layui.layer;
// 登录过期的时候跳出ifram框架

View File

@ -6,11 +6,6 @@
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<!-- 让IE8/9支持媒体查询从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<#include "${request.contextPath}/common/common.ftl">
</head>
@ -73,14 +68,9 @@
</div>
</body>
<script>
layui.extend({
admin: '${request.contextPath}/js/admin'
});
layui.use(['form', 'jquery', 'util', 'admin', 'layer'], function() {
layui.use(['form', 'util', 'layer'], function() {
var form = layui.form,
$ = layui.jquery,
util = layui.util,
admin = layui.admin,
layer = layui.layer;
//失去焦点时判断值为空不验证,一旦填写必须验证

View File

@ -60,15 +60,9 @@
</a>
</script>
<script type="text/javascript">
layui.extend({
admin: '${request.contextPath}/js/admin'
});
layui.use(['table', 'jquery','form', 'admin', 'laydate'], function() {
layui.use(['table', 'form', 'laydate'], function() {
var table = layui.table,
$ = layui.jquery,
form = layui.form,
admin = layui.admin,
laydate = layui.laydate;
laydate.render({

View File

@ -5,12 +5,6 @@
<title>添加菜单</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<!-- 让IE8/9支持媒体查询从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<#include "${request.contextPath}/common/common.ftl">
</head>
@ -105,14 +99,9 @@
</div>
</body>
<script>
layui.extend({
admin: '${request.contextPath}/js/admin'
});
layui.use(['form', 'jquery', 'util', 'admin', 'layer'], function() {
layui.use(['form', 'util', 'layer'], function() {
var form = layui.form,
$ = layui.jquery,
util = layui.util,
admin = layui.admin,
layer = layui.layer;
//监听提交

View File

@ -36,9 +36,8 @@
<script>
layui.use(['table', 'treetable'], function () {
var $ = layui.jquery;
var table = layui.table;
var treetable = layui.treetable;
var table = layui.table,
treetable = layui.treetable;
// 渲染表格
layer.load(2);

View File

@ -6,11 +6,6 @@
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<!-- 让IE8/9支持媒体查询从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<#include "${request.contextPath}/common/common.ftl">
</head>
@ -62,11 +57,9 @@
layui.extend({
admin: '${request.contextPath}/js/admin'
});
layui.use(['form', 'jquery', 'util', 'admin', 'layer'], function() {
layui.use(['form', 'util', 'layer'], function() {
var form = layui.form,
$ = layui.jquery,
util = layui.util,
admin = layui.admin,
layer = layui.layer;
//监听提交

View File

@ -60,11 +60,9 @@
admin: '${request.contextPath}/js/admin'
});
layui.use(['table', 'jquery','form', 'admin', 'laydate'], function() {
layui.use(['table', 'form', 'laydate'], function() {
var table = layui.table,
$ = layui.jquery,
form = layui.form,
admin = layui.admin,
laydate = layui.laydate;
laydate.render({

View File

@ -61,8 +61,7 @@
<script src="${request.contextPath}/static/js/layui-config.js?v=1.0.4" charset="utf-8"></script>
<script type="text/javascript">
layui.use(['layer','wangEditor'], function () {
var $ = layui.jquery,
layer = layui.layer,
var layer = layui.layer,
wangEditor = layui.wangEditor;
var editor = new wangEditor('#editor');

View File

@ -145,8 +145,7 @@
</div>
<script>
layui.use(['form', 'step'], function () {
var $ = layui.$,
form = layui.form,
var form = layui.form,
step = layui.step;
step.render({

View File

@ -63,8 +63,7 @@
layui.use(['iconPickerFa', 'form', 'layer'], function () {
var iconPickerFa = layui.iconPickerFa,
form = layui.form,
layer = layui.layer,
$ = layui.$;
layer = layui.layer;
iconPickerFa.render({
// 选择器推荐使用input

View File

@ -193,9 +193,8 @@
</div>
</body>
<script>
layui.use(['form', 'jquery', 'util', 'layer'], function () {
layui.use(['form', 'util', 'layer'], function () {
var form = layui.form,
$ = layui.jquery,
util = layui.util,
layer = layui.layer;

View File

@ -56,8 +56,7 @@
<!--js逻辑-->
<script>
layui.use(['form', 'table', 'splayer', 'sptable'], function () {
var $ = layui.$,
form = layui.form,
var form = layui.form,
table = layui.table,
splayer = layui.splayer,
sptable = layui.sptable;