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> </parent>
<groupId>com.songpeng</groupId> <groupId>com.songpeng</groupId>
<artifactId>sparchetype</artifactId> <artifactId>sparchetype</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>1.0.0</version>
<name>sparchetype</name> <name>sparchetype</name>
<description>maven 骨架生成所需项目</description> <description>maven 骨架生成所需项目</description>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<!-- docker 前缀名,通常用在上传镜像 -->
<docker.image.prefix>sparchetype</docker.image.prefix>
</properties> </properties>
<dependencies> <dependencies>
@ -148,6 +150,13 @@
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>3.6</version> <version>3.6</version>
</dependency> </dependency>
<!--logStash-->
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>5.3</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -156,6 +165,29 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> </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> </plugins>
</build> </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.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
/**
* @author SongPeng
*/
public class RedisCacheManager implements CacheManager { public class RedisCacheManager implements CacheManager {
private static final Logger logger = LoggerFactory private static final Logger logger = LoggerFactory.getLogger(RedisCacheManager.class);
.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 * The Redis key prefix for caches
*/ */
private String keyPrefix = "shiro_redis_cache:"; private String keyPrefix = "shiro_redis_cache:";
/** /**
* Returns the Redis session keys * Returns the Redis session keys
* prefix. * prefix.
* *
* @return The prefix * @return The prefix
*/ */
public String getKeyPrefix() { public String getKeyPrefix() {
return keyPrefix; return keyPrefix;
} }
/** /**
* Sets the Redis sessions key * Sets the Redis sessions key
* prefix. * prefix.
* *
* @param keyPrefix The prefix * @param keyPrefix The prefix
*/ */
public void setKeyPrefix(String keyPrefix) { public void setKeyPrefix(String keyPrefix) {
this.keyPrefix = keyPrefix; this.keyPrefix = keyPrefix;
} }
@Override @Override
public <K, V> Cache<K, V> getCache(String name) throws CacheException { public <K, V> Cache<K, V> getCache(String name) throws CacheException {
logger.debug("获取名称为: " + name + " 的RedisCache实例"); 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 // initialize the Redis manager instance
redisManager.init(); redisManager.init();
// create a new cache instance // create a new cache instance
c = new RedisCache<K, V>(redisManager, keyPrefix); c = new RedisCache<K, V>(redisManager, keyPrefix);
// add it to the cache collection // add it to the cache collection
caches.put(name, c); caches.put(name, c);
} }
return c; return c;
} }
public RedisManager getRedisManager() { public RedisManager getRedisManager() {
return redisManager; return redisManager;
} }
public void setRedisManager(RedisManager redisManager) { public void setRedisManager(RedisManager redisManager) {
this.redisManager = redisManager; this.redisManager = redisManager;
} }
} }

View File

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

View File

@ -21,7 +21,7 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver 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 url: jdbc:mysql://127.0.0.1:3306/sparchetype?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong
username: root username: root
password: 123456 password: root
druid: druid:
initial-size: 8 initial-size: 8
min-idle: 5 min-idle: 5
@ -50,4 +50,5 @@ spring:
logging: logging:
level: level:
root: info 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/html5shiv/r29/html5.min.js"></script>
<script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script> <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]--> <![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}/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/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> <script src="${request.contextPath}/js/layuimodule/config.js?v=1.0.0" charset="utf-8"></script>

View File

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

View File

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

View File

@ -6,11 +6,6 @@
<meta name="renderer" content="webkit"> <meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <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"> <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"> <#include "${request.contextPath}/common/common.ftl">
</head> </head>
@ -73,14 +68,9 @@
</div> </div>
</body> </body>
<script> <script>
layui.extend({ layui.use(['form', 'util', 'layer'], function() {
admin: '${request.contextPath}/js/admin'
});
layui.use(['form', 'jquery', 'util', 'admin', 'layer'], function() {
var form = layui.form, var form = layui.form,
$ = layui.jquery,
util = layui.util, util = layui.util,
admin = layui.admin,
layer = layui.layer; layer = layui.layer;
//失去焦点时判断值为空不验证,一旦填写必须验证 //失去焦点时判断值为空不验证,一旦填写必须验证

View File

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

View File

@ -5,12 +5,6 @@
<title>添加菜单</title> <title>添加菜单</title>
<meta name="renderer" content="webkit"> <meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <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"> <#include "${request.contextPath}/common/common.ftl">
</head> </head>
@ -105,14 +99,9 @@
</div> </div>
</body> </body>
<script> <script>
layui.extend({ layui.use(['form', 'util', 'layer'], function() {
admin: '${request.contextPath}/js/admin'
});
layui.use(['form', 'jquery', 'util', 'admin', 'layer'], function() {
var form = layui.form, var form = layui.form,
$ = layui.jquery,
util = layui.util, util = layui.util,
admin = layui.admin,
layer = layui.layer; layer = layui.layer;
//监听提交 //监听提交

View File

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

View File

@ -6,11 +6,6 @@
<meta name="renderer" content="webkit"> <meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <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"> <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"> <#include "${request.contextPath}/common/common.ftl">
</head> </head>
@ -62,11 +57,9 @@
layui.extend({ layui.extend({
admin: '${request.contextPath}/js/admin' admin: '${request.contextPath}/js/admin'
}); });
layui.use(['form', 'jquery', 'util', 'admin', 'layer'], function() { layui.use(['form', 'util', 'layer'], function() {
var form = layui.form, var form = layui.form,
$ = layui.jquery,
util = layui.util, util = layui.util,
admin = layui.admin,
layer = layui.layer; layer = layui.layer;
//监听提交 //监听提交

View File

@ -60,11 +60,9 @@
admin: '${request.contextPath}/js/admin' admin: '${request.contextPath}/js/admin'
}); });
layui.use(['table', 'jquery','form', 'admin', 'laydate'], function() { layui.use(['table', 'form', 'laydate'], function() {
var table = layui.table, var table = layui.table,
$ = layui.jquery,
form = layui.form, form = layui.form,
admin = layui.admin,
laydate = layui.laydate; laydate = layui.laydate;
laydate.render({ 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 src="${request.contextPath}/static/js/layui-config.js?v=1.0.4" charset="utf-8"></script>
<script type="text/javascript"> <script type="text/javascript">
layui.use(['layer','wangEditor'], function () { layui.use(['layer','wangEditor'], function () {
var $ = layui.jquery, var layer = layui.layer,
layer = layui.layer,
wangEditor = layui.wangEditor; wangEditor = layui.wangEditor;
var editor = new wangEditor('#editor'); var editor = new wangEditor('#editor');

View File

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

View File

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

View File

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

View File

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