Skip to content

Commit

Permalink
Merge pull request #32 from geekidea/dev
Browse files Browse the repository at this point in the history
🏇 5 Minutes Finish CRUD

Former-commit-id: d352970abafd0171f21253d9d10a2020c18143ea
  • Loading branch information
springboot-plus authored Aug 25, 2019
2 parents e235169 + 765697b commit 20e91ef
Show file tree
Hide file tree
Showing 15 changed files with 523 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
- 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](https://raw.githubusercontent.com/geekidea/spring-boot-plus/master/docs/img/spring-boot-plus-architecture.jpg)
- [5 Minutes Finish CRUD](https://github.com/geekidea/spring-boot-plus#5-minutes-finish-crud)

### 🔨 Dependency Upgrades
- `pom.xml` 使用 `spring-boot-starter-validation` 替换 `hibernate-validator` 依赖
Expand Down
83 changes: 82 additions & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,82 @@ cd spring-boot-plus
mvn clean package -Plocal
```

### 项目入口类

## 5分钟完成增删改查

### 创建数据库表
```sql
-- ----------------------------
-- Table structure for sys_user
-- ----------------------------
drop table if exists `sys_user`;
create table sys_user(
id bigint not null comment '主键',
name varchar(20) null comment '用户名称',
account varchar(20) not null comment '账号',
pwd varchar(20) not null comment '密码',
remark varchar(200) null comment '备注',
create_time timestamp default CURRENT_TIMESTAMP null comment '创建时间',
update_time timestamp null comment '修改时间',
primary key (`id`),
constraint sys_user_account_uindex
unique (account)
) comment '系统用户';
-- ----------------------------
-- 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);

```

### CodeGenerator CRUD
> 修改数据库信息
>修改组件名称/作者/数据库表名称/主键id
```text
/src/test/java/io/geekidea/springbootplus/test/CodeGenerator.java
```

```java
/**
* spring-boot-plus代码生成器入口类
* @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...
// ############################ 配置部分 start ############################
// 模块名称
private static final String MODULE_NAME = "system";
// 作者
private static final String AUTHOR = "geekidea";
// 生成的表名称
private static final String TABLE_NAME = "sys_user";
// 主键数据库列名称
private static final String PK_ID_COLUMN_NAME = "id";
// 代码生成策略 true:All/false:SIMPLE
private static final boolean GENERATOR_STRATEGY = true;
// 分页列表查询是否排序 true:有排序参数/false:无
private static final boolean PAGE_LIST_ORDER = false;
// ############################ 配置部分 end ############################

public static void main(String[] args) {
// Run...
}
}
```

### 启动项目
> 项目入口类
```text
/src/main/java/io/geekidea/springbootplus/SpringBootPlusApplication.java
```

```java
/**
* spring-boot-plus 项目启动入口
Expand All @@ -114,6 +189,12 @@ public class SpringBootPlusApplication {
}
```

### 访问项目swagger文档
[http://127.0.0.1:8888/swagger-ui.html](http://127.0.0.1:8888/swagger-ui.html)

### 系统用户 增删改查分页Swagger
![sys_user_swagger-zh.png](https://raw.githubusercontent.com/geekidea/spring-boot-plus/master/docs/img/sys_user_swagger-zh.png)

## 快速开始
[快速开始](https://springboot.plus/guide/quick-start.html)

Expand Down
91 changes: 86 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
## Purpose
> Everyone can develop projects independently, quickly and efficiently!
## Docs
## Repository
#### [GITHUB](https://github.com/geekidea/spring-boot-plus) | [GITEE](https://gitee.com/geekidea/spring-boot-plus)

#### Website:[springboot.plus](http://springboot.plus "springboot.plus")
#### Website
#### [springboot.plus](http://springboot.plus "springboot.plus")

# Architecture
![spring-boot-plus-architecture.jpg](https://raw.githubusercontent.com/geekidea/spring-boot-plus/master/docs/img/spring-boot-plus-architecture.jpg)


## Features
- Integrated spring boot common development component set, common configuration, AOP log, etc
- Integrated mybatis-plus fast dao operation
Expand All @@ -48,7 +48,6 @@
- Integrated Spring Boot Admin, real-time detection of project operation
- Integrate maven-assembly-plugin for different environment package deployment, including startup and restart commands, and extract configuration files to external config directory


### Project Environment
Middleware | Version | Remark
-|-|-
Expand Down Expand Up @@ -88,7 +87,82 @@ cd spring-boot-plus
mvn clean package -Plocal
```

### Project Main Class

## 5 Minutes Finish CRUD

### 1. Create Table
```sql
-- ----------------------------
-- 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
```text
/src/test/java/io/geekidea/springbootplus/test/CodeGenerator.java
```

```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
```text
/src/main/java/io/geekidea/springbootplus/SpringBootPlusApplication.java
```

```java
/**
* spring-boot-plus Project Main Class
Expand All @@ -114,6 +188,13 @@ public class SpringBootPlusApplication {
}
```

### 4. Access project swagger docs
[http://127.0.0.1:8888/swagger-ui.html](http://127.0.0.1:8888/swagger-ui.html)

### 5. SysUser CRUD Swagger
![sys_user_swagger.png](https://raw.githubusercontent.com/geekidea/spring-boot-plus/master/docs/img/sys_user_swagger.png)


## Quick Start
[Quick Start](https://springboot.plus/guide/quick-start.html)

Expand Down
Binary file added docs/img/sys_user_swagger-zh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/sys_user_swagger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package io.geekidea.springbootplus.system.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import io.geekidea.springbootplus.common.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Date;

/**
* <p>
* SystemUser
* </p>
*
* @author geekidea
* @since 2019-08-26
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="SysUser对象", description="SystemUser")
public class SysUser extends BaseEntity {

private static final long serialVersionUID = 1L;

@ApiModelProperty(value = "id")
@TableId(value = "id", type = IdType.ID_WORKER)
private Long id;

@ApiModelProperty(value = "name")
private String name;

@ApiModelProperty(value = "account")
private String account;

@ApiModelProperty(value = "password")
private String pwd;

@ApiModelProperty(value = "remark")
private String remark;

@ApiModelProperty(value = "create time")
private Date createTime;

@ApiModelProperty(value = "update time")
private Date updateTime;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package io.geekidea.springbootplus.system.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.geekidea.springbootplus.system.entity.SysUser;
import io.geekidea.springbootplus.system.web.param.SysUserQueryParam;
import io.geekidea.springbootplus.system.web.vo.SysUserQueryVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.io.Serializable;

/**
* <p>
* SystemUser Mapper 接口
* </p>
*
* @author geekidea
* @since 2019-08-26
*/
@Repository
public interface SysUserMapper extends BaseMapper<SysUser> {

/**
* 根据ID获取查询对象
* @param id
* @return
*/
SysUserQueryVo getSysUserById(Serializable id);

/**
* 获取分页对象
* @param page
* @param sysUserQueryParam
* @return
*/
IPage<SysUserQueryVo> getSysUserPageList(@Param("page") Page page, @Param("param") SysUserQueryParam sysUserQueryParam);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.geekidea.springbootplus.system.service;

import io.geekidea.springbootplus.system.entity.SysUser;
import io.geekidea.springbootplus.common.service.BaseService;
import io.geekidea.springbootplus.system.web.param.SysUserQueryParam;
import io.geekidea.springbootplus.system.web.vo.SysUserQueryVo;
import io.geekidea.springbootplus.common.web.vo.Paging;

import java.io.Serializable;

/**
* <p>
* SystemUser 服务类
* </p>
*
* @author geekidea
* @since 2019-08-26
*/
public interface SysUserService extends BaseService<SysUser> {

/**
* 根据ID获取查询对象
* @param id
* @return
*/
SysUserQueryVo getSysUserById(Serializable id) throws Exception;

/**
* 获取分页对象
* @param sysUserQueryParam
* @return
*/
Paging<SysUserQueryVo> getSysUserPageList(SysUserQueryParam sysUserQueryParam) throws Exception;

}
Loading

0 comments on commit 20e91ef

Please sign in to comment.