|
6 | 6 | var project = Model.Project;
|
7 | 7 | var buildTask = Model.Build;
|
8 | 8 | var table = Model.GetCurrentTable();
|
| 9 | + |
| 10 | + bool useAbstractEntity = false; |
| 11 | + String abstractEntityName = ""; |
| 12 | + String abstractEntityPackage = ""; |
| 13 | + ISet<String> abstractEntityProperties = new HashSet<string>(); |
| 14 | + if (buildTask.Parameters.TryGetValue("AbstractEntity", out var abstractEntity)) |
| 15 | + { |
| 16 | + useAbstractEntity = true; |
| 17 | + var abstractEntityParams = (Dictionary<Object, Object>) abstractEntity; |
| 18 | + if (!abstractEntityParams.TryGetValue("Name", out Object _abstractEntityName)) |
| 19 | + { |
| 20 | + throw new ArgumentException("AbstractEntity.Name can not be null."); |
| 21 | + } |
| 22 | + abstractEntityName = _abstractEntityName.ToString(); |
| 23 | + if (!abstractEntityParams.TryGetValue("Package", out var _abstractEntityPackage)) |
| 24 | + { |
| 25 | + throw new ArgumentException("AbstractEntity.Package can not be null."); |
| 26 | + } |
| 27 | + abstractEntityPackage = _abstractEntityPackage.ToString(); |
| 28 | + if (!abstractEntityParams.TryGetValue("Properties", out var _abstractEntityProperties)) |
| 29 | + { |
| 30 | + throw new ArgumentException("AbstractEntity.Properties can not be null."); |
| 31 | + } |
| 32 | + ((List<Object>) _abstractEntityProperties).ForEach(p => |
| 33 | + { |
| 34 | + abstractEntityProperties.Add(p.ToString()); |
| 35 | + }); |
| 36 | + } |
9 | 37 | }
|
10 | 38 |
|
11 | 39 | @functions {
|
@@ -37,19 +65,29 @@ import java.math.BigDecimal;
|
37 | 65 | import java.sql.Timestamp;
|
38 | 66 | import java.util.UUID;
|
39 | 67 | import java.util.Date;
|
| 68 | +@if (useAbstractEntity) |
| 69 | +{ |
| 70 | + <text>import @abstractEntityPackage;</text> |
| 71 | +} |
40 | 72 |
|
41 |
| -import lombok.Builder; |
42 | 73 | import lombok.Data;
|
43 | 74 | import lombok.ToString;
|
44 | 75 |
|
45 | 76 | @table.GetJavaSummary()
|
46 | 77 | @@Data
|
47 |
| -@@Builder |
48 | 78 | @@ToString
|
49 | 79 | public class @table.ConvertedName
|
| 80 | +@if (useAbstractEntity) |
| 81 | +{ |
| 82 | + <text>extends @abstractEntityName</text> |
| 83 | +} |
50 | 84 | {
|
51 | 85 | @foreach (var column in table.Columns)
|
52 | 86 | {
|
| 87 | + if (useAbstractEntity && abstractEntityProperties.Contains(column.ConvertedName)) |
| 88 | + { |
| 89 | + continue; |
| 90 | + } |
53 | 91 | <text>
|
54 | 92 | @column.GetJavaSummary()
|
55 | 93 | private @(ConvertLangType(column)) @column.ConvertedName;
|
|
0 commit comments