GithubHelp home page GithubHelp logo

codehelper.generator's Introduction

codehelper.generator

Jetbrains Plugins Version 下载量 一个月下载量

English Documentation

GenDaoCode 特性

  • 根据Pojo 文件一键生成 Dao,Service,Xml,Sql文件。
  • Pojo文件更新后一键更新对应的Sql和mybatis xml文件。
  • 提供insert,insertList,update,select,delete五种方法。
  • 能够批量生成多个Pojo的对应的文件。
  • Pojo文件新增字段后,同时生成添加字段的sql语句。
  • 自动将pojo的注释添加到对应的Sql文件的注释中。

  • 丰富的配置,如果没有配置文件,则会使用默认配置。
  • 可以在Intellij Idea中快捷键配置中配置快捷键。
  • 目前支持MySQL + Java,后续会支持更多的DB。
  • 如果喜欢我们的插件,非常感谢您的分享。

GenDaoCode 使用示例

  • generateMultiple

GenDaoCode 使用方法

  • 主菜单Tools-> Codehelper-> GenDaoCode 按键便可生成代码。
  • 方法一:点击GenDaoCode,然后根据提示框输入Pojo名字,多个Pojo以 | 分隔。
  • Codehelper Generator会根据默认配置为您生成代码。
  • 方法二:在工程目录下添加文件名为codehelper.properties的文件。
  • 点击GenDaoCode,Codehelper Generator会根据您的配置文件为您生成代码

GenDaoCode 使用必读

  • 支持的java field类型如下:

    • 基本类型:short, int, long, float, double
    • 对象类型:
      • java.lang.Short, java.lang.Integer, java.lang.Long
      • java.lang.Double, java.lang.Float, java.lang.String
      • java.util.Date, java.sql.Date, java.sql.Timestamp
      • java.math.BigDecimal
  • java pojo中必须包含 id 属性, 类型可以是 int, long, Integer, Long

    • sql中的id字段会加: BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 关键字。
  • java pojo中建议用 createTime表示 创建时间, updateTime表示更新时间。

  • select查询的xml语句中, 默认添加limit 1000, 使用的时候注意。

  • update操作的xml语句中, 没有update_time, 默认依赖update_timeON UPDATE CURRENT_TIMESTAMP来更新. (注意mysqlUPDATE CURRENT_TIMESTAMP 在更新的时候, 如果数据没有改变, update_time 不会更新 )

  • 如果java class文件中包含updateTime字段, sql中update_time 会加 NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 关键字。

  • 如果java class文件中包含createTime字段, sql中的create_time会加 NOT NULL DEFAULT CURRENT_TIMESTAMP 关键字。

GenDaoCode 个性化配置

  • 在工程目录下添加codehelper.properties文件。
  • 忽略某个字段(注释中包含 IgnoreAutoGenerate 关键字) 示例如下:
//IgnoreAutoGenerate
private String userName;
  • 配置示例如下:
#配置多个pojos,以 | 分隔
pojos=SamplePojo|AccountPojo

#Sql文件的charset配置
charset=utf8

#文件语言,有中文注释的设置为CN
language=CN

#mysql Engine
sqlEngine=InnoDB

#生成service、dao接口、mapper文件后綴
mapper.suffix=Mapper
dao.suffix=Mapper
service.suffix=Service

#配置各个文件的路径
mapper.path=src/main/resources/mapper
dao.path=src/main/java/com/codehelper/sample/dao
service.path=src/main/java/com/codehelper/sample/service
sql.path=doc/sql/generator

#module路径,如果“dao.path”、“service.path”包含了module目录,即并非从package根目录开始,请配置下面的项目。
dao.module.path=src/main/java
service.module.path=src/main/java

### 配置各个java类型的sql关键字
int=INTEGER(12) NOT NULL DEFAULT -1
double=DECIMAL(14,4) NOT NULL DEFAULT -1
java.lang.String=VARCHAR(50) NOT NULL DEFAULT ''
java.lang.Integer=INTEGER(12) NOT NULL DEFAULT -1

GenAllSetter 特性

  • 在Java方法中, 根据 new 关键词, 为Java Bean 生成所有Setter方法。
  • 按GenAllSetter键两次, 会为Setter方法生成默认值。
  • 可在Intellij Idea中为GenAllSetter设置快捷键。
  • 如何使用:
    • 将光标移动到 new 语句的下一行。
    • 点击主菜单Tools-> Codehelper-> GenAllSetter, 或者按下GenAllSetter快捷键。

GenAllSetter 使用示例

  • generateMultiple

联系作者 & 加入开发

  • QQ 群: 322824200

codehelper.generator's People

Contributors

forking003 avatar gejun123456 avatar zgj0607 avatar zhengjunbase avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codehelper.generator's Issues

JetBranins IDEA 版本2021.2.2 安装报如下错误

com.intellij.diagnostic.PluginException: com.ccnode.codegenerator.view.AutoCodingAction PluginClassLoader(plugin=PluginDescriptor(name=codehelper.generator, id=com.ccnode.codegenerator.mybatis.generator, descriptorPath=plugin.xml, path=\AppData\Roaming\JetBrains\IntelliJIdea2021.2\plugins\codehelper.generator, version=2018.12.14, package=null), packagePrefix=null, instanceId=264, state=active)
at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClass(ComponentManagerImpl.kt:895)
at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.instantiate(ActionManagerImpl.java:195)
at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.convertStub(ActionManagerImpl.java:180)
at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.getActionImpl(ActionManagerImpl.java:518)
at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.getAction(ActionManagerImpl.java:507)
at com.intellij.openapi.actionSystem.DefaultActionGroup.unStub(DefaultActionGroup.java:381)
at com.intellij.openapi.actionSystem.DefaultActionGroup.getChildren(DefaultActionGroup.java:341)
at com.intellij.openapi.actionSystem.DefaultActionGroup.getChildren(DefaultActionGroup.java:320)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.doGetChildren(ActionUpdater.java:594)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$new$1(ActionUpdater.java:114)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.callAction(ActionUpdater.java:176)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$new$2(ActionUpdater.java:114)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$getGroupChildren$26(ActionUpdater.java:403)
at com.intellij.util.TimeoutUtil.compute(TimeoutUtil.java:134)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$getGroupChildren$28(ActionUpdater.java:402)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1737)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.getGroupChildren(ActionUpdater.java:401)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.iterateGroupChildren(ActionUpdater.java:548)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.expandGroupChild(ActionUpdater.java:432)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$doExpandActionGroup$23(ActionUpdater.java:394)
at com.intellij.util.TimeoutUtil.compute(TimeoutUtil.java:134)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$doExpandActionGroup$25(ActionUpdater.java:393)
at com.intellij.util.containers.ContainerUtil.concat(ContainerUtil.java:1483)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.doExpandActionGroup(ActionUpdater.java:393)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.expandActionGroup(ActionUpdater.java:230)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$expandActionGroupAsync$14(ActionUpdater.java:281)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$expandActionGroupAsync$16(ActionUpdater.java:305)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1078)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$expandActionGroupAsync$17(ActionUpdater.java:305)
at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:161)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$expandActionGroupAsync$18(ActionUpdater.java:301)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:183)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:705)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:647)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:63)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:170)
at com.intellij.openapi.progress.util.BackgroundTaskUtil.runUnderDisposeAwareIndicator(BackgroundTaskUtil.java:270)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$expandActionGroupAsync$19(ActionUpdater.java:300)
at com.intellij.codeWithMe.ClientId$Companion.withClientId(ClientId.kt:135)
at com.intellij.codeWithMe.ClientId.withClientId(ClientId.kt)
at com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$expandActionGroupAsync$20(ActionUpdater.java:298)
at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:216)
at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:27)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.execute(BoundedTaskExecutor.java:195)
at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:213)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:184)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.ClassNotFoundException: com.ccnode.codegenerator.view.AutoCodingAction PluginClassLoader(plugin=PluginDescriptor(name=codehelper.generator, id=com.ccnode.codegenerator.mybatis.generator, descriptorPath=plugin.xml, path=
\AppData\Roaming\JetBrains\IntelliJIdea2021.2\plugins\codehelper.generator, version=2018.12.14, package=null), packagePrefix=null, instanceId=264, state=active)
at com.intellij.serviceContainer.ComponentManagerImplKt.doLoadClass(ComponentManagerImpl.kt:1489)
at com.intellij.serviceContainer.ComponentManagerImplKt.access$doLoadClass(ComponentManagerImpl.kt:1)
at com.intellij.serviceContainer.ComponentManagerImpl.instantiateClass(ComponentManagerImpl.kt:887)
... 52 more

idea启动GenDaoCode报错

null
java.lang.NullPointerException
	at com.ccnode.codegenerator.view.GenCodeAction.actionPerformed(GenCodeAction.java:56)
	at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:216)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:233)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.a(ActionMenuItem.java:310)
	at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:911)
	at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:136)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:300)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.a(ActionMenuItem.java:117)
	at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:86)
	at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:109)
	at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:118)
	at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:122)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:117)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
	at javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:308)
	at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
	at com.apple.laf.ScreenMenuItemCheckbox.itemStateChanged(ScreenMenuItemCheckbox.java:193)
	at java.awt.CheckboxMenuItem.processItemEvent(CheckboxMenuItem.java:389)
	at java.awt.CheckboxMenuItem.processEvent(CheckboxMenuItem.java:357)
	at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:355)
	at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:343)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:767)
	at java.awt.EventQueue.access$500(EventQueue.java:98)
	at java.awt.EventQueue$3.run(EventQueue.java:715)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
	at java.awt.EventQueue$4.run(EventQueue.java:737)
	at java.awt.EventQueue$4.run(EventQueue.java:735)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
	at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:821)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:649)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:365)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

GenAllSetter如何自定义默认值

GenAllSetter自动生成出来的赋值语句,都是默认赋空值,比如: user.setName(StringUtils.EMPTY),很多场景下这些字段默认值设置成空串是不符合需求的,因为后续代码中经常会对一个对象的字段做非空判断。
所以请问是否支持自定制默认值,可以把StringUtils.EMPTY改成有意义的字符串

idea 版本兼容性

IntelliJ IDEA 2018.2.6 (Ultimate Edition)
Build #IU-182.5107.16, built on November 6, 2018
Subscription is active until May 5, 2019
JRE: 1.8.0_152-release-1248-b22 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

idea这个版本使用 codehelper.generator 最新版,idea中无法使用,itools菜单找不到Codehelper菜单项

为什么mysql属性为datetime类型的在生成代码被忽略掉了

我的表

CREATE TABLE `meeting` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `meeting_name` varchar(100) COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '会议名称',
  `meeting_address` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '会议地点',
  `meeting_sponsor` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '主办方',
  `meeting_principal` int(11) NOT NULL DEFAULT '0' COMMENT '会议负责人',
  `meeting_adduser` int(11) NOT NULL DEFAULT '0' COMMENT '添加用户',
  `meeting_begin_time` datetime NOT NULL COMMENT '开始时间',
  `meeting_end_time` datetime NOT NULL COMMENT '结束时间',
  `meeting_describe` varchar(512) COLLATE utf8_bin DEFAULT '' COMMENT '会议描述',
  `meeting_participant` int(11) NOT NULL DEFAULT '0' COMMENT '参会人数',
  `meeting_status` int(3) NOT NULL DEFAULT '0' COMMENT '0为未付款,1为已付款,2为举办中,3为已完成。',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

生成的mapper

<resultMap id="AllColumnMap" type="com.hntxrj.meeting.entity.MeetingCommodity">
        <result column="id" property="id"/>
        <result column="commodity_name" property="commodityName"/>
        <result column="commodity_price" property="commodityPrice"/>
        <result column="commodity_inventory" property="commodityInventory"/>
        <result column="commodity_describe" property="commodityDescribe"/>
        <result column="commodity_promotion_price" property="commodityPromotionPrice"/>
        <result column="commodity_promotion" property="commodityPromotion"/>
        <result column="commodity_status" property="commodityStatus"/>
    </resultMap>

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.