Skip to content

Commit 6bef7d2

Browse files
committed
17.1.1
1 parent b4f9f0f commit 6bef7d2

2 files changed

Lines changed: 49 additions & 21 deletions

File tree

readme-en.md

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,22 @@ can generate whole set of MVC CRUD code for SpringBoot during compiling.
1818

1919
### How to customize generation templates
2020

21-
Just edit `xxxTemplate` value in `@MVCIntrospective`.
21+
`@MVCIntrospective` has multiple configurable fields. Each of them has detailed description at [Javadoc](/src/main/java/firok/spring/mvci/MVCIntrospective.java).
2222

23-
> Resetting any of those values to `firok.spring.mvci.Constants.DISABLE` (`"##DISABLE##"`) will disable generating that code
23+
Most of those fields are annotated with `@AvailableValues` annotation, which describes the acceptable values of the relevant fields. A field can take any custom value (usually for a template string), if `Constants.CUSTOM` is listed in a `@AvailableValues`. Or any other non-listed values would cause compile error.
2424

25-
> If you do not want to write a long string template for many times, you could define that value as a `public static final String` field and use it in annotation.
25+
`PREFER_XXX` values means that those values could be overrided by upper configs. `DEFAULT` means the default value (usually a default template string) would be taken.
2626

27-
Default templates are stored in `firok.spring.mvci.internal.DefaultXXXTemplate`.
27+
`@MVCIntrospective` can be annotated on `class` or `package`.
28+
When generating for a bean class, we would search from children packages to parent packages to find any `@MVCIntrospective`. Then decide each value of fields.
29+
30+
> Hope you know what is `package-info.java`
31+
32+
### Replacing-key-value-pair for templates
33+
34+
You could adjust templates by editing `templateXXX` fields in `@MVCIntrospective`.
35+
36+
> default templates are stored in `resources` folder
2837
2938
When customizing templates, keys below will be replaced:
3039

@@ -42,26 +51,45 @@ Key | Meaning | Example
4251
`##SERVICE_IMPL_PACKAGE##` | service impl package | `firok.spring.demo.service.impl`
4352
`##CONTROLLER_PACKAGE##` | controller package | `firok.spring.demo.controller`
4453

45-
### How to customize generation names
54+
Most of **replacing-value** of **replacing-key** are generated from templates. However, we do not guarantee the order in which the **replacing-values** are generated.
4655

47-
Editing `xxxPackage` of `@MVCIntrospective` would change the package to generate; Editing `xxxName` would change the name to generate.
56+
An extra replacement would be taken when generating `XXX_PACKAGE##`, which would replace the `\.entity|bean\.` to `.mapper.`, `.service.`, `.service_impl.` or `.controller.`.
57+
58+
> For a bean class `a.b.c.entity.d.e.TestEntity`,
59+
> package for controller should be `a.b.c.controller.d.e`
60+
61+
Except default replacing-key-value-pairs, you could create custom ones by editing `extraParams` of `@MVCIntrospective`. If multiple configs contain the same **replacing-key**, the **replacing-value** closer to bean class definition would be adopted.
62+
63+
> `a.b``##TEST## = "test"`
64+
> `a.b.c``##TEST## = "test2"`,
65+
> `a.b.c.TestBean``##TEST## = "test3"`,
66+
> `a.b.c.TestBean``##TEST## = "test3"`,
67+
> `a.b.c.Test2Bean``##TEST## = "test2"`,
68+
> `a.b.DemoBean``##TEST## = "test"`
4869
4970
## Something else
5071

5172
**MVCI itself** is not based on SpringBoot and MybatisPlus. But **the default templates used by MVCI** is based on SpringBoot and MybatisPlus.
5273
By default, you should import them as dependencies, or the project will not pass the compilation.
5374

54-
A usable maven dependency is:
75+
In addition, you need to properly import dependencies such as database drivers, or your project may not work properly.
5576

56-
```xml
57-
<dependency>
58-
<groupId>com.baomidou</groupId>
59-
<artifactId>mybatis-plus-boot-starter</artifactId>
60-
<version>3.4.3.2</version>
61-
</dependency>
62-
```
77+
MVCI has only passed testing under **Java17**. It may work in lower version of Java. But you may need to edit the `@SupportedSourceVersion` value of `firok.spring.mvci.MVCIntrospectProcessor` and some code of MVCI.
6378

64-
In addition, you need to properly import dependencies such as database drivers, or your project may not work properly.
79+
## Changelog
80+
81+
### 17.1.1
82+
83+
* minor code improvements
84+
85+
### 17.1.0
86+
87+
* now we could adjust generation on package level
88+
89+
### 17.0.0
90+
91+
* increased supported JDK version to 17
6592

66-
MVCI has only passed testing under **Java16**. It may work in lower version of Java. But you may need to edit the `@SupportedSourceVersion` value of `firok.spring.mvci.MVCIntrospectProcessor` and some code of MVCI.
93+
### 1.0.0
6794

95+
* implemented base functions

readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
为 SpringBoot 生成一整套 MVC CRUD 结构.
55
(包含 mapper, service, service impl, controller)
66

7-
[Readme - English](readme-en.md) (尚未更新至17.1.x)
7+
[Readme - English](readme-en.md)
88

99
## 使用方式
1010

@@ -22,7 +22,7 @@
2222

2323
`@MVCIntrospective` 有多个字段可供配置, 各字段配置含义在 [Javadoc 中](/src/main/java/firok/spring/mvci/MVCIntrospective.java) 有详细描述.
2424

25-
大部分字段标注了 `@AvailableValues`注解, 这描述了相关字段可接受的值.
25+
大部分字段标注了 `@AvailableValues` 注解, 这描述了相关字段可接受的值.
2626
如果 `@AvailableValues` 中包含 `Constants.CUSTOM`, 则表示此字段可以提供任意自定义值 (一般是自定义模板字符串);
2727
否则只能为此字段提供预设值之一, 提供其它值会使得代码无法通过编译.
2828

@@ -38,7 +38,7 @@
3838

3939
修改 `@MVCIntrospective` 注解中的 `templateXXX` 值即可调整相关的生成模板.
4040

41-
默认的模板存放在 `resources` 目录下.
41+
> 默认的模板存放在 `resources` 目录下
4242
4343
根据模板生成内容时, 如下键会被替换:
4444

@@ -56,7 +56,7 @@
5656
`##SERVICE_IMPL_PACKAGE##` | Service Impl 位置 | `firok.spring.demo.service.impl`
5757
`##CONTROLLER_PACKAGE##` | Controller 位置 | `firok.spring.demo.controller`
5858

59-
虽然大部分 **替换键****替换值** 也是根据模板生成的, 但我们不对生成相关 **替换值** 的顺序做任何保证, 在调整这些 **替换键模板** 时请 **不要** 使用除了 `##BEAN_NAME_FULL##`, `##BEAN_NAME_SHORT##``##BEAN_PACKAGE##` 之外的 **替换键**.
59+
大部分 **替换键****替换值** 也是根据模板生成的, 但我们不对生成相关 **替换值** 的顺序做任何保证, 在调整这些 **替换键模板** 时请 **不要** 使用除了 `##BEAN_NAME_FULL##`, `##BEAN_NAME_SHORT##``##BEAN_PACKAGE##` 之外的 **替换键**.
6060

6161
生成各 `##XXX_PACKAGE##` 替换值时, 会多执行一次额外替换, 替换内容是将 `\.entity|bean\.` 替换为 `.mapper.`, `.service.`, `.service_impl.``.controller.`.
6262

@@ -67,7 +67,7 @@
6767

6868
> 假如在 `a.b` 包上指定了 `##TEST## = "test"`,
6969
> 假如在 `a.b.c` 包上指定了 `##TEST## = "test2"`,
70-
> `a.b.c.TestBean` 上指定了 `##TEST## = "test3"`,
70+
> 假如在 `a.b.c.TestBean` 上指定了 `##TEST## = "test3"`,
7171
> 生成 `a.b.c.TestBean` 实体时将使用 `##TEST## = "test3"`,
7272
> 生成 `a.b.c.Test2Bean` 实体时将使用 `##TEST## = "test2"`,
7373
> 生成 `a.b.DemoBean` 实体时将使用 `##TEST## = "test"`

0 commit comments

Comments
 (0)