-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathreadme_en.md
More file actions
556 lines (412 loc) · 12 KB
/
readme_en.md
File metadata and controls
556 lines (412 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
# EasyEE Auto Manual
EasyEE Auto is an automated code generator for the [EasyEE Open Source JavaEE Enterprise Rapid Development Platform] (https://github.com/ushelp/EasyEE). Based on the entity rules configuration, can be a key to quickly generate a direct working model, controller, view code.
Least version: `1.3.3-RELEASE` (`EasyEE 4.2.X`)
## Code Generator Support
Provides code and view generation for five types of projects.
- **EasyEE-SH-SpringBoot**: `Spring Boot` + `Hibernate(JPA)`
- **EasyEE-SM-SpringBoot**: `Spring Boot` + `MyBatis`
- **EasyEE-SSH**: `Spring` + `Struts2` + `Hibernate(JPA)`
- **EasyEE-SH**: `SpringMVC` + `Hibernate(JPA)`
- **EasyEE-SM**: `SpringMVC` + `MyBatis`
## Maven
```XML
<dependency>
<groupId>cn.easyproject</groupId>
<artifactId>easyee-auto</artifactId>
<version>1.3.3-RELEASE</version>
</dependency>
```
## Steps for usage
### 1. Create a module package and write entities
**cn.easyproject.easyee.xxx.`yourmodule`.entity**
EasyEE Auto generates both the model and the controller code under the module package (`yourmodule`), at the same level as the `entity`. The automatic generation structure is as follows:
`<>`: Automatic generated
`[]`: Optional generated
```
cn.easyproject.easyee.xxx
yourmodule
entity
<controller/action>
<criteria>
<service>
[<dao>]
```
### 2. Annotation entities, specify the generation rules
Write entities, annotate entities, and configure generation rules.
- Class annotation:
```JAVA
@EasyModule
@EasyPage
@EasyAddDialog
@EasyEditDialog
@EasyCriterias/@EasyCriteria
```
- Field annotation:
```JAVA
@EasyId
@EasyField
@EasyCriteria
```
- Example
```JAVA
@EasyModule(label="Website info",mybatisTable="web_basic")
@EasyPage // PageType, default is PageType.NONE
public class Basic {
@EasyId // Object Id(Primary key), **required**
@EasyField(show = false, inputShow=false) // Field information is not displayed when querying and entering
private int id;
@EasyField(label = "Email")
private String email;
@EasyField(label = "QQ")
private String qq;
@EasyField(label = "Telphone")
private String tel;
@EasyField(label = "Company Address")
private String address;
@EasyField(label = "Weibo")
private String weibo;
@EasyField(label = "Copyright")
private String copyright;
@EasyField(label = "Description")
private String description;
// setters&getters...
}
```
### 3. Code generation
Select the project code generator for code automation. Generating complete outputs the permission list information.
- Generator
`SHSpringBootCodeGenerator.java`: **Spring Boot + Hibernate(JPA)**
`SMSpringBootCodeGenerator.java`: **Spring Boot + MyBatis**
`SHCodeGenerator.java`: **SpringMVC + Hibernate(JPA)**
`SMCodeGenerator.java`: **SpringMVC + MyBatis**
`SSHCodeGenerator.java`: **Spring + Struts2 + Hibernate(JPA)**
- Method
```JAVA
// Generate all the classes under the entity package
generator(String entityPackage)
// Choice modules to generate
generator(EasyAutoModule[] modules, String entityPackage)
// Generates the specified class
generator(Class... entity)
// Choice modules to generate
generator(EasyAutoModule[] modules, Class... entity)
```
- Example
```JAVA
public class Code {
public static void main(String[] args) {
// EasyEE Auto
// Generate all the classes under the entity package
String entityPackage="cn.easyproject.easyee.ssh.cms.entity";
new SHCodeGenerator().generator(entityPackage);
// Generates the specified class
// new SHCodeGenerator().generator(Basic.class);
System.out.println("Generator work done.");
}
}
```
- Generating Module Selection:
You can specify the modules that are generated by enumerating the arrays.
```JAVA
// Generator all modules, you can choice
new SMCodeGenerator().generator(new EasyAutoModule[]{
EasyAutoModule.CONTROLLER_CLASS, // Controller/Action 控制器类
EasyAutoModule.CRITERIA_CLASS, // Criteria
EasyAutoModule.MYBATIS_DAO_INTERFACE, // MyBatis DAO interface
EasyAutoModule.MYBATIS_MAPPER_XML, // MyBatis mapper.xml
EasyAutoModule.PAGE, // View page
EasyAutoModule.SERVICE_INTERFACE, // Service interface
EasyAutoModule.SERVICE_IMPLEMENTS // Server implements
},entityPackage);
```
### 3. Configure permissions
Code generation completes automatically by outputting `menu permissions (#)` and `operation rights (-)` which need to be configured. Use the administrator login system, on-demand configuration can be assigned permissions.
- Output Example
```
需要配置的权限列表/Need permission list
`#` Menu permissions
`-` Operation permissions
# Basic/page
- Basic/list
- Basic/get
- Basic/save
- Basic/update
- Basic/delete
- Basic/deleteCascade
# Menu/page
- Menu/list
- Menu/get
- Menu/save
- Menu/update
- Menu/delete
- Menu/deleteCascade
# Slider/page
- Slider/list
- Slider/get
- Slider/save
- Slider/update
- Slider/delete
- Slider/deleteCascade
```
### 4. Running, on-demand adjustment
Make custom adjustments as needed.
## Page generation structure

## Annotation function
### Class annotation:
#### @EasyModule
```JAVA
/**
* 显示的模块名称,默认为类名
* @return 生成的显示名
*/
String label() default "";
/**
* 模块名称 I18N 国际化键,优先级低于label()
* @return 国际化键名
*/
String labelKey() default "";
/**
* 是否显示分页,默认为true
* @return 是否
*/
boolean pagination() default true;
/**
* 是否显示保存,默认为true
* @return 是否
*/
boolean saveButton() default true;
/**
* 是否显示修改,默认为true
* @return 是否
*/
boolean updateButton() default true;
/**
* 是否显示删除,默认为true
* @return 是否
*/
boolean removeButton() default true;
/**
* 是否搜索,默认为true
* @return 是否
*/
boolean searchButton() default true;
/**
* 是否显示工具栏,默认为true
* @return 是否
*/
boolean toolbar() default true;
/**
* 是否显示右键菜单,默认为true
* @return 是否
*/
boolean contextMenu() default true;
/**
* 是否批量删除,默认为true
* @return 是否
*/
boolean mutipleDelete() default true;
/**
* MyBatis 表名,默认为类名(MyBatis 专有)
* @return 表名
*/
String mybatisTable() default "";
```
#### @EasyPage
```JAVA
/**
* 页面类型,默认为 PageType.NONE
* @return
*/
PageType value() default PageType.NONE;
```
##### PageType
```JAVA
public enum PageType {
/**
* 无需直接编辑,默认方式
* 自动添加以下类注解
* @EasyAddDialog
* @EasyEditDialog
*/
NONE,
/**
* 行编辑模式
*/
ROW_EDIT,
/**
* 列编辑模式
*/
CELL_EDIT,
/**
* 表单编辑模式,单行数据
*/
FORM_EDIT;
}
```
- `ROW_EDIT` PageType

- `CELL_EDIT` PageType

- `FORM_EDIT` PageType

#### @EasyAddDialog
The Add dialog is generated.
```JAVA
/**
* User multipart form. (enctype="multipart/form-data")
* @return
*/
boolean multipart() default false;
```

#### @EasyEditDialog
The Modify dialog is generated.
```JAVA
/**
* User multipart form. (enctype="multipart/form-data")
* @return
*/
boolean multipart() default false;
```

#### @Criterias/@Criteria
Criteria condition classes and page condition options can be generated automatically.
```JAVA
/**
* 显示的条件说明,默认为属性名
* @return 条件属性名
*/
String label() default "";
/**
* 条件说明 I18N 国际化键,优先级低于label()
* @return 国际化键名
*/
String labelKey() default "";
/**
* Criteria 条件类属性名,默认为属性名
* @return 条件属性名
*/
String filed() default "";
/**
* 查询时,使用的 SQL/HQL 条件名称
* @return 查询条件名称
*/
String queryConditionName() default "";
/**
* 查询对象的数据类型
* @return 数据类型
*/
@SuppressWarnings("rawtypes")
Class type() default Object.class;
/**
* 进行模糊查询
* @return 是否模糊查询
*/
boolean like() default false;
```
- Example
```JAVA
// 自定义条件字段
@EasyCriterias({
// label 条件显示的名称, filed Criteria 条件类属性名,queryConditionName sql/hql 查询条件名,type
// 条件属性数据类型,like 是否模糊查询
@EasyCriteria(label = "部门", filed = "deptno", queryConditionName = "dept.deptno", type = Integer.class)
})
@EasyModule(label="员工")
@EasyPage
public class Emp implements java.io.Serializable {
@EasyId // 主键字段,**必须**
@EasyCriteria(label = "员工编号") // 条件字段信息
@EasyField(show = false, inputShow=false) // 查询和输入时不显示字段信息
private Integer empno;
@EasyCriteria(label = "员工姓名", like = true) // 条件字段,模糊查询
@EasyField(label = "员工姓名", inputRequired = true)
private String ename;
@EasyCriteria(label = "职务") // 条件字段
@EasyField(label = "职务")
private String job;
@EasyField(label = "部门", field = "dept.dname", inputField = "dept.deptno", inputRequired = true)
private Dept dept;
//....
}
```
### 字段注解
#### @EasyId
The primary key field. required.
#### @Criteria
A condition field.
#### @EasyField
```JAVA
/**
* 显示的说明名称,默认为属性名
* @return 生成的显示名
*/
String label() default "";
/**
* 名称 I18N 国际化键,优先级低于label()
* @return 国际化键名
*/
String labelKey() default "";
/**
* 是否显示在列表,默认显示
* @return 是否在数据网格中显示该字段
*/
boolean show() default true;
/**
* 获取数据的字段名称,默认为属性名
* @return 生成的显示名
*/
String field() default "";
/**
* 在添加或编辑时是否显示该字段,默认显示, 仅 DIALOG 编辑模式有效
* @return 是否在数据网格中显示该字段
*/
boolean inputShow() default true;
/**
* 添加或编辑时使用的字段名称,默认为属性名, 仅 DIALOG 编辑模式有效
* @return 输入信息的字段名
*/
String inputField() default "";
/**
* 添加或编辑时,是否必填,默认为false
* @return 是否必填
*/
boolean inputRequired() default false;
/**
* 编辑模式时(Dialog, ROW, CELL, FORM),是否可编辑,默认为true
* @return 是否必填
*/
boolean updateAble() default true;
/**
* 编辑模式时,表单元素类型(easyui-textbox, easyui-filebox, easyui-numberbox...)。默认为easyui-textbox。
* @return 是否必填
*/
String inputClass() default "easyui-textbox";
/**
* MyBatis 列名,默认为属性名(MyBatis专有)
* @return 表名
*/
String mybatisColumn() default "";
```
## I18N 国际化支持
`@EasyModule`, `@EasyCriteria`, `@EasyField` can use `labelKey` instead of `label`, set i18n key.
```JAVA
@EasyField(
// label = "邮箱",
labelKey="basic.mail")
private String email;
```
## End
Email:<inthinkcolor@gmail.com>
[http://www.easyproject.cn](http://www.easyproject.cn "EasyProject Home")
**Donation/捐助:**
<a href="http://www.easyproject.cn/donation">
<img alt="
支付宝/微信/QQ/云闪付/PayPal 扫码支付" src="http://www.easyproject.cn/thanks/donation.png" title="支付宝/微信/QQ/云闪付/PayPal 扫码支付" height="320" width="320"></img></a>
<div>支付宝/微信/QQ/云闪付/PayPal</div>
<br/>
我们相信,每个人的点滴贡献,都将是推动产生更多、更好免费开源产品的一大步。
**感谢慷慨捐助,以支持服务器运行和鼓励更多社区成员。**
We believe that the contribution of each bit by bit, will be driven to produce more and better free and open source products a big step.
**Thank you donation to support the server running and encourage more community members.**