Giter Site home page Giter Site logo

ibatiscodehelper's Introduction

MyBatisCodeHelper

GitHub release Jetbrains Plugins Version
Downloads Downloads last month

Intellij下代码自动生成插件 支持生成mybatis的dao接口,mapper xml,和建表sql, 支持直接从接口方法名直接生成sql.

  • 根据数据库对象一键生成 Dao接口,Service,Xml,数据库建表Sql文件 提供dao与xml的跳转 generateFile

  • 根据dao中的方法名生成对应的在xml并进行方法补全 find update delete count all_1

安装

支持下面产品编译号为141以上的产品。

  • Android Studio
  • IntelliJ IDEA
  • IntelliJ IDEA Community Edition

使用 IDE 内置插件系统:

  • Preferences(Settings) > Plugins > Browse repositories... > 搜索并找到"MybatisCodeHelper" > Install Plugin

手动:

重启IDE.

使用方法

  • 在数据库对象上使用alt+insert (generate mybatis files)生成对应的dao xml文件等 (mac上使用 ctrl+N 即getter setter对应的快捷键)
  • 当数据库对象添加字段后也可使用alt+insert (generate mybatis files)来生成更新后的xml。(只会更新默认的insert,insertList,update方法 其他自定义的方法不会变)
  • 在mybatis的接口文件上的方法名上使用alt+enter generatedaoxml 生成对应的mybatis sql及方法的补全

需要注意的点

  • 使用方法名生成sql 需要在接口中提供一个insert或save或add方法并以数据库对象为第一参数 (可以通过数据库对象自动生成)
  • 使用方法名生成的sql的字段会从数据库对象对应的resultMap中的数据库字段来设置。

方法名生成sql

数据库对象User

字段名 类型
id Integer
userName String
password String

表名为user

xml中对应的resultMap为

<resultMap id="AllCoumnMap" type="com.codehelper.domain.User">
    <result column="id" property="id"/>
    <result column="user_name" property="userName"/>
    <result column="password" property="password"/>
</resultMap>

以下是方法名与sql的对应关系(方法名的大小写无所谓)

可以跟在字段后面的比较符有

比较符 生成sql
between prop >={} and prop <={}
lessthan prop < {}
greaterthan prop > {}
isnull prop is null
notnull prop is not null
like prop like {}
in prop in {}
notin prop not in {}
not prop != {}
notlike prop not like {}
  • find方法

支持获取多字段,by后面可以设置多个字段的条件
支持orderBy,distinct, findFirst

方法名 sql
find select * from user
findUserName select user_name from user
findById select * from user where id = {}
findByIdGreaterThanAndUserName select * from user where id > {} and user_name = {}
findByIdGreaterThanOrIdLessThan select * from user where id > {} or id < {}
findByIdLessThanAndUserNameIn select * from user where id < {} and user_name in {}
findByUserNameAndPassword select * from user where user_name = {} and password = {}
findUserNameOrderByIdDesc select user_name from user order by id desc
findDistinctUserNameByIdBetween select distinct(user_name) from user where id >= {} and id <={}
findFirstByIdGreaterThan select * from user where id > {} limit 1
findFirst20ByIdLessThan select * from user where id < {} limit 20
findFirst10ByIdGreaterThanOrderByUserName select * from user where id > {} order by user_name limit 10
  • update方法 by后面设置的条件同上
方法名 sql
updateUserNameById update user set user_name = {} where id = {}
updateUserNameAndPasswordByIdIn update user set user_name = {} and password = {} where id in {}
  • delete方法 by后面设置的条件同上
方法名 sql
deleteById delete from user where id = {}
deleteByUserNameIsNull delete from user where user_name is null
  • count方法 by后面设置的条件同上 支持distinct
方法名 sql
count select count(1) from user
countDistinctUserNameByIdGreaterThan select count(distinct(user_name)) from user where id > {}

CHANGELOG

latest

feature:

  • 添加mapper与dao的相互跳转
  • 使用alt+insert来生成dao xml等
  • 添加方法名生成sql
  • 添加方法名自动提示

其他

截图中的项目来自https://github.com/gejun123456/codehelperPluginDemo

ibatiscodehelper's People

Contributors

gejun123456 avatar zhengjunbase avatar

Watchers

草莽 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.