Compare commits
10 Commits
4bc34ef94c
...
bb4d29c4c2
Author | SHA1 | Date | |
---|---|---|---|
bb4d29c4c2 | |||
c403b90bd9 | |||
2da510fd16 | |||
c85899ba9b | |||
df7442e5bd | |||
74802d4a17 | |||
538d13e555 | |||
738db217f6 | |||
73a3299a2f | |||
0b79f47cb2 |
36
.gitignore
vendored
Normal file
36
.gitignore
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
.mvn
|
||||
mvnw
|
||||
mvnw.cmd
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
12
pom.xml
12
pom.xml
@ -56,12 +56,24 @@
|
||||
</dependency>
|
||||
<!-- freemarker end -->
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.30</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.30</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
@ -19,7 +19,6 @@ import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
import javafx.stage.Stage;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@ -103,6 +102,7 @@ public class GenerateController implements Initializable {
|
||||
this.generateService = new GenerateService(fieldTableView);
|
||||
this.fieldService.setTableView(fieldTableView);
|
||||
this.fieldService.setTableName(tableVO.getTableName());
|
||||
this.fieldService.setTableNamePrefix(this.tablePrefixTextField.getText());
|
||||
this.fieldService.showField();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package ink.wgink.code.factory.controller;
|
||||
|
||||
import com.sun.javafx.robot.impl.FXRobotHelper;
|
||||
import ink.wgink.code.factory.utils.MsgUtil;
|
||||
import javafx.application.Platform;
|
||||
import javafx.concurrent.Service;
|
||||
@ -9,7 +8,6 @@ import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.stage.Stage;
|
||||
|
@ -12,103 +12,44 @@ package ink.wgink.code.factory.enums;
|
||||
**/
|
||||
public enum FormFieldTypeEnum {
|
||||
|
||||
/**
|
||||
* 文本
|
||||
*/
|
||||
TEXT("text"),
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
DATETIME("datetime"),
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
DATE("date"),
|
||||
/**
|
||||
* 整形
|
||||
*/
|
||||
NUMBER("number"),
|
||||
/**
|
||||
* 双精度
|
||||
*/
|
||||
DOUBLE("double"),
|
||||
/**
|
||||
* 文本域
|
||||
*/
|
||||
TEXTAREA("textarea"),
|
||||
/**
|
||||
* 富文本
|
||||
*/
|
||||
RICH_TEXT("richText"),
|
||||
/**
|
||||
* ID 选择
|
||||
*/
|
||||
ID_SELECT("idSelect"),
|
||||
/**
|
||||
* 下拉选择
|
||||
*/
|
||||
SELECT("select"),
|
||||
/**
|
||||
* 复选
|
||||
*/
|
||||
CHECKBOX("checkbox"),
|
||||
/**
|
||||
* 单选
|
||||
*/
|
||||
RADIO("radio"),
|
||||
/**
|
||||
* 选择人员
|
||||
*/
|
||||
SELECT_USER("selectUser"),
|
||||
/**
|
||||
* 选择部门
|
||||
*/
|
||||
SELECT_DEPARTMENT("selectDepartment"),
|
||||
/**
|
||||
* 文件
|
||||
*/
|
||||
FILE("file"),
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
IMAGE("image"),
|
||||
/**
|
||||
* 视频
|
||||
*/
|
||||
VIDEO("video"),
|
||||
/**
|
||||
* 音频
|
||||
*/
|
||||
AUDIO("audio"),
|
||||
/**
|
||||
* 当前用户
|
||||
*/
|
||||
CURRENT_USER("currentUser"),
|
||||
/**
|
||||
* 当前部门
|
||||
*/
|
||||
CURRENT_DEPARTMENT("currentDepartment"),
|
||||
/**
|
||||
* 当前角色
|
||||
*/
|
||||
CURRENT_ROLE("currentRole"),
|
||||
/**
|
||||
* 当前组
|
||||
*/
|
||||
CURRENT_GROUP("currentGroup"),
|
||||
/**
|
||||
* 当前职位
|
||||
*/
|
||||
CURRENT_POSITION("currentPosition");
|
||||
TEXT("text", "文本"),
|
||||
DATETIME("datetime", "时间戳"),
|
||||
DATE("date", "日期"),
|
||||
NUMBER("number", "整形"),
|
||||
DOUBLE("double", "双精度"),
|
||||
TEXTAREA("textarea", "文本域"),
|
||||
RICH_TEXT("richText", "富文本"),
|
||||
ID_SELECT("idSelect", "ID 选择"),
|
||||
SELECT("select", "下拉选择"),
|
||||
CHECKBOX("checkbox", "复选"),
|
||||
STATIC_CHECKBOX("staticCheckbox", "静态复选"),
|
||||
RADIO("radio", "单选"),
|
||||
STATIC_RADIO("staticRadio", "静态单选"),
|
||||
SELECT_USER("selectUser", "选择人员"),
|
||||
SELECT_DEPARTMENT("selectDepartment", "选择部门"),
|
||||
FILE("file", "文件"),
|
||||
IMAGE("image", "图片"),
|
||||
VIDEO("video", "视频"),
|
||||
AUDIO("audio", "音频"),
|
||||
CURRENT_USER("currentUser", "当前用户"),
|
||||
CURRENT_DEPARTMENT("currentDepartment", "当前部门"),
|
||||
CURRENT_ROLE("currentRole", "当前角色"),
|
||||
CURRENT_GROUP("currentGroup", "当前组"),
|
||||
CURRENT_POSITION("currentPosition", "当前职位");
|
||||
|
||||
private String value;
|
||||
private String summary;
|
||||
|
||||
FormFieldTypeEnum(String value) {
|
||||
FormFieldTypeEnum(String value, String summary) {
|
||||
this.value = value;
|
||||
this.summary = summary;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
|
||||
public String getSummary() {
|
||||
return summary == null ? "" : summary.trim();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,9 @@
|
||||
package ink.wgink.code.factory.factory;
|
||||
|
||||
import com.sun.deploy.uitoolkit.impl.fx.ui.FXUIFactory;
|
||||
import ink.wgink.code.factory.service.FieldService;
|
||||
import ink.wgink.code.factory.vos.FieldVO;
|
||||
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.control.CheckBox;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.util.Callback;
|
||||
@ -37,9 +34,32 @@ public class CheckBoxTableCellFactory implements Callback<TableColumn.CellDataFe
|
||||
public ObservableValue<CheckBox> call(TableColumn.CellDataFeatures<FieldVO, String> param) {
|
||||
FieldVO fieldVO = param.getValue();
|
||||
CheckBox checkBox = new CheckBox();
|
||||
String tableName = param.getValue().getTableName();
|
||||
String tableNamePrefix = param.getValue().getTableNamePrefix();
|
||||
if (StringUtils.equals(IS_FORM_SHOW, property)) {
|
||||
Boolean isFormShow = param.getValue().getFormShow();
|
||||
checkBox.setSelected(isFormShow == null || !isFormShow ? false : true);
|
||||
// 如果是主键
|
||||
if (StringUtils.equals(String.format("%s_id", tableName.replace(tableNamePrefix, "")), param.getValue().getColumnName())) {
|
||||
param.getValue().setFormShow(false);
|
||||
checkBox.setSelected(false);
|
||||
} else if(StringUtils.equals(FieldService.DEFAULT_COLUMN_CREATOR, param.getValue().getColumnName())) {
|
||||
param.getValue().setFormShow(false);
|
||||
checkBox.setSelected(false);
|
||||
} else if(StringUtils.equals(FieldService.DEFAULT_COLUMN_GMT_CREATE, param.getValue().getColumnName())) {
|
||||
param.getValue().setFormShow(false);
|
||||
checkBox.setSelected(false);
|
||||
} else if(StringUtils.equals(FieldService.DEFAULT_COLUMN_MODIFIER, param.getValue().getColumnName())) {
|
||||
param.getValue().setFormShow(false);
|
||||
checkBox.setSelected(false);
|
||||
} else if(StringUtils.equals(FieldService.DEFAULT_COLUMN_GMT_MODIFIED, param.getValue().getColumnName())) {
|
||||
param.getValue().setFormShow(false);
|
||||
checkBox.setSelected(false);
|
||||
} else if(StringUtils.equals(FieldService.DEFAULT_COLUMN_IS_DELETE, param.getValue().getColumnName())) {
|
||||
param.getValue().setFormShow(false);
|
||||
checkBox.setSelected(false);
|
||||
} else {
|
||||
checkBox.setSelected(isFormShow == null || !isFormShow ? false : true);
|
||||
}
|
||||
}
|
||||
if (StringUtils.equals(IS_LIST_SHOW, property)) {
|
||||
Boolean isListShow = param.getValue().getListShow();
|
||||
|
@ -26,12 +26,13 @@ public class ChoiceBoxTableCellFactory implements Callback<TableColumn.CellDataF
|
||||
private final String property;
|
||||
private ObservableList<String> normalSelect = FXCollections.observableArrayList(
|
||||
"", FormFieldTypeEnum.TEXT.getValue(), FormFieldTypeEnum.NUMBER.getValue(),
|
||||
FormFieldTypeEnum.DOUBLE.getValue(), FormFieldTypeEnum.TEXTAREA.getValue(),
|
||||
FormFieldTypeEnum.DOUBLE.getValue(), FormFieldTypeEnum.TEXTAREA.getValue(), FormFieldTypeEnum.RICH_TEXT.getValue(),
|
||||
FormFieldTypeEnum.STATIC_RADIO.getValue(),
|
||||
FormFieldTypeEnum.CHECKBOX.getValue(), FormFieldTypeEnum.STATIC_CHECKBOX.getValue(),
|
||||
FormFieldTypeEnum.SELECT_USER.getValue(), FormFieldTypeEnum.SELECT_DEPARTMENT.getValue(),
|
||||
FormFieldTypeEnum.FILE.getValue(), FormFieldTypeEnum.IMAGE.getValue(),
|
||||
FormFieldTypeEnum.AUDIO.getValue(), FormFieldTypeEnum.VIDEO.getValue(),
|
||||
FormFieldTypeEnum.DATETIME.getValue(), FormFieldTypeEnum.DATE.getValue(),
|
||||
FormFieldTypeEnum.CHECKBOX.getValue()
|
||||
FormFieldTypeEnum.DATETIME.getValue(), FormFieldTypeEnum.DATE.getValue()
|
||||
);
|
||||
private ObservableList<String> singleSelect = FXCollections.observableArrayList(
|
||||
"",
|
||||
|
@ -47,6 +47,7 @@ public class FieldService {
|
||||
private ObservableList<FieldVO> fields = FXCollections.observableArrayList();
|
||||
private TableView tableView;
|
||||
private String tableName;
|
||||
private String tableNamePrefix;
|
||||
private Stage fieldStage;
|
||||
|
||||
/**
|
||||
@ -69,7 +70,7 @@ public class FieldService {
|
||||
} else if (StringUtils.equalsIgnoreCase(ColumnDataTypeEnum.TEXT.getValue(), columnDataType)) {
|
||||
return FormFieldTypeEnum.TEXTAREA.getValue();
|
||||
} else if (StringUtils.equalsIgnoreCase(ColumnDataTypeEnum.LONGTEXT.getValue(), columnDataType)) {
|
||||
return FormFieldTypeEnum.RICH_TEXT.getValue();
|
||||
return FormFieldTypeEnum.RICH_TEXT.getValue();
|
||||
} else if (StringUtils.equalsIgnoreCase(ColumnDataTypeEnum.CHAR.getValue(), columnDataType)) {
|
||||
return FormFieldTypeEnum.ID_SELECT.getValue();
|
||||
}
|
||||
@ -114,11 +115,13 @@ public class FieldService {
|
||||
continue;
|
||||
}
|
||||
FieldVO fieldVO = new FieldVO();
|
||||
fieldVO.setTableName(tableName);
|
||||
fieldVO.setTableNamePrefix(tableNamePrefix);
|
||||
fieldVO.setRowNumber(fieldIndex);
|
||||
fieldVO.setColumnName(columnName);
|
||||
fieldVO.setColumnType(field.get("COLUMN_TYPE").toString());
|
||||
fieldVO.setDataType(field.get("DATA_TYPE").toString());
|
||||
fieldVO.setCharacterMaximum(field.get("CHARACTER_MAXIMUM_LENGTH") == null ? 0 : Integer.valueOf(field.get("CHARACTER_MAXIMUM_LENGTH").toString()));
|
||||
fieldVO.setCharacterMaximum(field.get("CHARACTER_MAXIMUM_LENGTH") == null ? 0 : Long.valueOf(field.get("CHARACTER_MAXIMUM_LENGTH").toString()));
|
||||
fieldVO.setNumericPrecision(field.get("NUMERIC_PRECISION") == null ? 0 : Integer.valueOf(field.get("NUMERIC_PRECISION").toString()));
|
||||
fieldVO.setNumericScale(field.get("NUMERIC_SCALE") == null ? 0 : Integer.valueOf(field.get("NUMERIC_SCALE").toString()));
|
||||
fieldVO.setColumnComment(field.get("COLUMN_COMMENT") == null ? "" : field.get("COLUMN_COMMENT").toString());
|
||||
@ -170,6 +173,14 @@ public class FieldService {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public String getTableNamePrefix() {
|
||||
return tableNamePrefix == null ? "" : tableNamePrefix.trim();
|
||||
}
|
||||
|
||||
public void setTableNamePrefix(String tableNamePrefix) {
|
||||
this.tableNamePrefix = tableNamePrefix;
|
||||
}
|
||||
|
||||
public void removeField(String columnName) {
|
||||
new Service<Integer>() {
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package ink.wgink.code.factory.service;
|
||||
|
||||
import freemarker.cache.ClassTemplateLoader;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
import ink.wgink.code.factory.enums.FormFieldTypeEnum;
|
||||
import ink.wgink.code.factory.utils.DateUtil;
|
||||
import ink.wgink.code.factory.utils.MsgUtil;
|
||||
import ink.wgink.code.factory.utils.WStringUtil;
|
||||
@ -18,10 +18,7 @@ import javafx.stage.Stage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.io.*;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -41,6 +38,7 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
public class GenerateService {
|
||||
|
||||
public static final String UTF_8 = "UTF-8";
|
||||
private Stage fieldStage;
|
||||
private TableView tableView;
|
||||
Configuration freemarkerConfiguration = new Configuration(Configuration.getVersion());
|
||||
@ -53,7 +51,7 @@ public class GenerateService {
|
||||
// this.freemarkerConfiguration.setTemplateLoader(new ClassTemplateLoader(this.getClass(), "/template"));
|
||||
// 3.加载 jar中的模板
|
||||
this.freemarkerConfiguration.setClassForTemplateLoading(this.getClass(), "/template");
|
||||
this.freemarkerConfiguration.setDefaultEncoding("utf-8");
|
||||
this.freemarkerConfiguration.setDefaultEncoding(UTF_8);
|
||||
}
|
||||
|
||||
public void generateCode(TableVO tableVO, GenerateVO generateVO) throws IOException, TemplateException {
|
||||
@ -68,20 +66,24 @@ public class GenerateService {
|
||||
String tableFullName = tableVO.getTableName();
|
||||
String tableNameWithoutPrefix = tableFullName.replaceFirst(generateVO.getTablePrefix(), "");
|
||||
String tableName = WStringUtil.underLine2LowerUpper(tableNameWithoutPrefix);
|
||||
String underlineTableName = WStringUtil.lowerUpper2UnderLine(tableName);
|
||||
// 首字母大写驼峰表名
|
||||
String firstUpperTableName = WStringUtil.firstToUpper(tableName);
|
||||
// 首字母小写驼峰表明
|
||||
String firstLowerTableName = WStringUtil.firstToLower(tableName);
|
||||
String lowerTableName = tableNameWithoutPrefix.replaceAll("\\_", "").toLowerCase();
|
||||
String requestMappingName = tableNameWithoutPrefix.replaceAll("\\_", "-").toLowerCase();
|
||||
Map<String, Object> dataModel = new HashMap<>(16);
|
||||
dataModel.put("context", generateVO.getContext());
|
||||
dataModel.put("codePackage", generateVO.getCodePackage());
|
||||
dataModel.put("tableNameWithoutPrefix", tableNameWithoutPrefix);
|
||||
dataModel.put("lowerTableName", lowerTableName);
|
||||
dataModel.put("requestMappingName", requestMappingName);
|
||||
dataModel.put("tableName", tableName);
|
||||
dataModel.put("tableFullName", tableFullName);
|
||||
dataModel.put("firstUpperTableName", firstUpperTableName);
|
||||
dataModel.put("firstLowerTableName", firstLowerTableName);
|
||||
dataModel.put("underlineTableName", underlineTableName);
|
||||
dataModel.put("tableExplain", tableVO.getTableComment());
|
||||
dataModel.put("author", "CodeFactory");
|
||||
dataModel.put("date", DateUtil.getTime());
|
||||
@ -107,13 +109,13 @@ public class GenerateService {
|
||||
iDaoCode("/normal/dao/i-dao.ftl", String.format("%s/dao/%s", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
}
|
||||
if (generateVO.getHasMySQL()) {
|
||||
mySqlMapperCode("/normal/mapper/mysql-mapper.ftl", String.format("%s/mapper/%s", outFolder, tableName), tableName, dataModel);
|
||||
mySqlMapperCode("/normal/mapper/mysql-mapper.ftl", String.format("%s/mapper/%s", outFolder, requestMappingName), tableName, dataModel);
|
||||
}
|
||||
if (generateVO.getHasHtml()) {
|
||||
htmlCode("/normal/page", String.format("%s/static/route/%s", outFolder, tableName), tableName, dataModel);
|
||||
htmlCode("/normal/page", String.format("%s/static/route/%s", outFolder, requestMappingName), tableName, dataModel);
|
||||
}
|
||||
if (generateVO.getHasThymeleaf()) {
|
||||
thymeleafCode("/normal/page", String.format("%s/templates/%s", outFolder, tableName), tableName, dataModel);
|
||||
thymeleafCode("/normal/page", String.format("%s/templates/%s", outFolder, requestMappingName), tableName, dataModel);
|
||||
}
|
||||
if (generateVO.getHasRoute()) {
|
||||
routeCode("/normal/controller/route-controller.ftl", String.format("%s/controller/route/%s", outFolder, lowerTableName), firstUpperTableName, dataModel);
|
||||
@ -132,16 +134,27 @@ public class GenerateService {
|
||||
*/
|
||||
private void initFieldList(String tableNameWithoutPrefix, Map<String, Object> dataModel, ObservableList<FieldVO> fields) {
|
||||
List<Map<String, Object>> fieldList = new ArrayList<>();
|
||||
String idColumn = null;
|
||||
boolean hasId = false;
|
||||
boolean idFormShow = false;
|
||||
boolean hasGmtCreate = false;
|
||||
boolean hasCreator = false;
|
||||
boolean hasGmtModified = false;
|
||||
boolean gmtModifiedFormShow = false;
|
||||
boolean hasModifier = false;
|
||||
boolean modifierFormShow = false;
|
||||
boolean hasIsDelete = false;
|
||||
boolean hasFile = false;
|
||||
boolean hasImage = false;
|
||||
boolean hasVideo = false;
|
||||
boolean hasAudio = false;
|
||||
boolean hasRichText = false;
|
||||
for (int i = 0; i < fields.size(); i++) {
|
||||
FieldVO field = fields.get(i);
|
||||
if (!hasId && StringUtils.equals(String.format("%s_id", tableNameWithoutPrefix), field.getColumnName())) {
|
||||
hasId = true;
|
||||
idColumn = field.getColumnName();
|
||||
idFormShow = field.getFormShow();
|
||||
}
|
||||
if (!hasGmtCreate && StringUtils.equals(FieldService.DEFAULT_FIELD_GMT_CREATE, field.getPropertyName())) {
|
||||
hasGmtCreate = true;
|
||||
@ -151,13 +164,30 @@ public class GenerateService {
|
||||
}
|
||||
if (!hasGmtModified && StringUtils.equals(FieldService.DEFAULT_FIELD_GMT_MODIFIED, field.getPropertyName())) {
|
||||
hasGmtModified = true;
|
||||
gmtModifiedFormShow = field.getFormShow();
|
||||
}
|
||||
if (!hasModifier && StringUtils.equals(FieldService.DEFAULT_FIELD_MODIFIER, field.getPropertyName())) {
|
||||
hasModifier = true;
|
||||
modifierFormShow = field.getFormShow();
|
||||
}
|
||||
if (!hasIsDelete && StringUtils.equals(FieldService.DEFAULT_FIELD_IS_DELETE, field.getPropertyName())) {
|
||||
hasIsDelete = true;
|
||||
}
|
||||
if (!hasFile && StringUtils.equals(FormFieldTypeEnum.FILE.getValue(), field.getFormFieldValue())) {
|
||||
hasFile = true;
|
||||
}
|
||||
if (!hasImage && StringUtils.equals(FormFieldTypeEnum.IMAGE.getValue(), field.getFormFieldValue())) {
|
||||
hasImage = true;
|
||||
}
|
||||
if (!hasVideo && StringUtils.equals(FormFieldTypeEnum.VIDEO.getValue(), field.getFormFieldValue())) {
|
||||
hasVideo = true;
|
||||
}
|
||||
if (!hasAudio && StringUtils.equals(FormFieldTypeEnum.AUDIO.getValue(), field.getFormFieldValue())) {
|
||||
hasAudio = true;
|
||||
}
|
||||
if (!hasRichText && StringUtils.equals(FormFieldTypeEnum.RICH_TEXT.getValue(), field.getFormFieldValue())) {
|
||||
hasRichText = true;
|
||||
}
|
||||
Map<String, Object> fieldMap = new HashMap<>(16);
|
||||
fieldMap.put("columnName", field.getColumnName());
|
||||
fieldMap.put("propertyName", field.getPropertyName());
|
||||
@ -176,13 +206,22 @@ public class GenerateService {
|
||||
fieldMap.put("fieldSplit", fieldSplit);
|
||||
fieldList.add(fieldMap);
|
||||
}
|
||||
dataModel.put("idColumn", idColumn);
|
||||
dataModel.put("hasId", hasId);
|
||||
dataModel.put("idFormShow", idFormShow);
|
||||
dataModel.put("hasGmtCreate", hasGmtCreate);
|
||||
dataModel.put("hasCreator", hasCreator);
|
||||
dataModel.put("hasGmtModified", hasGmtModified);
|
||||
dataModel.put("gmtModifiedFormShow", gmtModifiedFormShow);
|
||||
dataModel.put("hasModifier", hasModifier);
|
||||
dataModel.put("modifierFormShow", modifierFormShow);
|
||||
dataModel.put("hasIsDelete", hasIsDelete);
|
||||
dataModel.put("fieldList", fieldList);
|
||||
dataModel.put("hasFile", hasFile);
|
||||
dataModel.put("hasImage", hasImage);
|
||||
dataModel.put("hasVideo", hasVideo);
|
||||
dataModel.put("hasAudio", hasAudio);
|
||||
dataModel.put("hasRichText", hasRichText);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -308,7 +347,7 @@ public class GenerateService {
|
||||
if (!folder.exists()) {
|
||||
folder.mkdirs();
|
||||
}
|
||||
code(templateFtl, String.format("%s/%s-mapper.xml", outFolder, tableName), dataModel);
|
||||
code(templateFtl, String.format("%s/%s-mapper.xml", outFolder, WStringUtil.lowerUpper2Separator(tableName, "-")), dataModel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -455,8 +494,8 @@ public class GenerateService {
|
||||
* @throws TemplateException
|
||||
*/
|
||||
private void code(String templateFtl, String outFile, Map<String, Object> dataModel) throws IOException, TemplateException {
|
||||
Template template = freemarkerConfiguration.getTemplate(templateFtl);
|
||||
Writer out = new FileWriter(outFile);
|
||||
Template template = freemarkerConfiguration.getTemplate(templateFtl, UTF_8);
|
||||
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), UTF_8));
|
||||
template.process(dataModel, out);
|
||||
out.close();
|
||||
}
|
||||
|
@ -138,15 +138,31 @@ public class WStringUtil {
|
||||
* @date 2018年2月28日 下午4:28:45
|
||||
*/
|
||||
public static String lowerUpper2UnderLine(String str) {
|
||||
return lowerUpper2Separator(str, "-");
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* title 驼峰名称转分隔符名称
|
||||
* </p>
|
||||
* <p>
|
||||
* description 驼峰名称转小写名称用分隔符名称
|
||||
* </p>
|
||||
*
|
||||
* @param str
|
||||
* @param separator
|
||||
* @return
|
||||
*/
|
||||
public static String lowerUpper2Separator(String str, String separator) {
|
||||
Matcher matcher = LOWER_UPPER_PATTERN.matcher(str);
|
||||
while (matcher.find()) {
|
||||
String group = matcher.group();
|
||||
String lower = "_" + group.toLowerCase();
|
||||
String lower = separator + group.toLowerCase();
|
||||
str = str.replaceFirst(group, lower);
|
||||
matcher = LOWER_UPPER_PATTERN.matcher(str);
|
||||
}
|
||||
if (str.startsWith("_")) {
|
||||
str = str.substring(1, str.length());
|
||||
if (str.startsWith(separator)) {
|
||||
str = str.substring(1);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
@ -167,7 +183,23 @@ public class WStringUtil {
|
||||
* @date 2018年2月28日 下午4:49:13
|
||||
*/
|
||||
public static String underLine2LowerUpper(String str) {
|
||||
String[] strs = str.split("_");
|
||||
return separator2LowerUpper(str, "_");
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* title 分割符转驼峰式
|
||||
* </p>
|
||||
* <p>
|
||||
* description 分割符转驼峰式
|
||||
* </p>
|
||||
*
|
||||
* @param str 字符串
|
||||
* @param separator 分隔符
|
||||
* @return
|
||||
*/
|
||||
public static String separator2LowerUpper(String str, String separator) {
|
||||
String[] strs = str.split(separator);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < strs.length; i++) {
|
||||
String letter = strs[i].toLowerCase();
|
||||
@ -208,7 +240,29 @@ public class WStringUtil {
|
||||
String result = underLine2LowerUpper(str);
|
||||
if (firstLower) {
|
||||
int first = result.charAt(0) + 32;
|
||||
result = ((char) first) + result.substring(1, result.length());
|
||||
result = ((char) first) + result.substring(1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* title 分隔符转驼峰式
|
||||
* </p>
|
||||
* <p>
|
||||
* description 分隔符转驼峰式
|
||||
* </p>
|
||||
*
|
||||
* @param str 字符串
|
||||
* @param separator 分隔符
|
||||
* @param firstLower 首字母小写
|
||||
* @return
|
||||
*/
|
||||
public static String separator2LowerUpper(String str, String separator, boolean firstLower) {
|
||||
String result = separator2LowerUpper(str, separator);
|
||||
if (firstLower) {
|
||||
int first = result.charAt(0) + 32;
|
||||
result = ((char) first) + result.substring(1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ink.wgink.code.factory.vos;
|
||||
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleLongProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
/**
|
||||
@ -21,17 +22,19 @@ public class FieldVO {
|
||||
private SimpleStringProperty columnDefault;
|
||||
private String dataType;
|
||||
private SimpleStringProperty columnType;
|
||||
private Integer characterMaximum;
|
||||
private Long characterMaximum;
|
||||
private Integer numericPrecision;
|
||||
private Integer numericScale;
|
||||
private SimpleStringProperty propertyName;
|
||||
private SimpleStringProperty propertyType;
|
||||
private SimpleIntegerProperty propertyLength;
|
||||
private SimpleLongProperty propertyLength;
|
||||
private String formFieldType;
|
||||
private String formFieldValue;
|
||||
private Boolean isFormShow;
|
||||
private Boolean isListShow;
|
||||
private Boolean isNotNull;
|
||||
private String tableName;
|
||||
private String tableNamePrefix;
|
||||
|
||||
public FieldVO() {
|
||||
this.rowNumber = new SimpleIntegerProperty(0);
|
||||
@ -41,7 +44,7 @@ public class FieldVO {
|
||||
this.columnType = new SimpleStringProperty();
|
||||
this.propertyName = new SimpleStringProperty();
|
||||
this.propertyType = new SimpleStringProperty();
|
||||
this.propertyLength = new SimpleIntegerProperty(0);
|
||||
this.propertyLength = new SimpleLongProperty(0);
|
||||
}
|
||||
|
||||
public int getRowNumber() {
|
||||
@ -112,11 +115,11 @@ public class FieldVO {
|
||||
this.columnType.set(columnType);
|
||||
}
|
||||
|
||||
public Integer getCharacterMaximum() {
|
||||
public Long getCharacterMaximum() {
|
||||
return characterMaximum;
|
||||
}
|
||||
|
||||
public void setCharacterMaximum(Integer characterMaximum) {
|
||||
public void setCharacterMaximum(Long characterMaximum) {
|
||||
this.characterMaximum = characterMaximum;
|
||||
}
|
||||
|
||||
@ -160,15 +163,15 @@ public class FieldVO {
|
||||
this.propertyType.set(propertyType);
|
||||
}
|
||||
|
||||
public int getPropertyLength() {
|
||||
public long getPropertyLength() {
|
||||
return propertyLength.get();
|
||||
}
|
||||
|
||||
public SimpleIntegerProperty propertyLengthProperty() {
|
||||
public SimpleLongProperty propertyLengthProperty() {
|
||||
return propertyLength;
|
||||
}
|
||||
|
||||
public void setPropertyLength(int propertyLength) {
|
||||
public void setPropertyLength(long propertyLength) {
|
||||
this.propertyLength.set(propertyLength);
|
||||
}
|
||||
|
||||
@ -212,44 +215,20 @@ public class FieldVO {
|
||||
isNotNull = notNull;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"rowNumber\":")
|
||||
.append(rowNumber);
|
||||
sb.append(",\"columnName\":")
|
||||
.append(columnName);
|
||||
sb.append(",\"columnComment\":")
|
||||
.append(columnComment);
|
||||
sb.append(",\"columnDefault\":")
|
||||
.append(columnDefault);
|
||||
sb.append(",\"dataType\":\"")
|
||||
.append(dataType).append('\"');
|
||||
sb.append(",\"columnType\":")
|
||||
.append(columnType);
|
||||
sb.append(",\"characterMaximum\":")
|
||||
.append(characterMaximum);
|
||||
sb.append(",\"numericPrecision\":")
|
||||
.append(numericPrecision);
|
||||
sb.append(",\"numericScale\":")
|
||||
.append(numericScale);
|
||||
sb.append(",\"propertyName\":")
|
||||
.append(propertyName);
|
||||
sb.append(",\"propertyType\":")
|
||||
.append(propertyType);
|
||||
sb.append(",\"propertyLength\":")
|
||||
.append(propertyLength);
|
||||
sb.append(",\"formFieldType\":\"")
|
||||
.append(formFieldType).append('\"');
|
||||
sb.append(",\"formFieldValue\":\"")
|
||||
.append(formFieldValue).append('\"');
|
||||
sb.append(",\"isFormShow\":")
|
||||
.append(isFormShow);
|
||||
sb.append(",\"isListShow\":")
|
||||
.append(isListShow);
|
||||
sb.append(",\"isNotNull\":")
|
||||
.append(isNotNull);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
public String getTableName() {
|
||||
return tableName == null ? "" : tableName.trim();
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public String getTableNamePrefix() {
|
||||
return tableNamePrefix == null ? "" : tableNamePrefix.trim();
|
||||
}
|
||||
|
||||
public void setTableNamePrefix(String tableNamePrefix) {
|
||||
this.tableNamePrefix = tableNamePrefix;
|
||||
}
|
||||
|
||||
}
|
||||
|
3
src/main/resources/META-INF/MANIFEST.MF
Normal file
3
src/main/resources/META-INF/MANIFEST.MF
Normal file
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: ink.wgink.code.factory.StartUp
|
||||
|
8
src/main/resources/log4j.properties
Normal file
8
src/main/resources/log4j.properties
Normal file
@ -0,0 +1,8 @@
|
||||
log4j.logger.info=debug
|
||||
log4j.appender.info=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.info.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.info.layout.ConversionPattern=%d{yyyy-MM-dd-HH-mm} [%t] [%c] [%p] - %m%n
|
||||
log4j.appender.info.datePattern='.'yyyy-MM-dd
|
||||
log4j.appender.info.Threshold = info
|
||||
log4j.appender.info.append=true
|
||||
# log4j.appender.info.File=/mylog/info.log
|
@ -28,7 +28,7 @@ import java.util.Map;
|
||||
**/
|
||||
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "${tableExplain}接口")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.API_PREFIX + "/${lowerTableName}")
|
||||
@RequestMapping(ISystemConstant.API_PREFIX + "/${requestMappingName}")
|
||||
public class ${firstUpperTableName}Controller extends DefaultBaseController {
|
||||
|
||||
@Autowired
|
||||
|
@ -28,7 +28,7 @@ import java.util.Map;
|
||||
**/
|
||||
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "${tableExplain}接口")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.APP_PREFIX + "/${lowerTableName}")
|
||||
@RequestMapping(ISystemConstant.APP_PREFIX + "/${requestMappingName}")
|
||||
public class ${firstUpperTableName}AppController extends DefaultBaseController {
|
||||
|
||||
@Autowired
|
||||
@ -64,7 +64,7 @@ public class ${firstUpperTableName}AppController extends DefaultBaseController {
|
||||
@ApiImplicitParam(name = "${firstLowerTableName}Id", value = "${tableExplain}ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("update${lowerTableName}/{${firstLowerTableName}Id}")
|
||||
@PutMapping("update/{${firstLowerTableName}Id}")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult update${firstUpperTableName}(@RequestHeader("token") String token, @PathVariable("${firstLowerTableName}Id") String ${firstLowerTableName}Id, @RequestBody ${firstUpperTableName}VO ${firstLowerTableName}VO) {
|
||||
${firstLowerTableName}Service.update(token, ${firstLowerTableName}Id, ${firstLowerTableName}VO);
|
||||
@ -103,7 +103,7 @@ public class ${firstUpperTableName}AppController extends DefaultBaseController {
|
||||
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage${lowerTableName}")
|
||||
@GetMapping("listpage")
|
||||
public SuccessResultList<List<${firstUpperTableName}DTO>> listPage(@RequestHeader("token") String token, ListPage page) {
|
||||
Map<String, Object> params = requestParams();
|
||||
page.setParams(params);
|
||||
|
@ -28,7 +28,7 @@ import java.util.Map;
|
||||
**/
|
||||
@Api(tags = ISystemConstant.API_TAGS_RESOURCE_PREFIX + "${tableExplain}接口")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.RESOURCE_PREFIX + "/${lowerTableName}")
|
||||
@RequestMapping(ISystemConstant.RESOURCE_PREFIX + "/${requestMappingName}")
|
||||
public class ${firstUpperTableName}ResourceController extends DefaultBaseController {
|
||||
|
||||
@Autowired
|
||||
|
@ -21,22 +21,22 @@ import java.util.Map;
|
||||
**/
|
||||
@Api(tags = ISystemConstant.ROUTE_TAGS_PREFIX + "${tableExplain}路由")
|
||||
@RestController
|
||||
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/${lowerTableName}")
|
||||
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/${requestMappingName}")
|
||||
public class ${firstUpperTableName}RouteController extends DefaultBaseController {
|
||||
|
||||
@GetMapping("save")
|
||||
public ModelAndView save() {
|
||||
return new ModelAndView("${lowerTableName}/save");
|
||||
return new ModelAndView("${requestMappingName}/save");
|
||||
}
|
||||
|
||||
@GetMapping("update")
|
||||
public ModelAndView update() {
|
||||
return new ModelAndView("${lowerTableName}/update");
|
||||
return new ModelAndView("${requestMappingName}/update");
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public ModelAndView list() {
|
||||
return new ModelAndView("${lowerTableName}/list");
|
||||
return new ModelAndView("${requestMappingName}/list");
|
||||
}
|
||||
|
||||
}
|
@ -50,7 +50,7 @@
|
||||
is_delete = 1
|
||||
WHERE
|
||||
<#if hasId>
|
||||
${tableName}_id IN
|
||||
${idColumn} IN
|
||||
<foreach collection="${firstLowerTableName}Ids" index="index" open="(" separator="," close=")">
|
||||
${r"#{"}${firstLowerTableName}${r"Ids[${index}]}"}
|
||||
</foreach>
|
||||
@ -66,7 +66,7 @@
|
||||
${tableFullName}
|
||||
WHERE
|
||||
<#if hasId>
|
||||
${tableName}_id IN
|
||||
${idColumn} IN
|
||||
<foreach collection="${firstLowerTableName}Ids" index="index" open="(" separator="," close=")">
|
||||
${r"#{"}${firstLowerTableName}${r"Ids[${index}]}"}
|
||||
</foreach>
|
||||
@ -81,36 +81,44 @@
|
||||
${tableFullName}
|
||||
SET
|
||||
<#list fieldList! as field>
|
||||
<#if field.listShow>
|
||||
<#if field.formFieldValue == "number" || field.formFieldValue == "double">
|
||||
<if test="${field.propertyName} != null">
|
||||
<#if field.formShow>
|
||||
<#if field.formFieldValue == "number" || field.formFieldValue == "double">
|
||||
<if test="${field.propertyName} != null">
|
||||
${field.columnName} = ${r"#{"}${field.propertyName}${r"}"},
|
||||
</if>
|
||||
<#elseif field.formFieldValue == "radio" || field.formFieldValue == "checkbox" || field.formFieldValue == "select">
|
||||
<if test="${field.propertyName} != null">
|
||||
</if>
|
||||
<#elseif field.formFieldValue == "radio" || field.formFieldValue == "checkbox" || field.formFieldValue == "select">
|
||||
<if test="${field.propertyName} != null">
|
||||
${field.columnName} = ${r"#{"}${field.propertyName}${r"}"},
|
||||
</if>
|
||||
<#else>
|
||||
<if test="${field.propertyName} != null and ${field.propertyName} != ''">
|
||||
</if>
|
||||
<#else>
|
||||
<#if hasId>
|
||||
<#if field.columnName != idColumn>
|
||||
<if test="${field.propertyName} != null and ${field.propertyName} != ''">
|
||||
${field.columnName} = ${r"#{"}${field.propertyName}${r"}"},
|
||||
</if>
|
||||
</#if>
|
||||
<#if hasGmtModified>
|
||||
gmt_modified = ${r"#{gmtModified}"},
|
||||
</#if>
|
||||
<#if hasModifier>
|
||||
modifier = ${r"#{modifier}"},
|
||||
</#if>
|
||||
</#if>
|
||||
<#if hasId>
|
||||
${tableName}_id = ${tableName}_id
|
||||
<#else>
|
||||
<!-- 填充条件 -->
|
||||
</if>
|
||||
</#if>
|
||||
<#else>
|
||||
<if test="${field.propertyName} != null and ${field.propertyName} != ''">
|
||||
${field.columnName} = ${r"#{"}${field.propertyName}${r"}"},
|
||||
</if>
|
||||
</#if>
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
<#if hasGmtModified && !gmtModifiedFormShow>
|
||||
gmt_modified = ${r"#{gmtModified}"},
|
||||
</#if>
|
||||
<#if hasModifier && !modifierFormShow>
|
||||
modifier = ${r"#{modifier}"},
|
||||
</#if>
|
||||
<#if hasId>
|
||||
${idColumn} = ${idColumn}
|
||||
<#else>
|
||||
<!-- 填充条件 -->
|
||||
</#if>
|
||||
WHERE
|
||||
<#if hasId>
|
||||
${tableName}_id = ${r"#{"}${firstLowerTableName}${r"Id}"}
|
||||
${idColumn} = ${r"#{"}${firstLowerTableName}${r"Id}"}
|
||||
<#else>
|
||||
<!-- 添加条件 -->
|
||||
</#if>
|
||||
@ -125,7 +133,7 @@
|
||||
</#if>
|
||||
</#list>
|
||||
<#if hasId>
|
||||
t1.${tableName}_id
|
||||
t1.${idColumn}
|
||||
<#else>
|
||||
1
|
||||
</#if>
|
||||
@ -140,7 +148,7 @@
|
||||
<#if hasId>
|
||||
<if test="${firstLowerTableName}Id != null and ${firstLowerTableName}Id != ''">
|
||||
AND
|
||||
t1.${tableName}_id = ${r"#{"}${firstLowerTableName}${r"Id}"}
|
||||
t1.${idColumn} = ${r"#{"}${firstLowerTableName}${r"Id}"}
|
||||
</if>
|
||||
<#else>
|
||||
<!-- 添加条件 -->
|
||||
@ -164,7 +172,7 @@
|
||||
<#if hasId>
|
||||
<if test="${firstLowerTableName}Id != null and ${firstLowerTableName}Id != ''">
|
||||
AND
|
||||
t1.${tableName}_id = ${r"#{"}${firstLowerTableName}${r"Id}"}
|
||||
t1.${idColumn} = ${r"#{"}${firstLowerTableName}${r"Id}"}
|
||||
</if>
|
||||
<#else>
|
||||
<!-- 添加条件 -->
|
||||
@ -188,7 +196,7 @@
|
||||
<#if hasId>
|
||||
<if test="${firstLowerTableName}Id != null and ${firstLowerTableName}Id != ''">
|
||||
AND
|
||||
t1.${tableName}_id = ${r"#{"}${firstLowerTableName}${r"Id}"}
|
||||
t1.${idColumn} = ${r"#{"}${firstLowerTableName}${r"Id}"}
|
||||
</if>
|
||||
<#else>
|
||||
<!-- 添加条件 -->
|
||||
@ -231,7 +239,7 @@
|
||||
<#if hasId>
|
||||
<if test="${firstLowerTableName}Ids != null and ${firstLowerTableName}Ids.size > 0">
|
||||
AND
|
||||
t1.${tableName}_id IN
|
||||
t1.${idColumn} IN
|
||||
<foreach collection="${firstLowerTableName}Ids" index="index" open="(" separator="," close=")">
|
||||
${r"#{"}${firstLowerTableName}${r"Ids[${index}]}"}
|
||||
</foreach>
|
||||
@ -272,7 +280,7 @@
|
||||
<#if hasId>
|
||||
<if test="${firstLowerTableName}Ids != null and ${firstLowerTableName}Ids.size > 0">
|
||||
AND
|
||||
t1.${tableName}_id IN
|
||||
t1.${idColumn} IN
|
||||
<foreach collection="${firstLowerTableName}Ids" index="index" open="(" separator="," close=")">
|
||||
${r"#{"}${firstLowerTableName}${r"Ids[${index}]}"}
|
||||
</foreach>
|
||||
@ -313,7 +321,7 @@
|
||||
<#if hasId>
|
||||
<if test="${firstLowerTableName}Ids != null and ${firstLowerTableName}Ids.size > 0">
|
||||
AND
|
||||
t1.${tableName}_id IN
|
||||
t1.${idColumn} IN
|
||||
<foreach collection="${firstLowerTableName}Ids" index="index" open="(" separator="," close=")">
|
||||
${r"#{"}${firstLowerTableName}${r"Ids[${index}]}"}
|
||||
</foreach>
|
||||
|
@ -28,13 +28,14 @@
|
||||
<div class="layui-card-body">
|
||||
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="keywords" class="layui-input search-item" placeholder="输入关键字">
|
||||
<input type="text" id="keywords" class="layui-input search-item search-item-width-100" placeholder="输入关键字">
|
||||
</div>
|
||||
新增时间
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="startTime" class="layui-input search-item search-item-width-100" placeholder="开始时间" readonly>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="startTime" class="layui-input search-item" placeholder="开始时间" readonly>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="endTime" class="layui-input search-item" placeholder="结束时间" readonly>
|
||||
<input type="text" id="endTime" class="layui-input search-item search-item-width-100" placeholder="结束时间" readonly>
|
||||
</div>
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
@ -75,7 +76,7 @@
|
||||
var laydate = layui.laydate;
|
||||
var common = layui.common;
|
||||
var resizeTimeout = null;
|
||||
var tableUrl = 'api/${lowerTableName}/listpage';
|
||||
var tableUrl = 'api/${requestMappingName}/listpage';
|
||||
|
||||
// 初始化表格
|
||||
function initTable() {
|
||||
@ -141,7 +142,6 @@
|
||||
// 重载表格
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
url: top.restAjax.path(tableUrl, []),
|
||||
where: {
|
||||
keywords: $('#keywords').val(),
|
||||
startTime: $('#startTime').val(),
|
||||
@ -150,7 +150,6 @@
|
||||
page: {
|
||||
curr: currentPage
|
||||
},
|
||||
height: $win.height() - 90,
|
||||
});
|
||||
}
|
||||
// 初始化日期
|
||||
@ -174,7 +173,7 @@
|
||||
yes: function (index) {
|
||||
top.dialog.close(index);
|
||||
var layIndex;
|
||||
top.restAjax.delete(top.restAjax.path('api/${lowerTableName}/remove/{ids}', [ids]), {}, null, function (code, data) {
|
||||
top.restAjax.delete(top.restAjax.path('api/${requestMappingName}/remove/{ids}', [ids]), {}, null, function (code, data) {
|
||||
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
|
||||
reloadTable();
|
||||
}, function (code, data) {
|
||||
@ -213,7 +212,7 @@
|
||||
area: ['100%', '100%'],
|
||||
shadeClose: true,
|
||||
anim: 2,
|
||||
content: top.restAjax.path('route/${lowerTableName}/save<#if html>.html</#if>', []),
|
||||
content: top.restAjax.path('route/${requestMappingName}/save<#if html>.html</#if>', []),
|
||||
end: function() {
|
||||
reloadTable();
|
||||
}
|
||||
@ -231,7 +230,7 @@
|
||||
area: ['100%', '100%'],
|
||||
shadeClose: true,
|
||||
anim: 2,
|
||||
content: top.restAjax.path('route/${lowerTableName}/update<#if html>.html</#if>?${firstLowerTableName}Id={${firstLowerTableName}Id}', [checkDatas[0].${firstLowerTableName}Id]),
|
||||
content: top.restAjax.path('route/${requestMappingName}/update<#if html>.html</#if>?${firstLowerTableName}Id={${firstLowerTableName}Id}', [checkDatas[0].${firstLowerTableName}Id]),
|
||||
end: function() {
|
||||
reloadTable();
|
||||
}
|
||||
|
@ -19,7 +19,9 @@
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
<#if hasImage>
|
||||
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
|
||||
</#if>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||
@ -81,6 +83,13 @@
|
||||
{{# } }}
|
||||
</select>
|
||||
</script>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "staticCheckbox">
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block layui-form" lay-filter="${field.propertyName}CheckboxTemplateBox">
|
||||
<input type="checkbox" name="${field.propertyName}" value="">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "checkbox">
|
||||
<div class="layui-form-item" pane>
|
||||
@ -91,6 +100,13 @@
|
||||
<input type="checkbox" name="${field.propertyName}[{{item.selectId}}]" value="{{item.selectId}}" title="{{item.selectName}}">
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "staticRadio">
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block layui-form">
|
||||
<input type="radio" name="${field.propertyName}" value="">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "radio">
|
||||
<div class="layui-form-item" pane>
|
||||
@ -281,28 +297,39 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<#if hasRichText>
|
||||
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
|
||||
</#if>
|
||||
<#if hasVideo>
|
||||
<script src="assets/js/vendor/ckplayer/ckplayer/ckplayer.js"></script>
|
||||
</#if>
|
||||
<#if hasImage>
|
||||
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
||||
</#if>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||
}).extend({
|
||||
index: 'lib/index' //主入口模块
|
||||
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||||
}).use(['index', 'form', 'laydate', 'laytpl', 'upload'], function(){
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
var laytpl = layui.laytpl;
|
||||
var laydate = layui.laydate;
|
||||
<#if hasRichText>
|
||||
var wangEditor = window.wangEditor;
|
||||
var wangEditorObj = {};
|
||||
</#if>
|
||||
<#if hasImage>
|
||||
var viewerObj = {};
|
||||
</#if>
|
||||
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
<#if hasFile || hasImage>
|
||||
function refreshDownloadTemplet(fileName, file) {
|
||||
var dataRander = {};
|
||||
dataRander[fileName] = file;
|
||||
@ -337,7 +364,9 @@
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if hasVideo>
|
||||
// 初始化视频
|
||||
function initVideo(fileName, data) {
|
||||
for(var i = 0, item; item = data[i++];) {
|
||||
@ -352,6 +381,7 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow>
|
||||
@ -710,7 +740,7 @@
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
top.restAjax.post(top.restAjax.path('api/${lowerTableName}/save', []), formData.field, null, function(code, data) {
|
||||
top.restAjax.post(top.restAjax.path('api/${requestMappingName}/save', []), formData.field, null, function(code, data) {
|
||||
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
|
@ -19,7 +19,9 @@
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
<#if hasImage>
|
||||
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
|
||||
</#if>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||
@ -68,6 +70,13 @@
|
||||
<div class="layui-input-block">
|
||||
<div id="${field.propertyName}"></div>
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "staticSelect">
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block layui-form" lay-filter="${field.propertyName}CheckboxTemplateBox">
|
||||
<input type="checkbox" name="${field.propertyName}" value="">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "select">
|
||||
<div class="layui-form-item">
|
||||
@ -91,6 +100,13 @@
|
||||
<input type="checkbox" name="${field.propertyName}[{{item.selectId}}]" value="{{item.selectId}}" title="{{item.selectName}}">
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "staticRadio">
|
||||
<div class="layui-form-item" pane>
|
||||
<label class="layui-form-label">${field.columnComment}</label>
|
||||
<div class="layui-input-block layui-form">
|
||||
<input type="radio" name="${field.propertyName}" value="">
|
||||
</div>
|
||||
</div>
|
||||
<#elseif field.formFieldValue == "radio">
|
||||
<div class="layui-form-item" pane>
|
||||
@ -281,30 +297,41 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<#if hasRichText>
|
||||
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
|
||||
</#if>
|
||||
<#if hasVideo>
|
||||
<script src="assets/js/vendor/ckplayer/ckplayer/ckplayer.js"></script>
|
||||
</#if>
|
||||
<#if hasImage>
|
||||
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
||||
</#if>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||
}).extend({
|
||||
index: 'lib/index' //主入口模块
|
||||
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
|
||||
}).use(['index', 'form', 'laydate', 'laytpl', 'upload'], function(){
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
var laytpl = layui.laytpl;
|
||||
var laydate = layui.laydate;
|
||||
var ${firstLowerTableName}Id = top.restAjax.params(window.location.href).${firstLowerTableName}Id;
|
||||
|
||||
<#if hasRichText>
|
||||
var wangEditor = window.wangEditor;
|
||||
var wangEditorObj = {};
|
||||
</#if>
|
||||
<#if hasImage>
|
||||
var viewerObj = {};
|
||||
</#if>
|
||||
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
<#if hasFile || hasImage>
|
||||
function refreshDownloadTemplet(fileName, file) {
|
||||
var dataRander = {};
|
||||
dataRander[fileName] = file;
|
||||
@ -339,7 +366,9 @@
|
||||
top.dialog.msg(data.msg);
|
||||
});
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if hasVideo>
|
||||
// 初始化视频
|
||||
function initVideo(fileName, data) {
|
||||
for(var i = 0, item; item = data[i++];) {
|
||||
@ -354,6 +383,7 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#list fieldList! as field>
|
||||
<#if field.formShow>
|
||||
@ -689,7 +719,7 @@
|
||||
// 初始化内容
|
||||
function initData() {
|
||||
var loadLayerIndex;
|
||||
top.restAjax.get(top.restAjax.path('api/${lowerTableName}/get/{${firstLowerTableName}Id}', [${firstLowerTableName}Id]), {}, null, function(code, data) {
|
||||
top.restAjax.get(top.restAjax.path('api/${requestMappingName}/get/{${firstLowerTableName}Id}', [${firstLowerTableName}Id]), {}, null, function(code, data) {
|
||||
var dataFormData = {};
|
||||
for(var i in data) {
|
||||
dataFormData[i] = data[i] +'';
|
||||
@ -741,7 +771,7 @@
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
top.restAjax.put(top.restAjax.path('api/${lowerTableName}/update/{${firstLowerTableName}Id}', [${firstLowerTableName}Id]), formData.field, null, function(code, data) {
|
||||
top.restAjax.put(top.restAjax.path('api/${requestMappingName}/update/{${firstLowerTableName}Id}', [${firstLowerTableName}Id]), formData.field, null, function(code, data) {
|
||||
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
|
Loading…
Reference in New Issue
Block a user