一:框架 springboot+vue+mysql+mybatis
二:主要技术点,
freemarker模板语言,没什么难点,就是画模板的时候要细心,各个字段控件的原始代码,【可以在element上面直接copy,然后把对应字段改成动态绑定】
三:demo展示 ,
数据库是动态链接,暂时就添加了mysql一种,根据需要进行调整
生成之前的操作页面(查询,列表,编辑,必填,根据需要进行勾选,勾选之后就体现在生成后的代码)
最终生成的样式展示(数据库表按要求设计之后,增删改查就直接完成,不需要修改代码)
四:代码
1:前台代码
<template>
<div>
<el-row>
<el-col :offset="1" :span="23">
<el-form :model="form" ref="ff" label-width="10px" size="small">
<el-row>
<el-col :span="24">
<el-table :data="detailList" style="width: 100%" border>
<el-table-column label="序号" width="50" align='center' type="index" ></el-table-column>
<el-table-column prop="fieldName" label="名称" header-align="center" ></el-table-column>
<el-table-column prop="fieldTypeJdbc" label="类型" header-align="center" ></el-table-column>
<el-table-column prop="fieldTypeJava" label="泛型" header-align="center" ></el-table-column>
<el-table-column prop="fieldLength" width="50" label="长度" header-align="center" ></el-table-column>
<!--<el-table-column prop="fieldSccle" label="小数点右边的位数" header-align="center" ></el-table-column>-->
<el-table-column prop="remarks" label="备注" header-align="center" ></el-table-column>
<el-table-column prop="cx" label="查询" width="50" align='center'>
<template slot-scope="scope">
<el-checkbox v-model="scope.row.cx"></el-checkbox>
<!--<el-select v-model="scope.row.cx" clearable placeholder="请选择" style="width: 80px;">
<el-option key="1" label="是" value="1"> </el-option>
<el-option key="0" label="否" value="0"> </el-option>
</el-select>-->
</template>
</el-table-column>
<el-table-column prop="lb" label="列表" width="50" align='center'>
<template slot-scope="scope">
<el-checkbox v-model="scope.row.lb"></el-checkbox>
</template>
</el-table-column>
<el-table-column prop="bj" label="编辑" width="50" align='center'>
<template slot-scope="scope">
<el-checkbox v-model="scope.row.bj"></el-checkbox>
</template>
</el-table-column>
<el-table-column prop="bt" label="必填" width="50" align='center'>
<template slot-scope="scope">
<el-checkbox v-model="scope.row.bt"></el-checkbox>
</template>
</el-table-column>
<el-table-column prop="xslx" label="显示类型" width="140" align='center'>
<template slot-scope="scope">
<el-select v-model="scope.row.xslx" clearable placeholder="请选择" style="width: 120px;">
<el-option key="1" label="文本框" value="1"> </el-option>
<el-option key="2" label="下拉选择框" value="2"> </el-option>
<el-option key="3" label="日期选择框" value="3"> </el-option>
<el-option key="4" label="时间选择框" value="4"> </el-option>
</el-select>
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
</el-form>
<div style="text-align: center">
<span >
<el-button type="primary" @click="subitForm" >保 存</el-button>
<el-button type="info" @click="closeDialog">取消</el-button>
</span>
</div>
</el-col>
</el-row>
</div>
</template>
<script>
import {baseUrl} from '../../../conf/env.js'
export default {
props: {
tableName: '',
queryParm:''
},
data: function () {
return {
detailList: [],
table:{
dbAddress:'',
port:'',
databaseName:'',
username:'',
password:'',
tableName:''
},
form: {}
}
},
created() {
this.getDataInfo();
},
methods: {
closeDialog:function(){
this.$emit("listenClosed",null)
},
getDataInfo() {
var _self = this;
_self.table =this.queryParm;
_self.table.tableName=this.tableName;
this.$axios.post(baseUrl + '/createCode/column', _self.table).then(function (response) {
let data = response.data;
if (data.code == 100) {
_self.detailList = data.data;
}
}).catch(function (error) {
console.log(error)
})
},
subitForm() {
var _self = this;
this.$axios.post(baseUrl + '/createCode/savecolumn/'+_self.tableName, _self.detailList).then(function (response) {
let data = response.data;
if (data.code == 100) {
_self.$message({message: '代码生成成功!', type: 'success'});
_self.$emit("listenClosed",null)
}
}).catch(function (error) {
console.log(error)
})
},
onSubmit(formName) {
var _self = this;
_self.$refs[formName].validate((valid) => {
if (valid) {
this.$axios.post(baseUrl + '/sysUser/save', _self.formData).then(function (response) {
let data = response.data;
if (data.code === 100) {
_self.$message({message: '保存成功!', type: 'success'});
_self.$router.push('/system/user/list')
} else {
_self.$message.error('保存失败');
console.log("erro", response)
}
}).catch(function (error) {
_self.$message.error('保存失败');
console.log(error)
});
} else {
return false;
}
})
}
}
}
</script>
后台代码
package com.ebiz.manager.controller.sys;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.ebiz.common.Keys;
import com.ebiz.common.base.controller.BaseController;
import com.ebiz.common.base.vo.SysCodeVo;
import com.ebiz.common.base.vo.SysTableVo;
import com.ebiz.common.util.DbUtils;
import com.ebiz.common.util.Generator;
import com.ebiz.common.util.ResultModel;
import com.ebiz.common.util.constants.ResultStatus;
/**
* 类名称: 反向生成
*/
@RestController
@RequestMapping(value = "/createCode")
public class SysCodeController extends BaseController {
@RequestMapping(value = "table", method = RequestMethod.GET)
public ResultModel get() {
SysCodeVo vo = new SysCodeVo();
vo.setDbAddress(Keys.dbAddress);
vo.setPort(Keys.port);
vo.setDatabaseName(Keys.databaseName);
vo.setUsername(Keys.username);
vo.setPassword(Keys.password);
return ResultModel.ok(vo);
}
/**
* 列出所有表
*
* @param
* @throws SQLException
* @throws ClassNotFoundException
* @throws Exception
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "tablelist", method = RequestMethod.POST)
public Object listAllTable(@RequestBody SysCodeVo vo) throws Exception {
List<String> tableList = new ArrayList<String>();
String username = vo.getUsername(); // 用户名
String password = vo.getPassword(); // 密码
String address = vo.getDbAddress(); // 数据库连接地址
String dbport = vo.getPort(); // 端口
String databaseName = vo.getDatabaseName(); // 数据库名
String dbtype = Keys.dbtype;
Connection conn = DbUtils.getCon(dbtype, username, password, address + ":" + dbport, databaseName);
if ("oracle".equals(dbtype)) {
databaseName = username;
}
Object[] arrOb = { databaseName, DbUtils.getTablesByCon(conn, "sqlserver".equals(dbtype) ? null : databaseName),
dbtype };
tableList = (List<String>) arrOb[1];
List<SysCodeVo> sysTableVoList = new ArrayList<SysCodeVo>();
Long total = 5l;
for (String table : tableList) {
SysCodeVo tablevo = new SysCodeVo();
tablevo.setTableName(table);
sysTableVoList.add(tablevo);
}
return ResultModel.ok(sysTableVoList, total);
}
/**
* 去代码生成器页面(进入弹窗)
*
* @return
* @throws Exception
*/
@RequestMapping(value = "column", method = RequestMethod.POST)
public Object goProductCode(@RequestBody SysCodeVo vo) throws Exception {
List<SysTableVo> columnList = DbUtils.getFieldParameterLsit(DbUtils.getDbUtils(vo), vo.getTableName()); //
for (SysTableVo stvo : columnList) {
if (stvo.getFieldTypeJdbc().equals("DATE")) {
stvo.setXslx("3");
} else if (stvo.getFieldTypeJdbc().equals("TIMESTAMP")) {
stvo.setXslx("4");
} else if (stvo.getFieldTypeJdbc().equals("VARCHAR")) {
stvo.setXslx("1");
}
stvo.setLb(true);
}
return ResultModel.ok(columnList);
}
/**
* @return
* @throws Exception
*/
@RequestMapping(value = "savecolumn/{tableName}", method = RequestMethod.POST)
public Object savecolumn(@PathVariable("tableName") String tableName, @RequestBody List<SysTableVo> voList)
throws Exception {
try {
List<Map<String, Object>> columnList = new ArrayList<Map<String, Object>>();
Set<String> packageImportList = new HashSet<String>();
for (SysTableVo vo : voList) {
logger.info("============" + vo.getFieldName());
Map<String, Object> column = new HashMap<String, Object>();
column.put("javaName", StringUtils.capitalize(vo.getFieldName().toLowerCase()));
column.put("lowerCaseName", StringUtils.lowerCase(vo.getFieldName()));
int lastIndex = vo.getFieldTypeJava().lastIndexOf('.');
if (lastIndex != -1 && !vo.getFieldTypeJava().startsWith("java.lang.")) {
packageImportList.add(vo.getFieldTypeJava());
}
column.put("javaType", vo.getFieldTypeJava().substring(lastIndex + 1));
column.put("jdbcType", vo.getFieldTypeJdbc());
if (vo.getXslx() == null) {
column.put("formType", 1);
} else {
column.put("formType", Integer.valueOf(vo.getXslx()));
}
column.put("name", vo.getFieldName());
column.put("remarks", vo.getRemarks());
column.put("fieldLength", Integer.valueOf(vo.getFieldLength()) / 2);
if (vo.isCx()) {// 查询
column.put("cx", "true");
}
if (vo.isLb()) {// 列表
column.put("lb", "true");
}
if (vo.isBj()) {// 编辑
column.put("bj", "true");
}
if (vo.isBt()) {// 必填
column.put("bt", "true");
}
columnList.add(column);
}
Arrays.sort(packageImportList.toArray());
Generator.run(columnList, tableName, packageImportList);
} catch (Exception e) {
e.printStackTrace();
return ResultModel.error(ResultStatus.EXCEPTION);
}
return ResultModel.ok();
}
}
具体运用freemarker生成文件代码
package com.ebiz.common.util;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.time.DateFormatUtils;
import com.ebiz.common.Keys;
/**
*
* @author zq
*
*/
public class Generator {
private static String saveBasePath, projectName, packagePrefix, modelName;
// Absoulute package path
private static String relativeRootPath, projectPackage, commonsPackage;
// Absoulute save path
private static String entityPath, daoMapperPath, servicePath, serviceImplPath, controllerPath, jspPath;
// start up
static {
projectName = Keys.config_project_name;
modelName = Keys.config_model_name;
packagePrefix = Keys.config_project_package_prefix;
commonsPackage = Keys.config_project_package_commons_prefix;
saveBasePath = Keys.config_savepath;
relativeRootPath = new StringBuffer(packagePrefix.replace(".", File.separator)).append(File.separator)
.append(projectName).append(File.separator).toString();
projectPackage = packagePrefix + "." + projectName;
entityPath = relativeRootPath + "entity";
daoMapperPath = relativeRootPath + "dao";
servicePath = relativeRootPath + "service";
serviceImplPath = relativeRootPath + "service/impl";
controllerPath = relativeRootPath + "controller";
jspPath = relativeRootPath;
}
public static void run(List<Map<String, Object>> columnList, String tableName, Set<String> packageImportList)
throws Exception {
String ftlPath = FreemarkerUtils.ftlPath; // ftl路径
// fileName
String entityFileName = CommUtils.capitalize(tableName.toUpperCase()) + ".java";
String serviceFileName = CommUtils.capitalize(tableName.toUpperCase()) + "Service" + ".java";
String serviceImplFileName = CommUtils.capitalize(tableName.toUpperCase()) + "ServiceImpl" + ".java";
String daoImplFileName = CommUtils.capitalize(tableName.toUpperCase()) + "Dao" + ".java";
String daoImplSqlMapFileName = CommUtils.capitalize(tableName.toUpperCase()) + "Dao" + ".xml";
String controllerFileName = CommUtils.capitalize(tableName.toUpperCase()) + "Controller" + ".java";
String listFileName = CommUtils.toLowerCaseFirstLetter(CommUtils.capitalize(tableName.toUpperCase()))
+ "/list.vue";
String formFileName = CommUtils.toLowerCaseFirstLetter(CommUtils.capitalize(tableName.toUpperCase()))
+ "/form.vue";
String viewFileName = CommUtils.toLowerCaseFirstLetter(CommUtils.capitalize(tableName.toUpperCase()))
+ "/view.vue";
// Initialize a model
Map<String, Object> model = new HashMap<String, Object>();
model.put("packagePrefix", projectPackage);
model.put("commonsPackagePrefix", commonsPackage);
model.put("generatorTime", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm"));
model.put("packageImportList", packageImportList);
model.put("modelName", modelName);
Map<String, Object> table = new HashMap<String, Object>();
table.put("javaName", CommUtils.capitalize(tableName.toUpperCase()));
table.put("javaNameUpperCase", CommUtils.capitalize(tableName).toUpperCase());
table.put("name", tableName);
table.put("variableName", CommUtils.toLowerCaseFirstLetter(CommUtils.capitalize(tableName.toUpperCase())));
table.put("columeList", columnList);
model.put("table", table);
List<Map<String, Object>> tableList = new ArrayList<Map<String, Object>>();
tableList.add(table);
model.put("tableList", tableList);
/* 生成实体类 */
FreemarkerUtils.printFile("entity.ftl", model, entityPath + "/" + entityFileName, saveBasePath, ftlPath);
/* 生成service层 */
FreemarkerUtils.printFile("service.ftl", model, servicePath + "/" + serviceFileName, saveBasePath, ftlPath);
/* 生成serviceimpl层 */
FreemarkerUtils.printFile("serviceimpl.ftl", model, serviceImplPath + "/" + serviceImplFileName, saveBasePath,
ftlPath);
// FreemarkerUtils.printFile("FacdeService.ftl", model, serviceImplPath + "/" +
// serviceFacadeImplName,
// saveBasePath, ftlPath);
/* 生成dao层 */
FreemarkerUtils.printFile("dao.ftl", model, daoMapperPath + "/" + daoImplFileName, saveBasePath, ftlPath);
FreemarkerUtils.printFile("sqlmap.ftl", model, daoMapperPath + "/" + daoImplSqlMapFileName, saveBasePath,
ftlPath);
/* 生成controller */
FreemarkerUtils.printFile("controller.ftl", model, controllerPath + "/" + controllerFileName, saveBasePath,
ftlPath);
/* 生成页面层 */
FreemarkerUtils.printFile("listvue.ftl", model, jspPath + "/" + listFileName, saveBasePath, ftlPath);
FreemarkerUtils.printFile("formvue.ftl", model, jspPath + "/" + formFileName, saveBasePath, ftlPath);
FreemarkerUtils.printFile("viewvue.ftl", model, jspPath + "/" + viewFileName, saveBasePath, ftlPath);
}
}
路径什么的,根据实际情况进行修改,也可以做到页面,可动态填写,(作者觉得不是重点就直接写死)
freemarker模板中
前台表单页面模板代码
<template>
<div>
<el-form ref="form" size="small" :model="formData" :rules="rules" label-width="120px">
<el-row style="margin-bottom: 5px">
<el-col :span="2" :offset="18">
<el-button type="primary" v-if="!isView" @click="onSubmit('form')" size="mini">保存</el-button>
</el-col>
<el-col :span="2">
<el-button v-if="!isView" @click="closeDialog" size="mini">取消</el-button>
</el-col>
</el-row>
<div style="height: 550px;overflow:auto;overflow-x:hidden;border: 1px solid #dcdfe6">
<#list table.columeList as col>
<#if col.bj??>
<#if (col.formType == 1)>
<el-row style="margin-top: 5px">
<el-col :span="11">
<el-form-item label="${col.remarks}:" prop="${col.lowerCaseName}">
<el-input v-model="formData.${col.lowerCaseName}" maxlength="20"></el-input>
</el-form-item>
</el-col>
</el-row>
</#if>
<#if (col.formType == 2)>
<el-row>
<el-col :span="11">
<el-form-item label="${col.remarks}:" prop="${col.lowerCaseName}">
<el-select style="width: 100%" v-model="formData.${col.lowerCaseName}" clearable placeholder="请选择">
<el-option key="0" label="测试0。。。" value="0"> </el-option>
<el-option key="1" label="测试1。。。" value="1"> </el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
</#if>
<#if (col.formType == 3)>
<el-row>
<el-col :span="11">
<el-form-item label="${col.remarks}:">
<el-date-picker style="width: 150px;"
v-model="formData.${col.lowerCaseName}"
align="right"
type="date"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
placeholder="选择日期">
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
</#if>
<#if (col.formType == 4)>
<el-row>
<el-col :span="11">
<el-form-item label="${col.remarks}:">
<el-date-picker style="width: 200px;"
v-model="formData.${col.lowerCaseName}"
align="right"
type="datetime"
format="yyyy-MM-dd HH:mm:ss"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择日期">
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
</#if>
</#if>
</#list>
</div>
</el-form>
</div>
</template>
<script>
import {baseUrl} from '../../../conf/env.js'
export default {
props: {
${table.variableName}Id: '',
type: {
type: String,
default: ''
}
},
data: function () {
var checkNum = (rule, value, callback) => {
if (value) {
var reg = /^(0|[1-9]\d{0,8})$/;
var flag = reg.test(value);
if (!flag) {
callback(new Error('请输入正确的数字格式!'));
} else {
callback();
}
} else {
callback();
}
};
return {
isView: false,
formData: {
<#list table.columeList as col>
<#if col.bj??>
${col.lowerCaseName}: '',
</#if>
</#list>
},
rules: {
<#list table.columeList as col>
<#if col.bt??>
${col.lowerCaseName}: [ {required: true, message: '请输入${col.remarks}', trigger: 'blur'}],
</#if>
</#list>
}
}
},
created() {
if("add"==this.type){
}else if("edit"==this.type){
this.getDataInfo(this.${table.variableName}Id);
}else if("view"==this.type){
this.isView=true;
this.getDataInfo(this.${table.variableName}Id);
}
},
watch: {
},
methods: {
closeDialog:function(){
this.restForm();
this.$emit("listenClosed",null)
},
restForm:function(){
this.formData.${table.variableName}Id='';
},
goBack() {
this.$router.push('/system/${table.variableName}/list');
},
getDataInfo(id) {
var _self = this;
this.$axios.get(baseUrl + '/${table.variableName}/view/' + id).then(function (response) {
let data = response.data;
if (data.code == 100) {
_self.formData = data.data;
}
}).catch(function (error) {
console.log(error)
})
},
onSubmit(formName) {
var _self = this;
_self.$refs[formName].validate((valid) => {
if (valid) {
this.$axios.post(baseUrl + '/${table.variableName}/save', _self.formData).then(function (response) {
let data = response.data;
if (data.code === 100) {
_self.$message({message: '保存成功!', type: 'success'});
_self.$emit('getData',1);
_self.$emit("listenClosed",null)
} else {
_self.$message.error('保存失败');
console.log("erro", response)
}
}).catch(function (error) {
_self.$message.error('保存失败');
console.log(error)
});
} else {
return false;
}
})
}
}
}
</script>
后台控制页面模板代码
package ${packagePrefix}.manager.controller.${modelName};
import java.util.List;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import ${packagePrefix}.common.base.controller.BaseController;
import ${packagePrefix}.common.base.entity.${table.javaName};
import ${packagePrefix}.common.util.ResultModel;
import ${packagePrefix}.common.util.StringTools;
import ${packagePrefix}.common.util.annotation.SysLog;
import ${packagePrefix}.common.util.constants.ResultStatus;
import ${packagePrefix}.common.util.constants.DictCodeList;
import ${packagePrefix}.manager.service.${modelName}.${table.javaName}Service;
/**
* @author ZHANGQ
* @version ${generatorTime}
*/
@RestController
@RequestMapping(value = "/${table.variableName}")
public class ${table.javaName}Controller extends BaseController {
private Logger logger = LoggerFactory.getLogger(${table.javaName}Controller.class);
@Autowired
private ${table.javaName}Service ${table.variableName}Service;
@SysLog("获取${table.javaName}列表")
@RequiresPermissions(value = { "${table.variableName}:list", "${table.variableName}:add", "${table.variableName}:update", "${table.variableName}:delete","${table.variableName}:audit" }, logical = Logical.OR)
@RequestMapping(value = "pageList", method = RequestMethod.POST)
public ResultModel getList(@RequestBody ${table.javaName} ${table.variableName}) {
${table.variableName}.setIs_del(0);
Long recordCount = this.${table.variableName}Service.selectEntityCount(${table.variableName});
List<${table.javaName}> ${table.variableName}List = ${table.variableName}Service.selectEntityPageList(${table.variableName});
return ResultModel.ok(${table.variableName}List, recordCount);
}
@SysLog("保存${table.javaName}")
@RequiresPermissions(value = { "${table.variableName}:update", "${table.variableName}:add" }, logical = Logical.OR)
@RequestMapping(value = "save", method = RequestMethod.POST)
public ResultModel save${table.javaName}Info(@RequestBody ${table.javaName} ${table.variableName}) {
if (${table.variableName} == null) {
return ResultModel.error(ResultStatus.V_PARMS_ERRO);
}
try {
if (StringTools.isNullOrEmpty(${table.variableName}.getId())) {// 新增
${table.variableName}.preInsert();
${table.variableName}Service.insertEntity(${table.variableName});
} else {
${table.variableName}.preUpdate();
${table.variableName}Service.updateEntity(${table.variableName});
}
} catch (Exception e) {
logger.error("保存${table.javaName}erro--" + e.getMessage(), e);
return ResultModel.error(ResultStatus.EXCEPTION);
}
return ResultModel.ok();
}
@SysLog("查看${table.javaName}")
@RequiresPermissions("${table.variableName}:view")
@RequestMapping(value = "view/{${table.variableName}Id}", method = RequestMethod.GET)
public ResultModel view${table.javaName}(@PathVariable("${table.variableName}Id") String ${table.variableName}Id) {
try {
${table.javaName} ${table.variableName} = new ${table.javaName}();
${table.variableName}.setId(${table.variableName}Id);
${table.variableName} = ${table.variableName}Service.selectEntity(${table.variableName});
return ResultModel.ok(${table.variableName});
} catch (Exception e) {
logger.error("查看${table.javaName}erro--" + e.getMessage(), e);
return ResultModel.error(ResultStatus.EXCEPTION);
}
}
@SysLog("状态删除${table.javaName}")
@RequiresPermissions("${table.variableName}:delete")
@RequestMapping(value = "updateDel", method = RequestMethod.POST)
public ResultModel updateDel(@RequestBody ${table.javaName} ${table.variableName}) {
try {
${table.variableName}.setIs_del(1);
${table.variableName}Service.updateEntity(${table.variableName});
} catch (Exception e) {
logger.error("${table.javaName}删除失败:" + e.getMessage(), e);
return ResultModel.exception(e.getMessage());
}
return ResultModel.ok();
}
@SysLog("物理删除${table.javaName}")
@RequiresPermissions("${table.variableName}:delete")
@RequestMapping(value = "del", method = RequestMethod.POST)
public ResultModel delEntity(@RequestBody ${table.javaName} ${table.variableName}) {
try {
${table.variableName}Service.deleteEntity(${table.variableName});
} catch (Exception e) {
logger.error("${table.javaName}删除失败:" + e.getMessage(), e);
return ResultModel.exception(e.getMessage());
}
return ResultModel.ok();
}
}
模板文件可以根据实际情况进行调整修改,还可以做到更完善,细节还有很多