代码生成器添加外键模式

This commit is contained in:
D 2024-01-14 01:52:09 +08:00
parent 43be880712
commit c2ad991110
12 changed files with 448 additions and 222 deletions

87
doc/代码生成.drawio Normal file
View File

@ -0,0 +1,87 @@
<mxfile host="65bd71144e">
<diagram id="xy79Wy17eWdTJqY27ViR" name="第 1 页">
<mxGraphModel dx="892" dy="563" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="7" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="2" target="6">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="2" value="代码生成" style="html=1;" vertex="1" parent="1">
<mxGeometry x="205" y="20" width="110" height="50" as="geometry"/>
</mxCell>
<mxCell id="9" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="3" target="8">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="3" value="预览代码" style="html=1;" vertex="1" parent="1">
<mxGeometry x="525" y="20" width="110" height="50" as="geometry"/>
</mxCell>
<mxCell id="13" value="" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="6" target="12">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="6" value="GenTableServiceImpl.previewCode" style="html=1;" vertex="1" parent="1">
<mxGeometry x="150" y="120" width="220" height="50" as="geometry"/>
</mxCell>
<mxCell id="11" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="8" target="10">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="8" value="GenTableServiceImpl.downloadCode" style="html=1;" vertex="1" parent="1">
<mxGeometry x="460" y="100" width="240" height="50" as="geometry"/>
</mxCell>
<mxCell id="14" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="10" target="12">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="10" value="GenTableServiceImpl.generatorCode" style="html=1;" vertex="1" parent="1">
<mxGeometry x="460" y="190" width="240" height="50" as="geometry"/>
</mxCell>
<mxCell id="16" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="12" target="17">
<mxGeometry relative="1" as="geometry">
<mxPoint x="360" y="580" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="12" value="GenTableMapper.selectGenTableById&amp;nbsp; &amp;nbsp;查询表信息" style="html=1;" vertex="1" parent="1">
<mxGeometry x="230" y="330" width="310" height="50" as="geometry"/>
</mxCell>
<mxCell id="19" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="17" target="18">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="17" value="GenTableServiceImpl.setSubTable&amp;nbsp; 设置主子表信息" style="html=1;" vertex="1" parent="1">
<mxGeometry x="237.5" y="420" width="297.5" height="50" as="geometry"/>
</mxCell>
<mxCell id="21" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="18" target="20">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="18" value="GenTableServiceImpl.setPkColumn&amp;nbsp; 设置主键列信息" style="html=1;" vertex="1" parent="1">
<mxGeometry x="232.5" y="515" width="307.5" height="50" as="geometry"/>
</mxCell>
<mxCell id="23" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="20" target="22">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="20" value="VelocityInitializer.initVelocity&amp;nbsp; &amp;nbsp;初始化vm方法" style="html=1;" vertex="1" parent="1">
<mxGeometry x="242.5" y="595" width="287.5" height="50" as="geometry"/>
</mxCell>
<mxCell id="25" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="22" target="24">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="22" value="VelocityUtils.prepareContext&amp;nbsp; &lt;font color=&quot;#ff0000&quot;&gt;设置模板变量信息&lt;/font&gt;" style="html=1;" vertex="1" parent="1">
<mxGeometry x="242.5" y="685" width="287.5" height="50" as="geometry"/>
</mxCell>
<mxCell id="27" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="24" target="26">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="24" value="VelocityUtils.getTemplateList&amp;nbsp; &lt;font color=&quot;#ff0000&quot;&gt;获取模板列表&lt;/font&gt;" style="html=1;" vertex="1" parent="1">
<mxGeometry x="242.5" y="770" width="287.5" height="50" as="geometry"/>
</mxCell>
<mxCell id="30" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="26" target="29">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="26" value="Velocity.getTemplate 渲染模板" style="html=1;" vertex="1" parent="1">
<mxGeometry x="242.5" y="860" width="287.5" height="50" as="geometry"/>
</mxCell>
<mxCell id="29" value="预览代码 -&amp;gt; 结果储存到dataMap中&lt;br&gt;自定义路径 -&amp;gt; 通过FileUtils写入到指定位置&lt;br&gt;下载代码 -&amp;gt; 将生抽的信息添加到zip然后下载" style="html=1;" vertex="1" parent="1">
<mxGeometry x="242.5" y="950" width="287.5" height="50" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

View File

@ -1,137 +1,137 @@
<mxfile host="65bd71144e"> <mxfile host="65bd71144e">
<diagram id="IyeDk-cAWrKOq7F3gyWb" name="第 1 页"> <diagram id="IyeDk-cAWrKOq7F3gyWb" name="第 1 页">
<mxGraphModel dx="985" dy="704" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" background="#000000" math="0" shadow="0"> <mxGraphModel dx="652" dy="563" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" background="#000000" math="0" shadow="0">
<root> <root>
<mxCell id="0"/> <mxCell id="0"/>
<mxCell id="1" parent="0"/> <mxCell id="1" parent="0"/>
<mxCell id="7" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="5" target="6"> <mxCell id="7" value="" style="edgeStyle=none;html=1;" parent="1" source="5" target="6" edge="1">
<mxGeometry relative="1" as="geometry"/> <mxGeometry relative="1" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="5" value="访问/login" style="html=1;" vertex="1" parent="1"> <mxCell id="5" value="访问/login" style="html=1;" parent="1" vertex="1">
<mxGeometry x="304" y="60" width="110" height="50" as="geometry"/> <mxGeometry x="304" y="60" width="110" height="50" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="9" value="" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="6" target="20"> <mxCell id="9" value="" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="6" target="20" edge="1">
<mxGeometry relative="1" as="geometry"> <mxGeometry relative="1" as="geometry">
<mxPoint x="359.0000000000001" y="240" as="targetPoint"/> <mxPoint x="359.0000000000001" y="240" as="targetPoint"/>
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="6" value="被SysLoginController.login()捕获" style="html=1;" vertex="1" parent="1"> <mxCell id="6" value="被SysLoginController.login()捕获" style="html=1;" parent="1" vertex="1">
<mxGeometry x="265.5" y="130" width="187" height="40" as="geometry"/> <mxGeometry x="265.5" y="130" width="187" height="40" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="20" value="&lt;span style=&quot;font-weight: 400;&quot;&gt;调用方法SysLoginService.login()执行登录逻辑&lt;/span&gt;" style="swimlane;whiteSpace=wrap;html=1;" vertex="1" parent="1"> <mxCell id="20" value="&lt;span style=&quot;font-weight: 400;&quot;&gt;调用方法SysLoginService.login()执行登录逻辑&lt;/span&gt;" style="swimlane;whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="110" y="195" width="500" height="1075" as="geometry"> <mxGeometry x="110" y="195" width="500" height="1075" as="geometry">
<mxRectangle x="109" y="195" width="290" height="30" as="alternateBounds"/> <mxRectangle x="109" y="195" width="290" height="30" as="alternateBounds"/>
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="22" value="" style="edgeStyle=none;html=1;" edge="1" parent="20" source="10" target="21"> <mxCell id="22" value="" style="edgeStyle=none;html=1;" parent="20" source="10" target="21" edge="1">
<mxGeometry relative="1" as="geometry"/> <mxGeometry relative="1" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="10" value="调用方法SysLoginService.validateCaptcha()&lt;br&gt;1. &lt;font color=&quot;#00ffff&quot;&gt;从redis里拿到验证码对应的验证信息&lt;/font&gt;&lt;br&gt;2. &lt;font color=&quot;#00ffff&quot;&gt;删除redis中验证码对应的验证信息&lt;/font&gt;&lt;br&gt;3. 如果验证信息为空,&lt;font color=&quot;#ff0000&quot;&gt;抛出验证码过期的异常&lt;/font&gt;&lt;br&gt;4. 如果code与验证信息的值不同&lt;font color=&quot;#ff0000&quot;&gt;抛出验证码错误的异常&lt;/font&gt;" style="html=1;" vertex="1" parent="20"> <mxCell id="10" value="调用方法SysLoginService.validateCaptcha()&lt;br&gt;1. &lt;font color=&quot;#00ffff&quot;&gt;从redis里拿到验证码对应的验证信息&lt;/font&gt;&lt;br&gt;2. &lt;font color=&quot;#00ffff&quot;&gt;删除redis中验证码对应的验证信息&lt;/font&gt;&lt;br&gt;3. 如果验证信息为空,&lt;font color=&quot;#ff0000&quot;&gt;抛出验证码过期的异常&lt;/font&gt;&lt;br&gt;4. 如果code与验证信息的值不同&lt;font color=&quot;#ff0000&quot;&gt;抛出验证码错误的异常&lt;/font&gt;" style="html=1;" parent="20" vertex="1">
<mxGeometry x="104.85" y="45" width="312.25" height="100" as="geometry"/> <mxGeometry x="104.85" y="45" width="312.25" height="100" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="24" value="" style="edgeStyle=none;html=1;" edge="1" parent="20" source="21" target="23"> <mxCell id="24" value="" style="edgeStyle=none;html=1;" parent="20" source="21" target="23" edge="1">
<mxGeometry relative="1" as="geometry"/> <mxGeometry relative="1" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="21" value="调用方法SysLoginService.loginPreCheck()&lt;br&gt;1. &lt;font color=&quot;#ff0000&quot;&gt;用户名或密码为空 -&amp;gt; 错误 抛出异常&lt;/font&gt;&lt;br&gt;2. &lt;font color=&quot;#ff0000&quot;&gt;密码不在指定范围内 -&amp;gt; 错误 抛出异常&lt;/font&gt;&lt;br&gt;3. &lt;font color=&quot;#ff0000&quot;&gt;用户名不在指定范围内 -&amp;gt; 错误 抛出异常&lt;/font&gt;&lt;br&gt;4. &lt;font color=&quot;#ff0000&quot;&gt;IP黑名单校验 -&amp;gt; 错误 抛出异常&lt;/font&gt;" style="html=1;" vertex="1" parent="20"> <mxCell id="21" value="调用方法SysLoginService.loginPreCheck()&lt;br&gt;1. &lt;font color=&quot;#ff0000&quot;&gt;用户名或密码为空 -&amp;gt; 错误 抛出异常&lt;/font&gt;&lt;br&gt;2. &lt;font color=&quot;#ff0000&quot;&gt;密码不在指定范围内 -&amp;gt; 错误 抛出异常&lt;/font&gt;&lt;br&gt;3. &lt;font color=&quot;#ff0000&quot;&gt;用户名不在指定范围内 -&amp;gt; 错误 抛出异常&lt;/font&gt;&lt;br&gt;4. &lt;font color=&quot;#ff0000&quot;&gt;IP黑名单校验 -&amp;gt; 错误 抛出异常&lt;/font&gt;" style="html=1;" parent="20" vertex="1">
<mxGeometry x="104.85" y="170" width="312.25" height="100" as="geometry"/> <mxGeometry x="104.85" y="170" width="312.25" height="100" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="26" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="20" source="23" target="25"> <mxCell id="26" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="20" source="23" target="25" edge="1">
<mxGeometry relative="1" as="geometry"/> <mxGeometry relative="1" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="23" value="&lt;font color=&quot;#00ff00&quot;&gt;通过new UsernamePasswordAuthenticationToken生成一个认证信息&lt;br&gt;通过AuthenticationContextHolder.setContext将认证信息设置到上下文&lt;/font&gt;&lt;br&gt;通过AuthenticationManager.authenticate()对认证信息进行认证,这个方法&lt;br&gt;会去调用UserDetailsServiceImpl.loadUserByUsername()方法进行认证" style="html=1;" vertex="1" parent="20"> <mxCell id="23" value="&lt;font color=&quot;#00ff00&quot;&gt;通过new UsernamePasswordAuthenticationToken生成一个认证信息&lt;br&gt;通过AuthenticationContextHolder.setContext将认证信息设置到上下文&lt;/font&gt;&lt;br&gt;通过AuthenticationManager.authenticate()对认证信息进行认证,这个方法&lt;br&gt;会去调用UserDetailsServiceImpl.loadUserByUsername()方法进行认证" style="html=1;" parent="20" vertex="1">
<mxGeometry x="57.91" y="300" width="406.13" height="70" as="geometry"/> <mxGeometry x="57.91" y="300" width="406.13" height="70" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="39" value="" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="20" source="25" target="40"> <mxCell id="39" value="" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" parent="20" source="25" target="40" edge="1">
<mxGeometry relative="1" as="geometry"> <mxGeometry relative="1" as="geometry">
<mxPoint x="261" y="785" as="sourcePoint"/> <mxPoint x="261" y="785" as="sourcePoint"/>
<mxPoint x="245.01" y="805" as="targetPoint"/> <mxPoint x="245.01" y="805" as="targetPoint"/>
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="25" value="&lt;span style=&quot;font-weight: 400;&quot;&gt;loadUserByUsername&lt;/span&gt;" style="swimlane;whiteSpace=wrap;html=1;" vertex="1" parent="20"> <mxCell id="25" value="&lt;span style=&quot;font-weight: 400;&quot;&gt;loadUserByUsername&lt;/span&gt;" style="swimlane;whiteSpace=wrap;html=1;" parent="20" vertex="1">
<mxGeometry x="41.94" y="385" width="438.06" height="390" as="geometry"> <mxGeometry x="41.94" y="385" width="438.06" height="390" as="geometry">
<mxRectangle x="25.97999999999999" y="380" width="160" height="30" as="alternateBounds"/> <mxRectangle x="25.97999999999999" y="380" width="160" height="30" as="alternateBounds"/>
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="29" value="" style="edgeStyle=none;html=1;" edge="1" parent="25" source="27" target="28"> <mxCell id="29" value="" style="edgeStyle=none;html=1;" parent="25" source="27" target="28" edge="1">
<mxGeometry relative="1" as="geometry"/> <mxGeometry relative="1" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="27" value="调用ISysUserService.selectUserByUserName()获取用户信息&lt;br&gt;校验是否为空 -&amp;gt; &lt;font color=&quot;#ff0000&quot;&gt;抛出用户不存在的异常&lt;/font&gt;&lt;br&gt;校验是否已被删除 -&amp;gt; &lt;font color=&quot;#ff0000&quot;&gt;抛出用户已被删除的异常&lt;/font&gt;&lt;br&gt;校验是否已被停用 -&amp;gt; &lt;font color=&quot;#ff0000&quot;&gt;抛出用户已被停用的异常&lt;/font&gt;" style="whiteSpace=wrap;html=1;" vertex="1" parent="25"> <mxCell id="27" value="调用ISysUserService.selectUserByUserName()获取用户信息&lt;br&gt;校验是否为空 -&amp;gt; &lt;font color=&quot;#ff0000&quot;&gt;抛出用户不存在的异常&lt;/font&gt;&lt;br&gt;校验是否已被删除 -&amp;gt; &lt;font color=&quot;#ff0000&quot;&gt;抛出用户已被删除的异常&lt;/font&gt;&lt;br&gt;校验是否已被停用 -&amp;gt; &lt;font color=&quot;#ff0000&quot;&gt;抛出用户已被停用的异常&lt;/font&gt;" style="whiteSpace=wrap;html=1;" parent="25" vertex="1">
<mxGeometry x="30.04" y="30" width="379.96" height="60" as="geometry"/> <mxGeometry x="30.04" y="30" width="379.96" height="60" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="28" value="调用SysPasswordService.validate()进行认证&lt;br&gt;1. 获取上下文的认证信息,并获取认证信息中携带的用户名和密码&lt;br&gt;2. &lt;font color=&quot;#00ffff&quot;&gt;从redis中获取该用户名密码错误次数&lt;/font&gt;&lt;br&gt;3. 校验该用户名密码错误次数是否过多&lt;br&gt;若次数过多,则&lt;font color=&quot;#ff0000&quot;&gt;抛出密码错误次数过多的异常&lt;/font&gt;&lt;br&gt;4. 调用SecurityUtils.matchesPassword方法校验用户名密码是否匹配&lt;br&gt;5. 若不匹配,则密码错误次数加一,且&lt;font color=&quot;#ff0000&quot;&gt;抛出密码错误的异常&lt;/font&gt;&lt;br&gt;否则清楚密码错误次数,校验结束即校验通过" style="whiteSpace=wrap;html=1;" vertex="1" parent="25"> <mxCell id="28" value="调用SysPasswordService.validate()进行认证&lt;br&gt;1. 获取上下文的认证信息,并获取认证信息中携带的用户名和密码&lt;br&gt;2. &lt;font color=&quot;#00ffff&quot;&gt;从redis中获取该用户名密码错误次数&lt;/font&gt;&lt;br&gt;3. 校验该用户名密码错误次数是否过多&lt;br&gt;若次数过多,则&lt;font color=&quot;#ff0000&quot;&gt;抛出密码错误次数过多的异常&lt;/font&gt;&lt;br&gt;4. 调用SecurityUtils.matchesPassword方法校验用户名密码是否匹配&lt;br&gt;5. 若不匹配,则密码错误次数加一,且&lt;font color=&quot;#ff0000&quot;&gt;抛出密码错误的异常&lt;/font&gt;&lt;br&gt;否则清楚密码错误次数,校验结束即校验通过" style="whiteSpace=wrap;html=1;" parent="25" vertex="1">
<mxGeometry x="29.05" y="120" width="379.96" height="120" as="geometry"/> <mxGeometry x="29.05" y="120" width="379.96" height="120" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="36" value="调用createLoginUser方法new&amp;nbsp;LoginUser()创建一个UserDetails凭证&lt;br&gt;调用SysPermissionService.getMenuPermission()方法获取用户角色权限" style="html=1;" vertex="1" parent="25"> <mxCell id="36" value="调用createLoginUser方法new&amp;nbsp;LoginUser()创建一个UserDetails凭证&lt;br&gt;调用SysPermissionService.getMenuPermission()方法获取用户角色权限" style="html=1;" parent="25" vertex="1">
<mxGeometry x="15.960000000000008" y="275" width="406.13" height="70" as="geometry"/> <mxGeometry x="15.960000000000008" y="275" width="406.13" height="70" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="37" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="25" source="28" target="36"> <mxCell id="37" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="25" source="28" target="36" edge="1">
<mxGeometry relative="1" as="geometry"/> <mxGeometry relative="1" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="44" value="" style="edgeStyle=none;html=1;" edge="1" parent="20" source="40" target="43"> <mxCell id="44" value="" style="edgeStyle=none;html=1;" parent="20" source="40" target="43" edge="1">
<mxGeometry relative="1" as="geometry"/> <mxGeometry relative="1" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="40" value="1. &lt;font color=&quot;#ff0000&quot;&gt;若上述环节抛出异常则处理异常并抛出对应的新的异常,校验环节结束&lt;/font&gt;&lt;br&gt;2. 无论校验结果如何,清除上下文" style="html=1;" vertex="1" parent="20"> <mxCell id="40" value="1. &lt;font color=&quot;#ff0000&quot;&gt;若上述环节抛出异常则处理异常并抛出对应的新的异常,校验环节结束&lt;/font&gt;&lt;br&gt;2. 无论校验结果如何,清除上下文" style="html=1;" parent="20" vertex="1">
<mxGeometry x="57.91" y="805" width="406.13" height="70" as="geometry"/> <mxGeometry x="57.91" y="805" width="406.13" height="70" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="43" value="1. 调用createToken()记录并更新用户信息&lt;br&gt;2. 调用TokenService.createToken()生成token&lt;br&gt;设置用户代理信息LoginUser将&lt;font color=&quot;#00ffff&quot;&gt;LoginUser存入redis&lt;/font&gt;" style="html=1;" vertex="1" parent="20"> <mxCell id="43" value="1. 调用createToken()记录并更新用户信息&lt;br&gt;2. 调用TokenService.createToken()生成token&lt;br&gt;设置用户代理信息LoginUser将&lt;font color=&quot;#00ffff&quot;&gt;LoginUser存入redis&lt;/font&gt;" style="html=1;" parent="20" vertex="1">
<mxGeometry x="57.91" y="925" width="406.13" height="70" as="geometry"/> <mxGeometry x="57.91" y="925" width="406.13" height="70" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="45" style="edgeStyle=none;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="40" target="46"> <mxCell id="45" style="edgeStyle=none;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" parent="1" source="40" target="46" edge="1">
<mxGeometry relative="1" as="geometry"> <mxGeometry relative="1" as="geometry">
<mxPoint x="660" y="1055" as="targetPoint"/> <mxPoint x="660" y="1055" as="targetPoint"/>
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="46" value="认证失败" style="html=1;fontColor=#FF0000;labelBorderColor=none;strokeColor=#FF0000;" vertex="1" parent="1"> <mxCell id="46" value="认证失败" style="html=1;fontColor=#FF0000;labelBorderColor=none;strokeColor=#FF0000;" parent="1" vertex="1">
<mxGeometry x="660" y="1010" width="100" height="50" as="geometry"/> <mxGeometry x="660" y="1010" width="100" height="50" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="47" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="43" target="48"> <mxCell id="47" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" parent="1" source="43" target="48" edge="1">
<mxGeometry relative="1" as="geometry"> <mxGeometry relative="1" as="geometry">
<mxPoint x="333.06500000000005" y="1330.0000000000002" as="targetPoint"/> <mxPoint x="333.06500000000005" y="1330.0000000000002" as="targetPoint"/>
</mxGeometry> </mxGeometry>
</mxCell> </mxCell>
<mxCell id="65" value="" style="edgeStyle=none;html=1;fontColor=#00FFFF;" edge="1" parent="1" source="48" target="64"> <mxCell id="65" value="" style="edgeStyle=none;html=1;fontColor=#00FFFF;" parent="1" source="48" target="64" edge="1">
<mxGeometry relative="1" as="geometry"/> <mxGeometry relative="1" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="48" value="认证成功&lt;br&gt;将Token返回给前端" style="html=1;" vertex="1" parent="1"> <mxCell id="48" value="认证成功&lt;br&gt;将Token返回给前端" style="html=1;" parent="1" vertex="1">
<mxGeometry x="302.51" y="1300" width="136.93" height="80" as="geometry"/> <mxGeometry x="302.51" y="1300" width="136.93" height="80" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="51" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="49" target="50"> <mxCell id="51" value="" style="edgeStyle=none;html=1;" parent="1" source="49" target="50" edge="1">
<mxGeometry relative="1" as="geometry"/> <mxGeometry relative="1" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="49" value="Token认证" style="whiteSpace=wrap;html=1;" vertex="1" parent="1"> <mxCell id="49" value="Token认证" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="310.98" y="1570" width="120" height="60" as="geometry"/> <mxGeometry x="310.98" y="1570" width="120" height="60" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="53" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="50" target="52"> <mxCell id="53" value="" style="edgeStyle=none;html=1;" parent="1" source="50" target="52" edge="1">
<mxGeometry relative="1" as="geometry"/> <mxGeometry relative="1" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="50" value="触发JwtAuthenticationTokenFilter拦截器&lt;br&gt;调用doFilterInternal方法进行处理" style="whiteSpace=wrap;html=1;" vertex="1" parent="1"> <mxCell id="50" value="触发JwtAuthenticationTokenFilter拦截器&lt;br&gt;调用doFilterInternal方法进行处理" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="235.98" y="1690" width="270" height="60" as="geometry"/> <mxGeometry x="235.98" y="1680" width="270" height="60" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="55" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="52" target="54"> <mxCell id="55" value="" style="edgeStyle=none;html=1;" parent="1" source="52" target="54" edge="1">
<mxGeometry relative="1" as="geometry"/> <mxGeometry relative="1" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="52" value="调用TokenService.getLoginUser()方法&lt;br&gt;1. 调用方法getToken从request的请求头中获取token&lt;br&gt;&lt;font color=&quot;#00ffff&quot;&gt;2. 通过token在redis中获取用户代理信息LoginUser&lt;/font&gt;" style="whiteSpace=wrap;html=1;" vertex="1" parent="1"> <mxCell id="52" value="调用TokenService.getLoginUser()方法&lt;br&gt;1. 调用方法getToken从request的请求头中获取token&lt;br&gt;&lt;font color=&quot;#00ffff&quot;&gt;2. 通过token在redis中获取用户代理信息LoginUser&lt;/font&gt;" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="185.98" y="1780" width="370" height="60" as="geometry"/> <mxGeometry x="185.98" y="1780" width="370" height="60" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="57" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="54" target="56"> <mxCell id="57" value="" style="edgeStyle=none;html=1;" parent="1" source="54" target="56" edge="1">
<mxGeometry relative="1" as="geometry"/> <mxGeometry relative="1" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="54" value="判断用户凭证是非空并且判断上下文认证信息为空&lt;br&gt;调用TokenService.verifyToken()校验token并判断最小时间刷新token" style="whiteSpace=wrap;html=1;" vertex="1" parent="1"> <mxCell id="54" value="判断用户凭证是非空并且判断上下文认证信息为空&lt;br&gt;调用TokenService.verifyToken()校验token并判断最小时间刷新token" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="175.98" y="1860" width="390" height="60" as="geometry"/> <mxGeometry x="175.98" y="1860" width="390" height="60" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="59" value="" style="edgeStyle=none;html=1;" edge="1" parent="1" source="56" target="58"> <mxCell id="59" value="" style="edgeStyle=none;html=1;" parent="1" source="56" target="58" edge="1">
<mxGeometry relative="1" as="geometry"/> <mxGeometry relative="1" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="56" value="&lt;font color=&quot;#00ff00&quot;&gt;1. 通过UsernamePasswordAuthenticationToken创建一个认证信息&lt;br&gt;2. 通过WebAuthenticationDetailsSource构建一个用户凭证并通过UsernamePasswordAuthenticationToken.setDetails设置到认证信息里&lt;br&gt;3. 将认证信息通过SecurityContextHolder.getContext().setAuthentication&lt;br&gt;拿到上下文并设置到上下文&lt;/font&gt;" style="whiteSpace=wrap;html=1;strokeColor=#00FF00;" vertex="1" parent="1"> <mxCell id="56" value="&lt;font color=&quot;#00ff00&quot;&gt;1. 通过UsernamePasswordAuthenticationToken创建一个认证信息&lt;br&gt;2. 通过WebAuthenticationDetailsSource构建一个用户凭证并通过UsernamePasswordAuthenticationToken.setDetails设置到认证信息里&lt;br&gt;3. 将认证信息通过SecurityContextHolder.getContext().setAuthentication&lt;br&gt;拿到上下文并设置到上下文&lt;/font&gt;" style="whiteSpace=wrap;html=1;strokeColor=#00FF00;" parent="1" vertex="1">
<mxGeometry x="161.45999999999998" y="1950" width="419.02" height="80" as="geometry"/> <mxGeometry x="161.45999999999998" y="1950" width="419.02" height="80" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="58" value="继续过滤&lt;br&gt;在鉴权系统中会用到上述设置的上下文" style="whiteSpace=wrap;html=1;" vertex="1" parent="1"> <mxCell id="58" value="继续过滤&lt;br&gt;在鉴权系统中会用到上述设置的上下文" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="300.98" y="2060" width="140" height="60" as="geometry"/> <mxGeometry x="300.98" y="2060" width="140" height="60" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="66" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontColor=#00FFFF;" edge="1" parent="1" source="64" target="49"> <mxCell id="66" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;fontColor=#00FFFF;" parent="1" source="64" target="49" edge="1">
<mxGeometry relative="1" as="geometry"/> <mxGeometry relative="1" as="geometry"/>
</mxCell> </mxCell>
<mxCell id="64" value="前端拿到token后存到浏览器中&lt;br&gt;后续发送请求在浏览器中拿到token&lt;br&gt;并将token设置到请求头里" style="whiteSpace=wrap;html=1;" vertex="1" parent="1"> <mxCell id="64" value="前端拿到token后存到浏览器中&lt;br&gt;后续发送请求在浏览器中拿到token&lt;br&gt;并将token设置到请求头里" style="whiteSpace=wrap;html=1;" parent="1" vertex="1">
<mxGeometry x="251.46" y="1430" width="239.02" height="90" as="geometry"/> <mxGeometry x="251.46" y="1430" width="239.02" height="90" as="geometry"/>
</mxCell> </mxCell>
</root> </root>

View File

@ -1,12 +1,15 @@
package com.ruoyi.generator.domain; package com.ruoyi.generator.domain;
import java.util.List; import java.util.List;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import com.ruoyi.generator.constant.GenConstants;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.generator.constant.GenConstants;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
/** /**
* 业务表 gen_table * 业务表 gen_table
@ -97,6 +100,18 @@ public class GenTable extends BaseEntity {
/** 上级菜单名称字段 */ /** 上级菜单名称字段 */
private String parentMenuName; private String parentMenuName;
/** 是否含有关联字段 */
private String haveSubColumn;
public String getHaveSubColumn() {
return haveSubColumn;
}
public void setHaveSubColumn(String haveSubColumn) {
this.haveSubColumn = haveSubColumn;
}
public Long getTableId() { public Long getTableId() {
return tableId; return tableId;
} }

View File

@ -1,9 +1,10 @@
package com.ruoyi.generator.domain; package com.ruoyi.generator.domain;
import jakarta.validation.constraints.NotBlank;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import jakarta.validation.constraints.NotBlank;
/** /**
* 代码生成业务字段表 gen_table_column * 代码生成业务字段表 gen_table_column
* *
@ -68,6 +69,62 @@ public class GenTableColumn extends BaseEntity
/** 排序 */ /** 排序 */
private Integer sort; private Integer sort;
/** 关联表名称 */
private String subColumnTableName;
/** 关联字段名称 */
private String subColumnFkName;
/** 映射字段名称 */
private String subColumnName;
/** 映射字段Java字段名 */
private String subColumnJavaField;
/** 映射字段Java类型 */
private String subColumnJavaType;
public String getSubColumnJavaField() {
return subColumnJavaField;
}
public void setSubColumnJavaField(String subColumnJavaField) {
this.subColumnJavaField = subColumnJavaField;
}
public String getSubColumnJavaType() {
return subColumnJavaType;
}
public void setSubColumnJavaType(String subColumnJavaType) {
this.subColumnJavaType = subColumnJavaType;
}
public String getSubColumnTableName() {
return subColumnTableName;
}
public void setSubColumnTableName(String subColumnTableName) {
this.subColumnTableName = subColumnTableName;
}
public String getSubColumnFkName() {
return subColumnFkName;
}
public void setSubColumnFkName(String subColumnFkName) {
this.subColumnFkName = subColumnFkName;
}
public String getSubColumnName() {
return subColumnName;
}
public void setSubColumnName(String subColumnName) {
this.subColumnName = subColumnName;
}
public void setColumnId(Long columnId) public void setColumnId(Long columnId)
{ {
this.columnId = columnId; this.columnId = columnId;

View File

@ -11,6 +11,7 @@ import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.velocity.Template; import org.apache.velocity.Template;
@ -21,14 +22,15 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.Constants;
import com.ruoyi.generator.constant.GenConstants;
import com.ruoyi.common.core.text.CharsetKit; import com.ruoyi.common.core.text.CharsetKit;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.generator.constant.GenConstants;
import com.ruoyi.generator.domain.GenTable; import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn; import com.ruoyi.generator.domain.GenTableColumn;
import com.ruoyi.generator.mapper.GenTableColumnMapper; import com.ruoyi.generator.mapper.GenTableColumnMapper;
@ -43,8 +45,7 @@ import com.ruoyi.generator.util.VelocityUtils;
* @author ruoyi * @author ruoyi
*/ */
@Service @Service
public class GenTableServiceImpl implements IGenTableService public class GenTableServiceImpl implements IGenTableService {
{
private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class); private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
@Autowired @Autowired
@ -60,8 +61,7 @@ public class GenTableServiceImpl implements IGenTableService
* @return 业务信息 * @return 业务信息
*/ */
@Override @Override
public GenTable selectGenTableById(Long id) public GenTable selectGenTableById(Long id) {
{
GenTable genTable = genTableMapper.selectGenTableById(id); GenTable genTable = genTableMapper.selectGenTableById(id);
setTableFromOptions(genTable); setTableFromOptions(genTable);
return genTable; return genTable;
@ -74,8 +74,7 @@ public class GenTableServiceImpl implements IGenTableService
* @return 业务集合 * @return 业务集合
*/ */
@Override @Override
public List<GenTable> selectGenTableList(GenTable genTable) public List<GenTable> selectGenTableList(GenTable genTable) {
{
return genTableMapper.selectGenTableList(genTable); return genTableMapper.selectGenTableList(genTable);
} }
@ -86,8 +85,7 @@ public class GenTableServiceImpl implements IGenTableService
* @return 数据库表集合 * @return 数据库表集合
*/ */
@Override @Override
public List<GenTable> selectDbTableList(GenTable genTable) public List<GenTable> selectDbTableList(GenTable genTable) {
{
return genTableMapper.selectDbTableList(genTable); return genTableMapper.selectDbTableList(genTable);
} }
@ -98,8 +96,7 @@ public class GenTableServiceImpl implements IGenTableService
* @return 数据库表集合 * @return 数据库表集合
*/ */
@Override @Override
public List<GenTable> selectDbTableListByNames(String[] tableNames) public List<GenTable> selectDbTableListByNames(String[] tableNames) {
{
return genTableMapper.selectDbTableListByNames(tableNames); return genTableMapper.selectDbTableListByNames(tableNames);
} }
@ -109,8 +106,7 @@ public class GenTableServiceImpl implements IGenTableService
* @return 表信息集合 * @return 表信息集合
*/ */
@Override @Override
public List<GenTable> selectGenTableAll() public List<GenTable> selectGenTableAll() {
{
return genTableMapper.selectGenTableAll(); return genTableMapper.selectGenTableAll();
} }
@ -122,15 +118,12 @@ public class GenTableServiceImpl implements IGenTableService
*/ */
@Override @Override
@Transactional @Transactional
public void updateGenTable(GenTable genTable) public void updateGenTable(GenTable genTable) {
{
String options = JSON.toJSONString(genTable.getParams()); String options = JSON.toJSONString(genTable.getParams());
genTable.setOptions(options); genTable.setOptions(options);
int row = genTableMapper.updateGenTable(genTable); int row = genTableMapper.updateGenTable(genTable);
if (row > 0) if (row > 0) {
{ for (GenTableColumn cenTableColumn : genTable.getColumns()) {
for (GenTableColumn cenTableColumn : genTable.getColumns())
{
genTableColumnMapper.updateGenTableColumn(cenTableColumn); genTableColumnMapper.updateGenTableColumn(cenTableColumn);
} }
} }
@ -144,8 +137,7 @@ public class GenTableServiceImpl implements IGenTableService
*/ */
@Override @Override
@Transactional @Transactional
public void deleteGenTableByIds(Long[] tableIds) public void deleteGenTableByIds(Long[] tableIds) {
{
genTableMapper.deleteGenTableByIds(tableIds); genTableMapper.deleteGenTableByIds(tableIds);
genTableColumnMapper.deleteGenTableColumnByIds(tableIds); genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
} }
@ -157,30 +149,23 @@ public class GenTableServiceImpl implements IGenTableService
*/ */
@Override @Override
@Transactional @Transactional
public void importGenTable(List<GenTable> tableList) public void importGenTable(List<GenTable> tableList) {
{
String operName = SecurityUtils.getUsername(); String operName = SecurityUtils.getUsername();
try try {
{ for (GenTable table : tableList) {
for (GenTable table : tableList)
{
String tableName = table.getTableName(); String tableName = table.getTableName();
GenUtils.initTable(table, operName); GenUtils.initTable(table, operName);
int row = genTableMapper.insertGenTable(table); int row = genTableMapper.insertGenTable(table);
if (row > 0) if (row > 0) {
{
// 保存列信息 // 保存列信息
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
for (GenTableColumn column : genTableColumns) for (GenTableColumn column : genTableColumns) {
{
GenUtils.initColumnField(column, table); GenUtils.initColumnField(column, table);
genTableColumnMapper.insertGenTableColumn(column); genTableColumnMapper.insertGenTableColumn(column);
} }
} }
} }
} } catch (Exception e) {
catch (Exception e)
{
throw new ServiceException("导入失败:" + e.getMessage()); throw new ServiceException("导入失败:" + e.getMessage());
} }
} }
@ -192,8 +177,7 @@ public class GenTableServiceImpl implements IGenTableService
* @return 预览数据列表 * @return 预览数据列表
*/ */
@Override @Override
public Map<String, String> previewCode(Long tableId) public Map<String, String> previewCode(Long tableId) {
{
Map<String, String> dataMap = new LinkedHashMap<>(); Map<String, String> dataMap = new LinkedHashMap<>();
// 查询表信息 // 查询表信息
GenTable table = genTableMapper.selectGenTableById(tableId); GenTable table = genTableMapper.selectGenTableById(tableId);
@ -207,8 +191,7 @@ public class GenTableServiceImpl implements IGenTableService
// 获取模板列表 // 获取模板列表
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType()); List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType());
for (String template : templates) for (String template : templates) {
{
// 渲染模板 // 渲染模板
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
Template tpl = Velocity.getTemplate(template, Constants.UTF8); Template tpl = Velocity.getTemplate(template, Constants.UTF8);
@ -225,8 +208,7 @@ public class GenTableServiceImpl implements IGenTableService
* @return 数据 * @return 数据
*/ */
@Override @Override
public byte[] downloadCode(String tableName) public byte[] downloadCode(String tableName) {
{
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream); ZipOutputStream zip = new ZipOutputStream(outputStream);
generatorCode(tableName, zip); generatorCode(tableName, zip);
@ -240,8 +222,7 @@ public class GenTableServiceImpl implements IGenTableService
* @param tableName 表名称 * @param tableName 表名称
*/ */
@Override @Override
public void generatorCode(String tableName) public void generatorCode(String tableName) {
{
// 查询表信息 // 查询表信息
GenTable table = genTableMapper.selectGenTableByName(tableName); GenTable table = genTableMapper.selectGenTableByName(tableName);
// 设置主子表信息 // 设置主子表信息
@ -255,26 +236,19 @@ public class GenTableServiceImpl implements IGenTableService
// 获取模板列表 // 获取模板列表
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType()); List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType());
for (String template : templates) for (String template : templates) {
{
if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm"))
{
// 渲染模板 // 渲染模板
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
Template tpl = Velocity.getTemplate(template, Constants.UTF8); Template tpl = Velocity.getTemplate(template, Constants.UTF8);
tpl.merge(context, sw); tpl.merge(context, sw);
try try {
{
String path = getGenPath(table, template); String path = getGenPath(table, template);
FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8); FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8);
} } catch (IOException e) {
catch (IOException e)
{
throw new ServiceException("渲染模板失败,表名:" + table.getTableName()); throw new ServiceException("渲染模板失败,表名:" + table.getTableName());
} }
} }
} }
}
/** /**
* 同步数据库 * 同步数据库
@ -283,50 +257,45 @@ public class GenTableServiceImpl implements IGenTableService
*/ */
@Override @Override
@Transactional @Transactional
public void synchDb(String tableName) public void synchDb(String tableName) {
{
GenTable table = genTableMapper.selectGenTableByName(tableName); GenTable table = genTableMapper.selectGenTableByName(tableName);
List<GenTableColumn> tableColumns = table.getColumns(); List<GenTableColumn> tableColumns = table.getColumns();
Map<String, GenTableColumn> tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity())); Map<String, GenTableColumn> tableColumnMap = tableColumns.stream()
.collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity()));
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
if (StringUtils.isEmpty(dbTableColumns)) if (StringUtils.isEmpty(dbTableColumns)) {
{
throw new ServiceException("同步数据失败,原表结构不存在"); throw new ServiceException("同步数据失败,原表结构不存在");
} }
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName)
.collect(Collectors.toList());
dbTableColumns.forEach(column -> { dbTableColumns.forEach(column -> {
GenUtils.initColumnField(column, table); GenUtils.initColumnField(column, table);
if (tableColumnMap.containsKey(column.getColumnName())) if (tableColumnMap.containsKey(column.getColumnName())) {
{
GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName()); GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName());
column.setColumnId(prevColumn.getColumnId()); column.setColumnId(prevColumn.getColumnId());
if (column.isList()) if (column.isList()) {
{
// 如果是列表继续保留查询方式/字典类型选项 // 如果是列表继续保留查询方式/字典类型选项
column.setDictType(prevColumn.getDictType()); column.setDictType(prevColumn.getDictType());
column.setQueryType(prevColumn.getQueryType()); column.setQueryType(prevColumn.getQueryType());
} }
if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk() if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk()
&& (column.isInsert() || column.isEdit()) && (column.isInsert() || column.isEdit())
&& ((column.isUsableColumn()) || (!column.isSuperColumn()))) && ((column.isUsableColumn()) || (!column.isSuperColumn()))) {
{
// 如果是(新增/修改&非主键/非忽略及父属性)继续保留必填/显示类型选项 // 如果是(新增/修改&非主键/非忽略及父属性)继续保留必填/显示类型选项
column.setIsRequired(prevColumn.getIsRequired()); column.setIsRequired(prevColumn.getIsRequired());
column.setHtmlType(prevColumn.getHtmlType()); column.setHtmlType(prevColumn.getHtmlType());
} }
genTableColumnMapper.updateGenTableColumn(column); genTableColumnMapper.updateGenTableColumn(column);
} } else {
else
{
genTableColumnMapper.insertGenTableColumn(column); genTableColumnMapper.insertGenTableColumn(column);
} }
}); });
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList()); List<GenTableColumn> delColumns = tableColumns.stream()
if (StringUtils.isNotEmpty(delColumns)) .filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
{ if (StringUtils.isNotEmpty(delColumns)) {
genTableColumnMapper.deleteGenTableColumns(delColumns); genTableColumnMapper.deleteGenTableColumns(delColumns);
} }
} }
@ -338,12 +307,10 @@ public class GenTableServiceImpl implements IGenTableService
* @return 数据 * @return 数据
*/ */
@Override @Override
public byte[] downloadCode(String[] tableNames) public byte[] downloadCode(String[] tableNames) {
{
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream); ZipOutputStream zip = new ZipOutputStream(outputStream);
for (String tableName : tableNames) for (String tableName : tableNames) {
{
generatorCode(tableName, zip); generatorCode(tableName, zip);
} }
IOUtils.closeQuietly(zip); IOUtils.closeQuietly(zip);
@ -353,8 +320,7 @@ public class GenTableServiceImpl implements IGenTableService
/** /**
* 查询表信息并生成代码 * 查询表信息并生成代码
*/ */
private void generatorCode(String tableName, ZipOutputStream zip) private void generatorCode(String tableName, ZipOutputStream zip) {
{
// 查询表信息 // 查询表信息
GenTable table = genTableMapper.selectGenTableByName(tableName); GenTable table = genTableMapper.selectGenTableByName(tableName);
// 设置主子表信息 // 设置主子表信息
@ -368,23 +334,19 @@ public class GenTableServiceImpl implements IGenTableService
// 获取模板列表 // 获取模板列表
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType()); List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory(), table.getTplWebType());
for (String template : templates) for (String template : templates) {
{
// 渲染模板 // 渲染模板
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
Template tpl = Velocity.getTemplate(template, Constants.UTF8); Template tpl = Velocity.getTemplate(template, Constants.UTF8);
tpl.merge(context, sw); tpl.merge(context, sw);
try try {
{
// 添加到zip // 添加到zip
zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
IOUtils.write(sw.toString(), zip, Constants.UTF8); IOUtils.write(sw.toString(), zip, Constants.UTF8);
IOUtils.closeQuietly(sw); IOUtils.closeQuietly(sw);
zip.flush(); zip.flush();
zip.closeEntry(); zip.closeEntry();
} } catch (IOException e) {
catch (IOException e)
{
log.error("渲染模板失败,表名:" + table.getTableName(), e); log.error("渲染模板失败,表名:" + table.getTableName(), e);
} }
} }
@ -396,32 +358,20 @@ public class GenTableServiceImpl implements IGenTableService
* @param genTable 业务信息 * @param genTable 业务信息
*/ */
@Override @Override
public void validateEdit(GenTable genTable) public void validateEdit(GenTable genTable) {
{ if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory()))
{
String options = JSON.toJSONString(genTable.getParams()); String options = JSON.toJSONString(genTable.getParams());
JSONObject paramsObj = JSON.parseObject(options); JSONObject paramsObj = JSON.parseObject(options);
if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) {
{
throw new ServiceException("树编码字段不能为空"); throw new ServiceException("树编码字段不能为空");
} } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) {
else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE)))
{
throw new ServiceException("树父编码字段不能为空"); throw new ServiceException("树父编码字段不能为空");
} } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) {
else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME)))
{
throw new ServiceException("树名称字段不能为空"); throw new ServiceException("树名称字段不能为空");
} } else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) {
else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) if (StringUtils.isEmpty(genTable.getSubTableName())) {
{
if (StringUtils.isEmpty(genTable.getSubTableName()))
{
throw new ServiceException("关联子表的表名不能为空"); throw new ServiceException("关联子表的表名不能为空");
} } else if (StringUtils.isEmpty(genTable.getSubTableFkName())) {
else if (StringUtils.isEmpty(genTable.getSubTableFkName()))
{
throw new ServiceException("子表关联的外键名不能为空"); throw new ServiceException("子表关联的外键名不能为空");
} }
} }
@ -433,32 +383,24 @@ public class GenTableServiceImpl implements IGenTableService
* *
* @param table 业务表信息 * @param table 业务表信息
*/ */
public void setPkColumn(GenTable table) public void setPkColumn(GenTable table) {
{ for (GenTableColumn column : table.getColumns()) {
for (GenTableColumn column : table.getColumns()) if (column.isPk()) {
{
if (column.isPk())
{
table.setPkColumn(column); table.setPkColumn(column);
break; break;
} }
} }
if (StringUtils.isNull(table.getPkColumn())) if (StringUtils.isNull(table.getPkColumn())) {
{
table.setPkColumn(table.getColumns().get(0)); table.setPkColumn(table.getColumns().get(0));
} }
if (GenConstants.TPL_SUB.equals(table.getTplCategory())) if (GenConstants.TPL_SUB.equals(table.getTplCategory())) {
{ for (GenTableColumn column : table.getSubTable().getColumns()) {
for (GenTableColumn column : table.getSubTable().getColumns()) if (column.isPk()) {
{
if (column.isPk())
{
table.getSubTable().setPkColumn(column); table.getSubTable().setPkColumn(column);
break; break;
} }
} }
if (StringUtils.isNull(table.getSubTable().getPkColumn())) if (StringUtils.isNull(table.getSubTable().getPkColumn())) {
{
table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0)); table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
} }
} }
@ -469,11 +411,9 @@ public class GenTableServiceImpl implements IGenTableService
* *
* @param table 业务表信息 * @param table 业务表信息
*/ */
public void setSubTable(GenTable table) public void setSubTable(GenTable table) {
{
String subTableName = table.getSubTableName(); String subTableName = table.getSubTableName();
if (StringUtils.isNotEmpty(subTableName)) if (StringUtils.isNotEmpty(subTableName)) {
{
table.setSubTable(genTableMapper.selectGenTableByName(subTableName)); table.setSubTable(genTableMapper.selectGenTableByName(subTableName));
} }
} }
@ -483,11 +423,9 @@ public class GenTableServiceImpl implements IGenTableService
* *
* @param genTable 设置后的生成对象 * @param genTable 设置后的生成对象
*/ */
public void setTableFromOptions(GenTable genTable) public void setTableFromOptions(GenTable genTable) {
{
JSONObject paramsObj = JSON.parseObject(genTable.getOptions()); JSONObject paramsObj = JSON.parseObject(genTable.getOptions());
if (StringUtils.isNotNull(paramsObj)) if (StringUtils.isNotNull(paramsObj)) {
{
String treeCode = paramsObj.getString(GenConstants.TREE_CODE); String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE); String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
String treeName = paramsObj.getString(GenConstants.TREE_NAME); String treeName = paramsObj.getString(GenConstants.TREE_NAME);
@ -509,12 +447,11 @@ public class GenTableServiceImpl implements IGenTableService
* @param template 模板文件路径 * @param template 模板文件路径
* @return 生成地址 * @return 生成地址
*/ */
public static String getGenPath(GenTable table, String template) public static String getGenPath(GenTable table, String template) {
{
String genPath = table.getGenPath(); String genPath = table.getGenPath();
if (StringUtils.equals(genPath, "/")) if (StringUtils.equals(genPath, "/")) {
{ return System.getProperty("user.dir") + File.separator + "src" + File.separator
return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table); + VelocityUtils.getFileName(template, table);
} }
return genPath + File.separator + VelocityUtils.getFileName(template, table); return genPath + File.separator + VelocityUtils.getFileName(template, table);
} }

View File

@ -4,12 +4,14 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.velocity.VelocityContext; import org.apache.velocity.VelocityContext;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.generator.constant.GenConstants;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.generator.constant.GenConstants;
import com.ruoyi.generator.domain.GenTable; import com.ruoyi.generator.domain.GenTable;
import com.ruoyi.generator.domain.GenTableColumn; import com.ruoyi.generator.domain.GenTableColumn;
@ -142,9 +144,6 @@ public class VelocityUtils
templates.add("vm/xml/mapper.xml.vm"); templates.add("vm/xml/mapper.xml.vm");
templates.add("vm/sql/sql.vm"); templates.add("vm/sql/sql.vm");
templates.add("vm/js/api.js.vm"); templates.add("vm/js/api.js.vm");
templates.add("vm/uniapp/edit.vue.vm");
templates.add("vm/uniapp/list.vue.vm");
templates.add("vm/uniapp/show.vue.vm");
if (GenConstants.TPL_CRUD.equals(tplCategory)) if (GenConstants.TPL_CRUD.equals(tplCategory))
{ {
templates.add(useWebType + "/index.vue.vm"); templates.add(useWebType + "/index.vue.vm");
@ -158,6 +157,10 @@ public class VelocityUtils
templates.add(useWebType + "/index.vue.vm"); templates.add(useWebType + "/index.vue.vm");
templates.add("vm/java/sub-domain.java.vm"); templates.add("vm/java/sub-domain.java.vm");
} }
templates.add("vm/uniapp/edit.vue.vm");
templates.add("vm/uniapp/list.vue.vm");
templates.add("vm/uniapp/show.vue.vm");
return templates; return templates;
} }

View File

@ -23,6 +23,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="htmlType" column="html_type" /> <result property="htmlType" column="html_type" />
<result property="dictType" column="dict_type" /> <result property="dictType" column="dict_type" />
<result property="sort" column="sort" /> <result property="sort" column="sort" />
<result property="subColumnTableName" column="sub_column_table_name" />
<result property="subColumnFkName" column="sub_column_fk_name" />
<result property="subColumnName" column="sub_column_name" />
<result property="subColumnJavaField" column="sub_column_java_field" />
<result property="subColumnJavaType" column="sub_column_java_type" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
@ -30,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectGenTableColumnVo"> <sql id="selectGenTableColumnVo">
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort,sub_column_table_name,sub_column_fk_name,sub_column_name,sub_column_java_type,sub_column_java_field, create_by, create_time, update_by, update_time from gen_table_column
</sql> </sql>
<select id="selectGenTableColumnListByTableId" parameterType="Long" resultMap="GenTableColumnResult"> <select id="selectGenTableColumnListByTableId" parameterType="Long" resultMap="GenTableColumnResult">
@ -64,6 +69,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="htmlType != null and htmlType != ''">html_type,</if> <if test="htmlType != null and htmlType != ''">html_type,</if>
<if test="dictType != null and dictType != ''">dict_type,</if> <if test="dictType != null and dictType != ''">dict_type,</if>
<if test="sort != null">sort,</if> <if test="sort != null">sort,</if>
<if test="subColumnTableName != null and subColumnTableName != ''">sub_column_table_name,</if>
<if test="subColumnFkName != null and subColumnFkName != ''">sub_column_fk_name,</if>
<if test="subColumnName != null and subColumnName != ''">sub_column_name,</if>
<if test="subColumnJavaField != null and subColumnJavaField != ''">sub_column_java_field,</if>
<if test="subColumnJavaType != null and subColumnJavaType != ''">sub_column_java_type,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
create_time create_time
)values( )values(
@ -84,6 +94,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="htmlType != null and htmlType != ''">#{htmlType},</if> <if test="htmlType != null and htmlType != ''">#{htmlType},</if>
<if test="dictType != null and dictType != ''">#{dictType},</if> <if test="dictType != null and dictType != ''">#{dictType},</if>
<if test="sort != null">#{sort},</if> <if test="sort != null">#{sort},</if>
<if test="subColumnTableName != null and subColumnTableName != ''">#{subColumnTableName},</if>
<if test="subColumnFkName != null and subColumnFkName != ''">#{subColumnFkName},</if>
<if test="subColumnName != null and subColumnName != ''">#{subColumnName},</if>
<if test="subColumnJavaField != null and subColumnJavaField != ''">#{subColumnJavaField},</if>
<if test="subColumnJavaType != null and subColumnJavaType != ''">#{subColumnJavaType},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate() sysdate()
) )
@ -104,6 +119,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="htmlType != null">html_type = #{htmlType},</if> <if test="htmlType != null">html_type = #{htmlType},</if>
<if test="dictType != null">dict_type = #{dictType},</if> <if test="dictType != null">dict_type = #{dictType},</if>
<if test="sort != null">sort = #{sort},</if> <if test="sort != null">sort = #{sort},</if>
<if test="subColumnTableName != null and subColumnTableName != ''">sub_column_table_name = #{subColumnTableName},</if>
<if test="subColumnFkName != null and subColumnFkName != ''">sub_column_fk_name = #{subColumnFkName},</if>
<if test="subColumnName != null and subColumnName != ''">sub_column_name = #{subColumnName},</if>
<if test="subColumnJavaField != null and subColumnJavaField != ''">sub_column_java_field = #{subColumnJavaField},</if>
<if test="subColumnJavaType != null and subColumnJavaType != ''">sub_column_java_type = #{subColumnJavaType},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
update_time = sysdate() update_time = sysdate()
</set> </set>

View File

@ -21,6 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="genType" column="gen_type" /> <result property="genType" column="gen_type" />
<result property="genPath" column="gen_path" /> <result property="genPath" column="gen_path" />
<result property="options" column="options" /> <result property="options" column="options" />
<result property="haveSubColumn" column="have_sub_column" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
@ -48,6 +49,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="htmlType" column="html_type" /> <result property="htmlType" column="html_type" />
<result property="dictType" column="dict_type" /> <result property="dictType" column="dict_type" />
<result property="sort" column="sort" /> <result property="sort" column="sort" />
<result property="subColumnTableName" column="sub_column_table_name" />
<result property="subColumnFkName" column="sub_column_fk_name" />
<result property="subColumnName" column="sub_column_name" />
<result property="subColumnJavaField" column="sub_column_java_field" />
<result property="subColumnJavaType" column="sub_column_java_type" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
@ -55,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectGenTableVo"> <sql id="selectGenTableVo">
select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, tpl_web_type, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, tpl_web_type, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, have_sub_column,create_by, create_time, update_by, update_time, remark from gen_table
</sql> </sql>
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult"> <select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
@ -112,8 +118,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult"> <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.tpl_web_type, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.tpl_web_type, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,t.have_sub_column,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort,c.sub_column_table_name,c.sub_column_fk_name,c.sub_column_name,c.sub_column_java_type,c.sub_column_java_field
FROM gen_table t FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_id = #{tableId} order by c.sort where t.table_id = #{tableId} order by c.sort
@ -121,7 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult"> <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.tpl_web_type, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.tpl_web_type, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort,c.sub_column_table_name,c.sub_column_fk_name,c.sub_column_name,c.sub_column_java_type,c.sub_column_java_field
FROM gen_table t FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_name = #{tableName} order by c.sort where t.table_name = #{tableName} order by c.sort
@ -129,7 +135,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult"> <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.tpl_web_type, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark, SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.tpl_web_type, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort,c.sub_column_table_name,c.sub_column_fk_name,c.sub_column_name,c.sub_column_java_type,c.sub_column_java_field
FROM gen_table t FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id LEFT JOIN gen_table_column c ON t.table_id = c.table_id
order by c.sort order by c.sort
@ -151,6 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="genPath != null and genPath != ''">gen_path,</if> <if test="genPath != null and genPath != ''">gen_path,</if>
<if test="remark != null and remark != ''">remark,</if> <if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
<if test="haveSubColumn != null and haveSubColumn != ''">have_sub_column,</if>
create_time create_time
)values( )values(
<if test="tableName != null">#{tableName},</if> <if test="tableName != null">#{tableName},</if>
@ -166,6 +173,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="genType != null and genType != ''">#{genType},</if> <if test="genType != null and genType != ''">#{genType},</if>
<if test="genPath != null and genPath != ''">#{genPath},</if> <if test="genPath != null and genPath != ''">#{genPath},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="haveSubColumn != null and haveSubColumn != ''">#{haveSubColumn},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate() sysdate()
) )
@ -191,6 +199,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="options != null and options != ''">options = #{options},</if> <if test="options != null and options != ''">options = #{options},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="haveSubColumn != null and haveSubColumn != ''">have_sub_column = #{haveSubColumn},</if>
update_time = sysdate() update_time = sysdate()
</set> </set>
where table_id = #{tableId} where table_id = #{tableId}

View File

@ -60,6 +60,12 @@ public class ${ClassName} extends ${Entity}
#end #end
private $column.javaType $column.javaField; private $column.javaType $column.javaField;
#if($column.subColumnTableName && $table.haveSubColumn == '1')
/** $column.javaField 到 $column.subColumnTableName 映射 */
private $column.subColumnJavaType $column.subColumnJavaField;
#end
#end #end
#end #end
#if($table.sub) #if($table.sub)
@ -83,6 +89,24 @@ public class ${ClassName} extends ${Entity}
{ {
return $column.javaField; return $column.javaField;
} }
#if($column.subColumnTableName && $table.haveSubColumn == '1')
#if($column.subColumnJavaField.length() > 2 && $column.subColumnJavaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.subColumnJavaField)
#else
#set($AttrName=$column.subColumnJavaField.substring(0,1).toUpperCase() + ${column.subColumnJavaField.substring(1)})
#end
public void set${AttrName}($column.subColumnJavaType $column.subColumnJavaField)
{
this.$column.subColumnJavaField = $column.subColumnJavaField;
}
public $column.subColumnJavaType get${AttrName}()
{
return $column.subColumnJavaField;
}
#end
#end #end
#end #end
@ -108,6 +132,14 @@ public class ${ClassName} extends ${Entity}
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end #end
.append("${column.javaField}", get${AttrName}()) .append("${column.javaField}", get${AttrName}())
#if($column.subColumnTableName && $table.haveSubColumn == '1')
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.subColumnJavaField)
#else
#set($AttrName=$column.subColumnJavaField.substring(0,1).toUpperCase() + ${column.subColumnJavaField.substring(1)})
#end
.append("${column.subColumnJavaField}", get${AttrName}())
#end
#end #end
#if($table.sub) #if($table.sub)
.append("${subclassName}List", get${subClassName}List()) .append("${subclassName}List", get${subClassName}List())

View File

@ -12,17 +12,17 @@
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
#if($column.htmlType == "input") #if($column.htmlType == "input")
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="#if($column.subColumnTableName)${column.subColumnJavaField}#else${column.javaField}#end">
<el-input <el-input
v-model="queryParams.${column.javaField}" v-model="queryParams.#if($column.subColumnTableName)${column.subColumnJavaField}#else${column.javaField}#end"
placeholder="请输入${comment}" placeholder="请输入${comment}"
clearable clearable
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="#if($column.subColumnTableName)${column.subColumnJavaField}#else${column.javaField}#end">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> <el-select v-model="queryParams.#if($column.subColumnTableName)${column.subColumnJavaField}#else${column.javaField}#end" placeholder="请选择${comment}" clearable>
<el-option <el-option
v-for="dict in dict.type.${dictType}" v-for="dict in dict.type.${dictType}"
:key="dict.value" :key="dict.value"
@ -32,15 +32,15 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="#if($column.subColumnTableName)${column.subColumnJavaField}#else${column.javaField}#end">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> <el-select v-model="queryParams.#if($column.subColumnTableName)${column.subColumnJavaField}#else${column.javaField}#end" placeholder="请选择${comment}" clearable>
<el-option label="请选择字典生成" value="" /> <el-option label="请选择字典生成" value="" />
</el-select> </el-select>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "date" && $column.queryType != "BETWEEN") #elseif($column.htmlType == "date" && $column.queryType != "BETWEEN")
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="#if($column.subColumnTableName)${column.subColumnJavaField}#else${column.javaField}#end">
<el-date-picker clearable <el-date-picker clearable
v-model="queryParams.${column.javaField}" v-model="queryParams.#if($column.subColumnTableName)${column.subColumnJavaField}#else${column.javaField}#end"
type="date" type="date"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd"
placeholder="请选择${comment}"> placeholder="请选择${comment}">
@ -58,9 +58,9 @@
end-placeholder="结束日期" end-placeholder="结束日期"
></el-date-picker> ></el-date-picker>
#elseif($column.htmlType == "time" && $column.queryType != "BETWEEN") #elseif($column.htmlType == "time" && $column.queryType != "BETWEEN")
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="#if($column.subColumnTableName)${column.subColumnJavaField}#else${column.javaField}#end">
<el-time-picker clearable <el-time-picker clearable
v-model="queryParams.${column.javaField}" v-model="queryParams.#if($column.subColumnTableName)${column.subColumnJavaField}#else${column.javaField}#end"
format="HH:mm:ss" format="HH:mm:ss"
:picker-options="{selectableRange: '00:00:00 - 23:59:59'}" :picker-options="{selectableRange: '00:00:00 - 23:59:59'}"
placeholder="请选择${comment}"> placeholder="请选择${comment}">
@ -78,9 +78,9 @@
end-placeholder="结束时间" end-placeholder="结束时间"
></el-time-picker> ></el-time-picker>
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") #elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="#if($column.subColumnTableName)${column.subColumnJavaField}#else${column.javaField}#end">
<el-date-picker clearable <el-date-picker clearable
v-model="queryParams.${column.javaField}" v-model="queryParams.#if($column.subColumnTableName)${column.subColumnJavaField}#else${column.javaField}#end"
type="datetime" type="datetime"
value-format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择${comment}"> placeholder="请选择${comment}">
@ -580,7 +580,7 @@ export default {
this.form = response.data; this.form = response.data;
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.htmlType == "checkbox") #if($column.htmlType == "checkbox")
this.form.$column.javaField = this.form.${column.javaField}.split(","); this.form.$column.javaField = this.form.#if($column.subColumnTableName)${column.subColumnJavaField}#else${column.javaField}#end.split(",");
#end #end
#end #end
#if($table.sub) #if($table.sub)
@ -596,7 +596,7 @@ export default {
if (valid) { if (valid) {
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.htmlType == "checkbox") #if($column.htmlType == "checkbox")
this.form.$column.javaField = this.form.${column.javaField}.join(","); this.form.$column.javaField = this.form.#if($column.subColumnTableName)${column.subColumnJavaField}#else${column.javaField}#end.join(",");
#end #end
#end #end
#if($table.sub) #if($table.sub)

View File

@ -12,17 +12,17 @@
#set($comment=$column.columnComment) #set($comment=$column.columnComment)
#end #end
#if($column.htmlType == "input") #if($column.htmlType == "input")
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="#if($column.subColumnTableName && $table.haveSubColumn == '1')${column.subColumnJavaField}#else${column.javaField}#end">
<el-input <el-input
v-model="queryParams.${column.javaField}" v-model="queryParams.#if($column.subColumnTableName && $table.haveSubColumn == '1')${column.subColumnJavaField}#else${column.javaField}#end"
placeholder="请输入${comment}" placeholder="请输入${comment}"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
/> />
</el-form-item> </el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType) #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="#if($column.subColumnTableName && $table.haveSubColumn == '1')${column.subColumnJavaField}#else${column.javaField}#end">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> <el-select v-model="queryParams.#if($column.subColumnTableName && $table.haveSubColumn == '1')${column.subColumnJavaField}#else${column.javaField}#end" placeholder="请选择${comment}" clearable>
<el-option <el-option
v-for="dict in ${dictType}" v-for="dict in ${dictType}"
:key="dict.value" :key="dict.value"
@ -32,15 +32,15 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType) #elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="#if($column.subColumnTableName && $table.haveSubColumn == '1')${column.subColumnJavaField}#else${column.javaField}#end">
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${comment}" clearable> <el-select v-model="queryParams.#if($column.subColumnTableName && $table.haveSubColumn == '1')${column.subColumnJavaField}#else${column.javaField}#end" placeholder="请选择${comment}" clearable>
<el-option label="请选择字典生成" value="" /> <el-option label="请选择字典生成" value="" />
</el-select> </el-select>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN") #elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
<el-form-item label="${comment}" prop="${column.javaField}"> <el-form-item label="${comment}" prop="#if($column.subColumnTableName && $table.haveSubColumn == '1')${column.subColumnJavaField}#else${column.javaField}#end">
<el-date-picker clearable <el-date-picker clearable
v-model="queryParams.${column.javaField}" v-model="queryParams.#if($column.subColumnTableName && $table.haveSubColumn == '1')${column.subColumnJavaField}#else${column.javaField}#end"
type="date" type="date"
value-format="YYYY-MM-DD" value-format="YYYY-MM-DD"
placeholder="请选择${comment}"> placeholder="请选择${comment}">
@ -111,7 +111,11 @@
<el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="${businessName}List" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
#foreach($column in $columns) #foreach($column in $columns)
#if($column.subColumnTableName && $table.haveSubColumn == '1')
#set($javaField=$column.subColumnJavaField)
#else
#set($javaField=$column.javaField) #set($javaField=$column.javaField)
#end
#set($parentheseIndex=$column.columnComment.indexOf("")) #set($parentheseIndex=$column.columnComment.indexOf(""))
#if($parentheseIndex != -1) #if($parentheseIndex != -1)
#set($comment=$column.columnComment.substring(0, $parentheseIndex)) #set($comment=$column.columnComment.substring(0, $parentheseIndex))
@ -167,6 +171,7 @@
<el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px"> <el-form ref="${businessName}Ref" :model="form" :rules="rules" label-width="80px">
#foreach($column in $columns) #foreach($column in $columns)
#set($field=$column.javaField) #set($field=$column.javaField)
#set($Field = $column.javaField.substring(0, 1).toUpperCase() + $column.javaField.substring(1))
#if($column.insert && !$column.pk) #if($column.insert && !$column.pk)
#if(($column.usableColumn) || (!$column.superColumn)) #if(($column.usableColumn) || (!$column.superColumn))
#set($parentheseIndex=$column.columnComment.indexOf("")) #set($parentheseIndex=$column.columnComment.indexOf(""))
@ -178,7 +183,19 @@
#set($dictType=$column.dictType) #set($dictType=$column.dictType)
#if($column.htmlType == "input") #if($column.htmlType == "input")
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
#if($column.subColumnTableName && $table.haveSubColumn == '1')
<el-select v-model="form.${field}" multiple filterable remote reserve-keyword
placeholder="请输入${comment}"
:remote-method="remoteMethod${Field}"
:loading="loading${Field}"
>
<el-option v-for="item in options${Field}" :key="item.value"
:label="item.label" :value="item.value"
/>
</el-select>
#else
<el-input v-model="form.${field}" placeholder="请输入${comment}" /> <el-input v-model="form.${field}" placeholder="请输入${comment}" />
#end
</el-form-item> </el-form-item>
#elseif($column.htmlType == "imageUpload") #elseif($column.htmlType == "imageUpload")
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
@ -192,6 +209,18 @@
<el-form-item label="${comment}"> <el-form-item label="${comment}">
<editor v-model="form.${field}" :min-height="192"/> <editor v-model="form.${field}" :min-height="192"/>
</el-form-item> </el-form-item>
#elseif($column.htmlType == "select" && "" != $column.subColumnTableName)
<el-form-item label="${comment}" prop="${field}">
<el-select v-model="form.${field}" multiple filterable remote reserve-keyword remote-show-suffix
placeholder="请选择${comment}"
:remote-method="remoteMethod${Field}"
:loading="loading${Field}"
>
<el-option v-for="item in options${Field}" :key="item.value"
:label="item.label" :value="item.value"
/>
</el-select>
</el-form-item>
#elseif($column.htmlType == "select" && "" != $dictType) #elseif($column.htmlType == "select" && "" != $dictType)
<el-form-item label="${comment}" prop="${field}"> <el-form-item label="${comment}" prop="${field}">
<el-select v-model="form.${field}" placeholder="请选择${comment}"> <el-select v-model="form.${field}" placeholder="请选择${comment}">
@ -491,7 +520,7 @@ function handleUpdate(row) {
form.value = response.data; form.value = response.data;
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.htmlType == "checkbox") #if($column.htmlType == "checkbox")
form.value.$column.javaField = form.value.${column.javaField}.split(","); form.value.$column.javaField = form.value.#if($column.subColumnTableName && $table.haveSubColumn == '1')${column.subColumnJavaField}#else${column.javaField}#end.split(",");
#end #end
#end #end
#if($table.sub) #if($table.sub)
@ -508,7 +537,7 @@ function submitForm() {
if (valid) { if (valid) {
#foreach ($column in $columns) #foreach ($column in $columns)
#if($column.htmlType == "checkbox") #if($column.htmlType == "checkbox")
form.value.$column.javaField = form.value.${column.javaField}.join(","); form.value.$column.javaField = form.value.#if($column.subColumnTableName && $table.haveSubColumn == '1')${column.subColumnJavaField}#else${column.javaField}#end.join(",");
#end #end
#end #end
#if($table.sub) #if($table.sub)
@ -579,6 +608,28 @@ function handle${subClassName}SelectionChange(selection) {
} }
#end #end
#if($table.haveSubColumn == '1')
#foreach($column in $columns)
#if($column.subColumnTableName)
#set($JavaField = $column.javaField.substring(0, 1).toUpperCase() + $column.javaField.substring(1))
/** 映射字段选中操作 */
const loading${column.javaField} = ref(false)
function remoteMethod${JavaField}(query){
if (query) {
loading${JavaField}.value = true
list目标业务名().then(res=>{
loading${JavaField}.value = false
options.value = res.rows.map(item=>({label:item.${column.subColumnJavaField},value:item.${column.subColumnFkName}}))
})
} else {
options.value = []
}
}
#end
#end
#end
/** 导出按钮操作 */ /** 导出按钮操作 */
function handleExport() { function handleExport() {
proxy.download('${moduleName}/${businessName}/export', { proxy.download('${moduleName}/${businessName}/export', {

View File

@ -23,7 +23,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#end #end
<sql id="select${ClassName}Vo"> <sql id="select${ClassName}Vo">
#if($table.haveSubColumn=="1")
select#foreach($column in $columns) #if($column.subColumnTableName)${column.subColumnTableName}.${column.subColumnName}#else${tableName}.${column.columnName}#end#if($foreach.count != $columns.size()),#end#end from ${tableName}
#foreach($column in $columns)
#if($column.subColumnTableName)
left join ${column.subColumnTableName} on ${column.subColumnTableName}.${column.subColumnName}=${tableName}.${column.columnName}
#end
#end
#else
select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end from ${tableName} select#foreach($column in $columns) $column.columnName#if($foreach.count != $columns.size()),#end#end from ${tableName}
#end
</sql> </sql>
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result"> <select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
@ -31,9 +40,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where> <where>
#foreach($column in $columns) #foreach($column in $columns)
#set($queryType=$column.queryType) #set($queryType=$column.queryType)
#set($javaField=$column.javaField) #if($column.subColumnTableName)
#set($javaType=$column.javaType) #set($javaField=$column.subColumnJavaField)
#set($columnName=$column.columnName) #set($javaType=$column.subColumnJavaType)
#set($columnName=$column.subColumnName)
#else
#set($javaField=$column.javaField)
#set($javaType=$column.javaType)
#set($columnName=$column.columnName)
#end
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#if($column.query) #if($column.query)
#if($column.queryType == "EQ") #if($column.queryType == "EQ")