This commit is contained in:
parent
10383ac958
commit
6a0e6312c2
|
|
@ -204,7 +204,11 @@ export default {
|
|||
submitForm() {
|
||||
const basicForm = this.$refs.basicInfo.$refs.basicInfoForm;
|
||||
const genForm = this.$refs.genInfo.$refs.genInfoForm;
|
||||
const assColumns = this.$refs.genInfo.$refs.assCloumnTable.data;
|
||||
const assCloumnTable = this.$refs.genInfo.$refs.assCloumnTable
|
||||
let assColumns = null;
|
||||
if (assCloumnTable!=undefined){
|
||||
assColumns = assCloumnTable.data
|
||||
}
|
||||
Promise.all([basicForm, genForm].map(this.getFormPromise)).then(res => {
|
||||
const validateResult = res.every(item => !!item);
|
||||
if (validateResult) {
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@
|
|||
<div v-if="info.tplCategory == 'ass'">
|
||||
<el-row>
|
||||
<h4 class="form-header">关联关系</h4>
|
||||
<el-col :span="8">
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<span slot="label">
|
||||
主表id
|
||||
|
|
@ -233,7 +233,7 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<span slot="label">
|
||||
关联表表名
|
||||
|
|
@ -250,7 +250,7 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<span slot="label">
|
||||
关联表表名
|
||||
|
|
@ -267,6 +267,21 @@
|
|||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item>
|
||||
<span slot="label">
|
||||
关联查询方式
|
||||
<el-tooltip content="关联子表的查询方式, 如:inner join" placement="top">
|
||||
<i class="el-icon-question"></i>
|
||||
</el-tooltip>
|
||||
</span>
|
||||
<el-select v-model="info.assQueryType" placeholder="请选择查询方式">
|
||||
<el-option label="inner join" value="inner"/>
|
||||
<el-option label="left join" value="left"/>
|
||||
<el-option label="right join" value="right"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-table ref="assCloumnTable" :data="assCloumns" row-key="columnId" :max-height="tableHeight">
|
||||
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag" />
|
||||
|
|
|
|||
|
|
@ -306,7 +306,6 @@ export default {
|
|||
highlightedCode(code, key) {
|
||||
const vmName = key.substring(key.lastIndexOf("/") + 1, key.indexOf(".vm"));
|
||||
var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
|
||||
console.log(language)
|
||||
const result = hljs.highlight(language, code || "", true);
|
||||
return result.value || ' ';
|
||||
},
|
||||
|
|
@ -325,7 +324,8 @@ export default {
|
|||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const tableIds = row.tableId || this.ids;
|
||||
this.$confirm('是否确认删除表编号为"' + tableIds + '"的数据项?', "警告", {
|
||||
const tableName = row.tableName;
|
||||
this.$confirm('是否确认删除表"' + tableName + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ token:
|
|||
# 令牌自定义标识
|
||||
header: Authorization
|
||||
# 令牌密钥
|
||||
secret: abcdefghijklmnopqrstuvwxyz
|
||||
secret: hcy@2020
|
||||
# 令牌有效期(默认30分钟)
|
||||
expireTime: 30
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ public class GenConstants
|
|||
/** 主子表(增删改查) */
|
||||
public static final String TPL_SUB = "sub";
|
||||
|
||||
/** 关联查询(增删改查) */
|
||||
public static final String TPL_ASS = "ass";
|
||||
|
||||
/** 树编码字段 */
|
||||
public static final String TREE_CODE = "treeCode";
|
||||
|
||||
|
|
|
|||
|
|
@ -392,8 +392,23 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分割sql字符串
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String sqlFormat(String str){
|
||||
String[] strList = str.split("_");
|
||||
String sqlStr = "";
|
||||
for (String s:strList) {
|
||||
sqlStr +=s.substring(0,1);
|
||||
}
|
||||
return sqlStr;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T cast(Object obj) {
|
||||
return (T) obj;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -6,6 +6,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.hchyun.common.constant.ReturnConstants;
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
|
@ -128,8 +130,17 @@ public class GenController extends BaseController {
|
|||
@Log(title = "代码生成" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{tableIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] tableIds) {
|
||||
genTableService.deleteGenTableByIds(tableIds);
|
||||
return AjaxResult.success();
|
||||
try {
|
||||
ServerResult<Integer> serverResult = genTableService.deleteGenTableByIds(tableIds);
|
||||
if (serverResult.isStart()){
|
||||
return AjaxResult.success();
|
||||
}else {
|
||||
return AjaxResult.error(serverResult.getMsg());
|
||||
}
|
||||
}catch (RuntimeException e){
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ReturnConstants.SYS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class GenTable extends BaseEntity
|
|||
@NotBlank(message = "实体类名称不能为空")
|
||||
private String className;
|
||||
|
||||
/** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */
|
||||
/** 使用的模板(crud单表操作 tree树表操作 sub主子表操作 ass关联表操作) */
|
||||
private String tplCategory;
|
||||
|
||||
/** 生成包路径 */
|
||||
|
|
@ -98,12 +98,25 @@ public class GenTable extends BaseEntity
|
|||
/** 上级菜单名称字段 */
|
||||
private String parentMenuName;
|
||||
|
||||
/** 关联表名 */
|
||||
private String assTableName;
|
||||
|
||||
/** 主表字段 */
|
||||
private String assTableColumn;
|
||||
|
||||
/** 关联表key */
|
||||
private String assTableFkColumn;
|
||||
|
||||
/** 关联查询方式 */
|
||||
private String assQueryType;
|
||||
|
||||
public String getAssQueryType() {
|
||||
return assQueryType;
|
||||
}
|
||||
|
||||
public void setAssQueryType(String assQueryType) {
|
||||
this.assQueryType = assQueryType;
|
||||
}
|
||||
|
||||
public List<AssColumn> getAssColumns() {
|
||||
return assColumns;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.hchyun.generator.service;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import com.hchyun.generator.entity.GenTable;
|
||||
|
||||
/**
|
||||
|
|
@ -64,7 +66,7 @@ public interface IGenTableService
|
|||
* @param tableIds 需要删除的表数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public void deleteGenTableByIds(Long[] tableIds);
|
||||
public ServerResult<Integer> deleteGenTableByIds(Long[] tableIds);
|
||||
|
||||
/**
|
||||
* 导入表结构
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import java.util.zip.ZipEntry;
|
|||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import com.hchyun.common.constant.ReturnConstants;
|
||||
import com.hchyun.common.utils.ServerResult;
|
||||
import com.hchyun.generator.dao.AssociatedDao;
|
||||
import com.hchyun.generator.entity.AssColumn;
|
||||
import com.hchyun.generator.service.IGenTableService;
|
||||
|
|
@ -132,12 +133,12 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||
if (row > 0) {
|
||||
genTableColumnDao.updateGenTableColumn(genTable.getColumns());
|
||||
List<AssColumn> assColumns = genTable.getAssColumns();
|
||||
if (assColumns.size() > 0){
|
||||
if (assColumns != null) {
|
||||
associatedDao.deleteTableColumn(genTable.getTableId());
|
||||
associatedDao.insertColumns(assColumns);
|
||||
}
|
||||
}
|
||||
}catch (CustomException e){
|
||||
} catch (CustomException e) {
|
||||
log.error(e.getMessage());
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
throw new CustomException(ReturnConstants.DB_EX);
|
||||
|
|
@ -152,9 +153,16 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteGenTableByIds(Long[] tableIds) {
|
||||
genTableDao.deleteGenTableByIds(tableIds);
|
||||
genTableColumnDao.deleteGenTableColumnByIds(tableIds);
|
||||
public ServerResult<Integer> deleteGenTableByIds(Long[] tableIds) {
|
||||
try {
|
||||
genTableDao.deleteGenTableByIds(tableIds);
|
||||
genTableColumnDao.deleteGenTableColumnByIds(tableIds);
|
||||
return new ServerResult<>(true);
|
||||
}catch (RuntimeException e){
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
log.error(e.getMessage());
|
||||
return new ServerResult<>(false,ReturnConstants.DB_EX);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -196,8 +204,13 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||
Map<String, String> dataMap = new LinkedHashMap<>();
|
||||
// 查询表信息
|
||||
GenTable table = genTableDao.selectGenTableById(tableId);
|
||||
// 设置主子表信息
|
||||
setSubTable(table);
|
||||
if (table.getTplCategory().equals(GenConstants.TPL_SUB)) {
|
||||
// 设置主子表信息
|
||||
setSubTable(table);
|
||||
}
|
||||
if (table.getTplCategory().equals(GenConstants.TPL_ASS)) {
|
||||
table.setAssColumns(associatedDao.selectTableColumnByTableId(tableId));
|
||||
}
|
||||
// 设置主键列信息
|
||||
setPkColumn(table);
|
||||
VelocityInitializer.initVelocity();
|
||||
|
|
@ -260,10 +273,10 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||
tpl.merge(context, sw);
|
||||
if (template.equals("vm/sql/table.sql.vm")) {
|
||||
Boolean start = insertMenuItem(sw);
|
||||
if (start){
|
||||
if (start) {
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
try {
|
||||
String path = getGenPath(table, template);
|
||||
FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8);
|
||||
|
|
@ -321,7 +334,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||
for (String tableName : tableNames) {
|
||||
zip = generatorCode(tableName, zip);
|
||||
// generatorCode(tableName, zip);
|
||||
if (zip==null){
|
||||
if (zip == null) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -330,13 +343,13 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||
}
|
||||
|
||||
@Transactional
|
||||
boolean insertMenuItem(StringWriter stringWriter){
|
||||
boolean insertMenuItem(StringWriter stringWriter) {
|
||||
try {
|
||||
String sql = stringWriter.toString();
|
||||
int start = genTableDao.insertMenu(sql);
|
||||
if (start > 0){
|
||||
if (start > 0) {
|
||||
return false;
|
||||
}else {
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
|
|
@ -345,6 +358,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* todo 查询表信息并生成代码
|
||||
*/
|
||||
|
|
@ -355,6 +369,9 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||
setSubTable(table);
|
||||
// 设置主键列信息
|
||||
setPkColumn(table);
|
||||
if (table.getTplCategory().equals(GenConstants.TPL_ASS)){
|
||||
table.setAssColumns(associatedDao.selectTableColumnByTableId(table.getTableId()));
|
||||
}
|
||||
|
||||
VelocityInitializer.initVelocity();
|
||||
|
||||
|
|
@ -370,7 +387,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||
|
||||
if (template.equals("vm/sql/table.sql.vm")) {
|
||||
Boolean start = insertMenuItem(sw);
|
||||
if (start){
|
||||
if (start) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -410,6 +427,8 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||
} else if (StringUtils.isEmpty(genTable.getSubTableFkName())) {
|
||||
throw new CustomException("子表关联的外键名不能为空");
|
||||
}
|
||||
} else if (GenConstants.TPL_ASS.equals(genTable.getTplCategory())) {
|
||||
// todo 规则校验
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,24 +47,24 @@ public class VelocityUtils {
|
|||
String functionName = genTable.getFunctionName();
|
||||
|
||||
VelocityContext velocityContext = new VelocityContext();
|
||||
velocityContext.put("tplCategory", genTable.getTplCategory());
|
||||
velocityContext.put("tableName", genTable.getTableName());
|
||||
velocityContext.put("functionName", StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
|
||||
velocityContext.put("ClassName", genTable.getClassName());
|
||||
velocityContext.put("className", StringUtils.uncapitalize(genTable.getClassName()));
|
||||
velocityContext.put("moduleName", genTable.getModuleName());
|
||||
velocityContext.put("BusinessName", StringUtils.capitalize(genTable.getBusinessName()));
|
||||
velocityContext.put("businessName", genTable.getBusinessName());
|
||||
velocityContext.put("basePackage", getPackagePrefix(packageName));
|
||||
velocityContext.put("packageName", packageName);
|
||||
velocityContext.put("author", genTable.getFunctionAuthor());
|
||||
velocityContext.put("datetime", DateUtils.getDate());
|
||||
velocityContext.put("createBy", SecurityUtils.getUserId());
|
||||
velocityContext.put("pkColumn", genTable.getPkColumn());
|
||||
velocityContext.put("importList", getImportList(genTable));
|
||||
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
|
||||
velocityContext.put("columns", genTable.getColumns());
|
||||
velocityContext.put("table", genTable);
|
||||
velocityContext.put("tplCategory" , genTable.getTplCategory());
|
||||
velocityContext.put("tableName" , genTable.getTableName());
|
||||
velocityContext.put("functionName" , StringUtils.isNotEmpty(functionName) ? functionName : "【请填写功能名称】");
|
||||
velocityContext.put("ClassName" , genTable.getClassName());
|
||||
velocityContext.put("className" , StringUtils.uncapitalize(genTable.getClassName()));
|
||||
velocityContext.put("moduleName" , genTable.getModuleName());
|
||||
velocityContext.put("BusinessName" , StringUtils.capitalize(genTable.getBusinessName()));
|
||||
velocityContext.put("businessName" , genTable.getBusinessName());
|
||||
velocityContext.put("basePackage" , getPackagePrefix(packageName));
|
||||
velocityContext.put("packageName" , packageName);
|
||||
velocityContext.put("author" , genTable.getFunctionAuthor());
|
||||
velocityContext.put("datetime" , DateUtils.getDate());
|
||||
velocityContext.put("createBy" , SecurityUtils.getUserId());
|
||||
velocityContext.put("pkColumn" , genTable.getPkColumn());
|
||||
velocityContext.put("importList" , getImportList(genTable));
|
||||
velocityContext.put("permissionPrefix" , getPermissionPrefix(moduleName, businessName));
|
||||
velocityContext.put("columns" , genTable.getColumns());
|
||||
velocityContext.put("table" , genTable);
|
||||
setMenuVelocityContext(velocityContext, genTable);
|
||||
if (GenConstants.TPL_TREE.equals(tplCategory)) {
|
||||
setTreeVelocityContext(velocityContext, genTable);
|
||||
|
|
@ -72,14 +72,25 @@ public class VelocityUtils {
|
|||
if (GenConstants.TPL_SUB.equals(tplCategory)) {
|
||||
setSubVelocityContext(velocityContext, genTable);
|
||||
}
|
||||
if (GenConstants.TPL_ASS.equals(tplCategory)) {
|
||||
setAssVelocityContext(velocityContext, genTable);
|
||||
}
|
||||
return velocityContext;
|
||||
}
|
||||
|
||||
public static void setAssVelocityContext(VelocityContext context, GenTable genTable) {
|
||||
String assClassName = GenUtils.convertClassName(genTable.getAssTableName());
|
||||
context.put("assClassName" , assClassName);
|
||||
context.put("assclassName" , StringUtils.uncapitalize(assClassName));
|
||||
context.put("tableMapping" , StringUtils.sqlFormat(genTable.getTableName()));
|
||||
context.put("assMapping" , StringUtils.sqlFormat(genTable.getAssTableName()));
|
||||
}
|
||||
|
||||
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) {
|
||||
String options = genTable.getOptions();
|
||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
||||
String parentMenuId = getParentMenuId(paramsObj);
|
||||
context.put("parentMenuId", parentMenuId);
|
||||
context.put("parentMenuId" , parentMenuId);
|
||||
}
|
||||
|
||||
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) {
|
||||
|
|
@ -89,15 +100,15 @@ public class VelocityUtils {
|
|||
String treeParentCode = getTreeParentCode(paramsObj);
|
||||
String treeName = getTreeName(paramsObj);
|
||||
|
||||
context.put("treeCode", treeCode);
|
||||
context.put("treeParentCode", treeParentCode);
|
||||
context.put("treeName", treeName);
|
||||
context.put("expandColumn", getExpandColumn(genTable));
|
||||
context.put("treeCode" , treeCode);
|
||||
context.put("treeParentCode" , treeParentCode);
|
||||
context.put("treeName" , treeName);
|
||||
context.put("expandColumn" , getExpandColumn(genTable));
|
||||
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
|
||||
context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
||||
context.put("tree_parent_code" , paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
||||
}
|
||||
if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
|
||||
context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME));
|
||||
context.put("tree_name" , paramsObj.getString(GenConstants.TREE_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -108,14 +119,16 @@ public class VelocityUtils {
|
|||
String subClassName = genTable.getSubTable().getClassName();
|
||||
String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName);
|
||||
|
||||
context.put("subTable", subTable);
|
||||
context.put("subTableName", subTableName);
|
||||
context.put("subTableFkName", subTableFkName);
|
||||
context.put("subTableFkClassName", subTableFkClassName);
|
||||
context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName));
|
||||
context.put("subClassName", subClassName);
|
||||
context.put("subclassName", StringUtils.uncapitalize(subClassName));
|
||||
context.put("subImportList", getImportList(genTable.getSubTable()));
|
||||
context.put("tableMapping" , StringUtils.sqlFormat(genTable.getTableName()));
|
||||
context.put("subMapping" , StringUtils.sqlFormat(subTable.getTableName()));
|
||||
context.put("subTable" , subTable);
|
||||
context.put("subTableName" , subTableName);
|
||||
context.put("subTableFkName" , subTableFkName);
|
||||
context.put("subTableFkClassName" , subTableFkClassName);
|
||||
context.put("subTableFkclassName" , StringUtils.uncapitalize(subTableFkClassName));
|
||||
context.put("subClassName" , subClassName);
|
||||
context.put("subclassName" , StringUtils.uncapitalize(subClassName));
|
||||
context.put("subImportList" , getImportList(genTable.getSubTable()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -140,6 +153,9 @@ public class VelocityUtils {
|
|||
} else if (GenConstants.TPL_SUB.equals(tplCategory)) {
|
||||
templates.add("vm/vue/index.vue.vm");
|
||||
templates.add("vm/java/sub-entity.java.vm");
|
||||
} else if (GenConstants.TPL_ASS.equals(tplCategory)) {
|
||||
templates.add("vm/vue/index.vue.vm");
|
||||
templates.add("vm/java/ass-entity.java.vm");
|
||||
}
|
||||
return templates;
|
||||
}
|
||||
|
|
@ -159,33 +175,35 @@ public class VelocityUtils {
|
|||
// 业务名称
|
||||
String businessName = genTable.getBusinessName();
|
||||
|
||||
String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, ".", "/");
|
||||
String javaPath = PROJECT_PATH + "/" + StringUtils.replace(packageName, "." , "/");
|
||||
String mybatisPath = MYBATIS_PATH + "/" + moduleName;
|
||||
String vuePath = "vue";
|
||||
|
||||
if (template.contains("entity.java.vm")) {
|
||||
fileName = StringUtils.format("{}/entity/{}.java", javaPath, className);
|
||||
fileName = StringUtils.format("{}/entity/{}.java" , javaPath, className);
|
||||
}
|
||||
if (template.contains("sub-entity.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) {
|
||||
fileName = StringUtils.format("{}/entity/{}.java", javaPath, genTable.getSubTable().getClassName());
|
||||
fileName = StringUtils.format("{}/entity/{}.java" , javaPath, genTable.getSubTable().getClassName());
|
||||
} else if (template.contains("ass-entity.java.vm")) {
|
||||
fileName = StringUtils.format("{}/entity/{}.java" , javaPath, GenUtils.convertClassName(genTable.getAssTableName()));
|
||||
} else if (template.contains("dao.java.vm")) {
|
||||
fileName = StringUtils.format("{}/dao/{}Dao.java", javaPath, className);
|
||||
fileName = StringUtils.format("{}/dao/{}Dao.java" , javaPath, className);
|
||||
} else if (template.contains("service.java.vm")) {
|
||||
fileName = StringUtils.format("{}/service/{}Service.java", javaPath, className);
|
||||
fileName = StringUtils.format("{}/service/{}Service.java" , javaPath, className);
|
||||
} else if (template.contains("serviceImpl.java.vm")) {
|
||||
fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
|
||||
fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java" , javaPath, className);
|
||||
} else if (template.contains("controller.java.vm")) {
|
||||
fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
|
||||
fileName = StringUtils.format("{}/controller/{}Controller.java" , javaPath, className);
|
||||
} else if (template.contains("mapper.xml.vm")) {
|
||||
fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
|
||||
fileName = StringUtils.format("{}/{}Mapper.xml" , mybatisPath, className);
|
||||
} else if (template.contains("table.sql.vm")) {
|
||||
fileName = businessName + "Menu.sql";
|
||||
} else if (template.contains("api.js.vm")) {
|
||||
fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
|
||||
fileName = StringUtils.format("{}/api/{}/{}.js" , vuePath, moduleName, businessName);
|
||||
} else if (template.contains("index.vue.vm")) {
|
||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue" , vuePath, moduleName, businessName);
|
||||
} else if (template.contains("index-tree.vue.vm")) {
|
||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue" , vuePath, moduleName, businessName);
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
|
@ -234,7 +252,7 @@ public class VelocityUtils {
|
|||
* @return 返回权限前缀
|
||||
*/
|
||||
public static String getPermissionPrefix(String moduleName, String businessName) {
|
||||
return StringUtils.format("{}:{}", moduleName, businessName);
|
||||
return StringUtils.format("{}:{}" , moduleName, businessName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ gen:
|
|||
# 作者
|
||||
author: hchyun
|
||||
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
|
||||
packageName: com.hchyun.system
|
||||
packageName: com.hchyun.test
|
||||
# 自动去除表前缀,默认是false
|
||||
autoRemovePre: true
|
||||
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
|
||||
tablePrefix: sys_
|
||||
tablePrefix: sys_,test_
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
AND table_name NOT LIKE 'gen_%'
|
||||
</select>
|
||||
<select id="selectTableColumnByTableId" resultType="com.hchyun.generator.entity.AssColumn" parameterType="Long">
|
||||
select * from gen_acc_column where table_id = #{tableId} order by sort
|
||||
select * from gen_ass_column where table_id = #{tableId} order by sort
|
||||
</select>
|
||||
|
||||
<select id="selectTableColumn" resultType="com.hchyun.generator.entity.AssColumn" parameterType="String">
|
||||
|
|
@ -24,14 +24,14 @@
|
|||
|
||||
<delete id="deleteTableColumn" parameterType="Long">
|
||||
delete
|
||||
from gen_acc_column
|
||||
from gen_ass_column
|
||||
where table_id = #{tableId}
|
||||
</delete>
|
||||
|
||||
|
||||
|
||||
<insert id="insertColumns" parameterType="java.util.List">
|
||||
insert into gen_acc_column(table_id, column_name, column_comment, column_type, java_type, java_field, is_list,
|
||||
insert into gen_ass_column(table_id, column_name, column_comment, column_type, java_type, java_field, is_list,
|
||||
is_query, query_type, html_type, dict_type, sort, create_by, update_by)
|
||||
values
|
||||
<foreach collection="list" item="item" index="index" separator=",">
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="assTableName" column="ass_table_name" />
|
||||
<result property="assTableColumn" column="ass_table_column" />
|
||||
<result property="assTableFkColumn" column="ass_table_fk_column"/>
|
||||
<result property="assQueryType" column="ass_query_type"/>
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
|
|
@ -31,6 +32,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="AssColumnResult" type="com.hchyun.generator.entity.AssColumn">
|
||||
<id property="id" column="id" />
|
||||
<result property="tableId" column="table_id" />
|
||||
<result property="columnName" column="column_name" />
|
||||
<result property="columnComment" column="column_comment" />
|
||||
<result property="columnType" column="column_type" />
|
||||
<result property="javaType" column="java_type" />
|
||||
<result property="javaField" column="java_field" />
|
||||
<result property="isList" column="is_list" />
|
||||
<result property="isQuery" column="is_query" />
|
||||
<result property="queryType" column="query_type" />
|
||||
<result property="htmlType" column="html_type" />
|
||||
<result property="dictType" column="dict_type" />
|
||||
<result property="sort" column="sort" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="com.hchyun.generator.entity.GenTableColumn" id="GenTableColumnResult">
|
||||
<id property="columnId" column="column_id" />
|
||||
<result property="tableId" column="table_id" />
|
||||
|
|
@ -64,7 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<sql id="selectGenTableVo">
|
||||
select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category,
|
||||
package_name, module_name, business_name, function_name, function_author, gen_type, gen_path,
|
||||
options, ass_table_name, ass_table_column, ass_table_fk_column, create_by, create_time, update_by, update_time, remark from gen_table
|
||||
options, ass_table_name, ass_table_column, ass_table_fk_column, ass_query_type, create_by, create_time, update_by, update_time, remark from gen_table
|
||||
</sql>
|
||||
|
||||
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
||||
|
|
@ -122,7 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<!--todo 获取表信息 预览代码使用-->
|
||||
<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.ass_table_name,t.ass_table_column,
|
||||
t.ass_table_fk_column, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name,
|
||||
t.ass_table_fk_column, t.ass_query_type, t.class_name, t.tpl_category, 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.is_regular, r.regular
|
||||
|
|
@ -131,10 +148,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN sys_regular r ON c.is_regular = r.id
|
||||
where t.table_id = #{tableId} order by c.sort
|
||||
</select>
|
||||
|
||||
<!--todo 获取表信息 生成代码使用-->
|
||||
<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.ass_table_name,t.ass_table_column,
|
||||
t.ass_table_fk_column, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name,
|
||||
t.ass_table_fk_column, t.ass_query_type, t.class_name, t.tpl_category, 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.is_regular, r.regular
|
||||
|
|
@ -145,7 +162,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
<!-- todo 查询数据库行配置信息-->
|
||||
<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.ass_table_name,t.ass_table_column,t.ass_table_fk_column,
|
||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name,t.ass_table_name,t.ass_table_column,t.ass_table_fk_column,t.ass_query_type,
|
||||
t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, 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
|
||||
|
|
@ -198,6 +215,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="assTableName != null and assTableName !=''">ass_table_name = #{assTableName},</if>
|
||||
<if test="assTableColumn != null and assTableColumn !=''">ass_table_column = #{assTableColumn},</if>
|
||||
<if test="assTableFkColumn != null and assTableFkColumn !=''">ass_table_fk_column = #{assTableFkColumn},</if>
|
||||
<if test="assQueryType != null and assQueryType !=''">ass_query_type = #{assQueryType},</if>
|
||||
<if test="className != null and className != ''">class_name = #{className},</if>
|
||||
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
|
||||
<if test="genType != null and genType != ''">gen_type = #{genType},</if>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
package ${packageName}.entity;
|
||||
|
||||
#foreach ($import in $subImportList)
|
||||
import ${import};
|
||||
#end
|
||||
import com.hchyun.common.annotation.Excel;
|
||||
import com.hchyun.common.core.entity.BaseEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ${author}
|
||||
* @date ${datetime}
|
||||
*/
|
||||
|
||||
public class ${assClassName} extends BaseEntity{
|
||||
|
||||
#foreach($column in $table.assColumns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
/** $column.columnComment */
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($parentheseIndex != -1)
|
||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||
#elseif($column.javaType == 'Date')
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
#else
|
||||
@Excel(name = "${comment}")
|
||||
#end
|
||||
private $column.javaType $column.javaField;
|
||||
|
||||
#end
|
||||
#end
|
||||
|
||||
#foreach ($column in $table.assColumns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||
#set($AttrName=$column.javaField)
|
||||
#else
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#end
|
||||
public void set${AttrName}($column.javaType $column.javaField){
|
||||
this.$column.javaField = $column.javaField;
|
||||
}
|
||||
|
||||
public $column.javaType get${AttrName}(){
|
||||
return $column.javaField;
|
||||
}
|
||||
#end
|
||||
#end
|
||||
}
|
||||
|
|
@ -32,6 +32,8 @@ import com.hchyun.common.utils.poi.ExcelUtil;
|
|||
#if($table.crud || $table.sub)
|
||||
import com.hchyun.common.core.page.TableDataInfo;
|
||||
#elseif($table.tree)
|
||||
#elseif($table.tplCategory.equals("ass"))
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
#end
|
||||
|
||||
/**
|
||||
|
|
@ -56,8 +58,12 @@ public class ${ClassName}Controller extends HcyBaseController {
|
|||
@ApiOperation("查询${functionName}列表")
|
||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
||||
@GetMapping("/list")
|
||||
#if($table.crud || $table.sub)
|
||||
#if($table.crud || $table.sub || $table.tplCategory.equals("ass"))
|
||||
#if($table.tplCategory.equals("ass"))
|
||||
public Serializable list(@Validated ${ClassName} ${className}) {
|
||||
#else
|
||||
public Serializable list(${ClassName} ${className}) {
|
||||
#end
|
||||
try {
|
||||
startPage();
|
||||
ServerResult<List<${ClassName}>> serverResult = ${className}Service.select${ClassName}List(${className});
|
||||
|
|
|
|||
|
|
@ -9,14 +9,17 @@ import com.hchyun.common.annotation.Excel;
|
|||
#elseif($table.tree)
|
||||
#set($Entity="TreeEntity")
|
||||
#end
|
||||
#if($table.tplCategory.equals("ass"))
|
||||
#set($Entity="BaseEntity")
|
||||
import ${packageName}.entity.${assClassName};
|
||||
#elseif($table.tplCategory.equals("sub"))
|
||||
import ${packageName}.entity.${subClassName};
|
||||
#end
|
||||
import com.hchyun.common.core.entity.${Entity};
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
#if($table.crud || $table.sub)
|
||||
#elseif($table.tree)
|
||||
#end
|
||||
|
||||
/**
|
||||
* ${functionName}对象 ${tableName}
|
||||
|
|
@ -63,6 +66,9 @@ public class ${ClassName} extends ${Entity}
|
|||
@ApiModelProperty("${table.subTable.functionName}信息")
|
||||
private List<${subClassName}> ${subclassName}List;
|
||||
|
||||
#elseif($table.tplCategory.equals("ass"))
|
||||
private ${assClassName} ${assclassName};
|
||||
|
||||
#end
|
||||
#foreach ($column in $columns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
|
|
@ -89,6 +95,15 @@ public class ${ClassName} extends ${Entity}
|
|||
public void set${subClassName}List(List<${subClassName}> ${subclassName}List){
|
||||
this.${subclassName}List = ${subclassName}List;
|
||||
}
|
||||
#end
|
||||
#if($table.tplCategory.equals("ass"))
|
||||
public ${assClassName} get${assClassName}(){
|
||||
return ${assclassName};
|
||||
}
|
||||
|
||||
public void set${assClassName}(${assClassName} ${assclassName}){
|
||||
this.${assclassName} = ${assclassName};
|
||||
}
|
||||
|
||||
#end
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
* @date ${datetime}
|
||||
*/
|
||||
public class ${subClassName} extends BaseEntity{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $subTable.columns)
|
||||
#if(!$table.isSuperColumn($column.javaField))
|
||||
|
|
|
|||
|
|
@ -341,8 +341,11 @@ export default {
|
|||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
$column.javaField: [
|
||||
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
|
||||
]#if($velocityCount != $columns.size()),#end
|
||||
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#end }
|
||||
#if($column.isRegular != 1)
|
||||
{ pattern: /${column.regular}/, message: '${column.columnComment}格式有误', trigger:"blur"},
|
||||
#end
|
||||
]#if($velocityCount != $columns.size()),#end
|
||||
|
||||
#end
|
||||
#end
|
||||
|
|
|
|||
|
|
@ -62,6 +62,68 @@
|
|||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#foreach($column in $table.assColumns)
|
||||
#if($column.isQuery == '1')
|
||||
#set($dictType=$column.dictType)
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.htmlType == "input")
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-input
|
||||
v-model="queryParams.${assclassName}.${column.javaField}"
|
||||
placeholder="请输入${comment}"
|
||||
clearable
|
||||
size="small"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && "" != $dictType)
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${assclassName}.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
||||
<el-option
|
||||
v-for="dict in ${column.javaField}Options"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif(($column.htmlType == "select" || $column.htmlType == "radio") && $dictType)
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${assclassName}.${column.javaField}" placeholder="请选择${comment}" clearable size="small">
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType != "BETWEEN")
|
||||
<el-form-item label="${comment}" prop="${column.javaField}">
|
||||
<el-date-picker clearable size="small"
|
||||
v-model="queryParams.${assclassName}.${column.javaField}"
|
||||
type="date"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择${comment}">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
<el-form-item label="${comment}">
|
||||
<el-date-picker
|
||||
v-model="assdaterange${AttrName}"
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
|
|
@ -126,19 +188,43 @@
|
|||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.pk)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||
#elseif($column.list && $column.htmlType == "datetime")
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
||||
<span>{{ parseTime(scope.row.${javaField}, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
#elseif($column.list && "" != $column.dictType)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" :formatter="${javaField}Format" />
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" :formatter="${javaField}Format" />
|
||||
#elseif($column.list && "" != $javaField)
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||
#end
|
||||
#end
|
||||
|
||||
#if($table.tplCategory.equals("ass"))
|
||||
#foreach($column in $table.assColumns)
|
||||
#set($javaField=$column.javaField)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if($column.isList == "1" && $column.htmlType == "datetime")
|
||||
<el-table-column label="${comment}" align="center" prop="${assclassName}.${javaField}" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.${assClassName}.${javaField}, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
#elseif($column.isList == "1" && "" != $column.dictType)
|
||||
<el-table-column label="${comment}" align="center" prop="${assclassName}.${javaField}" :formatter="${javaField}Format" />
|
||||
#elseif($column.isList == "1" && "" != $javaField)
|
||||
<el-table-column label="${comment}" align="center" prop="${assclassName}.${javaField}" />
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
|
|
@ -393,6 +479,22 @@ export default {
|
|||
// $comment时间范围
|
||||
daterange${AttrName}: [],
|
||||
#end
|
||||
#end
|
||||
#foreach ($column in $table.assColumns)
|
||||
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||
#if($parentheseIndex != -1)
|
||||
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||
#else
|
||||
#set($comment=$column.columnComment)
|
||||
#end
|
||||
#if(${column.dictType} != '')
|
||||
// $comment字典
|
||||
${column.javaField}Options: [],
|
||||
#elseif($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
// $comment时间范围
|
||||
assdaterange${AttrName}: [],
|
||||
#end
|
||||
#end
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
|
|
@ -403,6 +505,16 @@ export default {
|
|||
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
||||
|
||||
#end
|
||||
#end
|
||||
#if($table.tplCategory.equals("ass"))
|
||||
${assclassName}: {
|
||||
#foreach ($column in $table.assColumns)
|
||||
#if($column.isQuery == '1' && $column.htmlType != "datetime" && $column.queryType != "BETWEEN")
|
||||
${column.javaField}: null#if($velocityCount != $columns.size()),#end
|
||||
|
||||
#end
|
||||
#end
|
||||
}
|
||||
#end
|
||||
},
|
||||
// 表单参数
|
||||
|
|
@ -519,6 +631,11 @@ export default {
|
|||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.daterange${AttrName} = [];
|
||||
#end
|
||||
#end#foreach ($column in $table.assColumns)
|
||||
#if($column.htmlType == "datetime" && $column.queryType == "BETWEEN")
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.assdaterange${AttrName} = [];
|
||||
#end
|
||||
#end
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
|
|
|
|||
|
|
@ -4,36 +4,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="${packageName}.dao.${ClassName}Dao">
|
||||
|
||||
<resultMap type="${ClassName}" id="${ClassName}Result">
|
||||
<resultMap type="${packageName}.entity.${ClassName}" id="${ClassName}Result">
|
||||
#foreach ($column in $columns)
|
||||
<result property="${column.javaField}" column="${column.columnName}" />
|
||||
#end
|
||||
</resultMap>
|
||||
#if($table.sub)
|
||||
|
||||
<resultMap id="${ClassName}${subClassName}Result" type="${ClassName}" extends="${ClassName}Result">
|
||||
<resultMap id="${ClassName}${subClassName}Result" type="${packageName}.entity.${ClassName}" extends="${ClassName}Result">
|
||||
<collection property="${subclassName}List" notNullColumn="${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="${subClassName}" id="${subClassName}Result">
|
||||
<resultMap type="${packageName}.entity.${subClassName}" id="${subClassName}Result">
|
||||
#foreach ($column in $subTable.columns)
|
||||
<result property="${column.javaField}" column="${column.columnName}" />
|
||||
#end
|
||||
</resultMap>
|
||||
#end
|
||||
#if($table.tplCategory.equals("ass"))
|
||||
<resultMap id="${ClassName}${assClassName}Result" type="${packageName}.entity.${ClassName}" extends="${ClassName}Result">
|
||||
<collection property="${assclassName}" notNullColumn="${table.assTableColumn}" javaType="${packageName}.entity.${assClassName}" resultMap="${assClassName}Result" />
|
||||
</resultMap>
|
||||
<resultMap type="${packageName}.entity.${assClassName}" id="${assClassName}Result">
|
||||
#foreach ($column in $table.assColumns)
|
||||
<result property="${column.javaField}" column="${column.columnName}" />
|
||||
#end
|
||||
</resultMap>
|
||||
#end
|
||||
|
||||
<sql id="select${ClassName}Vo">
|
||||
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
|
||||
</sql>
|
||||
|
||||
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
|
||||
<include refid="select${ClassName}Vo"/>
|
||||
<where>
|
||||
#if($table.tplCategory.equals("ass"))
|
||||
select#foreach($column in $columns) ${tableMapping}.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
||||
#foreach($column in $table.assColumns) ${assMapping}.$column.columnName#if($velocityCount != $table.assColumns.size()),#end#end
|
||||
|
||||
from ${tableName} ${tableMapping}
|
||||
${table.assQueryType} join ${table.assTableName} ${assMapping} on ${assMapping}.${table.assTableFkColumn} = ${tableMapping}.${table.assTableColumn}
|
||||
<where>
|
||||
#foreach($column in $columns)
|
||||
#set($queryType=$column.queryType)
|
||||
#set($javaField=$column.javaField)
|
||||
#set($javaType=$column.javaType)
|
||||
#set($columnName=$column.columnName)
|
||||
#set($columnName=$tableMapping+'.'+$column.columnName)
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#if($column.query)
|
||||
#if($column.queryType == "EQ")
|
||||
|
|
@ -54,8 +68,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#foreach($column in $table.assColumns)
|
||||
#set($queryType=$column.queryType)
|
||||
#set($javaField=$assclassName+'.'+$column.javaField)
|
||||
#set($javaType=$column.javaType)
|
||||
#set($columnName=$assMapping+'.'+$column.columnName)
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#if($column.isQuery.equals("1"))
|
||||
#if($column.queryType == "EQ")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName = #{$javaField}</if>
|
||||
#elseif($queryType == "NE")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName != #{$javaField}</if>
|
||||
#elseif($queryType == "GT")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName > #{$javaField}</if>
|
||||
#elseif($queryType == "GTE")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName >= #{$javaField}</if>
|
||||
#elseif($queryType == "LT")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName < #{$javaField}</if>
|
||||
#elseif($queryType == "LTE")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName <= #{$javaField}</if>
|
||||
#elseif($queryType == "LIKE")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if>
|
||||
#elseif($queryType == "BETWEEN")
|
||||
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
</where>
|
||||
#else
|
||||
<include refid="select${ClassName}Vo"/>
|
||||
<where>
|
||||
#foreach($column in $columns)
|
||||
#set($queryType=$column.queryType)
|
||||
#set($javaField=$column.javaField)
|
||||
#set($javaType=$column.javaType)
|
||||
#set($columnName=$column.columnName)
|
||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
#if($column.isQuery.equals("1"))
|
||||
#if($column.queryType == "EQ")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName = #{$javaField}</if>
|
||||
#elseif($queryType == "NE")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName != #{$javaField}</if>
|
||||
#elseif($queryType == "GT")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName > #{$javaField}</if>
|
||||
#elseif($queryType == "GTE")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName >= #{$javaField}</if>
|
||||
#elseif($queryType == "LT")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName < #{$javaField}</if>
|
||||
#elseif($queryType == "LTE")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName <= #{$javaField}</if>
|
||||
#elseif($queryType == "LIKE")
|
||||
<if test="$javaField != null #if($javaType == 'String' ) and $javaField.trim() != ''#end"> and $columnName like concat('%', #{$javaField}, '%')</if>
|
||||
#elseif($queryType == "BETWEEN")
|
||||
<if test="params.begin$AttrName != null and params.begin$AttrName != '' and params.end$AttrName != null and params.end$AttrName != ''"> and $columnName between #{params.begin$AttrName} and #{params.end$AttrName}</if>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
</where>
|
||||
#end
|
||||
</select>
|
||||
|
||||
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
|
||||
|
|
@ -63,12 +134,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="select${ClassName}Vo"/>
|
||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
#elseif($table.sub)
|
||||
select#foreach($column in $columns) a.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
||||
#foreach($column in $subTable.columns) b.$column.columnName#if($velocityCount != $subTable.columns.size()),#end#end
|
||||
select#foreach($column in $columns) ${tableMapping}.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
||||
#foreach($column in $subTable.columns) ${subMapping}.$column.columnName#if($velocityCount != $subTable.columns.size()),#end#end
|
||||
|
||||
from ${tableName} a
|
||||
left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName}
|
||||
where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
from ${tableName} ${tableMapping}
|
||||
left join ${subTableName} ${subMapping} on ${subMapping}.${subTableFkName} = ${tableMapping}.${pkColumn.columnName}
|
||||
where ${tableMapping}.${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
#elseif($table.tplCategory.equals("ass"))
|
||||
select#foreach($column in $columns) ${tableMapping}.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
||||
#foreach($column in $table.assColumns) ${assMapping}.$column.columnName#if($velocityCount != $table.assColumns.size()),#end#end
|
||||
|
||||
from ${tableName} ${tableMapping}
|
||||
${table.assQueryType} join ${table.assTableName} ${assMapping} on ${assMapping}.${table.assTableFkColumn} = ${tableMapping}.${table.assTableColumn}
|
||||
where ${tableMapping}.${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||
#end
|
||||
</select>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue