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参数校验
|
||||
@RequestParam(required = false, defaultValue = "大狼狗") String authorName,
|
||||
@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
|
||||
ClassInfo classInfo = CodeGeneratorTool.processTableIntoClassInfo(tableSql);
|
||||
ClassInfo classInfo = CodeGeneratorTool.processTableIntoClassInfo(tableSql, isUnderLineToCamelCase);
|
||||
|
||||
// code genarete
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
|
||||
@ -19,8 +19,8 @@ public class CodeGeneratorTool {
|
||||
* @param tableSql
|
||||
* @return
|
||||
*/
|
||||
public static ClassInfo processTableIntoClassInfo(String tableSql) throws IOException {
|
||||
return TableParseUtil.processTableIntoClassInfo(tableSql);
|
||||
public static ClassInfo processTableIntoClassInfo(String tableSql, boolean isUnderLineToCamelCase) throws IOException {
|
||||
return TableParseUtil.processTableIntoClassInfo(tableSql, isUnderLineToCamelCase);
|
||||
}
|
||||
|
||||
}
|
||||
@ -24,7 +24,7 @@ public class TableParseUtil {
|
||||
* @param tableSql
|
||||
* @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) {
|
||||
throw new CodeGenerateException("Table structure can not be empty.");
|
||||
}
|
||||
@ -159,10 +159,16 @@ public class TableParseUtil {
|
||||
columnName = columnLine.substring(0, columnLine.indexOf(" "));
|
||||
|
||||
// field Name
|
||||
String fieldName = StringUtils.lowerCaseFirst(StringUtils.underlineToCamelCase(columnName));
|
||||
// 2019-09-08 yj 添加是否下划线转换为驼峰的判断
|
||||
String fieldName;
|
||||
if(isUnderLineToCamelCase){
|
||||
fieldName = StringUtils.lowerCaseFirst(StringUtils.underlineToCamelCase(columnName));
|
||||
if (fieldName.contains("_")) {
|
||||
fieldName = fieldName.replaceAll("_", "");
|
||||
}
|
||||
}else {
|
||||
fieldName = StringUtils.lowerCaseFirst(columnName);
|
||||
}
|
||||
|
||||
// field class
|
||||
columnLine = columnLine.substring(columnLine.indexOf("`")+1).trim();
|
||||
|
||||
@ -52,7 +52,8 @@
|
||||
"tableSql": tableSql,
|
||||
"packageName":$("#packageName").val(),
|
||||
"returnUtil":$("#returnUtil").val(),
|
||||
"authorName":$("#authorName").val()
|
||||
"authorName":$("#authorName").val(),
|
||||
"isUnderLineToCamelCase":$("#isUnderLineToCamelCase").val()
|
||||
},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
@ -137,6 +138,14 @@
|
||||
<span class="input-group-text">返回封装</span>
|
||||
</div>
|
||||
<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>
|
||||
<textarea id="ddlSqlArea" placeholder="请输入表结构信息..." class="form-control btn-lg" style="height: 250px;">
|
||||
CREATE TABLE `userinfo` (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user