Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
matrix
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
mall
arch
matrix
Commits
29193962
Commit
29193962
authored
Aug 14, 2019
by
李秋伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update README.md
parent
006420e8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
17 deletions
+87
-17
README.md
mybatis-starter/README.md
+87
-17
No files found.
mybatis-starter/README.md
View file @
29193962
# 介绍
# 介绍
mybatis-starter基于
[
mybatis-plus
](
https://mp.baomidou.com/
)
进行二次封装,简化对dao层数据访问操作。
mybatis-starter
# 特点
# 特点
-
-
提供分页Page对象统一封装
-
提供分页对象结果DataPage,进行统一定义
-
非生产环境提供sql打印
-
支持createTime默认字段填充(见demo)
-
支持事务切面。增加matrix.aop-transaction.enabled配置,默认false,未开启,此时在需要的事务上增加@Transactional。修改为true,表示service方法名以add、save、create、modify、update、remove、delete为前缀的方法自动追加事务。
# 最佳实践
-
matrix.aop-transaction.enabled设置为true,节省事务配置
-
bean路径放置com.secoo.mall.
**
.bean.domain
-
xml放置在resource/mybatis路径下
# 开始
-
对于复杂sql使用xml,如多表关联查询,对于单表操作使用QueryWapper操作
-
添加依赖
-
所有与数据叫交互放到Mapper中,不要直接写在service中。如
-
Maven:需要在自己项目的pom.xml增加,以下配置。
```
**注意:前置条件需要依赖项目中需要设置matrix的parent**
@Mapper
public interface ProjectMapper extends BaseMapper<Project> {
default Project getByName(String name) {
return this.selectOne(new QueryWrapper<Project> ().lambda().eq(Project::getName, name).ne(Project::getStatus, ProjectConstant.Status.DELETE).last(" limit 1"));
}
```
# 文档
```xml
-
[
mybaties-plus开发指南
](
https://mp.baomidou.com/guide/
)
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>mybatis-starter</artifactId>
# 开始
</dependency>
```
-
添加依赖
-
Maven:需要在自己项目的pom.xml增加,以下配置。
**注意:前置条件需要依赖项目中需要设置matrix的parent**
```xml
<dependency>
<groupId>com.secoo.mall</groupId>
<artifactId>mybatis-starter</artifactId>
</dependency>
```
# 示例
#
示例
-
Bean自动填充字段 @TableField
```
public class Project extends AbsBaseBean {
......
@ApiModelProperty(value = "创建时间", hidden = true)
@TableField(fill = FieldFill.INSERT)
private Date createTime;
.....
}
```
-
分页工具类PageUtil使用
-
ProjectController
```
@ApiOperation(value = "应用多属性查询", notes = "应用多属性查询")
@PostMapping("/search")
public Object search(Project project, ReqPage reqPage, Sort sort) {
Page<Project> page = PageUtil.createPage(reqPage, sort);
return service.search(project, page);
}
```
-
ProjectService
```
public DataPage<Project> search(Project project, Page<Project> page) {
IPage<Project> iPage = mapper.search(project, page);
return PageUtil.createDataPage(iPage);
}
```
-
访问方式
http://localhost:8080/doc.html切换为web可以进行调试
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment