spring-boot-plus V1.2.2 發佈,5 Minutes Finish CRUD

[V1.2.2-RELEASE] 2019.08.26

⭐️ New Features

  • 攔截器啟用禁用配置
  • 文件上傳下載安全/權限控制
  • 啟用 logback.xml 日誌配置

⚡️ Optimization

  • 更改core包目錄
  • 下載上傳攔截器
  • logback.xml顯示行號
  • application.yml 攔截器配置新增 include-path 攔截路徑配置

Added/Modified

  • Add UploadInterceptor 文件上傳全局攔截器
  • Add DownloadInterceptor 文件下載全局攔截器
  • Add DownloadHandler DefaultDownloadHandler 文件下載回調自定義處理器
  • Modify config/WebMvcConfig --> core/SpringBootPlusWebMvcConfig
  • Modify ImageController --> ResouceController,請求路徑 /api/resource
  • Add SysUser CRUD

Bug Fixes

  • Fix 文件下載路徑潛在安全漏洞,過濾 ../ 非法路徑參數
  • Fix 優化文件下載,Firefox 中文亂碼問題

Documentation

  • spring-boot-plus-architecture
  • 5 Minutes Finish CRUD

Dependency Upgrades

  • pom.xml 使用 spring-boot-starter-validation 替換 hibernate-validator 依賴

5 Minutes Finish CRUD

1. Create Table

-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
drop table if exists `sys_user`;
create table sys_user(
id bigint not null comment 'id',
name varchar(20) null comment 'name',
account varchar(20) not null comment 'account',
pwd varchar(20) not null comment 'password',
remark varchar(200) null comment 'remark',
create_time timestamp default CURRENT_TIMESTAMP null comment 'create time',
update_time timestamp null comment 'update time',
primary key (`id`),
constraint sys_user_account_uindex
unique (account)
) comment 'SystemUser';
-- ----------------------------
-- Records of sys_user
-- ----------------------------
INSERT INTO sys_user (id, name, account, pwd, remark, create_time, update_time) VALUES (1, 'Administrator', 'admin', '123456', 'Administrator Account', '2019-08-26 00:52:01', null);

2. Generator CRUD CODE

Modify database info

Modify module name / author / table name / primary key id

/src/test/java/io/geekidea/springbootplus/test/CodeGenerator.java
/**
* spring-boot-plus Code Generator
* @author geekidea
* @date 2018-11-08
*/
public class CodeGenerator {
private static final String USER_NAME = "root";
private static final String PASSWORD = "root";
private static final String DRIVER_NAME = "com.mysql.jdbc.Driver";
private static final String DRIVER_URL = "jdbc:mysql://localhost:3306/spring_boot_plus?useUnicode=true&characterEncoding=UTF-8&useSSL=false";
// CODE...
// ############################ Config start ############################
// Module name
private static final String MODULE_NAME = "system";
// Author
private static final String AUTHOR = "geekidea";
// Table name
private static final String TABLE_NAME = "sys_user";
// Primary key id
private static final String PK_ID_COLUMN_NAME = "id";
// Generator strategy. true:All / false:SIMPLE
private static final boolean GENERATOR_STRATEGY = true;
// Pagination list query Whether to sort. true:sort/false:non
private static final boolean PAGE_LIST_ORDER = false;
// ############################ Config end ############################
public static void main(String[] args) {
// Run...
}
}

3. Startup Project

Project Main Class

/src/main/java/io/geekidea/springbootplus/SpringBootPlusApplication.java
/**
* spring-boot-plus Project Main Class
* @author geekidea
* @since 2018-11-08
*/
@EnableAsync
@EnableScheduling
@EnableTransactionManagement
@EnableConfigurationProperties
@EnableAdminServer
@MapperScan({"io.geekidea.springbootplus.**.mapper"})
@SpringBootApplication
public class SpringBootPlusApplication {
public static void main(String[] args) {
// Run spring-boot-plus
ConfigurableApplicationContext context = SpringApplication.run(SpringBootPlusApplication.class, args);
// Print Project Info
PrintApplicationInfo.print(context);
}
}

4. Access project swagger docs

http://127.0.0.1:8888/swagger-ui.html

5. SysUser CRUD Swagger

spring-boot-plus V1.2.2 發佈,5 Minutes Finish CRUD


分享到:


相關文章: