-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from enilu/develop
Develop
- Loading branch information
Showing
67 changed files
with
2,209 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
material-core/src/main/java/cn/enilu/material/bean/entity/test/Boy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
material-core/src/main/java/cn/enilu/material/bean/entity/test/Girl.java
This file was deleted.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
...aterial/bean/exception/GunsException.java → .../bean/exception/ApplicationException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
{ | ||
"codeConfig": { | ||
"type": "cn.enilu.sbvue.code.CodeConfig", | ||
"type": "cn.enilu.flash.code.CodeConfig", | ||
"fields": { | ||
entityModel: "guns-entity", | ||
daoModel: "guns-dao1", | ||
serviceModel: "guns-service2", | ||
controllerModel: "guns-api", | ||
viewModel: "guns-admin-vuejs" | ||
entityModel: "material-core", | ||
daoModel: "material-core", | ||
serviceModel: "material-core", | ||
controllerModel: "material-manage", | ||
viewModel: "material-manage" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# 代码生成 | ||
|
||
## 用法 | ||
- 在material-core/pom.xml中添加依赖 | ||
```xml | ||
<dependency> | ||
<groupId>cn.enilu</groupId> | ||
<artifactId>material-generator</artifactId> | ||
<version>${project.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
``` | ||
- 下载intellij代码生成插件,在插件中心搜索并安装插件:webflash-generator | ||
|
||
- 写好实体类,例如: | ||
```java | ||
package cn.enilu.material.bean.entity.test; | ||
import cn.enilu.material.bean.entity.BaseEntity; | ||
import lombok.Data; | ||
import org.hibernate.annotations.Table; | ||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
|
||
@Entity(name="t_test_boy") | ||
@Table(appliesTo = "t_test_boy",comment = "男孩") | ||
@Data | ||
|
||
public class Boy extends BaseEntity { | ||
@Column(columnDefinition = "VARCHAR(32) COMMENT '姓名'") | ||
private String name; | ||
@Column(columnDefinition = "INT COMMENT '年龄'") | ||
private Integer age; | ||
@Column(columnDefinition = "VARCHAR(12) COMMENT '生日'") | ||
private String birthday; | ||
@Column(name = "has_girl_friend",columnDefinition = "TINYINT COMMENT '是否有女朋友'") | ||
private Boolean hasGirFriend; | ||
} | ||
|
||
``` | ||
- 上面实体类注意事项 | ||
- @Table注解要使用org.hibernate.annotations.Table 不要使用javax.persistence.Table | ||
- @Table注解 必须配置表名(applyiesTo)和注释(comment) | ||
- @Column注解必须配置columnDefinition来表述列信息(英文全部大写):包括类型,注释COMMENT | ||
- 实体类必须继承BaseEntity | ||
- 实体类准备好了后,打开实体类,右键点击“Generator"-->"web-flash-mvc",弹出如下图所示对话框 | ||
![code-generator](./doc/code-generate.jpg) | ||
**注意**不用更改对话框中的配置(大部分没有什么作用) | ||
- 运行生成代码后,将会生成controller,service,repository,以及对应的增上改查页面和js,以TestBoy为例,生成的代码如下所示: | ||
![generate-result](./doc/generate-result.png) | ||
- 代码生成后,在系统中配置对应的菜单和权限,即可使用 | ||
![菜单配置](./doc/menu.png) | ||
|
||
![功能预览](./doc/boy-list.png) | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>material-admin</artifactId> | ||
<groupId>cn.enilu</groupId> | ||
<version>0.1</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>material-generator</artifactId> | ||
<properties> | ||
<java-version>1.8</java-version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<evo-inflector-version>1.0.1</evo-inflector-version> | ||
<velocity-version>1.7</velocity-version> | ||
<commons-cli-version>1.2</commons-cli-version> | ||
<spring.boot.version>2.1.1.RELEASE</spring.boot.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.atteo</groupId> | ||
<artifactId>evo-inflector</artifactId> | ||
<version>${evo-inflector-version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>commons-cli</groupId> | ||
<artifactId>commons-cli</artifactId> | ||
<version>${commons-cli-version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.velocity</groupId> | ||
<artifactId>velocity</artifactId> | ||
<version>${velocity-version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.nutz</groupId> | ||
<artifactId>nutz</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
21 changes: 21 additions & 0 deletions
21
material-generator/src/main/java/cn/enilu/flash/code/AbstractLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package cn.enilu.flash.code; | ||
|
||
import org.nutz.ioc.Ioc; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* 基础的数据结构加载器<br> | ||
* @author : zhangtao <br> | ||
* 创建日期: 16-7-12<br> | ||
*/ | ||
public abstract class AbstractLoader { | ||
|
||
public abstract Map<String, TableDescriptor> loadTables(Ioc ioc, | ||
String basePackageName, String baseUri, | ||
String servPackageName, | ||
String repositoryPackageName, | ||
String modPackageName) throws Exception; | ||
|
||
|
||
} |
Oops, something went wrong.