";
79 | for(int i = 0; i < level; i++) {
80 | result += System.getProperties().get("line.separator") + " ";
81 | }
82 | result += responseParamModel.getKey();
83 | result += " | ";
84 |
85 | result += responseParamModel.isRequired() ? "必须" : "可选";
86 | result += " | ";
87 |
88 | if(responseParamModel.getConstraintStr() == null || responseParamModel.getConstraintStr().isEmpty()) {
89 | result += " --- ";
90 | } else {
91 | for (String constraintStr : responseParamModel.getConstraintStr()) {
92 | result += constraintStr + " ";
93 | }
94 | }
95 | result += " | ";
96 |
97 | result += responseParamModel.getComment();
98 | result += " | ";
99 |
100 | if(responseParamModel.getSubParamModel() != null && responseParamModel.getSubParamModel().size() > 0) {
101 | level++;
102 | for(ParamModel subResponseParamModel : responseParamModel.getSubParamModel()) {
103 | result += generator(subResponseParamModel, level);
104 | }
105 | }
106 |
107 | return result + "
";
108 | }
109 |
110 | }
111 |
112 | class MdSuccessReturnJsonGenerator implements TemplateMethodModelEx {
113 |
114 | @Override
115 | public Object exec(List list) throws TemplateModelException {
116 |
117 | try {
118 | if (list != null && list.size() == 1) {
119 | return list.get(0).toString();
120 | } else {
121 | return " --- ";
122 | }
123 | } catch (NullPointerException e) {
124 | return " --- ";
125 | }
126 |
127 | }
128 | }
129 |
130 | class IsMaxDouble implements TemplateMethodModelEx {
131 | @Override
132 | public Object exec(List list) throws TemplateModelException {
133 | Double d = (Double)(((SimpleNumber)list.get(0)).getAsNumber());
134 | return d == Double.MAX_VALUE;
135 | }
136 | }
137 |
--------------------------------------------------------------------------------
/src/main/java/com/jtool/codegenbuilderplugin/model/CodeGenModel.java:
--------------------------------------------------------------------------------
1 | package com.jtool.codegenbuilderplugin.model;
2 |
3 | import com.alibaba.fastjson.JSON;
4 |
5 | import java.util.List;
6 | import java.util.Optional;
7 |
8 | public class CodeGenModel implements Comparable