优化代码生成功能
This commit is contained in:
@@ -67,22 +67,6 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
return SUCCESS(vm);
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 获取表格列
|
||||
///// </summary>
|
||||
///// <param name="dbName"></param>
|
||||
///// <param name="tableName"></param>
|
||||
///// <returns></returns>
|
||||
//[HttpGet("getColumnInfo")]
|
||||
//[ActionPermissionFilter(Permission = "tool:gen:list")]
|
||||
//public IActionResult QueryColumnInfo(string dbName, string tableName)
|
||||
//{
|
||||
// if (string.IsNullOrEmpty(dbName) || string.IsNullOrEmpty(tableName))
|
||||
// return ToRespose(ResultCode.PARAM_ERROR);
|
||||
|
||||
// return SUCCESS(_CodeGeneraterService.GetColumnInfo(dbName, tableName));
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 代码生成器
|
||||
/// </summary>
|
||||
@@ -149,7 +133,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
public IActionResult Remove(string tableIds)
|
||||
{
|
||||
long[] tableId = Tools.SpitLongArrary(tableIds);
|
||||
|
||||
|
||||
GenTableService.DeleteGenTableByIds(tableId);
|
||||
return SUCCESS(1);
|
||||
}
|
||||
@@ -207,7 +191,7 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
TableName = tableName,
|
||||
CsharpType = TableMappingHelper.GetPropertyDatatype(column.DataType),
|
||||
CsharpField = column.DbColumnName.Substring(0, 1).ToUpper() + column.DbColumnName[1..],
|
||||
IsRequired = column.IsNullable,
|
||||
IsRequired = !column.IsNullable,
|
||||
IsIncrement = column.IsIdentity,
|
||||
Create_by = userName,
|
||||
Create_time = DateTime.Now,
|
||||
@@ -222,19 +206,23 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_IMAGE_UPLOAD;
|
||||
}
|
||||
if (genTableColumn.CsharpType.ToLower().Contains("datetime"))
|
||||
else if (genTableColumn.CsharpType.ToLower().Contains("datetime"))
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_DATETIME;
|
||||
}
|
||||
if (CodeGeneratorTool.radioFiled.Any(f => column.DbColumnName.Contains(f)))
|
||||
else if (CodeGeneratorTool.radioFiled.Any(f => column.DbColumnName.Contains(f)))
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_RADIO;
|
||||
}
|
||||
if (column.Length > 200)
|
||||
else if (CodeGeneratorTool.selectFiled.Any(f => column.DbColumnName.Contains(f)))
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_SELECT;
|
||||
}
|
||||
else if (column.Length > 300)
|
||||
{
|
||||
genTableColumn.HtmlType = GenConstants.HTML_TEXTAREA;
|
||||
}
|
||||
|
||||
|
||||
genTableColumns.Add(genTableColumn);
|
||||
}
|
||||
|
||||
@@ -251,14 +239,14 @@ namespace ZR.Admin.WebApi.Controllers
|
||||
/// 代码生成保存
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPut()]
|
||||
[HttpPut]
|
||||
//[Log(Title = "代码生成", BusinessType = BusinessType.UPDATE)]
|
||||
[ActionPermissionFilter(Permission = "tool:gen:edit")]
|
||||
public IActionResult EditSave([FromBody]GenTableDto genTableDto)
|
||||
public IActionResult EditSave([FromBody] GenTableDto genTableDto)
|
||||
{
|
||||
if (genTableDto == null) throw new CustomException("请求参数错误");
|
||||
var genTable = genTableDto.Adapt<GenTable>().ToUpdate();
|
||||
|
||||
var genTable = genTableDto.Adapt<GenTable>().ToUpdate(HttpContext);
|
||||
|
||||
int rows = GenTableService.UpdateGenTable(genTable);
|
||||
if (rows > 0)
|
||||
{
|
||||
|
||||
@@ -57,7 +57,10 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
{
|
||||
types.GetProperty("UpdateTime").SetValue(source, DateTime.Now, null);
|
||||
}
|
||||
|
||||
if (types.GetProperty("Update_Time") != null)
|
||||
{
|
||||
types.GetProperty("Update_Time").SetValue(source, DateTime.Now, null);
|
||||
}
|
||||
//if (types.GetProperty("UpdateID") != null)
|
||||
//{
|
||||
// types.GetProperty("UpdateID").SetValue(source, userSession.UserID, null);
|
||||
@@ -67,6 +70,10 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
{
|
||||
types.GetProperty("UpdateBy").SetValue(source,context.GetName(), null);
|
||||
}
|
||||
if (types.GetProperty("Update_by") != null)
|
||||
{
|
||||
types.GetProperty("Update_by").SetValue(source, context.GetName(), null);
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace ZR.Admin.WebApi.Extensions
|
||||
}
|
||||
public static string GetName(this HttpContext context)
|
||||
{
|
||||
var uid = context.User.Identity.Name;
|
||||
var uid = context.User?.Identity?.Name;
|
||||
|
||||
return uid;
|
||||
}
|
||||
|
||||
@@ -80,9 +80,12 @@ namespace {ApiControllerNamespace}.Controllers
|
||||
throw new CustomException("请求参数错误");
|
||||
}
|
||||
//从 Dto 映射到 实体
|
||||
var addModel = parm.Adapt<{ModelName}>().ToCreate();
|
||||
var model = parm.Adapt<{ModelName}>().ToCreate();
|
||||
|
||||
return SUCCESS(_{ModelName}Service.Add(addModel));
|
||||
return SUCCESS(_{ModelName}Service.Add(model, it => new
|
||||
{
|
||||
{InsertColumn}
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -99,9 +102,9 @@ namespace {ApiControllerNamespace}.Controllers
|
||||
throw new CustomException("请求实体不能为空");
|
||||
}
|
||||
//从 Dto 映射到 实体
|
||||
var updateModel = parm.Adapt<{ModelName}>().ToUpdate();
|
||||
var model = parm.Adapt<{ModelName}>().ToUpdate();
|
||||
|
||||
var response = _{ModelName}Service.Update(w => w.{PrimaryKey} == updateModel.{PrimaryKey}, it => new {ModelName}()
|
||||
var response = _{ModelName}Service.Update(w => w.{PrimaryKey} == model.{PrimaryKey}, it => new {ModelName}()
|
||||
{
|
||||
//Update 字段映射
|
||||
{UpdateColumn}
|
||||
|
||||
@@ -13,8 +13,12 @@ namespace {DtosNamespace}.Dto
|
||||
{PropertyName}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// {TableNameDesc}查询对象模型
|
||||
/// </summary>
|
||||
public class {ModelTypeName}QueryDto: PagerInfo
|
||||
{
|
||||
{QueryProperty}
|
||||
public DateTime? BeginTime { get; set; }
|
||||
public DateTime? EndTime { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,24 +1,8 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 -->
|
||||
<!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 -->
|
||||
<el-form :model="queryParams" label-position="left" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch" @submit.native.prevent>
|
||||
<el-form-item label="文本文字">
|
||||
<el-input v-model="queryParams.xxx" placeholder="" />
|
||||
</el-form-item>
|
||||
<el-form-item label="数字">
|
||||
<el-input v-model.number="queryParams.xxx" placeholder="" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="下拉框">
|
||||
<el-select v-model="queryParams.xxx" placeholder="">
|
||||
<el-option v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="时间范围">
|
||||
<el-date-picker size="small" style="width: 240px" v-model="timeRange" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
{vueQueryFormHtml}
|
||||
|
||||
<el-row class="mb8" style="text-align:center">
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
@@ -47,7 +31,7 @@
|
||||
<el-table-column label="操作" align="center" width="200">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" v-hasPermi="['{Permission}:update']" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
|
||||
<el-popconfirm title="确定删除吗?" @onConfirm="handleDelete(scope.row)" style="margin-left:10px">
|
||||
<el-popconfirm title="确定删除吗?" @confirm="handleDelete(scope.row)" style="margin-left:10px">
|
||||
<el-button slot="reference" v-hasPermi="['{Permission}:delete']" size="mini" type="text" icon="el-icon-delete">删除</el-button>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
@@ -103,8 +87,7 @@ export default {
|
||||
form: {},
|
||||
// 时间范围数组
|
||||
timeRange: [],
|
||||
// xxx下拉框
|
||||
statusOptions: [],
|
||||
{VueDataContent}
|
||||
// 数据列表
|
||||
dataList: [],
|
||||
// 总记录数
|
||||
|
||||
Reference in New Issue
Block a user