mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2025-12-26 13:52:39 +08:00
Merge pull request #42 from youngking28/fe-isUnderLineToCamelCase
添加是否下划线转换为驼峰的选择 @youngking28
This commit is contained in:
commit
1af9644b40
@ -39,7 +39,8 @@ public class IndexController {
|
|||||||
//2019-2-10 liutf 修改为@RequestParam参数校验
|
//2019-2-10 liutf 修改为@RequestParam参数校验
|
||||||
@RequestParam(required = false, defaultValue = "大狼狗") String authorName,
|
@RequestParam(required = false, defaultValue = "大狼狗") String authorName,
|
||||||
@RequestParam(required = false, defaultValue = "com.softdev.system")String packageName,
|
@RequestParam(required = false, defaultValue = "com.softdev.system")String packageName,
|
||||||
@RequestParam(required = false, defaultValue = "ApiReturnUtil")String returnUtil
|
@RequestParam(required = false, defaultValue = "ApiReturnUtil")String returnUtil,
|
||||||
|
@RequestParam(required = false, defaultValue = "true")boolean isUnderLineToCamelCase
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
@ -50,7 +51,7 @@ public class IndexController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// parse table
|
// parse table
|
||||||
ClassInfo classInfo = CodeGeneratorTool.processTableIntoClassInfo(tableSql);
|
ClassInfo classInfo = CodeGeneratorTool.processTableIntoClassInfo(tableSql, isUnderLineToCamelCase);
|
||||||
|
|
||||||
// code genarete
|
// code genarete
|
||||||
Map<String, Object> params = new HashMap<String, Object>();
|
Map<String, Object> params = new HashMap<String, Object>();
|
||||||
|
|||||||
@ -19,8 +19,8 @@ public class CodeGeneratorTool {
|
|||||||
* @param tableSql
|
* @param tableSql
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ClassInfo processTableIntoClassInfo(String tableSql) throws IOException {
|
public static ClassInfo processTableIntoClassInfo(String tableSql, boolean isUnderLineToCamelCase) throws IOException {
|
||||||
return TableParseUtil.processTableIntoClassInfo(tableSql);
|
return TableParseUtil.processTableIntoClassInfo(tableSql, isUnderLineToCamelCase);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -24,7 +24,7 @@ public class TableParseUtil {
|
|||||||
* @param tableSql
|
* @param tableSql
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static ClassInfo processTableIntoClassInfo(String tableSql) throws IOException {
|
public static ClassInfo processTableIntoClassInfo(String tableSql, boolean isUnderLineToCamelCase) throws IOException {
|
||||||
if (tableSql==null || tableSql.trim().length()==0) {
|
if (tableSql==null || tableSql.trim().length()==0) {
|
||||||
throw new CodeGenerateException("Table structure can not be empty.");
|
throw new CodeGenerateException("Table structure can not be empty.");
|
||||||
}
|
}
|
||||||
@ -159,9 +159,15 @@ public class TableParseUtil {
|
|||||||
columnName = columnLine.substring(0, columnLine.indexOf(" "));
|
columnName = columnLine.substring(0, columnLine.indexOf(" "));
|
||||||
|
|
||||||
// field Name
|
// field Name
|
||||||
String fieldName = StringUtils.lowerCaseFirst(StringUtils.underlineToCamelCase(columnName));
|
// 2019-09-08 yj 添加是否下划线转换为驼峰的判断
|
||||||
if (fieldName.contains("_")) {
|
String fieldName;
|
||||||
fieldName = fieldName.replaceAll("_", "");
|
if(isUnderLineToCamelCase){
|
||||||
|
fieldName = StringUtils.lowerCaseFirst(StringUtils.underlineToCamelCase(columnName));
|
||||||
|
if (fieldName.contains("_")) {
|
||||||
|
fieldName = fieldName.replaceAll("_", "");
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
fieldName = StringUtils.lowerCaseFirst(columnName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// field class
|
// field class
|
||||||
|
|||||||
@ -52,7 +52,8 @@
|
|||||||
"tableSql": tableSql,
|
"tableSql": tableSql,
|
||||||
"packageName":$("#packageName").val(),
|
"packageName":$("#packageName").val(),
|
||||||
"returnUtil":$("#returnUtil").val(),
|
"returnUtil":$("#returnUtil").val(),
|
||||||
"authorName":$("#authorName").val()
|
"authorName":$("#authorName").val(),
|
||||||
|
"isUnderLineToCamelCase":$("#isUnderLineToCamelCase").val()
|
||||||
},
|
},
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
@ -137,6 +138,14 @@
|
|||||||
<span class="input-group-text">返回封装</span>
|
<span class="input-group-text">返回封装</span>
|
||||||
</div>
|
</div>
|
||||||
<input type="text" class="form-control" id="returnUtil" name="returnUtil" placeholder="ApiReturnObject">
|
<input type="text" class="form-control" id="returnUtil" name="returnUtil" placeholder="ApiReturnObject">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="input-group-text">是否下划线转换为驼峰</span>
|
||||||
|
</div>
|
||||||
|
<select type="text" class="form-control" id="isUnderLineToCamelCase"
|
||||||
|
name="isUnderLineToCamelCase">
|
||||||
|
<option value="true">转换</option>
|
||||||
|
<option value="false">不转换</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<textarea id="ddlSqlArea" placeholder="请输入表结构信息..." class="form-control btn-lg" style="height: 250px;">
|
<textarea id="ddlSqlArea" placeholder="请输入表结构信息..." class="form-control btn-lg" style="height: 250px;">
|
||||||
CREATE TABLE `userinfo` (
|
CREATE TABLE `userinfo` (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user