This commit is contained in:
parent
10383ac958
commit
6a0e6312c2
|
|
@ -204,7 +204,11 @@ export default {
|
||||||
submitForm() {
|
submitForm() {
|
||||||
const basicForm = this.$refs.basicInfo.$refs.basicInfoForm;
|
const basicForm = this.$refs.basicInfo.$refs.basicInfoForm;
|
||||||
const genForm = this.$refs.genInfo.$refs.genInfoForm;
|
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 => {
|
Promise.all([basicForm, genForm].map(this.getFormPromise)).then(res => {
|
||||||
const validateResult = res.every(item => !!item);
|
const validateResult = res.every(item => !!item);
|
||||||
if (validateResult) {
|
if (validateResult) {
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@
|
||||||
<div v-if="info.tplCategory == 'ass'">
|
<div v-if="info.tplCategory == 'ass'">
|
||||||
<el-row>
|
<el-row>
|
||||||
<h4 class="form-header">关联关系</h4>
|
<h4 class="form-header">关联关系</h4>
|
||||||
<el-col :span="8">
|
<el-col :span="6">
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<span slot="label">
|
<span slot="label">
|
||||||
主表id
|
主表id
|
||||||
|
|
@ -233,7 +233,7 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="6">
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<span slot="label">
|
<span slot="label">
|
||||||
关联表表名
|
关联表表名
|
||||||
|
|
@ -250,7 +250,7 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8">
|
<el-col :span="6">
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<span slot="label">
|
<span slot="label">
|
||||||
关联表表名
|
关联表表名
|
||||||
|
|
@ -267,6 +267,21 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</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-row>
|
||||||
<el-table ref="assCloumnTable" :data="assCloumns" row-key="columnId" :max-height="tableHeight">
|
<el-table ref="assCloumnTable" :data="assCloumns" row-key="columnId" :max-height="tableHeight">
|
||||||
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag" />
|
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag" />
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,6 @@ export default {
|
||||||
highlightedCode(code, key) {
|
highlightedCode(code, key) {
|
||||||
const vmName = key.substring(key.lastIndexOf("/") + 1, key.indexOf(".vm"));
|
const vmName = key.substring(key.lastIndexOf("/") + 1, key.indexOf(".vm"));
|
||||||
var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
|
var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
|
||||||
console.log(language)
|
|
||||||
const result = hljs.highlight(language, code || "", true);
|
const result = hljs.highlight(language, code || "", true);
|
||||||
return result.value || ' ';
|
return result.value || ' ';
|
||||||
},
|
},
|
||||||
|
|
@ -325,7 +324,8 @@ export default {
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
const tableIds = row.tableId || this.ids;
|
const tableIds = row.tableId || this.ids;
|
||||||
this.$confirm('是否确认删除表编号为"' + tableIds + '"的数据项?', "警告", {
|
const tableName = row.tableName;
|
||||||
|
this.$confirm('是否确认删除表"' + tableName + '"的数据项?', "警告", {
|
||||||
confirmButtonText: "确定",
|
confirmButtonText: "确定",
|
||||||
cancelButtonText: "取消",
|
cancelButtonText: "取消",
|
||||||
type: "warning"
|
type: "warning"
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ token:
|
||||||
# 令牌自定义标识
|
# 令牌自定义标识
|
||||||
header: Authorization
|
header: Authorization
|
||||||
# 令牌密钥
|
# 令牌密钥
|
||||||
secret: abcdefghijklmnopqrstuvwxyz
|
secret: hcy@2020
|
||||||
# 令牌有效期(默认30分钟)
|
# 令牌有效期(默认30分钟)
|
||||||
expireTime: 30
|
expireTime: 30
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@ public class GenConstants
|
||||||
/** 主子表(增删改查) */
|
/** 主子表(增删改查) */
|
||||||
public static final String TPL_SUB = "sub";
|
public static final String TPL_SUB = "sub";
|
||||||
|
|
||||||
|
/** 关联查询(增删改查) */
|
||||||
|
public static final String TPL_ASS = "ass";
|
||||||
|
|
||||||
/** 树编码字段 */
|
/** 树编码字段 */
|
||||||
public static final String TREE_CODE = "treeCode";
|
public static final String TREE_CODE = "treeCode";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -392,8 +392,23 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
||||||
return sb.toString();
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T> T cast(Object obj) {
|
public static <T> T cast(Object obj) {
|
||||||
return (T) obj;
|
return (T) obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -6,6 +6,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
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.apache.commons.io.IOUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
|
@ -128,8 +130,17 @@ public class GenController extends BaseController {
|
||||||
@Log(title = "代码生成" , businessType = BusinessType.DELETE)
|
@Log(title = "代码生成" , businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{tableIds}")
|
@DeleteMapping("/{tableIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] tableIds) {
|
public AjaxResult remove(@PathVariable Long[] tableIds) {
|
||||||
genTableService.deleteGenTableByIds(tableIds);
|
try {
|
||||||
|
ServerResult<Integer> serverResult = genTableService.deleteGenTableByIds(tableIds);
|
||||||
|
if (serverResult.isStart()){
|
||||||
return AjaxResult.success();
|
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 = "实体类名称不能为空")
|
@NotBlank(message = "实体类名称不能为空")
|
||||||
private String className;
|
private String className;
|
||||||
|
|
||||||
/** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */
|
/** 使用的模板(crud单表操作 tree树表操作 sub主子表操作 ass关联表操作) */
|
||||||
private String tplCategory;
|
private String tplCategory;
|
||||||
|
|
||||||
/** 生成包路径 */
|
/** 生成包路径 */
|
||||||
|
|
@ -98,12 +98,25 @@ public class GenTable extends BaseEntity
|
||||||
/** 上级菜单名称字段 */
|
/** 上级菜单名称字段 */
|
||||||
private String parentMenuName;
|
private String parentMenuName;
|
||||||
|
|
||||||
|
/** 关联表名 */
|
||||||
private String assTableName;
|
private String assTableName;
|
||||||
|
|
||||||
|
/** 主表字段 */
|
||||||
private String assTableColumn;
|
private String assTableColumn;
|
||||||
|
|
||||||
|
/** 关联表key */
|
||||||
private String assTableFkColumn;
|
private String assTableFkColumn;
|
||||||
|
|
||||||
|
/** 关联查询方式 */
|
||||||
|
private String assQueryType;
|
||||||
|
|
||||||
|
public String getAssQueryType() {
|
||||||
|
return assQueryType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAssQueryType(String assQueryType) {
|
||||||
|
this.assQueryType = assQueryType;
|
||||||
|
}
|
||||||
|
|
||||||
public List<AssColumn> getAssColumns() {
|
public List<AssColumn> getAssColumns() {
|
||||||
return assColumns;
|
return assColumns;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@ package com.hchyun.generator.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.hchyun.common.utils.ServerResult;
|
||||||
import com.hchyun.generator.entity.GenTable;
|
import com.hchyun.generator.entity.GenTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -64,7 +66,7 @@ public interface IGenTableService
|
||||||
* @param tableIds 需要删除的表数据ID
|
* @param tableIds 需要删除的表数据ID
|
||||||
* @return 结果
|
* @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 java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
import com.hchyun.common.constant.ReturnConstants;
|
import com.hchyun.common.constant.ReturnConstants;
|
||||||
|
import com.hchyun.common.utils.ServerResult;
|
||||||
import com.hchyun.generator.dao.AssociatedDao;
|
import com.hchyun.generator.dao.AssociatedDao;
|
||||||
import com.hchyun.generator.entity.AssColumn;
|
import com.hchyun.generator.entity.AssColumn;
|
||||||
import com.hchyun.generator.service.IGenTableService;
|
import com.hchyun.generator.service.IGenTableService;
|
||||||
|
|
@ -132,7 +133,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||||
if (row > 0) {
|
if (row > 0) {
|
||||||
genTableColumnDao.updateGenTableColumn(genTable.getColumns());
|
genTableColumnDao.updateGenTableColumn(genTable.getColumns());
|
||||||
List<AssColumn> assColumns = genTable.getAssColumns();
|
List<AssColumn> assColumns = genTable.getAssColumns();
|
||||||
if (assColumns.size() > 0){
|
if (assColumns != null) {
|
||||||
associatedDao.deleteTableColumn(genTable.getTableId());
|
associatedDao.deleteTableColumn(genTable.getTableId());
|
||||||
associatedDao.insertColumns(assColumns);
|
associatedDao.insertColumns(assColumns);
|
||||||
}
|
}
|
||||||
|
|
@ -152,9 +153,16 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void deleteGenTableByIds(Long[] tableIds) {
|
public ServerResult<Integer> deleteGenTableByIds(Long[] tableIds) {
|
||||||
|
try {
|
||||||
genTableDao.deleteGenTableByIds(tableIds);
|
genTableDao.deleteGenTableByIds(tableIds);
|
||||||
genTableColumnDao.deleteGenTableColumnByIds(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<>();
|
Map<String, String> dataMap = new LinkedHashMap<>();
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
GenTable table = genTableDao.selectGenTableById(tableId);
|
GenTable table = genTableDao.selectGenTableById(tableId);
|
||||||
|
if (table.getTplCategory().equals(GenConstants.TPL_SUB)) {
|
||||||
// 设置主子表信息
|
// 设置主子表信息
|
||||||
setSubTable(table);
|
setSubTable(table);
|
||||||
|
}
|
||||||
|
if (table.getTplCategory().equals(GenConstants.TPL_ASS)) {
|
||||||
|
table.setAssColumns(associatedDao.selectTableColumnByTableId(tableId));
|
||||||
|
}
|
||||||
// 设置主键列信息
|
// 设置主键列信息
|
||||||
setPkColumn(table);
|
setPkColumn(table);
|
||||||
VelocityInitializer.initVelocity();
|
VelocityInitializer.initVelocity();
|
||||||
|
|
@ -345,6 +358,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* todo 查询表信息并生成代码
|
* todo 查询表信息并生成代码
|
||||||
*/
|
*/
|
||||||
|
|
@ -355,6 +369,9 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||||
setSubTable(table);
|
setSubTable(table);
|
||||||
// 设置主键列信息
|
// 设置主键列信息
|
||||||
setPkColumn(table);
|
setPkColumn(table);
|
||||||
|
if (table.getTplCategory().equals(GenConstants.TPL_ASS)){
|
||||||
|
table.setAssColumns(associatedDao.selectTableColumnByTableId(table.getTableId()));
|
||||||
|
}
|
||||||
|
|
||||||
VelocityInitializer.initVelocity();
|
VelocityInitializer.initVelocity();
|
||||||
|
|
||||||
|
|
@ -410,6 +427,8 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||||
} else if (StringUtils.isEmpty(genTable.getSubTableFkName())) {
|
} else if (StringUtils.isEmpty(genTable.getSubTableFkName())) {
|
||||||
throw new CustomException("子表关联的外键名不能为空");
|
throw new CustomException("子表关联的外键名不能为空");
|
||||||
}
|
}
|
||||||
|
} else if (GenConstants.TPL_ASS.equals(genTable.getTplCategory())) {
|
||||||
|
// todo 规则校验
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,9 +72,20 @@ public class VelocityUtils {
|
||||||
if (GenConstants.TPL_SUB.equals(tplCategory)) {
|
if (GenConstants.TPL_SUB.equals(tplCategory)) {
|
||||||
setSubVelocityContext(velocityContext, genTable);
|
setSubVelocityContext(velocityContext, genTable);
|
||||||
}
|
}
|
||||||
|
if (GenConstants.TPL_ASS.equals(tplCategory)) {
|
||||||
|
setAssVelocityContext(velocityContext, genTable);
|
||||||
|
}
|
||||||
return velocityContext;
|
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) {
|
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) {
|
||||||
String options = genTable.getOptions();
|
String options = genTable.getOptions();
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
JSONObject paramsObj = JSONObject.parseObject(options);
|
||||||
|
|
@ -108,6 +119,8 @@ public class VelocityUtils {
|
||||||
String subClassName = genTable.getSubTable().getClassName();
|
String subClassName = genTable.getSubTable().getClassName();
|
||||||
String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName);
|
String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName);
|
||||||
|
|
||||||
|
context.put("tableMapping" , StringUtils.sqlFormat(genTable.getTableName()));
|
||||||
|
context.put("subMapping" , StringUtils.sqlFormat(subTable.getTableName()));
|
||||||
context.put("subTable" , subTable);
|
context.put("subTable" , subTable);
|
||||||
context.put("subTableName" , subTableName);
|
context.put("subTableName" , subTableName);
|
||||||
context.put("subTableFkName" , subTableFkName);
|
context.put("subTableFkName" , subTableFkName);
|
||||||
|
|
@ -140,6 +153,9 @@ public class VelocityUtils {
|
||||||
} else if (GenConstants.TPL_SUB.equals(tplCategory)) {
|
} else if (GenConstants.TPL_SUB.equals(tplCategory)) {
|
||||||
templates.add("vm/vue/index.vue.vm");
|
templates.add("vm/vue/index.vue.vm");
|
||||||
templates.add("vm/java/sub-entity.java.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;
|
return templates;
|
||||||
}
|
}
|
||||||
|
|
@ -168,6 +184,8 @@ public class VelocityUtils {
|
||||||
}
|
}
|
||||||
if (template.contains("sub-entity.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory())) {
|
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")) {
|
} 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")) {
|
} else if (template.contains("service.java.vm")) {
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ gen:
|
||||||
# 作者
|
# 作者
|
||||||
author: hchyun
|
author: hchyun
|
||||||
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
|
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
|
||||||
packageName: com.hchyun.system
|
packageName: com.hchyun.test
|
||||||
# 自动去除表前缀,默认是false
|
# 自动去除表前缀,默认是false
|
||||||
autoRemovePre: true
|
autoRemovePre: true
|
||||||
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
|
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
|
||||||
tablePrefix: sys_
|
tablePrefix: sys_,test_
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
AND table_name NOT LIKE 'gen_%'
|
AND table_name NOT LIKE 'gen_%'
|
||||||
</select>
|
</select>
|
||||||
<select id="selectTableColumnByTableId" resultType="com.hchyun.generator.entity.AssColumn" parameterType="Long">
|
<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>
|
||||||
|
|
||||||
<select id="selectTableColumn" resultType="com.hchyun.generator.entity.AssColumn" parameterType="String">
|
<select id="selectTableColumn" resultType="com.hchyun.generator.entity.AssColumn" parameterType="String">
|
||||||
|
|
@ -24,14 +24,14 @@
|
||||||
|
|
||||||
<delete id="deleteTableColumn" parameterType="Long">
|
<delete id="deleteTableColumn" parameterType="Long">
|
||||||
delete
|
delete
|
||||||
from gen_acc_column
|
from gen_ass_column
|
||||||
where table_id = #{tableId}
|
where table_id = #{tableId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<insert id="insertColumns" parameterType="java.util.List">
|
<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)
|
is_query, query_type, html_type, dict_type, sort, create_by, update_by)
|
||||||
values
|
values
|
||||||
<foreach collection="list" item="item" index="index" separator=",">
|
<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="assTableName" column="ass_table_name" />
|
||||||
<result property="assTableColumn" column="ass_table_column" />
|
<result property="assTableColumn" column="ass_table_column" />
|
||||||
<result property="assTableFkColumn" column="ass_table_fk_column"/>
|
<result property="assTableFkColumn" column="ass_table_fk_column"/>
|
||||||
|
<result property="assQueryType" column="ass_query_type"/>
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time" />
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
|
|
@ -31,6 +32,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
|
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
|
||||||
</resultMap>
|
</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">
|
<resultMap type="com.hchyun.generator.entity.GenTableColumn" id="GenTableColumnResult">
|
||||||
<id property="columnId" column="column_id" />
|
<id property="columnId" column="column_id" />
|
||||||
<result property="tableId" column="table_id" />
|
<result property="tableId" column="table_id" />
|
||||||
|
|
@ -64,7 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<sql id="selectGenTableVo">
|
<sql id="selectGenTableVo">
|
||||||
select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category,
|
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,
|
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>
|
</sql>
|
||||||
|
|
||||||
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
||||||
|
|
@ -122,7 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<!--todo 获取表信息 预览代码使用-->
|
<!--todo 获取表信息 预览代码使用-->
|
||||||
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name,t.ass_table_name,t.ass_table_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.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,
|
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.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
|
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
|
LEFT JOIN sys_regular r ON c.is_regular = r.id
|
||||||
where t.table_id = #{tableId} order by c.sort
|
where t.table_id = #{tableId} order by c.sort
|
||||||
</select>
|
</select>
|
||||||
|
<!--todo 获取表信息 生成代码使用-->
|
||||||
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name,t.ass_table_name,t.ass_table_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.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,
|
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.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
|
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>
|
</select>
|
||||||
<!-- todo 查询数据库行配置信息-->
|
<!-- todo 查询数据库行配置信息-->
|
||||||
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name,t.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,
|
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.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_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="assTableName != null and assTableName !=''">ass_table_name = #{assTableName},</if>
|
||||||
<if test="assTableColumn != null and assTableColumn !=''">ass_table_column = #{assTableColumn},</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="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="className != null and className != ''">class_name = #{className},</if>
|
||||||
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
|
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
|
||||||
<if test="genType != null and genType != ''">gen_type = #{genType},</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)
|
#if($table.crud || $table.sub)
|
||||||
import com.hchyun.common.core.page.TableDataInfo;
|
import com.hchyun.common.core.page.TableDataInfo;
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
|
#elseif($table.tplCategory.equals("ass"))
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
#end
|
#end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -56,8 +58,12 @@ public class ${ClassName}Controller extends HcyBaseController {
|
||||||
@ApiOperation("查询${functionName}列表")
|
@ApiOperation("查询${functionName}列表")
|
||||||
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
|
||||||
@GetMapping("/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}) {
|
public Serializable list(${ClassName} ${className}) {
|
||||||
|
#end
|
||||||
try {
|
try {
|
||||||
startPage();
|
startPage();
|
||||||
ServerResult<List<${ClassName}>> serverResult = ${className}Service.select${ClassName}List(${className});
|
ServerResult<List<${ClassName}>> serverResult = ${className}Service.select${ClassName}List(${className});
|
||||||
|
|
|
||||||
|
|
@ -9,14 +9,17 @@ import com.hchyun.common.annotation.Excel;
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
#set($Entity="TreeEntity")
|
#set($Entity="TreeEntity")
|
||||||
#end
|
#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 com.hchyun.common.core.entity.${Entity};
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
#if($table.crud || $table.sub)
|
|
||||||
#elseif($table.tree)
|
|
||||||
#end
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}对象 ${tableName}
|
* ${functionName}对象 ${tableName}
|
||||||
|
|
@ -63,6 +66,9 @@ public class ${ClassName} extends ${Entity}
|
||||||
@ApiModelProperty("${table.subTable.functionName}信息")
|
@ApiModelProperty("${table.subTable.functionName}信息")
|
||||||
private List<${subClassName}> ${subclassName}List;
|
private List<${subClassName}> ${subclassName}List;
|
||||||
|
|
||||||
|
#elseif($table.tplCategory.equals("ass"))
|
||||||
|
private ${assClassName} ${assclassName};
|
||||||
|
|
||||||
#end
|
#end
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if(!$table.isSuperColumn($column.javaField))
|
#if(!$table.isSuperColumn($column.javaField))
|
||||||
|
|
@ -89,6 +95,15 @@ public class ${ClassName} extends ${Entity}
|
||||||
public void set${subClassName}List(List<${subClassName}> ${subclassName}List){
|
public void set${subClassName}List(List<${subClassName}> ${subclassName}List){
|
||||||
this.${subclassName}List = ${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
|
#end
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
* @date ${datetime}
|
* @date ${datetime}
|
||||||
*/
|
*/
|
||||||
public class ${subClassName} extends BaseEntity{
|
public class ${subClassName} extends BaseEntity{
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
#foreach ($column in $subTable.columns)
|
#foreach ($column in $subTable.columns)
|
||||||
#if(!$table.isSuperColumn($column.javaField))
|
#if(!$table.isSuperColumn($column.javaField))
|
||||||
|
|
|
||||||
|
|
@ -342,6 +342,9 @@ export default {
|
||||||
#end
|
#end
|
||||||
$column.javaField: [
|
$column.javaField: [
|
||||||
{ required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select")"change"#else"blur"#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
|
]#if($velocityCount != $columns.size()),#end
|
||||||
|
|
||||||
#end
|
#end
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,68 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
#end
|
#end
|
||||||
#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
|
#end
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
|
@ -139,6 +201,30 @@
|
||||||
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
<el-table-column label="${comment}" align="center" prop="${javaField}" />
|
||||||
#end
|
#end
|
||||||
#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">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
<el-button
|
||||||
|
|
@ -393,6 +479,22 @@ export default {
|
||||||
// $comment时间范围
|
// $comment时间范围
|
||||||
daterange${AttrName}: [],
|
daterange${AttrName}: [],
|
||||||
#end
|
#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
|
#end
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
|
|
@ -403,6 +505,16 @@ export default {
|
||||||
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
$column.javaField: null#if($velocityCount != $columns.size()),#end
|
||||||
|
|
||||||
#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
|
#end
|
||||||
},
|
},
|
||||||
// 表单参数
|
// 表单参数
|
||||||
|
|
@ -519,6 +631,11 @@ export default {
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
this.daterange${AttrName} = [];
|
this.daterange${AttrName} = [];
|
||||||
#end
|
#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
|
#end
|
||||||
this.resetForm("queryForm");
|
this.resetForm("queryForm");
|
||||||
this.handleQuery();
|
this.handleQuery();
|
||||||
|
|
|
||||||
|
|
@ -4,36 +4,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="${packageName}.dao.${ClassName}Dao">
|
<mapper namespace="${packageName}.dao.${ClassName}Dao">
|
||||||
|
|
||||||
<resultMap type="${ClassName}" id="${ClassName}Result">
|
<resultMap type="${packageName}.entity.${ClassName}" id="${ClassName}Result">
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
<result property="${column.javaField}" column="${column.columnName}" />
|
<result property="${column.javaField}" column="${column.columnName}" />
|
||||||
#end
|
#end
|
||||||
</resultMap>
|
</resultMap>
|
||||||
#if($table.sub)
|
#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" />
|
<collection property="${subclassName}List" notNullColumn="${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap type="${subClassName}" id="${subClassName}Result">
|
<resultMap type="${packageName}.entity.${subClassName}" id="${subClassName}Result">
|
||||||
#foreach ($column in $subTable.columns)
|
#foreach ($column in $subTable.columns)
|
||||||
<result property="${column.javaField}" column="${column.columnName}" />
|
<result property="${column.javaField}" column="${column.columnName}" />
|
||||||
#end
|
#end
|
||||||
</resultMap>
|
</resultMap>
|
||||||
#end
|
#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">
|
<sql id="select${ClassName}Vo">
|
||||||
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
|
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
|
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
|
||||||
<include refid="select${ClassName}Vo"/>
|
#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>
|
<where>
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
#set($queryType=$column.queryType)
|
#set($queryType=$column.queryType)
|
||||||
#set($javaField=$column.javaField)
|
#set($javaField=$column.javaField)
|
||||||
#set($javaType=$column.javaType)
|
#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)})
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
#if($column.query)
|
#if($column.query)
|
||||||
#if($column.queryType == "EQ")
|
#if($column.queryType == "EQ")
|
||||||
|
|
@ -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>
|
<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
|
#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
|
#end
|
||||||
</where>
|
</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>
|
||||||
|
|
||||||
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
|
<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"/>
|
<include refid="select${ClassName}Vo"/>
|
||||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||||
#elseif($table.sub)
|
#elseif($table.sub)
|
||||||
select#foreach($column in $columns) a.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
select#foreach($column in $columns) ${tableMapping}.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
||||||
#foreach($column in $subTable.columns) b.$column.columnName#if($velocityCount != $subTable.columns.size()),#end#end
|
#foreach($column in $subTable.columns) ${subMapping}.$column.columnName#if($velocityCount != $subTable.columns.size()),#end#end
|
||||||
|
|
||||||
from ${tableName} a
|
from ${tableName} ${tableMapping}
|
||||||
left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName}
|
left join ${subTableName} ${subMapping} on ${subMapping}.${subTableFkName} = ${tableMapping}.${pkColumn.columnName}
|
||||||
where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
|
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
|
#end
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue