Skip to content

Commit 1b566b9

Browse files
Merge pull request #4 from geekidea/dev
优化 Former-commit-id: 98c7718bf2dc6d83dfad5284e6820e6f8d409d8c
2 parents 3fd5957 + 98ae8e0 commit 1b566b9

19 files changed

+114
-496
lines changed

docs/db/ip.sql

-28
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,36 @@
1-
-- Copyright 2019-2029 geekidea(https://github.com/geekidea)
2-
--
3-
-- Licensed under the Apache License, Version 2.0 (the "License");
4-
-- you may not use this file except in compliance with the License.
5-
-- You may obtain a copy of the License at
6-
--
7-
-- http://www.apache.org/licenses/LICENSE-2.0
8-
--
9-
-- Unless required by applicable law or agreed to in writing, software
10-
-- distributed under the License is distributed on an "AS IS" BASIS,
11-
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
-- See the License for the specific language governing permissions and
13-
-- limitations under the License.
1+
/*
2+
Navicat Premium Data Transfer
3+
4+
Source Server : mysql-localhost
5+
Source Server Type : MySQL
6+
Source Server Version : 50727
7+
Source Host : localhost:3306
8+
Source Schema : spring_boot_plus
9+
10+
Target Server Type : MySQL
11+
Target Server Version : 50727
12+
File Encoding : 65001
13+
14+
Date: 24/07/2019 16:25:18
15+
*/
16+
17+
SET NAMES utf8mb4;
18+
SET FOREIGN_KEY_CHECKS = 0;
19+
20+
-- ----------------------------
21+
-- Table structure for ip
22+
-- ----------------------------
23+
DROP TABLE IF EXISTS `ip`;
24+
CREATE TABLE `ip` (
25+
`ip_start` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
26+
`ip_end` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
27+
`area` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
28+
`operator` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
29+
`id` bigint(20) NOT NULL AUTO_INCREMENT,
30+
`ip_start_num` bigint(20) NOT NULL,
31+
`ip_end_num` bigint(20) NOT NULL,
32+
PRIMARY KEY (`id`) USING BTREE
33+
) ENGINE = InnoDB AUTO_INCREMENT = 526718 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
1434

1535
-- ----------------------------
1636
-- Table structure for sys_log
@@ -21,7 +41,7 @@ CREATE TABLE `sys_log` (
2141
`type` tinyint(1) NULL DEFAULT NULL COMMENT '类型',
2242
`content` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '内容',
2343
`create_id` bigint(18) NULL DEFAULT NULL COMMENT '创建人ID',
24-
`create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
44+
`create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
2545
PRIMARY KEY (`log_id`) USING BTREE
2646
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '系统日志' ROW_FORMAT = Dynamic;
2747

@@ -38,3 +58,5 @@ INSERT INTO `sys_log` VALUES (1060439062743166977, 0, '1111111111', 100000, '201
3858
INSERT INTO `sys_log` VALUES (1060439085228830721, 1, 'test redis lock ffbb79f6-9efe-4608-b204-fde5279b107f', 100000, '2018-11-16 16:46:35');
3959
INSERT INTO `sys_log` VALUES (1068528405778444290, NULL, NULL, NULL, '2018-11-30 23:33:21');
4060
INSERT INTO `sys_log` VALUES (1068528405778444291, NULL, NULL, NULL, '2018-11-30 23:33:21');
61+
62+
SET FOREIGN_KEY_CHECKS = 1;

src/main/java/io/geekidea/springbootplus/SpringBootPlusApplication.java

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
public class SpringBootPlusApplication {
4444

4545
public static void main(String[] args) {
46+
// 启动项目,准备工作提示
47+
PrintApplicationInfo.printTip();
48+
// 启动spring-boot-plus
4649
ConfigurableApplicationContext context = SpringApplication.run(SpringBootPlusApplication.class, args);
4750
// 打印项目信息
4851
PrintApplicationInfo.print(context);

src/main/java/io/geekidea/springbootplus/common/api/ApiResult.java

+7
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ public ApiResult() {
5757

5858
}
5959

60+
public static ApiResult result(boolean flag){
61+
if (flag){
62+
return ok();
63+
}
64+
return fail("");
65+
}
66+
6067
public static ApiResult result(ApiCode apiCode){
6168
return result(apiCode,null);
6269
}

src/main/java/io/geekidea/springbootplus/config/WebMvcConfig.java

+8-9
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616

1717
package io.geekidea.springbootplus.config;
1818

19-
import io.geekidea.springbootplus.security.interceptor.JwtInterceptor;
2019
import io.geekidea.springbootplus.common.web.interceptor.PermissionInterceptor;
2120
import io.geekidea.springbootplus.common.web.interceptor.TokenTimeoutInterceptor;
21+
import io.geekidea.springbootplus.security.interceptor.JwtInterceptor;
2222
import lombok.extern.slf4j.Slf4j;
2323
import org.springframework.beans.factory.annotation.Value;
24-
import org.springframework.context.annotation.Bean;
2524
import org.springframework.context.annotation.Configuration;
2625
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
2726
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -49,7 +48,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
4948
* jwt token验证拦截器
5049
* @return
5150
*/
52-
@Bean
51+
// @Bean
5352
public JwtInterceptor jwtInterceptor(){
5453
return new JwtInterceptor();
5554
}
@@ -58,7 +57,7 @@ public JwtInterceptor jwtInterceptor(){
5857
* 权限拦截器
5958
* @return
6059
*/
61-
@Bean
60+
// @Bean
6261
public PermissionInterceptor permissionInterceptor(){
6362
return new PermissionInterceptor();
6463
}
@@ -67,7 +66,7 @@ public PermissionInterceptor permissionInterceptor(){
6766
* TOKEN超时拦截器
6867
* @return
6968
*/
70-
@Bean
69+
// @Bean
7170
public TokenTimeoutInterceptor tokenTimeoutInterceptor(){
7271
return new TokenTimeoutInterceptor();
7372
}
@@ -76,10 +75,10 @@ public TokenTimeoutInterceptor tokenTimeoutInterceptor(){
7675
@Override
7776
public void addInterceptors(InterceptorRegistry registry) {
7877
log.info("PermissionInterceptor excludePaths : {}", Arrays.toString(permissionExcludePaths));
79-
80-
registry.addInterceptor(jwtInterceptor())
81-
.addPathPatterns("/**")
82-
.excludePathPatterns(jwtExcludePaths);
78+
//
79+
// registry.addInterceptor(jwtInterceptor())
80+
// .addPathPatterns("/**")
81+
// .excludePathPatterns(jwtExcludePaths);
8382

8483
// 1.TOKEN超时拦截器
8584
// registry.addInterceptor(tokenTimeoutInterceptor())

src/main/java/io/geekidea/springbootplus/util/AnsiUtil.java

+16-6
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,18 @@
2727
@Slf4j
2828
public class AnsiUtil {
2929

30-
private static boolean isEnableAnsi = false;
30+
private static boolean isEnableAnsi;
3131

3232
static {
33-
Environment environment = SpringContextUtil.getBean(Environment.class);
34-
Boolean value = environment.getProperty("springbootplus.isEnableAnsi",boolean.class);
35-
if (value != null){
36-
isEnableAnsi = value;
33+
Boolean value = false;
34+
try {
35+
Environment environment = SpringContextUtil.getBean(Environment.class);
36+
value = environment.getProperty("springbootplus.isEnableAnsi",boolean.class);
37+
value = value == null ? false : value;
38+
} catch (Exception e) {
39+
e.printStackTrace();
3740
}
38-
log.info("AnsiUtil isEnableAnsi = " + isEnableAnsi);
41+
isEnableAnsi = value;
3942
}
4043

4144
public static String getAnsi(Ansi.Color color,String text){
@@ -45,4 +48,11 @@ public static String getAnsi(Ansi.Color color,String text){
4548
}
4649
return text;
4750
}
51+
52+
public static String getAnsi(Ansi.Color color,String text,boolean flag){
53+
if (flag){
54+
return Ansi.ansi().eraseScreen().fg(color).a(text).reset().toString();
55+
}
56+
return text;
57+
}
4858
}

src/main/java/io/geekidea/springbootplus/util/PrintApplicationInfo.java

+21
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,27 @@
3131
@Slf4j
3232
public class PrintApplicationInfo {
3333

34+
35+
/**
36+
* 执行之前,打印前置条件提示
37+
*/
38+
public static void printTip(){
39+
StringBuffer tip = new StringBuffer();
40+
tip.append("======================================================================================\n");
41+
tip.append(" \n");
42+
tip.append(" !!!准备工作!!! \n");
43+
tip.append(" 1.请先在MySQL中创建数据库,默认数据库名称为:spring_boot_plus \n");
44+
tip.append(" 2.数据库脚本在项目docs/spring_boot_plus.sql \n");
45+
tip.append(" 3.请先启动redis服务 \n");
46+
tip.append(" 4.更多注意事项:请查看: https://springboot.plus \n");
47+
tip.append(" \n");
48+
tip.append("======================================================================================\n");
49+
log.info("\n{}",Ansi.ansi().eraseScreen().fg(Ansi.Color.YELLOW).a(tip.toString()).reset().toString());
50+
}
51+
52+
/**
53+
* 启动成功之后,打印项目信息
54+
*/
3455
public static void print(ConfigurableApplicationContext context){
3556
ConfigurableEnvironment environment = context.getEnvironment();
3657

src/main/resources/config/application-local.yml

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ spring:
2121
host: localhost
2222
password:
2323
port: 6379
24+

src/test/java/io/geekidea/springbootplus/test/CodeGenerator.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public class CodeGenerator {
5353

5454
// ############################ 配置部分 start ############################
5555
// 模块名称
56-
private static final String MODULE_NAME = "system";
56+
private static final String MODULE_NAME = "hello";
5757
// 作者
5858
private static final String AUTHOR = "geekidea";
5959
// 生成的表名称
60-
private static final String TABLE_NAME = "ip";
60+
private static final String TABLE_NAME = "sys_user";
6161
// 主键数据库列名称
6262
private static final String PK_ID_COLUMN_NAME = "id";
6363
// ############################ 配置部分 end ############################
@@ -121,6 +121,8 @@ public void initMap() {
121121
map.put("pkIdColumnName",PK_ID_COLUMN_NAME);
122122
// 主键ID驼峰名称
123123
map.put("pkIdCamelName",underlineToCamel(PK_ID_COLUMN_NAME));
124+
// 导入分页类
125+
map.put("paging",PARENT_PACKAGE + ".common.web.vo.Paging");
124126
this.setMap(map);
125127
}
126128
};

src/test/java/io/geekidea/springbootplus/test/HandlerIp.java

-98
This file was deleted.

0 commit comments

Comments
 (0)