All Projects → fit2cloud → Mybatis Tools

fit2cloud / Mybatis Tools

Licence: apache-2.0

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Mybatis Tools

gd-generator
A code generator that elegantly generates mybatis ORM (mapper and xml config) and intelligently retains user-defined mapper and xml, automatically creates/synchronizes database tables, and records and prints exactly after each domain model change Database repair sql, support for the production of a variety of complex VO (View Object) objects, al…
Stars: ✭ 82 (+485.71%)
Mutual labels:  mybatis, mybatis-generator
SpringBootMovie
基于Spring Boot的电影网站
Stars: ✭ 56 (+300%)
Mutual labels:  mybatis, mybatis-generator
mybatis-generator
MyBatis code generator
Stars: ✭ 25 (+78.57%)
Mutual labels:  mybatis, mybatis-generator
mybatis-generator-gui-plus
基于MyBatis-Generator+SQLite+beautyeye_lnf开发的一款图形化代码生成器
Stars: ✭ 16 (+14.29%)
Mutual labels:  mybatis, mybatis-generator
Yan
使用Maven构建,整合Dubbo+Zookeeper+SpringMVC+Spring+MyBatis+Redis支持分布式的高效率便捷开发框架
Stars: ✭ 293 (+1992.86%)
Mutual labels:  mybatis, mybatis-generator
atguigu ssm crud
Atguigu-SSM-CRUD 一个最基本的CRUD系统,采用IDEA+Maven搭建,具备前后端交互功能,前端采用BootStrap+Ajax异步请求DOM渲染,后端采用SpringMVC+MyBatis+Mysql8.0+Servlet+Jsp,符合REST风格URL规范,并加入了Hibernate提供的数据校验功能,支持PageHelper的分页功能,很适合SSM阶段性练习。同时用到了很多前端操作以及BootStrap组件,也有利于学习JS和前端框架。
Stars: ✭ 52 (+271.43%)
Mutual labels:  mybatis, mybatis-generator
demo springboot with mybatis
No description or website provided.
Stars: ✭ 17 (+21.43%)
Mutual labels:  mybatis, mybatis-generator
Spring Cloud Shop
spring cloud 版分布式电商项目,全力打造顶级多模块,高可用,高扩展电商项目
Stars: ✭ 248 (+1671.43%)
Mutual labels:  mybatis, mybatis-generator
Zheng
基于Spring+SpringMVC+Mybatis分布式敏捷开发系统架构,提供整套公共微服务服务模块:集中权限管理(单点登录)、内容管理、支付中心、用户管理(支持第三方登录)、微信平台、存储系统、配置中心、日志分析、任务和通知等,支持服务治理、监控和追踪,努力为中小型企业打造全方位J2EE企业级开发解决方案。
Stars: ✭ 16,163 (+115350%)
Mutual labels:  mybatis, mybatis-generator
mybatis-mapper2sql
Generate SQL Statements from the MyBatis3 Mapper XML file
Stars: ✭ 61 (+335.71%)
Mutual labels:  mybatis, mybatis-generator
lightbatis
Lightbatis 增强 MyBatis 版Java 数据库持久层,更简洁并易用
Stars: ✭ 52 (+271.43%)
Mutual labels:  mybatis, mybatis-generator
Generator
A code generator for MyBatis.
Stars: ✭ 4,847 (+34521.43%)
Mutual labels:  mybatis, mybatis-generator
IDEAPractice
Java练习 - Java基础知识,面试题,小demo,长期积累 | intellij idea + maven + tomcat
Stars: ✭ 45 (+221.43%)
Mutual labels:  mybatis, mybatis-generator
AllInOneFX
All In One JavaFX Application with a curated list of awesome JavaFX libraries, frameworks
Stars: ✭ 26 (+85.71%)
Mutual labels:  mybatis, mybatis-generator
mall
SpringBoot + Layui 电子商城系统
Stars: ✭ 38 (+171.43%)
Mutual labels:  mybatis, mybatis-generator
kite-mybatis-builder
web 形式的mybatis 生成器
Stars: ✭ 58 (+314.29%)
Mutual labels:  mybatis, mybatis-generator
Priest
dubbo mybatis springboot base soa rest api framework with customer code generator
Stars: ✭ 160 (+1042.86%)
Mutual labels:  mybatis, mybatis-generator
Roncoo Mybatis Generator
龙果开源-Mybatis代码自动生成工具
Stars: ✭ 165 (+1078.57%)
Mutual labels:  mybatis, mybatis-generator
mybatis-generator-plus
轻度扩展mybatis-generator-core插件,与官方插件兼容。
Stars: ✭ 62 (+342.86%)
Mutual labels:  mybatis, mybatis-generator
S Mall Ssm
小小商城系统,JavaWEB项目,基于SSM,仿天猫页面,功能齐全,实现了自动处理关联查询的通用Mapper、抽象 BaseService 类、注解鉴权、参数注解校验等
Stars: ✭ 456 (+3157.14%)
Mutual labels:  mybatis, mybatis-generator

1. com.fit2cloud.tools.mybatis.SqlCriterionGeneratorPlugin

What's this

A mybatis generator plugin that generates a method to add sql formatted criterion to the MBG generated criteria.

Why to use

Hanlde complex query conditons(e.g. including both 'and' and 'or') in a fluent way.

When to use

Consider some employees need to be filtered by name and other conditions, with the default criteria you may have to do this by tedious code.

Criteria criteria1 = example.or();
criteria1.andCountryEqualTo("USA");
criteria1.andStateEqualTo("California");
criteria1.andCityEqualTo("LA");
criteria1.andMaleEqualTo("Female");

criteria1.andFirstNameLike("%Ava%");

Criteria criteria2 = example.or();
criteria2.andCountryEqualTo("USA");
criteria2.andStateEqualTo("California");
criteria2.andCityEqualTo("LA");
criteria2.andMaleEqualTo("Female");

criteria2.andLastNameLike("%Ava%");

mapper.selectByExamle(example);

/*the query will be 
select * from employee where (country = 'USA' and state = 'California' and city = 'LA' and male = 'Female'
and first_name like '%Ava%') or (country = 'USA' and state = 'California' and city = 'LA' and male = 'Female'
and last_name like '%Ava%')
*/

With this generator plugin a new method called andSqlCriterion will be generated in the Criteria class.

public Criteria andSqlCriterion(String value) {
    addCriterion("(" + value + ")");
    return (Criteria) this;
}

Then above scenario can be implemented like this

Criteria criteria = example.or();
criteria.andCountryEqualTo("USA");
criteria.andStateEqualTo("California");
criteria.andCityEqualTo("LA");
criteria.andMaleEqualTo("Female");

criteria.andSqlCriterion("first_name like '%Ava%' or last_name like '%Ava%'");

mapper.selectByExamle(example);

/*the query will be 
select * from employee where country = 'USA' and state = 'California' and city = 'LA' and male = 'Female'
and ( first_name like '%Ava%' or last_name like '%Ava%')
*/
How to use

Simply mvn package the project and add the plugin in your generatorConfig.xml(maybe some other file you named).

<plugin type="com.fit2cloud.tools.mybatis.SqlCriterionGeneratorPlugin" />
Reference

Supplied Plugins by MBG

2. com.fit2cloud.tools.mybatis.swagger.ImportSwaggerPlugin

What's this

A mybatis generator plugin that adds Swagger Annotations for the fields of Java model based on table.

When to use

You develop a restful API which is described by swagger, the models might be generated by MBG and you want to add swagger annotations.

In such case, if you added the annotation manually then they would be removed when regenerating the models :(, but this plugin will help you :).

Assume you have a table user_key

CREATE TABLE `user_key` (
  `id` VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'user_key ID',
  `user_id` VARCHAR(50) NOT NULL COMMENT '用户ID',
  `access_key` VARCHAR(50) NOT NULL COMMENT 'access_key',
  `secret_key` VARCHAR(50) NOT NULL COMMENT 'secret key',
  `create_time` BIGINT(13) NOT NULL COMMENT '创建时间',
  `status` VARCHAR(10) DEFAULT NULL COMMENT '状态',
  PRIMARY KEY (`id`),
  UNIQUE KEY `IDX_AK` (`access_key`),
  KEY `IDX_USER_ID` (`user_id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4

With this generator you can get the model with annotations like this.

import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;

public class UserKey implements Serializable {
    
    @ApiModelProperty("user_key ID")
    private String id;

    @ApiModelProperty(value = "用户ID", required = true)
    private String userId;

    @ApiModelProperty(value = "access_key", required = true)
    private String accessKey;

    @ApiModelProperty(value = "secret key", required = true)
    private String secretKey;

    @ApiModelProperty("创建时间")
    private Long createTime;

    @ApiModelProperty("状态")
    private String status;
    
    // getter and setters..
}

Then you will get a swagger model.

swagger model

How to use

Simply mvn package the project and add the plugin in your generatorConfig.xml(maybe some other file you named).

<!-- this class add import(import io.swagger.annotations.ApiModelProperty;) in the model -->
<plugin type="com.fit2cloud.tools.mybatis.swagger.ImportSwaggerPlugin" />
<!-- this class add annotation(@ApiModelProperty) for the fields -->
<commentGenerator type="com.fit2cloud.tools.mybatis.swagger.ApiModelPropertyAnnotationGenerator">
    <property name="suppressDate" value="true"/>
</commentGenerator>
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].