开发代码生成功能
This commit is contained in:
parent
d581934a39
commit
9ff6fb8c98
@ -9,9 +9,9 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ZR.CodeGenerator;
|
using ZR.CodeGenerator;
|
||||||
|
using ZR.CodeGenerator.Model;
|
||||||
using ZR.CodeGenerator.Service;
|
using ZR.CodeGenerator.Service;
|
||||||
using ZR.Model;
|
using ZR.Model;
|
||||||
using ZR.Model.CodeGenerator;
|
|
||||||
using ZR.Model.Vo;
|
using ZR.Model.Vo;
|
||||||
using ZR.Service.IService;
|
using ZR.Service.IService;
|
||||||
using ZR.Service.System;
|
using ZR.Service.System;
|
||||||
@ -21,7 +21,7 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 代码生成
|
/// 代码生成
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("codeGenerator")]
|
[Route("tool/gen")]
|
||||||
public class CodeGeneratorController : BaseController
|
public class CodeGeneratorController : BaseController
|
||||||
{
|
{
|
||||||
//public ICodeGeneratorService CodeGeneratorService;
|
//public ICodeGeneratorService CodeGeneratorService;
|
||||||
@ -35,11 +35,13 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
/// 获取所有数据库的信息
|
/// 获取所有数据库的信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("GetListDataBase")]
|
[HttpGet("getDbList")]
|
||||||
//[YuebonAuthorize("GetListDataBase")]
|
//[YuebonAuthorize("GetListDataBase")]
|
||||||
public IActionResult GetListDataBase()
|
public IActionResult GetListDataBase()
|
||||||
{
|
{
|
||||||
return SUCCESS(_CodeGeneraterService.GetAllDataBases());
|
var dbList = _CodeGeneraterService.GetAllDataBases();
|
||||||
|
var defaultDb = dbList.Count > 0 ? dbList[0] : null;
|
||||||
|
return SUCCESS(new { dbList, defaultDb });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -59,27 +61,35 @@ namespace ZR.Admin.WebApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 代码生成器
|
/// 获取表格列
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dbName"></param>
|
/// <param name="dbName"></param>
|
||||||
/// <param name="tables">要生成代码的表</param>
|
/// <param name="tableName"></param>
|
||||||
/// <param name="baseSpace">项目命名空间</param>
|
/// <returns></returns>
|
||||||
/// <param name="replaceTableNameStr">要删除表名的字符串用英文逗号","隔开</param>
|
[HttpGet("QueryColumnInfo")]
|
||||||
|
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>
|
||||||
|
/// <param name="dto">数据传输对象</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("Generate")]
|
[HttpGet("Generate")]
|
||||||
[Log(Title = "代码生成", BusinessType = BusinessType.OTHER)]
|
[Log(Title = "代码生成", BusinessType = BusinessType.OTHER)]
|
||||||
public IActionResult Generate(string dbName, string baseSpace, string tables, string replaceTableNameStr)
|
public IActionResult Generate([FromQuery] GenerateDto dto)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(tables))
|
if (string.IsNullOrEmpty(dto.tables))
|
||||||
{
|
{
|
||||||
throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
|
throw new CustomException(ResultCode.CUSTOM_ERROR, "请求参数为空");
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(baseSpace))
|
DbTableInfo dbTableInfo = new() { Name = dto.tables };
|
||||||
{
|
CodeGeneratorTool.Generate(dbTableInfo, dto);
|
||||||
baseSpace = "ZR.Admin";
|
|
||||||
}
|
|
||||||
DbTableInfo dbTableInfo = new() { Name = tables };
|
|
||||||
CodeGeneratorTool.Generate(dbName, baseSpace, dbTableInfo, replaceTableNameStr, true);
|
|
||||||
|
|
||||||
return SUCCESS(1);
|
return SUCCESS(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,7 @@ using ZR.Model;
|
|||||||
namespace ZRAdmin.Controllers
|
namespace ZRAdmin.Controllers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// T4代码自动生成
|
/// 代码自动生成
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
[Verify]
|
[Verify]
|
||||||
@ -39,7 +39,7 @@ namespace ZRAdmin.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("list")]
|
[HttpGet("list")]
|
||||||
[ActionPermissionFilter(Permission = "<#=ModelName#>:list")]
|
[ActionPermissionFilter(Permission = "<#=Permission#>:list")]
|
||||||
public IActionResult Query([FromQuery] <#=ModelName#>QueryDto parm)
|
public IActionResult Query([FromQuery] <#=ModelName#>QueryDto parm)
|
||||||
{
|
{
|
||||||
//开始拼装查询条件
|
//开始拼装查询条件
|
||||||
@ -59,7 +59,7 @@ namespace ZRAdmin.Controllers
|
|||||||
/// <param name="{primaryKey}"></param>
|
/// <param name="{primaryKey}"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{{primaryKey}}")]
|
[HttpGet("{{primaryKey}}")]
|
||||||
public IActionResult Get(int {primaryKey})
|
public IActionResult Get({KeyTypeName} {primaryKey})
|
||||||
{
|
{
|
||||||
var response = _<#=ServiceName#>.GetId({primaryKey});
|
var response = _<#=ServiceName#>.GetId({primaryKey});
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ namespace ZRAdmin.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ActionPermissionFilter(Permission = "<#=ModelName#>:add")]
|
[ActionPermissionFilter(Permission = "<#=Permission#>:add")]
|
||||||
[Log(Title = "<#=FileName#>添加", BusinessType = BusinessType.INSERT)]
|
[Log(Title = "<#=FileName#>添加", BusinessType = BusinessType.INSERT)]
|
||||||
public IActionResult Create([FromBody] <#=ModelName#>Dto parm)
|
public IActionResult Create([FromBody] <#=ModelName#>Dto parm)
|
||||||
{
|
{
|
||||||
@ -91,7 +91,7 @@ namespace ZRAdmin.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut("edit")]
|
[HttpPut("edit")]
|
||||||
[ActionPermissionFilter(Permission = "<#=ModelName#>:update")]
|
[ActionPermissionFilter(Permission = "<#=Permission#>:update")]
|
||||||
[Log(Title = "<#=FileName#>修改", BusinessType = BusinessType.UPDATE)]
|
[Log(Title = "<#=FileName#>修改", BusinessType = BusinessType.UPDATE)]
|
||||||
public IActionResult Update([FromBody] <#=ModelName#>Dto parm)
|
public IActionResult Update([FromBody] <#=ModelName#>Dto parm)
|
||||||
{
|
{
|
||||||
@ -109,9 +109,9 @@ namespace ZRAdmin.Controllers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpDelete("{{primaryKey}}")]
|
[HttpDelete("{{primaryKey}}")]
|
||||||
[ActionPermissionFilter(Permission = "<#=ModelName#>:delete")]
|
[ActionPermissionFilter(Permission = "<#=Permission#>:delete")]
|
||||||
[Log(Title = "<#=FileName#>删除", BusinessType = BusinessType.DELETE)]
|
[Log(Title = "<#=FileName#>删除", BusinessType = BusinessType.DELETE)]
|
||||||
public IActionResult Delete(int {primaryKey} = 0)
|
public IActionResult Delete({KeyTypeName} {primaryKey} = 0)
|
||||||
{
|
{
|
||||||
if ({primaryKey} <= 0) { return OutputJson(ApiResult.Error($"删除失败Id 不能为空")); }
|
if ({primaryKey} <= 0) { return OutputJson(ApiResult.Error($"删除失败Id 不能为空")); }
|
||||||
|
|
||||||
|
|||||||
@ -62,7 +62,7 @@
|
|||||||
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">详情</el-button>
|
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">详情</el-button>
|
||||||
<el-button size="mini" v-hasPermi="['{ModelTypeName}:update']" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
|
<el-button size="mini" v-hasPermi="['{ModelTypeName}: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="确定删除吗?" @onConfirm="handleDelete(scope.row)" style="margin-left:10px">
|
||||||
<el-button slot="reference" v-hasPermi="['{ModelTypeName}:del']" size="mini" type="text" icon="el-icon-delete">删除</el-button>
|
<el-button slot="reference" v-hasPermi="['{ModelTypeName}:delete']" size="mini" type="text" icon="el-icon-delete">删除</el-button>
|
||||||
</el-popconfirm>
|
</el-popconfirm>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -83,7 +83,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
// import { list{ModelTypeName},add{ModelTypeName},del{ModelTypeName},edit{ModelTypeName} } from '@/api/{ModelTypeName}.js'
|
import { list{ModelTypeName},add{ModelTypeName},del{ModelTypeName},edit{ModelTypeName} } from '@{ModelTypeName}.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: '{ModelTypeName}',
|
name: '{ModelTypeName}',
|
||||||
@ -197,10 +197,7 @@ export default {
|
|||||||
|
|
||||||
// TODO 给表单赋值
|
// TODO 给表单赋值
|
||||||
this.form = {
|
this.form = {
|
||||||
content: row.content,
|
{VueViewEditFromBindContent}
|
||||||
userId: row.userId,
|
|
||||||
name: row.name,
|
|
||||||
sortId: row.sortId,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
|
|||||||
@ -1,14 +1,12 @@
|
|||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ZR.CodeGenerator.CodeGenerator;
|
using ZR.CodeGenerator.CodeGenerator;
|
||||||
|
using ZR.CodeGenerator.Model;
|
||||||
using ZR.CodeGenerator.Service;
|
using ZR.CodeGenerator.Service;
|
||||||
using ZR.Model;
|
|
||||||
|
|
||||||
namespace ZR.CodeGenerator
|
namespace ZR.CodeGenerator
|
||||||
{
|
{
|
||||||
@ -27,72 +25,55 @@ namespace ZR.CodeGenerator
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// InputDto输入实体是不包含字段
|
/// InputDto输入实体是不包含字段
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static string inputDtoNoField = "DeleteMark,CreatorTime,CreatorUserId,CompanyId,DeptId,LastModifyTime,LastModifyUserId,DeleteTime,DeleteUserId,";
|
private static string[] inputDtoNoField = new string[] { "DeleteMark", "CreateTime", "updateTime", "addtime" };
|
||||||
|
private static string[] imageFiled = new string[] { "icon", "img", "image", "url", "pic" };
|
||||||
|
private static string[] selectFiled = new string[] { "status", "type", "state" };
|
||||||
|
private static string[] radioFiled = new string[] { "status", "state", "is" };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 代码生成器入口方法
|
/// 代码生成器入口方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="baseNamespace"></param>
|
|
||||||
/// <param name="dbTableInfo"></param>
|
/// <param name="dbTableInfo"></param>
|
||||||
/// <param name="replaceTableNameStr">要删除表名称的字符</param>
|
/// <param name="dto"></param>
|
||||||
/// <param name="ifExsitedCovered">是否替换现有文件,为true时替换</param>
|
public static void Generate(DbTableInfo dbTableInfo, GenerateDto dto)
|
||||||
public static void Generate(string dbName, string baseNamespace, DbTableInfo dbTableInfo, string replaceTableNameStr, bool ifExsitedCovered = false)
|
|
||||||
{
|
{
|
||||||
_option.BaseNamespace = baseNamespace;
|
//_option.BaseNamespace = baseNamespace;
|
||||||
_option.DtosNamespace = baseNamespace + "ZR.Model";
|
_option.DtosNamespace = "ZR.Model";
|
||||||
_option.ModelsNamespace = baseNamespace + "ZR.Model";
|
_option.ModelsNamespace = "ZR.Model";
|
||||||
//_option.IRepositoriesNamespace = baseNamespace + ".IRepositorie";
|
_option.RepositoriesNamespace = "ZR.Repository";
|
||||||
_option.RepositoriesNamespace = baseNamespace + "ZR.Repository";
|
_option.IServicsNamespace = "ZR.Service";
|
||||||
_option.IServicsNamespace = baseNamespace + "ZR.Service";
|
_option.ServicesNamespace = "ZR.Service";
|
||||||
_option.ServicesNamespace = baseNamespace + "ZR.Service";
|
_option.ApiControllerNamespace = "ZR.Admin.WebApi";
|
||||||
_option.ApiControllerNamespace = baseNamespace + "ZR.Admin.WebApi";
|
_option.ReplaceTableNameStr = dto.replaceTableNameStr;
|
||||||
_option.ReplaceTableNameStr = replaceTableNameStr;
|
|
||||||
//_option.TableList = listTable;
|
//_option.TableList = listTable;
|
||||||
|
|
||||||
CodeGeneraterService codeGeneraterService = new CodeGeneraterService();
|
CodeGeneraterService codeGeneraterService = new CodeGeneraterService();
|
||||||
string profileContent = string.Empty;
|
|
||||||
List<DbColumnInfo> listField = codeGeneraterService.GetColumnInfo(dbName, dbTableInfo.Name);
|
List<DbColumnInfo> listField = codeGeneraterService.GetColumnInfo(dto.dbName, dbTableInfo.Name);
|
||||||
GenerateSingle(listField, dbTableInfo, ifExsitedCovered);
|
GenerateSingle(listField, dbTableInfo, dto);
|
||||||
//string tableName = dbTableInfo.TableName;
|
|
||||||
//if (!string.IsNullOrEmpty(_option.ReplaceTableNameStr))
|
|
||||||
//{
|
|
||||||
// string[] rel = _option.ReplaceTableNameStr.Split(';');
|
|
||||||
// for (int i = 0; i < rel.Length; i++)
|
|
||||||
// {
|
|
||||||
// if (!string.IsNullOrEmpty(rel[i].ToString()))
|
|
||||||
// {
|
|
||||||
// tableName = tableName.Replace(rel[i].ToString(), "");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//tableName = tableName.Substring(0, 1).ToUpper() + tableName.Substring(1);
|
|
||||||
//profileContent += string.Format(" CreateMap<{0}, {0}OutputDto>();\n", tableName);
|
|
||||||
//profileContent += string.Format(" CreateMap<{0}InputDto, {0}>();\n", tableName);
|
|
||||||
|
|
||||||
//GenerateDtoProfile(_option.ModelsNamespace, profileContent, ifExsitedCovered);
|
//GenerateDtoProfile(_option.ModelsNamespace, profileContent, ifExsitedCovered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 单表生成代码
|
/// 单表生成代码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="listField">表字段集合</param>
|
/// <param name="listField">表字段集合</param>
|
||||||
/// <param name="tableInfo">表信息</param>
|
/// <param name="tableInfo">表信息</param>
|
||||||
/// <param name="ifExsitedCovered">如果目标文件存在,是否覆盖。默认为false</param>
|
/// <param name="ifExsitedCovered">如果目标文件存在,是否覆盖。默认为false</param>
|
||||||
public static void GenerateSingle(List<DbColumnInfo> listField, DbTableInfo tableInfo, bool ifExsitedCovered = false)
|
public static void GenerateSingle(List<DbColumnInfo> listField, DbTableInfo tableInfo, GenerateDto dto)
|
||||||
{
|
{
|
||||||
var modelsNamespace = _option.ModelsNamespace;
|
bool ifExsitedCovered = dto.coverd;
|
||||||
var modelTypeName = GetModelName(tableInfo.Name); ;//表名
|
var modelTypeName = GetModelName(tableInfo.Name).Replace(_option.ReplaceTableNameStr, "");//表名
|
||||||
var modelTypeDesc = tableInfo.Description;//表描述
|
var modelTypeDesc = tableInfo.Description;//表描述
|
||||||
var primaryKey = "id";//主键
|
var primaryKey = "id";//主键
|
||||||
|
|
||||||
string keyTypeName = "int";//主键数据类型
|
string keyTypeName = "int";//主键数据类型
|
||||||
string modelcontent = "";//数据库模型字段
|
string modelContent = "";//数据库模型字段
|
||||||
string InputDtocontent = "";//输入模型
|
string InputDtoContent = "";//输入模型
|
||||||
string outputDtocontent = "";//输出模型
|
string outputDtoContent = "";//输出模型
|
||||||
string vueViewListContent = string.Empty;//Vue列表输出内容
|
string vueViewListContent = string.Empty;//Vue列表输出内容
|
||||||
string vueViewFromContent = string.Empty;//Vue表单输出内容
|
string vueViewFormContent = string.Empty;//Vue表单输出内容
|
||||||
string vueViewEditFromContent = string.Empty;//Vue变量输出内容
|
string vueViewEditFromContent = string.Empty;//Vue变量输出内容
|
||||||
string vueViewEditFromBindContent = string.Empty;//Vue显示初始化输出内容
|
string vueViewEditFromBindContent = string.Empty;//Vue显示初始化输出内容
|
||||||
string vueViewSaveBindContent = string.Empty;//Vue保存时输出内容
|
string vueViewSaveBindContent = string.Empty;//Vue保存时输出内容
|
||||||
@ -100,55 +81,81 @@ namespace ZR.CodeGenerator
|
|||||||
|
|
||||||
foreach (DbColumnInfo dbFieldInfo in listField)
|
foreach (DbColumnInfo dbFieldInfo in listField)
|
||||||
{
|
{
|
||||||
string columnName = dbFieldInfo.DbColumnName.Substring(0, 1).ToUpper() + dbFieldInfo.DbColumnName.Substring(1);
|
string columnName = FirstLowerCase(dbFieldInfo.DbColumnName);
|
||||||
|
|
||||||
modelcontent = GetModelTemplate(ref primaryKey, dbFieldInfo, columnName);
|
|
||||||
|
|
||||||
if (dbFieldInfo.DataType == "bool" || dbFieldInfo.DataType == "tinyint")
|
if (dbFieldInfo.DataType == "bool" || dbFieldInfo.DataType == "tinyint")
|
||||||
{
|
{
|
||||||
vueViewEditFromContent += string.Format(" {0}: 'true',\n", columnName);
|
vueViewEditFromContent += $" {columnName}: 'true',\n";
|
||||||
vueViewEditFromBindContent += string.Format(" this.editFrom.{0} = res.data.{0}+''\n", columnName);
|
vueViewEditFromBindContent += $" this.form.{columnName} = res.data.{0}+''\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vueViewEditFromContent += string.Format(" {0}: '',\n", columnName);
|
vueViewEditFromContent += $" {columnName}: undefined,\n";
|
||||||
vueViewEditFromBindContent += string.Format(" this.editFrom.{0} = res.ResData.{0}\n", columnName);
|
vueViewEditFromBindContent += $" {columnName} = row.{columnName}\n";
|
||||||
}
|
}
|
||||||
//vueViewSaveBindContent += string.Format(" '{0}':this.editFrom.{0},\n", columnName);
|
//vueViewSaveBindContent += string.Format(" '{0}':this.editFrom.{0},\n", columnName);
|
||||||
vueViewFromContent += GetVueViewFromContent(dbFieldInfo, columnName);
|
if (dbFieldInfo.IsIdentity || dbFieldInfo.IsPrimarykey)
|
||||||
vueViewListContent += GetTableColumn(dbFieldInfo, columnName);
|
|
||||||
//Rule 规则验证
|
|
||||||
if (!dbFieldInfo.IsNullable)
|
|
||||||
{
|
{
|
||||||
vueViewEditFromRuleContent += $" {columnName}: [\n";
|
primaryKey = columnName;
|
||||||
vueViewEditFromRuleContent += $" {{ required: true, message:\"请输入{dbFieldInfo.ColumnDescription}\", trigger: \"blur\"}},\n";
|
keyTypeName = dbFieldInfo.DataType;
|
||||||
//vueViewEditFromRuleContent += " { min: 2, max: 50, message: \"长度在 2 到 50 个字符\", trigger:\"blur\" }\n";
|
|
||||||
vueViewEditFromRuleContent += " ],\n";
|
|
||||||
}
|
}
|
||||||
|
modelContent += GetModelTemplate(dbFieldInfo);
|
||||||
//if (!inputDtoNoField.Contains(columnName) || columnName == "Id")
|
vueViewFormContent += GetVueViewFormContent(dbFieldInfo, columnName);
|
||||||
//{
|
vueViewListContent += GetTableColumn(dbFieldInfo, columnName);
|
||||||
InputDtocontent += " /// <summary>\n";
|
vueViewEditFromRuleContent += GetFormRules(dbFieldInfo, columnName);
|
||||||
InputDtocontent += $" /// 设置或获取{dbFieldInfo.ColumnDescription}\n";
|
InputDtoContent += GetDtoContent(dbFieldInfo, columnName);
|
||||||
InputDtocontent += " /// </summary>\n";
|
}
|
||||||
InputDtocontent += $" public {TableMappingHelper.GetPropertyDatatype(dbFieldInfo.DataType)} {columnName} {{ get; set; }}\n\r";
|
if (dto.genFiles.Contains(1))
|
||||||
//}
|
{
|
||||||
//
|
GenerateModels(_option.ModelsNamespace, modelTypeName, tableInfo.Name, modelContent, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
||||||
|
}
|
||||||
|
if (dto.genFiles.Contains(2))
|
||||||
|
{
|
||||||
|
GenerateInputDto(_option.ModelsNamespace, modelTypeName, modelTypeDesc, InputDtoContent, keyTypeName, ifExsitedCovered);
|
||||||
|
}
|
||||||
|
if (dto.genFiles.Contains(3))
|
||||||
|
{
|
||||||
|
GenerateRepository(modelTypeName, modelTypeDesc, tableInfo.Name, keyTypeName, ifExsitedCovered);
|
||||||
|
}
|
||||||
|
if (dto.genFiles.Contains(4))
|
||||||
|
{
|
||||||
|
GenerateIService(_option.ModelsNamespace, modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
||||||
|
GenerateService(_option.ModelsNamespace, modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
||||||
|
}
|
||||||
|
if (dto.genFiles.Contains(5))
|
||||||
|
{
|
||||||
|
GenerateControllers(modelTypeName, primaryKey, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
||||||
|
}
|
||||||
|
if (dto.genFiles.Contains(6))
|
||||||
|
{
|
||||||
|
GenerateVueViews(modelTypeName, primaryKey, modelTypeDesc, vueViewListContent, vueViewFormContent, vueViewEditFromContent, vueViewEditFromBindContent, vueViewSaveBindContent, vueViewEditFromRuleContent, ifExsitedCovered);
|
||||||
}
|
}
|
||||||
//GenerateModels(modelsNamespace, modelTypeName, tableInfo.Name, modelcontent, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
|
||||||
//GenerateInputDto(modelsNamespace, modelTypeName, modelTypeDesc, InputDtocontent, keyTypeName, ifExsitedCovered);
|
|
||||||
//GenerateRepository(modelTypeName, modelTypeDesc, tableInfo.Name, keyTypeName, ifExsitedCovered);
|
|
||||||
//GenerateIService(modelsNamespace, modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
|
||||||
//GenerateService(modelsNamespace, modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
|
||||||
//GenerateControllers(modelTypeName, primaryKey, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
|
||||||
|
|
||||||
//GenerateIRepository(modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
//GenerateIRepository(modelTypeName, modelTypeDesc, keyTypeName, ifExsitedCovered);
|
||||||
//GenerateOutputDto(modelTypeName, modelTypeDesc, outputDtocontent, ifExsitedCovered);
|
//GenerateOutputDto(modelTypeName, modelTypeDesc, outputDtocontent, ifExsitedCovered);
|
||||||
GenerateVueViews(modelTypeName, primaryKey, modelTypeDesc, vueViewListContent, vueViewFromContent, vueViewEditFromContent, vueViewEditFromBindContent, vueViewSaveBindContent, vueViewEditFromRuleContent, ifExsitedCovered);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetModelTemplate(ref string primaryKey, DbColumnInfo dbFieldInfo, string columnName)
|
#region Template
|
||||||
|
|
||||||
|
//rules
|
||||||
|
private static string GetFormRules(DbColumnInfo dbFieldInfo, string columnName)
|
||||||
{
|
{
|
||||||
|
string vueViewEditFromRuleContent = "";
|
||||||
|
//Rule 规则验证
|
||||||
|
if (!dbFieldInfo.IsNullable && !dbFieldInfo.IsIdentity)
|
||||||
|
{
|
||||||
|
vueViewEditFromRuleContent += $" {columnName}: [\n";
|
||||||
|
vueViewEditFromRuleContent += $" {{ required: true, message:\"请输入{dbFieldInfo.ColumnDescription}\", trigger: \"blur\"}},\n";
|
||||||
|
//vueViewEditFromRuleContent += " { min: 2, max: 50, message: \"长度在 2 到 50 个字符\", trigger:\"blur\" }\n";
|
||||||
|
vueViewEditFromRuleContent += " ],\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return vueViewEditFromRuleContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
//model 属性
|
||||||
|
private static string GetModelTemplate(DbColumnInfo dbFieldInfo)
|
||||||
|
{
|
||||||
|
string columnName = dbFieldInfo.DbColumnName.Substring(0, 1).ToUpper() + dbFieldInfo.DbColumnName.Substring(1);
|
||||||
var modelcontent = "";
|
var modelcontent = "";
|
||||||
modelcontent += " /// <summary>\n";
|
modelcontent += " /// <summary>\n";
|
||||||
modelcontent += $" /// 描述 :{dbFieldInfo.ColumnDescription}\n";
|
modelcontent += $" /// 描述 :{dbFieldInfo.ColumnDescription}\n";
|
||||||
@ -157,43 +164,57 @@ namespace ZR.CodeGenerator
|
|||||||
modelcontent += " /// </summary>\n";
|
modelcontent += " /// </summary>\n";
|
||||||
if (dbFieldInfo.IsIdentity || dbFieldInfo.IsPrimarykey)
|
if (dbFieldInfo.IsIdentity || dbFieldInfo.IsPrimarykey)
|
||||||
{
|
{
|
||||||
primaryKey = columnName;
|
|
||||||
modelcontent += $" [SqlSugar.SugarColumn(IsPrimaryKey = {dbFieldInfo.IsPrimarykey.ToString().ToLower()}, IsIdentity = {dbFieldInfo.IsIdentity.ToString().ToLower()})]\n";
|
modelcontent += $" [SqlSugar.SugarColumn(IsPrimaryKey = {dbFieldInfo.IsPrimarykey.ToString().ToLower()}, IsIdentity = {dbFieldInfo.IsIdentity.ToString().ToLower()})]\n";
|
||||||
}
|
}
|
||||||
modelcontent += $" public {TableMappingHelper.GetPropertyDatatype(dbFieldInfo.DataType)} {columnName} {{ get; set; }}\n\r";
|
modelcontent += $" public {TableMappingHelper.GetPropertyDatatype(dbFieldInfo.DataType)} {columnName} {{ get; set; }}\n\r";
|
||||||
return modelcontent;
|
return modelcontent;
|
||||||
}
|
}
|
||||||
//
|
//DTO model
|
||||||
//form-item
|
private static string GetDtoContent(DbColumnInfo dbFieldInfo, string columnName)
|
||||||
private static string GetVueViewFromContent(DbColumnInfo dbFieldInfo, string columnName)
|
|
||||||
{
|
{
|
||||||
|
string InputDtoContent = "";
|
||||||
|
if (!inputDtoNoField.Any(x => x.ToLower().Contains(columnName)) || !dbFieldInfo.IsIdentity)
|
||||||
|
{
|
||||||
|
InputDtoContent += " /// <summary>\n";
|
||||||
|
InputDtoContent += $" /// 设置或获取{dbFieldInfo.ColumnDescription}\n";
|
||||||
|
InputDtoContent += " /// </summary>\n";
|
||||||
|
InputDtoContent += $" public {TableMappingHelper.GetPropertyDatatype(dbFieldInfo.DataType)} {columnName} {{ get; set; }}\n\r";
|
||||||
|
}
|
||||||
|
|
||||||
|
return InputDtoContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
//form-item
|
||||||
|
private static string GetVueViewFormContent(DbColumnInfo dbFieldInfo, string columnName)
|
||||||
|
{
|
||||||
|
columnName = FirstLowerCase(columnName);
|
||||||
|
string labelName = GetLabelName(dbFieldInfo.ColumnDescription, columnName);
|
||||||
string vueViewFromContent = "";
|
string vueViewFromContent = "";
|
||||||
if (dbFieldInfo.DataType == "datetime")
|
if (dbFieldInfo.DataType == "datetime")
|
||||||
{
|
{
|
||||||
vueViewFromContent = "";
|
vueViewFromContent += "";
|
||||||
}
|
}
|
||||||
else if (columnName.Contains("iocn,image"))
|
else if (((IList)imageFiled).Contains(columnName))
|
||||||
{
|
{
|
||||||
//TODO 图片
|
//TODO 图片
|
||||||
}
|
}
|
||||||
else if (dbFieldInfo.DataType == "bool" || dbFieldInfo.DataType == "tinyint")
|
else if (radioFiled.Any(f => columnName.Contains(f)) && (dbFieldInfo.DataType == "bool" || dbFieldInfo.DataType == "tinyint"))
|
||||||
{
|
{
|
||||||
vueViewFromContent += $" <el-col :span=\"12\">\n";
|
vueViewFromContent += $" <el-col :span=\"12\">\n";
|
||||||
vueViewFromContent += $" <el-form-item label=\"{GetLabelName(dbFieldInfo.ColumnDescription, columnName)}\" :label-width=\"labelWidth\" prop=\"{FirstLowerCase(columnName)}\">";
|
vueViewFromContent += $" <el-form-item label=\"{labelName}\" :label-width=\"labelWidth\" prop=\"{columnName}\">";
|
||||||
vueViewFromContent += $" <el-radio-group v-model=\"form.{GetLabelName(dbFieldInfo.ColumnDescription, columnName)}\">\n";
|
vueViewFromContent += $" <el-radio-group v-model=\"form.{columnName}\">\n";
|
||||||
vueViewFromContent += " <el-radio label=\"true\">是</el-radio>\n";
|
vueViewFromContent += " <el-radio v-for=\"dict in statusOptions\" :key=\"dict.dictValue\" :label=\"dict.dictValue\">{{dict.dictLabel}}</el-radio>\n";
|
||||||
vueViewFromContent += " <el-radio label=\"false\">否</el-radio>\n";
|
|
||||||
vueViewFromContent += " </el-radio-group>\n";
|
vueViewFromContent += " </el-radio-group>\n";
|
||||||
vueViewFromContent += " </el-form-item>\n";
|
vueViewFromContent += " </el-form-item>\n";
|
||||||
vueViewFromContent += " </el-col>\n";
|
vueViewFromContent += " </el-col>\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vueViewFromContent += $" <el-col :span=\"12\">\n";
|
vueViewFromContent += $" <el-col :span=\"12\">\n";
|
||||||
vueViewFromContent += $" <el-form-item label=\"{ GetLabelName(dbFieldInfo.ColumnDescription, columnName)}\" :label-width=\"labelWidth\" prop=\"{FirstLowerCase(columnName)}\">\n";
|
vueViewFromContent += $" <el-form-item label=\"{ GetLabelName(dbFieldInfo.ColumnDescription, columnName)}\" :label-width=\"labelWidth\" prop=\"{FirstLowerCase(columnName)}\">\n";
|
||||||
vueViewFromContent += $" <el-input v-model=\"form.{FirstLowerCase(columnName)}\" placeholder=\"请输入{GetLabelName(dbFieldInfo.ColumnDescription, columnName)}\" />\n";
|
vueViewFromContent += $" <el-input v-model=\"form.{FirstLowerCase(columnName)}\" placeholder=\"请输入{GetLabelName(dbFieldInfo.ColumnDescription, columnName)}\" />\n";
|
||||||
vueViewFromContent += " </el-form-item>\n";
|
vueViewFromContent += " </el-form-item>\n";
|
||||||
vueViewFromContent += " </el-col>\n";
|
vueViewFromContent += " </el-col>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
return vueViewFromContent;
|
return vueViewFromContent;
|
||||||
@ -202,27 +223,36 @@ namespace ZR.CodeGenerator
|
|||||||
//table-column
|
//table-column
|
||||||
private static string GetTableColumn(DbColumnInfo dbFieldInfo, string columnName)
|
private static string GetTableColumn(DbColumnInfo dbFieldInfo, string columnName)
|
||||||
{
|
{
|
||||||
|
columnName = FirstLowerCase(columnName);
|
||||||
|
string label = GetLabelName(dbFieldInfo.ColumnDescription, columnName);
|
||||||
string vueViewListContent = "";
|
string vueViewListContent = "";
|
||||||
string showToolTip = dbFieldInfo.DataType == "varchar" ? ":show-overflow-tooltip=\"true\"" : "";
|
string showToolTip = dbFieldInfo.DataType.Contains("varchar") ? ":show-overflow-tooltip=\"true\"" : "";
|
||||||
|
|
||||||
if (dbFieldInfo.DataType == "bool" || dbFieldInfo.DataType == "tinyint")
|
if (imageFiled.Any(f => columnName.ToLower().Contains(f)))
|
||||||
{
|
{
|
||||||
vueViewListContent += $" <el-table-column prop=\"{FirstLowerCase(columnName)}\" label=\"{GetLabelName(dbFieldInfo.ColumnDescription, columnName)}\" width=\"120\" >\n";
|
vueViewListContent += $" <el-table-column prop=\"{ columnName}\" label=\"图片\">\n";
|
||||||
|
vueViewListContent += " <template slot-scope=\"scope\">\n";
|
||||||
|
vueViewListContent += $" <el-image class=\"table-td-thumb\" :src=\"scope.row.{columnName}\" :preview-src-list=\"[scope.row.{columnName}]\"></el-image>\n";
|
||||||
|
vueViewListContent += " </template>\n";
|
||||||
|
vueViewListContent += " </el-table-column>\n";
|
||||||
|
}
|
||||||
|
else if (dbFieldInfo.DataType == "bool" || dbFieldInfo.DataType == "tinyint")
|
||||||
|
{
|
||||||
|
vueViewListContent += $" <el-table-column prop=\"{columnName}\" label=\"{label}\" width=\"120\" >\n";
|
||||||
vueViewListContent += " <template slot-scope=\"scope\">\n";
|
vueViewListContent += " <template slot-scope=\"scope\">\n";
|
||||||
vueViewListContent += string.Format(" <el-tag :type=\"scope.row.{0} === true ? 'success' : 'info'\" disable-transitions >", columnName);
|
vueViewListContent += $" <el-tag :type=\"scope.row.{columnName} === true ? 'success' : 'info'\" disable-transitions >";
|
||||||
vueViewListContent += "{{ ";
|
vueViewListContent += $" {{scope.row.{columnName}===true?'启用':'禁用'}} </el-tag>\n";
|
||||||
vueViewListContent += string.Format("scope.row.{0}===true?'启用':'禁用' ", columnName);
|
|
||||||
vueViewListContent += "}}</el-tag>\n";
|
|
||||||
vueViewListContent += " </template>\n";
|
vueViewListContent += " </template>\n";
|
||||||
vueViewListContent += " </el-table-column>\n";
|
vueViewListContent += " </el-table-column>\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//table-column
|
//table-column
|
||||||
vueViewListContent += $" <el-table-column prop=\"{FirstLowerCase(columnName)}\" label=\"{GetLabelName(dbFieldInfo.ColumnDescription, columnName)}\" align=\"center\" width=\"100\" {showToolTip} />\n";
|
vueViewListContent += $" <el-table-column prop=\"{FirstLowerCase(columnName)}\" label=\"{GetLabelName(dbFieldInfo.ColumnDescription, columnName)}\" align=\"center\" width=\"100\" {showToolTip} />\n";
|
||||||
}
|
}
|
||||||
return vueViewListContent;
|
return vueViewListContent;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 生成Model
|
#region 生成Model
|
||||||
|
|
||||||
@ -240,14 +270,14 @@ namespace ZR.CodeGenerator
|
|||||||
{
|
{
|
||||||
var parentPath = "..";
|
var parentPath = "..";
|
||||||
//../ZR.Model
|
//../ZR.Model
|
||||||
var servicesPath = parentPath + "\\" + _option.BaseNamespace + "\\" + modelsNamespace;
|
var servicesPath = parentPath + "\\" + modelsNamespace + "\\Models\\";
|
||||||
if (!Directory.Exists(servicesPath))
|
if (!Directory.Exists(servicesPath))
|
||||||
{
|
{
|
||||||
//servicesPath = parentPath + "\\" + _option.ModelsNamespace;
|
|
||||||
Directory.CreateDirectory(servicesPath);
|
Directory.CreateDirectory(servicesPath);
|
||||||
}
|
}
|
||||||
// ../ZR.Model/Models/User.cs
|
// ../ZR.Model/Models/User.cs
|
||||||
var fullPath = servicesPath + "\\Models\\" + modelTypeName + ".cs";
|
var fullPath = servicesPath + modelTypeName + ".cs";
|
||||||
|
Console.WriteLine(fullPath);
|
||||||
if (File.Exists(fullPath) && !ifExsitedCovered)
|
if (File.Exists(fullPath) && !ifExsitedCovered)
|
||||||
return;
|
return;
|
||||||
var content = ReadTemplate("ModelTemplate.txt");
|
var content = ReadTemplate("ModelTemplate.txt");
|
||||||
@ -274,14 +304,14 @@ namespace ZR.CodeGenerator
|
|||||||
private static void GenerateInputDto(string modelsNamespace, string modelTypeName, string modelTypeDesc, string modelContent, string keyTypeName, bool ifExsitedCovered = false)
|
private static void GenerateInputDto(string modelsNamespace, string modelTypeName, string modelTypeDesc, string modelContent, string keyTypeName, bool ifExsitedCovered = false)
|
||||||
{
|
{
|
||||||
var parentPath = "..";
|
var parentPath = "..";
|
||||||
var servicesPath = parentPath + "\\" + _option.BaseNamespace + "\\" + modelsNamespace;
|
var servicesPath = parentPath + "\\" + modelsNamespace + "\\Dto\\";
|
||||||
if (!Directory.Exists(servicesPath))
|
if (!Directory.Exists(servicesPath))
|
||||||
{
|
{
|
||||||
//servicesPath = parentPath + "\\" + _option.BaseNamespace + "\\Dtos";
|
|
||||||
Directory.CreateDirectory(servicesPath);
|
Directory.CreateDirectory(servicesPath);
|
||||||
}
|
}
|
||||||
// ../ZR.Model/Dto/User.cs
|
// ../ZR.Model/Dto/User.cs
|
||||||
var fullPath = servicesPath + "\\Dto\\" + modelTypeName + "Dto.cs";
|
var fullPath = servicesPath + modelTypeName + "Dto.cs";
|
||||||
|
Console.WriteLine(fullPath);
|
||||||
if (File.Exists(fullPath) && !ifExsitedCovered)
|
if (File.Exists(fullPath) && !ifExsitedCovered)
|
||||||
return;
|
return;
|
||||||
var content = ReadTemplate("InputDtoTemplate.txt");
|
var content = ReadTemplate("InputDtoTemplate.txt");
|
||||||
@ -308,20 +338,19 @@ namespace ZR.CodeGenerator
|
|||||||
/// <param name="ifExsitedCovered">如果目标文件存在,是否覆盖。默认为false</param>
|
/// <param name="ifExsitedCovered">如果目标文件存在,是否覆盖。默认为false</param>
|
||||||
private static void GenerateRepository(string modelTypeName, string modelTypeDesc, string tableName, string keyTypeName, bool ifExsitedCovered = false)
|
private static void GenerateRepository(string modelTypeName, string modelTypeDesc, string tableName, string keyTypeName, bool ifExsitedCovered = false)
|
||||||
{
|
{
|
||||||
//var path = AppDomain.CurrentDomain.BaseDirectory;
|
var parentPath = "..";
|
||||||
var parentPath = "..";// path.Substring(0, path.LastIndexOf("\\"));
|
var repositoryPath = parentPath + "\\" + _option.RepositoriesNamespace + "\\Repositories\\";
|
||||||
var repositoryPath = parentPath + "\\" + _option.BaseNamespace + "\\" + _option.RepositoriesNamespace;
|
|
||||||
if (!Directory.Exists(repositoryPath))
|
if (!Directory.Exists(repositoryPath))
|
||||||
{
|
{
|
||||||
//repositoryPath = parentPath + "\\" + _option.BaseNamespace + "\\Repositories";
|
|
||||||
Directory.CreateDirectory(repositoryPath);
|
Directory.CreateDirectory(repositoryPath);
|
||||||
}
|
}
|
||||||
var fullPath = repositoryPath + "\\" + modelTypeName + "Repository.cs";
|
var fullPath = repositoryPath + "\\" + modelTypeName + "Repository.cs";
|
||||||
|
Console.WriteLine(fullPath);
|
||||||
if (File.Exists(fullPath) && !ifExsitedCovered)
|
if (File.Exists(fullPath) && !ifExsitedCovered)
|
||||||
return;
|
return;
|
||||||
var content = ReadTemplate("RepositoryTemplate.txt");
|
var content = ReadTemplate("RepositoryTemplate.txt");
|
||||||
content = content.Replace("{ModelsNamespace}", _option.ModelsNamespace)
|
content = content.Replace("{ModelsNamespace}", _option.ModelsNamespace)
|
||||||
.Replace("{IRepositoriesNamespace}", _option.IRepositoriesNamespace)
|
//.Replace("{IRepositoriesNamespace}", _option.IRepositoriesNamespace)
|
||||||
.Replace("{RepositoriesNamespace}", _option.RepositoriesNamespace)
|
.Replace("{RepositoriesNamespace}", _option.RepositoriesNamespace)
|
||||||
.Replace("{ModelTypeName}", modelTypeName)
|
.Replace("{ModelTypeName}", modelTypeName)
|
||||||
.Replace("{TableNameDesc}", modelTypeDesc)
|
.Replace("{TableNameDesc}", modelTypeDesc)
|
||||||
@ -343,16 +372,14 @@ namespace ZR.CodeGenerator
|
|||||||
/// <param name="ifExsitedCovered">如果目标文件存在,是否覆盖。默认为false</param>
|
/// <param name="ifExsitedCovered">如果目标文件存在,是否覆盖。默认为false</param>
|
||||||
private static void GenerateIService(string modelsNamespace, string modelTypeName, string modelTypeDesc, string keyTypeName, bool ifExsitedCovered = false)
|
private static void GenerateIService(string modelsNamespace, string modelTypeName, string modelTypeDesc, string keyTypeName, bool ifExsitedCovered = false)
|
||||||
{
|
{
|
||||||
//var path = AppDomain.CurrentDomain.BaseDirectory;
|
var parentPath = "..";
|
||||||
//path = path.Substring(0, path.IndexOf("\\bin"));
|
var iServicesPath = parentPath + "\\" + _option.IServicsNamespace + "\\Business\\IBusService\\";
|
||||||
var parentPath = "..";// path.Substring(0, path.LastIndexOf("\\"));
|
|
||||||
var iServicesPath = parentPath + "\\" + _option.BaseNamespace + "\\" + _option.IServicsNamespace;
|
|
||||||
if (!Directory.Exists(iServicesPath))
|
if (!Directory.Exists(iServicesPath))
|
||||||
{
|
{
|
||||||
iServicesPath = parentPath + "\\" + _option.BaseNamespace + "\\IBusService";
|
|
||||||
Directory.CreateDirectory(iServicesPath);
|
Directory.CreateDirectory(iServicesPath);
|
||||||
}
|
}
|
||||||
var fullPath = $"{iServicesPath}\\Business\\IService\\I{modelTypeName}Service.cs";
|
var fullPath = $"{iServicesPath}\\I{modelTypeName}Service.cs";
|
||||||
|
Console.WriteLine(fullPath);
|
||||||
if (File.Exists(fullPath) && !ifExsitedCovered)
|
if (File.Exists(fullPath) && !ifExsitedCovered)
|
||||||
return;
|
return;
|
||||||
var content = ReadTemplate("IServiceTemplate.txt");
|
var content = ReadTemplate("IServiceTemplate.txt");
|
||||||
@ -375,16 +402,13 @@ namespace ZR.CodeGenerator
|
|||||||
/// <param name="ifExsitedCovered">如果目标文件存在,是否覆盖。默认为false</param>
|
/// <param name="ifExsitedCovered">如果目标文件存在,是否覆盖。默认为false</param>
|
||||||
private static void GenerateService(string modelsNamespace, string modelTypeName, string modelTypeDesc, string keyTypeName, bool ifExsitedCovered = false)
|
private static void GenerateService(string modelsNamespace, string modelTypeName, string modelTypeDesc, string keyTypeName, bool ifExsitedCovered = false)
|
||||||
{
|
{
|
||||||
//var path = AppDomain.CurrentDomain.BaseDirectory;
|
var parentPath = "..";
|
||||||
//path = path.Substring(0, path.IndexOf("\\bin"));
|
var servicesPath = parentPath + "\\" + _option.ServicesNamespace + "\\Business\\";
|
||||||
var parentPath = "..";// path.Substring(0, path.LastIndexOf("\\"));
|
|
||||||
var servicesPath = parentPath + "\\" + _option.BaseNamespace + "\\" + _option.ServicesNamespace;
|
|
||||||
if (!Directory.Exists(servicesPath))
|
if (!Directory.Exists(servicesPath))
|
||||||
{
|
{
|
||||||
servicesPath = parentPath + "\\" + _option.BaseNamespace + "\\Business";
|
|
||||||
Directory.CreateDirectory(servicesPath);
|
Directory.CreateDirectory(servicesPath);
|
||||||
}
|
}
|
||||||
var fullPath = servicesPath + "\\Business\\" + modelTypeName + "Service.cs";
|
var fullPath = servicesPath + modelTypeName + "Service.cs";
|
||||||
Console.WriteLine(fullPath);
|
Console.WriteLine(fullPath);
|
||||||
if (File.Exists(fullPath) && !ifExsitedCovered)
|
if (File.Exists(fullPath) && !ifExsitedCovered)
|
||||||
return;
|
return;
|
||||||
@ -414,18 +438,13 @@ namespace ZR.CodeGenerator
|
|||||||
/// <param name="ifExsitedCovered">如果目标文件存在,是否覆盖。默认为false</param>
|
/// <param name="ifExsitedCovered">如果目标文件存在,是否覆盖。默认为false</param>
|
||||||
private static void GenerateControllers(string modelTypeName, string primaryKey, string modelTypeDesc, string keyTypeName, bool ifExsitedCovered = false)
|
private static void GenerateControllers(string modelTypeName, string primaryKey, string modelTypeDesc, string keyTypeName, bool ifExsitedCovered = false)
|
||||||
{
|
{
|
||||||
//var servicesNamespace = _option.DtosNamespace;
|
var parentPath = "..";
|
||||||
//var fileClassName = _option.BaseNamespace.Substring(_option.BaseNamespace.IndexOf('.') + 1);
|
var servicesPath = parentPath + "\\" + _option.ApiControllerNamespace + "\\Controllers\\business\\";
|
||||||
//var path = AppDomain.CurrentDomain.BaseDirectory;
|
|
||||||
//path = path.Substring(0, path.IndexOf("\\bin"));
|
|
||||||
var parentPath = "..";//path.Substring(0, path.LastIndexOf("\\"));
|
|
||||||
var servicesPath = parentPath + "\\" + _option.BaseNamespace + "\\" + _option.ApiControllerNamespace;
|
|
||||||
if (!Directory.Exists(servicesPath))
|
if (!Directory.Exists(servicesPath))
|
||||||
{
|
{
|
||||||
servicesPath = parentPath + "\\" + _option.BaseNamespace + "\\Controllers\\";
|
|
||||||
Directory.CreateDirectory(servicesPath);
|
Directory.CreateDirectory(servicesPath);
|
||||||
}
|
}
|
||||||
var fullPath = servicesPath + "\\Controllers\\business\\" + modelTypeName + "Controller.cs";
|
var fullPath = servicesPath + modelTypeName + "Controller.cs";
|
||||||
Console.WriteLine(fullPath);
|
Console.WriteLine(fullPath);
|
||||||
if (File.Exists(fullPath) && !ifExsitedCovered)
|
if (File.Exists(fullPath) && !ifExsitedCovered)
|
||||||
return;
|
return;
|
||||||
@ -437,6 +456,7 @@ namespace ZR.CodeGenerator
|
|||||||
.Replace("<#=FileName#>", modelTypeDesc)
|
.Replace("<#=FileName#>", modelTypeDesc)
|
||||||
.Replace("<#=ServiceName#>", modelTypeName + "Service")
|
.Replace("<#=ServiceName#>", modelTypeName + "Service")
|
||||||
.Replace("<#=ModelName#>", modelTypeName)
|
.Replace("<#=ModelName#>", modelTypeName)
|
||||||
|
.Replace("<#=Permission#>", modelTypeName.ToLower())
|
||||||
.Replace("{primaryKey}", primaryKey)
|
.Replace("{primaryKey}", primaryKey)
|
||||||
.Replace("{KeyTypeName}", keyTypeName);
|
.Replace("{KeyTypeName}", keyTypeName);
|
||||||
WriteAndSave(fullPath, content);
|
WriteAndSave(fullPath, content);
|
||||||
@ -459,14 +479,12 @@ namespace ZR.CodeGenerator
|
|||||||
private static void GenerateVueViews(string modelTypeName, string primaryKey, string modelTypeDesc, string vueViewListContent, string vueViewFromContent, string vueViewEditFromContent, string vueViewEditFromBindContent, string vueViewSaveBindContent, string vueViewEditFromRuleContent, bool ifExsitedCovered = false)
|
private static void GenerateVueViews(string modelTypeName, string primaryKey, string modelTypeDesc, string vueViewListContent, string vueViewFromContent, string vueViewEditFromContent, string vueViewEditFromBindContent, string vueViewSaveBindContent, string vueViewEditFromRuleContent, bool ifExsitedCovered = false)
|
||||||
{
|
{
|
||||||
var servicesNamespace = _option.DtosNamespace;
|
var servicesNamespace = _option.DtosNamespace;
|
||||||
var fileClassName = _option.BaseNamespace.Substring(_option.BaseNamespace.IndexOf('.') + 1);
|
var path = "..\\CodeGenerate\\";
|
||||||
var path = AppDomain.CurrentDomain.BaseDirectory;
|
|
||||||
//path = path.Substring(0, path.IndexOf("\\bin"));
|
|
||||||
var parentPath = path.Substring(0, path.LastIndexOf("\\"));
|
var parentPath = path.Substring(0, path.LastIndexOf("\\"));
|
||||||
var servicesPath = parentPath + "\\" + _option.BaseNamespace + "\\" + servicesNamespace;
|
var servicesPath = parentPath + "\\" + _option.BaseNamespace + "\\" + servicesNamespace;
|
||||||
if (!Directory.Exists(servicesPath))
|
if (!Directory.Exists(servicesPath))
|
||||||
{
|
{
|
||||||
servicesPath = parentPath + "\\" + _option.BaseNamespace + "\\vue\\" + modelTypeName.ToLower();
|
servicesPath = parentPath + "\\" + _option.BaseNamespace + "\\views\\" + FirstLowerCase(modelTypeName);
|
||||||
Directory.CreateDirectory(servicesPath);
|
Directory.CreateDirectory(servicesPath);
|
||||||
}
|
}
|
||||||
var fullPath = servicesPath + "\\" + "index.vue";
|
var fullPath = servicesPath + "\\" + "index.vue";
|
||||||
@ -474,12 +492,12 @@ namespace ZR.CodeGenerator
|
|||||||
return;
|
return;
|
||||||
var content = ReadTemplate("VueTemplate.txt");
|
var content = ReadTemplate("VueTemplate.txt");
|
||||||
content = content
|
content = content
|
||||||
.Replace("{BaseNamespace}", fileClassName.ToLower())
|
//.Replace("{BaseNamespace}", fileClassName.ToLower())
|
||||||
.Replace("{fileClassName}", modelTypeName.ToLower())
|
.Replace("{fileClassName}", FirstLowerCase(modelTypeName))
|
||||||
.Replace("{ModelTypeNameToLower}", modelTypeName.ToLower())
|
.Replace("{ModelTypeNameToLower}", FirstLowerCase(modelTypeName))
|
||||||
.Replace("{VueViewListContent}", vueViewListContent)
|
.Replace("{VueViewListContent}", vueViewListContent)
|
||||||
.Replace("{VueViewFromContent}", vueViewFromContent)
|
.Replace("{VueViewFromContent}", vueViewFromContent)
|
||||||
.Replace("{ModelTypeName}", modelTypeName)
|
.Replace("{ModelTypeName}", FirstLowerCase(modelTypeName))
|
||||||
.Replace("{VueViewEditFromContent}", vueViewEditFromContent)
|
.Replace("{VueViewEditFromContent}", vueViewEditFromContent)
|
||||||
.Replace("{VueViewEditFromBindContent}", vueViewEditFromBindContent)
|
.Replace("{VueViewEditFromBindContent}", vueViewEditFromBindContent)
|
||||||
.Replace("{VueViewSaveBindContent}", vueViewSaveBindContent)
|
.Replace("{VueViewSaveBindContent}", vueViewSaveBindContent)
|
||||||
@ -487,14 +505,14 @@ namespace ZR.CodeGenerator
|
|||||||
.Replace("{VueViewEditFromRuleContent}", vueViewEditFromRuleContent);
|
.Replace("{VueViewEditFromRuleContent}", vueViewEditFromRuleContent);
|
||||||
WriteAndSave(fullPath, content);
|
WriteAndSave(fullPath, content);
|
||||||
|
|
||||||
fullPath = servicesPath + "\\" + modelTypeName.ToLower() + ".js";
|
fullPath = servicesPath + "\\" + FirstLowerCase(modelTypeName) + ".js";
|
||||||
if (File.Exists(fullPath) && !ifExsitedCovered)
|
if (File.Exists(fullPath) && !ifExsitedCovered)
|
||||||
return;
|
return;
|
||||||
content = ReadTemplate("VueJsTemplate.txt");
|
content = ReadTemplate("VueJsTemplate.txt");
|
||||||
content = content
|
content = content
|
||||||
.Replace("{ModelTypeName}", modelTypeName)
|
.Replace("{ModelTypeName}", FirstLowerCase(modelTypeName))
|
||||||
.Replace("{ModelTypeDesc}", modelTypeDesc)
|
.Replace("{ModelTypeDesc}", modelTypeDesc);
|
||||||
.Replace("{fileClassName}", fileClassName);
|
//.Replace("{fileClassName}", fileClassName)
|
||||||
WriteAndSave(fullPath, content);
|
WriteAndSave(fullPath, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,6 +520,12 @@ namespace ZR.CodeGenerator
|
|||||||
|
|
||||||
#region 帮助方法
|
#region 帮助方法
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 如果有前缀替换将前缀替换成空,替换下划线"_"为空再将首字母大写
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modelTypeName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
private static string GetModelName(string modelTypeName)
|
private static string GetModelName(string modelTypeName)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(_option.ReplaceTableNameStr))
|
if (!string.IsNullOrEmpty(_option.ReplaceTableNameStr))
|
||||||
@ -512,15 +536,22 @@ namespace ZR.CodeGenerator
|
|||||||
modelTypeName = modelTypeName.Substring(0, 1).ToUpper() + modelTypeName.Substring(1);
|
modelTypeName = modelTypeName.Substring(0, 1).ToUpper() + modelTypeName.Substring(1);
|
||||||
return modelTypeName;
|
return modelTypeName;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 首字母转小写,输出前端
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str"></param>
|
||||||
|
/// <returns></returns>
|
||||||
private static string FirstLowerCase(string str)
|
private static string FirstLowerCase(string str)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(str))
|
return string.IsNullOrEmpty(str) ? str : str.Substring(0, 1).ToLower() + str[1..];
|
||||||
{
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
str = str.Substring(0, 1).ToLower() + str.Substring(1);
|
|
||||||
return str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取前端标签名
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="columnDescription"></param>
|
||||||
|
/// <param name="columnName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
private static string GetLabelName(string columnDescription, string columnName)
|
private static string GetLabelName(string columnDescription, string columnName)
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(columnDescription) ? columnName : columnDescription;
|
return string.IsNullOrEmpty(columnDescription) ? columnName : columnDescription;
|
||||||
|
|||||||
34
ZR.CodeGenerator/Model/GenerateDto.cs
Normal file
34
ZR.CodeGenerator/Model/GenerateDto.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ZR.CodeGenerator.Model
|
||||||
|
{
|
||||||
|
public class GenerateDto
|
||||||
|
{
|
||||||
|
public string queryColumn { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string dbName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 项目命名空间
|
||||||
|
/// </summary>
|
||||||
|
public string baseSpace { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 要生成代码的表
|
||||||
|
/// </summary>
|
||||||
|
public string tables { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 要删除表名的字符串用
|
||||||
|
/// </summary>
|
||||||
|
public string replaceTableNameStr { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 要生成的文件
|
||||||
|
/// </summary>
|
||||||
|
public int[] genFiles { get; set; }
|
||||||
|
public bool coverd { get; set; } = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using ZR.Model;
|
using ZR.Model;
|
||||||
using ZR.Model.CodeGenerator;
|
|
||||||
|
|
||||||
namespace ZR.CodeGenerator.Service
|
namespace ZR.CodeGenerator.Service
|
||||||
{
|
{
|
||||||
@ -12,18 +11,12 @@ namespace ZR.CodeGenerator.Service
|
|||||||
/// 获取所有数据库名
|
/// 获取所有数据库名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public List<DataBaseInfo> GetAllDataBases()
|
public List<string> GetAllDataBases()
|
||||||
{
|
{
|
||||||
List<DataBaseInfo> list = new();
|
|
||||||
|
|
||||||
var db = GetSugarDbContext();
|
var db = GetSugarDbContext();
|
||||||
var templist = db.DbMaintenance.GetDataBaseList(db.ScopedContext);
|
var templist = db.DbMaintenance.GetDataBaseList(db.ScopedContext);
|
||||||
templist.ForEach(item =>
|
|
||||||
{
|
|
||||||
list.Add(new DataBaseInfo() { DbName = item });
|
|
||||||
});
|
|
||||||
|
|
||||||
return list;
|
return templist;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -1,14 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace ZR.Model.CodeGenerator
|
|
||||||
{
|
|
||||||
public class DataBaseInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 数据库名称
|
|
||||||
/// </summary>
|
|
||||||
public string DbName { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -15,4 +15,8 @@
|
|||||||
<PackageReference Include="NETCore.Encrypt" Version="2.0.9" />
|
<PackageReference Include="NETCore.Encrypt" Version="2.0.9" />
|
||||||
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.3.4" />
|
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.0.3.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Repositories\" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using ZR.Model;
|
|
||||||
using ZR.Model.CodeGenerator;
|
|
||||||
|
|
||||||
namespace ZR.Service.IService
|
|
||||||
{
|
|
||||||
//public interface ICodeGeneratorService
|
|
||||||
//{
|
|
||||||
// List<DataBaseInfo> GetAllDataBases();
|
|
||||||
|
|
||||||
// List<SqlSugar.DbTableInfo> GetTablesWithPage(string tablename, string dbName, PagerInfo info);
|
|
||||||
|
|
||||||
// List<DbFieldInfo> GetAllColumns(string tableName);
|
|
||||||
|
|
||||||
// List<DbTableInfo> GetAllTables(string tabList);
|
|
||||||
|
|
||||||
// List<SqlSugar.DbColumnInfo> GetColumnInfo(string dbName, string tableName);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Business\" />
|
<Folder Include="Business\" />
|
||||||
|
<Folder Include="Business\IBusService\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-row :gutter="24">
|
<el-row :gutter="24">
|
||||||
<!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 -->
|
<!-- :model属性用于表单验证使用 比如下面的el-form-item 的 prop属性用于对表单值进行验证操作 -->
|
||||||
<el-form :model="queryParams" label-position="left" inline ref="queryForm" v-show="showSearch" @submit.native.prevent>
|
<el-form :model="queryParams" label-position="left" inline ref="queryForm" :label-width="labelWidth" v-show="showSearch" @submit.native.prevent>
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-form-item label="文本">
|
<el-form-item label="文本文字">
|
||||||
<el-input v-model="queryParams.xxx" placeholder="" />
|
<el-input v-model="queryParams.xxx" placeholder="" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -16,18 +16,18 @@
|
|||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-form-item label="下拉框">
|
<el-form-item label="下拉框">
|
||||||
<el-select v-model="queryParams.xxx" placeholder="">
|
<el-select v-model="queryParams.xxx" placeholder="">
|
||||||
<el-option v-for="dict in options" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
|
<el-option v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<el-form-item label="时间范围">
|
<el-form-item label="时间范围">
|
||||||
<el-date-picker v-model="queryParams.timeRange" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
|
<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-date-picker>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="24" style="text-align:center;">
|
<el-col :span="24" style="text-align:center;">
|
||||||
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-form>
|
</el-form>
|
||||||
@ -44,13 +44,13 @@
|
|||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="danger" plain icon="el-icon-delete" size="mini" @click="handleDelete">删除</el-button>
|
<el-button type="danger" plain icon="el-icon-delete" size="mini" @click="handleDelete">删除</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<!-- <el-col :span="1.5">
|
||||||
<el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport">导入</el-button>
|
<el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport">导入</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
|
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
|
||||||
</el-col>
|
</el-col> -->
|
||||||
<right-toolbar :showSearch.sync="showSearch"></right-toolbar>
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<!-- 数据区域 -->
|
<!-- 数据区域 -->
|
||||||
@ -58,13 +58,9 @@
|
|||||||
<el-table-column prop="id" label="id" width="60" sortable> </el-table-column>
|
<el-table-column prop="id" label="id" width="60" sortable> </el-table-column>
|
||||||
<el-table-column prop="userId" label="userid" width="80"> </el-table-column>
|
<el-table-column prop="userId" label="userid" width="80"> </el-table-column>
|
||||||
<!-- 显示图片 -->
|
<!-- 显示图片 -->
|
||||||
<el-table-column prop="photo" label="图片" width="110">
|
<el-table-column prop="photo" label="图片">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-popover placement="right" trigger="hover">
|
<el-image class="table-td-thumb" :src="scope.row.photo" :preview-src-list="[scope.row.photo]"></el-image>
|
||||||
<!-- click显示的大图 -->
|
|
||||||
<img :src="scope.row.photo" />
|
|
||||||
<img slot="reference" :src="scope.row.photo" width="100" height="50">
|
|
||||||
</el-popover>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="content" label="介绍" width="100" :show-overflow-tooltip="true">
|
<el-table-column prop="content" label="介绍" width="100" :show-overflow-tooltip="true">
|
||||||
@ -90,7 +86,7 @@
|
|||||||
|
|
||||||
<!-- 添加或修改菜单对话框 -->
|
<!-- 添加或修改菜单对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="用户Id" prop="userId">
|
<el-form-item label="用户Id" prop="userId">
|
||||||
@ -110,7 +106,7 @@
|
|||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-radio-group v-model="form.status">
|
<el-radio-group v-model="form.status">
|
||||||
<el-radio v-for="dict in options" :key="dict.dictValue" :label="dict.dictValue">{{dict.dictLabel}}</el-radio>
|
<el-radio v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictValue">{{dict.dictLabel}}</el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
@ -136,23 +132,23 @@ export default {
|
|||||||
name: "demo",
|
name: "demo",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
labelWidth: "70px",
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: true,
|
||||||
// 显示搜索条件
|
// 显示搜索条件
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {},
|
||||||
useridx: undefined,
|
|
||||||
name: undefined,
|
|
||||||
},
|
|
||||||
// 弹出层标题
|
// 弹出层标题
|
||||||
title: "",
|
title: "",
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
// 表单参数
|
// 表单参数
|
||||||
form: {},
|
form: {},
|
||||||
|
// 时间范围数组
|
||||||
|
timeRange: [],
|
||||||
// xxx下拉框
|
// xxx下拉框
|
||||||
options: [],
|
statusOptions: [],
|
||||||
// 数据列表
|
// 数据列表
|
||||||
dataList: [
|
dataList: [
|
||||||
{
|
{
|
||||||
@ -174,18 +170,30 @@ export default {
|
|||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
name: [{ required: true, message: "名称不能为空", trigger: "blur" }],
|
name: [{ required: true, message: "名称不能为空", trigger: "blur" }],
|
||||||
userId: [{ required: true, message: "id不能为空", trigger: "blur" }],
|
userId: [
|
||||||
|
{
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
message: "id不能为空,且不能为非数字",
|
||||||
|
trigger: "blur",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
// 列表数据查询
|
||||||
this.getList();
|
this.getList();
|
||||||
|
// 下拉框绑定
|
||||||
|
// this.getDicts("sys_normal_disable").then((response) => {
|
||||||
|
// this.statusOptions = response.data;
|
||||||
|
// });
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// 查询数据
|
// 查询数据
|
||||||
getList() {
|
getList() {
|
||||||
console.log(JSON.stringify(this.queryParams));
|
console.log(JSON.stringify(this.queryParams));
|
||||||
// listXXXX().then(res => {
|
// listXXXX(this.addDateRange(this.queryParams, this.timeRange)).then(res => {
|
||||||
// if (res.code == 200) {
|
// if (res.code == 200) {
|
||||||
// this.dataList = res.data.result;
|
// this.dataList = res.data.result;
|
||||||
// this.total = res.data.totalCount;
|
// this.total = res.data.totalCount;
|
||||||
@ -199,7 +207,6 @@ export default {
|
|||||||
},
|
},
|
||||||
// 重置数据表单
|
// 重置数据表单
|
||||||
reset() {
|
reset() {
|
||||||
this.btnSubmitVisible = true;
|
|
||||||
this.form = {
|
this.form = {
|
||||||
Id: undefined,
|
Id: undefined,
|
||||||
// TODO 其他列字段
|
// TODO 其他列字段
|
||||||
@ -208,7 +215,12 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 重置查询操作 */
|
/** 重置查询操作 */
|
||||||
resetQuery() {
|
resetQuery() {
|
||||||
|
this.timeRange = [];
|
||||||
this.resetForm("queryForm");
|
this.resetForm("queryForm");
|
||||||
|
this.queryParams = {
|
||||||
|
pageNum: 1,
|
||||||
|
//TODO 重置字段
|
||||||
|
};
|
||||||
},
|
},
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
@ -224,11 +236,9 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
// delXXX().then(function () {
|
// delXXX().then((res) => {
|
||||||
|
|
||||||
// })
|
|
||||||
// .then(() => {
|
|
||||||
// this.msgSuccess("删除成功");
|
// this.msgSuccess("删除成功");
|
||||||
|
// this.handleQuery();
|
||||||
// });
|
// });
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
@ -278,3 +288,8 @@ export default {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.table-td-thumb {
|
||||||
|
width: 80px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -70,7 +70,7 @@ export function genCode(tableName) {
|
|||||||
// 同步数据库
|
// 同步数据库
|
||||||
export function synchDb(tableName) {
|
export function synchDb(tableName) {
|
||||||
return request({
|
return request({
|
||||||
url: '/tool/gen/synchDb/' + tableName,
|
url: 'tool/gen/synchDb/' + tableName,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -80,9 +80,9 @@ export function synchDb(tableName) {
|
|||||||
/**
|
/**
|
||||||
* 创建数据库连接
|
* 创建数据库连接
|
||||||
*/
|
*/
|
||||||
export function createGetDBConn(data) {
|
export function createGetDBConn(data) {
|
||||||
return request({
|
return request({
|
||||||
url: 'CodeGenerator/CreateDBConn',
|
url: 'tool/gen/CreateDBConn',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data,
|
data: data,
|
||||||
})
|
})
|
||||||
@ -92,7 +92,7 @@ export function synchDb(tableName) {
|
|||||||
*/
|
*/
|
||||||
export function codeGetDBList() {
|
export function codeGetDBList() {
|
||||||
return request({
|
return request({
|
||||||
url: 'CodeGenerator/GetListDataBase',
|
url: 'tool/gen/getDbList',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ export function codeGetDBList() {
|
|||||||
*/
|
*/
|
||||||
export function codeGetTableList(data) {
|
export function codeGetTableList(data) {
|
||||||
return request({
|
return request({
|
||||||
url: 'CodeGenerator/FindListTable',
|
url: 'tool/gen/FindListTable',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: data,
|
params: data,
|
||||||
})
|
})
|
||||||
@ -111,12 +111,26 @@ export function codeGetTableList(data) {
|
|||||||
*/
|
*/
|
||||||
export async function codeGenerator(data) {
|
export async function codeGenerator(data) {
|
||||||
return await request({
|
return await request({
|
||||||
url: 'CodeGenerator/Generate',
|
url: '/tool/gen/Generate',
|
||||||
method: 'get',
|
method: 'post',
|
||||||
params: data,
|
data: data,
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取表格列信息
|
||||||
|
* @param {*} data
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function queryColumnInfo(data) {
|
||||||
|
return request({
|
||||||
|
url: 'tool/gen/queryColumnInfo',
|
||||||
|
method: 'GET',
|
||||||
|
params: data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* 数据库解密
|
* 数据库解密
|
||||||
|
|||||||
@ -36,13 +36,13 @@
|
|||||||
<!-- 工具区域 -->
|
<!-- 工具区域 -->
|
||||||
<el-row :gutter="10" class="mb8">
|
<el-row :gutter="10" class="mb8">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="primary" v-hasPermi="['Article:add']" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="success" v-hasPermi="['Article:update']" plain icon="el-icon-edit" size="mini" @click="handleUpdate">修改</el-button>
|
<el-button type="success" plain icon="el-icon-edit" size="mini" @click="handleUpdate">修改</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button type="danger" v-hasPermi="['Article:delete']" plain icon="el-icon-delete" size="mini" @click="handleDelete">删除</el-button>
|
<el-button type="danger" plain icon="el-icon-delete" size="mini" @click="handleDelete">删除</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<!-- <el-col :span="1.5">
|
<!-- <el-col :span="1.5">
|
||||||
<el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport">导入</el-button>
|
<el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport">导入</el-button>
|
||||||
@ -54,27 +54,30 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
<!-- 数据区域 -->
|
<!-- 数据区域 -->
|
||||||
<el-table :data="dataList" ref="table" border @selection-change="handleSelectionChange">
|
<el-table :data="dataList" ref="table" border>
|
||||||
<el-table-column type="selection" width="50" />
|
<el-table-column prop="id" label="id" width="60" sortable> </el-table-column>
|
||||||
<el-table-column prop="cid" label="Cid" align="center" width="100" />
|
<el-table-column prop="userId" label="userid" width="80"> </el-table-column>
|
||||||
<el-table-column prop="title" label="文章标题" align="center" width="100" :show-overflow-tooltip="true" />
|
<!-- 显示图片 -->
|
||||||
<el-table-column prop="content" label="文章内容" align="center" width="100" />
|
<el-table-column prop="photo" label="图片">
|
||||||
<el-table-column prop="userId" label="用户id" align="center" width="100" />
|
<template slot-scope="scope">
|
||||||
<el-table-column prop="status" label="文章状态1、已发布 2、草稿" align="center" width="100" :show-overflow-tooltip="true" />
|
<el-image class="table-td-thumb" :src="scope.row.photo" :preview-src-list="[scope.row.photo]"></el-image>
|
||||||
<el-table-column prop="fmt_type" label="编辑器类型markdown,html" align="center" width="100" :show-overflow-tooltip="true" />
|
</template>
|
||||||
<el-table-column prop="tags" label="文章标签" align="center" width="100" :show-overflow-tooltip="true" />
|
</el-table-column>
|
||||||
<el-table-column prop="hits" label="点击量" align="center" width="100" />
|
<el-table-column prop="content" label="介绍" width="100" :show-overflow-tooltip="true">
|
||||||
<el-table-column prop="category_id" label="目录id" align="center" width="100" />
|
</el-table-column>
|
||||||
<el-table-column prop="createTime" label="创建时间" align="center" width="100" />
|
<el-table-column sortable prop="isStart" align="center" label="状态" width="90">
|
||||||
<el-table-column prop="updateTime" label="修改时间" align="center" width="100" />
|
<template>
|
||||||
<el-table-column prop="authorName" label="作者名" align="center" width="100" :show-overflow-tooltip="true" />
|
<el-tag size="mini" type="success" disable-transitions>标签</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column prop="addtime" label="创建时间"> </el-table-column>
|
||||||
<el-table-column label="操作" align="center" width="200">
|
<el-table-column label="操作" align="center" width="200">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">详情</el-button>
|
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">详情</el-button>
|
||||||
<el-button size="mini" v-hasPermi="['Article:update']" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">编辑</el-button>
|
<el-button size="mini" 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="确定删除吗?" @onConfirm="handleDelete(scope.row)" style="margin-left:10px">
|
||||||
<el-button slot="reference" v-hasPermi="['Article:del']" size="mini" type="text" icon="el-icon-delete">删除</el-button>
|
<el-button slot="reference" size="mini" type="text" icon="el-icon-delete">删除</el-button>
|
||||||
</el-popconfirm>
|
</el-popconfirm>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -84,57 +87,35 @@
|
|||||||
<!-- 添加或修改菜单对话框 -->
|
<!-- 添加或修改菜单对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
<el-col :span="12">
|
<el-row>
|
||||||
<el-form-item label="Cid" :label-width="labelWidth" prop="cid">
|
<el-col :span="12">
|
||||||
<el-input v-model="form.cid" placeholder="请输入Cid" />
|
<el-form-item label="用户Id" prop="userId">
|
||||||
</el-form-item>
|
<el-input v-model.number="form.userId" placeholder="" :disabled="form.userId > 0" />
|
||||||
</el-col>
|
</el-form-item>
|
||||||
<el-col :span="12">
|
</el-col>
|
||||||
<el-form-item label="文章标题" :label-width="labelWidth" prop="title">
|
<el-col :span="12">
|
||||||
<el-input v-model="form.title" placeholder="请输入文章标题" />
|
<el-form-item label="用户昵称" prop="name">
|
||||||
</el-form-item>
|
<el-input v-model="form.name" placeholder="" />
|
||||||
</el-col>
|
</el-form-item>
|
||||||
<el-col :span="12">
|
</el-col>
|
||||||
<el-form-item label="文章内容" :label-width="labelWidth" prop="content">
|
<el-col :span="12">
|
||||||
<el-input v-model="form.content" placeholder="请输入文章内容" />
|
<el-form-item label="顺序" prop="sortId">
|
||||||
</el-form-item>
|
<el-input-number v-model="form.sortId" controls-position="right" :min="0" />
|
||||||
</el-col>
|
</el-form-item>
|
||||||
<el-col :span="12">
|
</el-col>
|
||||||
<el-form-item label="用户id" :label-width="labelWidth" prop="userId">
|
<el-col :span="12">
|
||||||
<el-input v-model="form.userId" placeholder="请输入用户id" />
|
<el-form-item label="状态" prop="status">
|
||||||
</el-form-item>
|
<el-radio-group v-model="form.status">
|
||||||
</el-col>
|
<el-radio v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictValue">{{dict.dictLabel}}</el-radio>
|
||||||
<el-col :span="12">
|
</el-radio-group>
|
||||||
<el-form-item label="文章状态1、已发布 2、草稿" :label-width="labelWidth" prop="status">
|
</el-form-item>
|
||||||
<el-input v-model="form.status" placeholder="请输入文章状态1、已发布 2、草稿" />
|
</el-col>
|
||||||
</el-form-item>
|
<el-col :span="24">
|
||||||
</el-col>
|
<el-form-item label="备注" prop="content">
|
||||||
<el-col :span="12">
|
<el-input v-model="form.content" :rows="2" type="textarea" placeholder="请输入内容" />
|
||||||
<el-form-item label="编辑器类型markdown,html" :label-width="labelWidth" prop="fmt_type">
|
</el-form-item>
|
||||||
<el-input v-model="form.fmt_type" placeholder="请输入编辑器类型markdown,html" />
|
</el-col>
|
||||||
</el-form-item>
|
</el-row>
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="文章标签" :label-width="labelWidth" prop="tags">
|
|
||||||
<el-input v-model="form.tags" placeholder="请输入文章标签" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="点击量" :label-width="labelWidth" prop="hits">
|
|
||||||
<el-input v-model="form.hits" placeholder="请输入点击量" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="目录id" :label-width="labelWidth" prop="category_id">
|
|
||||||
<el-input v-model="form.category_id" placeholder="请输入目录id" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="作者名" :label-width="labelWidth" prop="authorName">
|
|
||||||
<el-input v-model="form.authorName" placeholder="请输入作者名" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
</el-form>
|
</el-form>
|
||||||
<div slot="footer" class="dialog-footer" v-if="btnSubmitVisible">
|
<div slot="footer" class="dialog-footer" v-if="btnSubmitVisible">
|
||||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
@ -145,17 +126,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
// import { listArticle,addArticle,delArticle,editArticle } from '@/api/Article.js'
|
// import { listXXXX} from '@/api/xxxx.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Article",
|
name: "demo",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
labelWidth: "70px",
|
labelWidth: "70px",
|
||||||
// 选中数组
|
|
||||||
ids: [],
|
|
||||||
// 非多个禁用
|
|
||||||
multiple: true,
|
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: true,
|
||||||
// 显示搜索条件
|
// 显示搜索条件
|
||||||
@ -173,14 +150,34 @@ export default {
|
|||||||
// xxx下拉框
|
// xxx下拉框
|
||||||
statusOptions: [],
|
statusOptions: [],
|
||||||
// 数据列表
|
// 数据列表
|
||||||
dataList: [],
|
dataList: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
photo:
|
||||||
|
"https://ss1.baidu.com/-4o3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/d788d43f8794a4c2b124d0000df41bd5ad6e3991.jpg",
|
||||||
|
name: "你好",
|
||||||
|
userId: 1000001,
|
||||||
|
sortId: 1,
|
||||||
|
address: "浙江省杭州市西湖区",
|
||||||
|
content: "我是一个超长超长的文字啊",
|
||||||
|
addtime: "2021-8-7 23:00:00",
|
||||||
|
},
|
||||||
|
],
|
||||||
// 总记录数
|
// 总记录数
|
||||||
total: 0,
|
total: 0,
|
||||||
// 提交按钮是否显示
|
// 提交按钮是否显示
|
||||||
btnSubmitVisible: true,
|
btnSubmitVisible: true,
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {
|
rules: {
|
||||||
Cid: [{ required: true, message: "请输入", trigger: "blur" }],
|
name: [{ required: true, message: "名称不能为空", trigger: "blur" }],
|
||||||
|
userId: [
|
||||||
|
{
|
||||||
|
type: "number",
|
||||||
|
required: true,
|
||||||
|
message: "id不能为空,且不能为非数字",
|
||||||
|
trigger: "blur",
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -196,14 +193,12 @@ export default {
|
|||||||
// 查询数据
|
// 查询数据
|
||||||
getList() {
|
getList() {
|
||||||
console.log(JSON.stringify(this.queryParams));
|
console.log(JSON.stringify(this.queryParams));
|
||||||
listArticle(this.addDateRange(this.queryParams, this.timeRange)).then(
|
// listXXXX(this.addDateRange(this.queryParams, this.timeRange)).then(res => {
|
||||||
(res) => {
|
// if (res.code == 200) {
|
||||||
if (res.code == 200) {
|
// this.dataList = res.data.result;
|
||||||
this.dataList = res.data.result;
|
// this.total = res.data.totalCount;
|
||||||
this.total = res.data.totalCount;
|
// }
|
||||||
}
|
// })
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
cancel() {
|
cancel() {
|
||||||
@ -213,20 +208,8 @@ export default {
|
|||||||
// 重置数据表单
|
// 重置数据表单
|
||||||
reset() {
|
reset() {
|
||||||
this.form = {
|
this.form = {
|
||||||
Cid: "",
|
Id: undefined,
|
||||||
Title: "",
|
// TODO 其他列字段
|
||||||
Content: "",
|
|
||||||
UserId: "",
|
|
||||||
Status: "",
|
|
||||||
Fmt_type: "",
|
|
||||||
Tags: "",
|
|
||||||
Hits: "",
|
|
||||||
Category_id: "",
|
|
||||||
CreateTime: "",
|
|
||||||
UpdateTime: "",
|
|
||||||
AuthorName: "",
|
|
||||||
|
|
||||||
//需个性化处理内容
|
|
||||||
};
|
};
|
||||||
this.resetForm("form");
|
this.resetForm("form");
|
||||||
},
|
},
|
||||||
@ -239,11 +222,6 @@ export default {
|
|||||||
//TODO 重置字段
|
//TODO 重置字段
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
// 多选框选中数据
|
|
||||||
handleSelectionChange(selection) {
|
|
||||||
this.ids = selection.map((item) => item.Cid);
|
|
||||||
this.multiple = !selection.length;
|
|
||||||
},
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
this.getList();
|
this.getList();
|
||||||
@ -258,10 +236,10 @@ export default {
|
|||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
delArticle().then((res) => {
|
// delXXX().then((res) => {
|
||||||
this.msgSuccess("删除成功");
|
// this.msgSuccess("删除成功");
|
||||||
this.handleQuery();
|
// this.handleQuery();
|
||||||
});
|
// });
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
@ -285,7 +263,7 @@ export default {
|
|||||||
if (valid) {
|
if (valid) {
|
||||||
console.log(JSON.stringify(this.form));
|
console.log(JSON.stringify(this.form));
|
||||||
// TODO 记得改成表的主键
|
// TODO 记得改成表的主键
|
||||||
if (this.form.Cid != undefined) {
|
if (this.form.Id != undefined) {
|
||||||
//TODO 编辑业务代码
|
//TODO 编辑业务代码
|
||||||
} else {
|
} else {
|
||||||
//TODO 新增业务代码
|
//TODO 新增业务代码
|
||||||
|
|||||||
@ -1,44 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<!-- <div class="filter-container">
|
|
||||||
<el-card>
|
|
||||||
<el-form ref="searchDbform" :inline="true" :model="searchform" class="demo-form-inline" size="small">
|
|
||||||
<el-form-item label="数据库地址" prop="DbAddress">
|
|
||||||
<el-input v-model="searchDbform.DbAddress" placeholder="请输入数据库地址" autocomplete="off" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="数据库名称" prop="DbName">
|
|
||||||
<el-input v-model="searchDbform.DbName" placeholder="请输入数据库名称" autocomplete="off" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="用户名" prop="DbUserName">
|
|
||||||
<el-input v-model="searchDbform.DbUserName" placeholder="请输入用户名" autocomplete="off" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="访问密码" prop="DbPassword">
|
|
||||||
<el-input v-model="searchDbform.DbPassword" placeholder="请输入访问密码" autocomplete="off" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="数据库类型" prop="DbType">
|
|
||||||
<el-select v-model="searchDbform.DbType" clearable placeholder="请选数据库类型">
|
|
||||||
<el-option v-for="item in selectDbTypes" :key="item.Id" :label="item.Title" :value="item.Id" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="数据库端口" prop="DbPort">
|
|
||||||
<el-input v-model="searchDbform.DbPort" placeholder="请输入数据库端口" autocomplete="off" clearable />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="handleDbConn()">链接</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-card>
|
|
||||||
</div> -->
|
|
||||||
<el-card>
|
<el-card>
|
||||||
<div class="list-btn-container">
|
<div>
|
||||||
<el-form ref="codeform" :inline="true" :rules="rules" :model="codeform" class="demo-form-inline" size="small">
|
<el-form ref="codeform" :inline="true" :rules="rules" :model="codeform" size="small">
|
||||||
<el-form-item label="数据库" prop="dbName">
|
<el-form-item label="数据库" prop="dbName">
|
||||||
<el-select v-model="codeform.dbName" clearable placeholder="请选择" @change="handleShowTable">
|
<el-select v-model="codeform.dbName" clearable placeholder="请选择" @change="handleShowTable">
|
||||||
<el-option v-for="item in selectedDataBase" :key="item.Id" :label="item.dbName" :value="item.dbName" />
|
<el-option v-for="item in selectedDataBase" :key="item" :label="item" :value="item" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="表名">
|
<el-form-item label="表名">
|
||||||
<el-input v-model="searchform.tableName" clearable placeholder="输入要查询的表名" />
|
<el-input v-model="codeform.tableName" clearable placeholder="输入要查询的表名" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<!-- <el-form-item label="项目命名空间:" prop="baseSpace">
|
<!-- <el-form-item label="项目命名空间:" prop="baseSpace">
|
||||||
<el-tooltip class="item" effect="dark" content="系统会根据项目命名空间自动生成IService、Service、Models等子命名空间" placement="bottom">
|
<el-tooltip class="item" effect="dark" content="系统会根据项目命名空间自动生成IService、Service、Models等子命名空间" placement="bottom">
|
||||||
@ -46,32 +17,89 @@
|
|||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-form-item> -->
|
</el-form-item> -->
|
||||||
<el-form-item label="去掉表名前缀:">
|
<el-form-item label="去掉表名前缀:">
|
||||||
<el-tooltip class="item" effect="dark" content="表名直接变为类名,去掉表名前缀。多个前缀用“;”隔开和结束" placement="bottom">
|
<el-tooltip class="item" effect="dark" content="表名直接变为类名,去掉表名前缀。" placement="bottom">
|
||||||
<el-input v-model="codeform.replaceTableNameStr" clearable width="300" placeholder="多个前缀用“;”隔开" />
|
<el-input v-model="codeform.replaceTableNameStr" clearable width="300" placeholder="例如:sys_" />
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="handleSearch()">查询</el-button>
|
<el-button type="primary" @click="handleSearch()">查询</el-button>
|
||||||
<!-- <el-button type="primary" icon="iconfont icon-code" @click="handleGenerate()">生成代码</el-button> -->
|
|
||||||
<el-button type="default" icon="el-icon-refresh" size="small" @click="loadTableData()">刷新</el-button>
|
<el-button type="default" icon="el-icon-refresh" size="small" @click="loadTableData()">刷新</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
<el-table ref="gridtable" v-loading="tableloading" :data="tableData" border stripe highlight-current-row style="width: 100%" @selection-change="handleSelectChange">
|
<el-table ref="gridtable" v-loading="tableloading" :data="tableData" border stripe highlight-current-row style="width: 100%">
|
||||||
<!-- <el-table-column type="selection" width="50" /> -->
|
<!-- <el-table-column type="selection" width="50" /> -->
|
||||||
<el-table-column prop="name" label="表名" sortable="custom" width="380" />
|
<el-table-column prop="name" label="表名" sortable="custom" width="380" />
|
||||||
<el-table-column prop="description" label="表描述" />
|
<el-table-column prop="description" label="表描述" />
|
||||||
<el-table-column label="操作" align="center" width="200">
|
<el-table-column label="操作" align="center" width="200">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button type="text" icon="el-icon-view">预览</el-button>
|
<el-button type="text" icon="el-icon-view" @click="handlePreview()">预览</el-button>
|
||||||
<el-button type="text" icon="el-icon-download" @click="handleGenerate(scope.row)">生成代码</el-button>
|
<el-button type="text" icon="el-icon-download" @click="handleShowDialog(scope.row)">生成代码</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<div class="pagination-container">
|
<el-pagination background :current-page="pagination.pageNum" :page-sizes="[5,10,20,50,100, 200, 300, 400]" :page-size="pagination.pagesize" layout="total, sizes, prev, pager, next, jumper" :total="pagination.pageTotal" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
|
||||||
<el-pagination background :current-page="pagination.pageNum" :page-sizes="[5,10,20,50,100, 200, 300, 400]" :page-size="pagination.pagesize" layout="total, sizes, prev, pager, next, jumper" :total="pagination.pageTotal" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
|
|
||||||
</div>
|
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
|
<el-dialog :visible.sync="showGenerate" title="代码生成" width="800px">
|
||||||
|
<el-form ref="codeGenerateForm" label-width="140px">
|
||||||
|
<el-form-item label="要生成的文件">
|
||||||
|
<el-checkbox-group v-model="checkedCodeGenerateForm">
|
||||||
|
<el-checkbox :label="1">生成Model</el-checkbox>
|
||||||
|
<el-checkbox :label="2">生成Dto</el-checkbox>
|
||||||
|
<el-checkbox :label="3">生成Repository</el-checkbox>
|
||||||
|
<el-checkbox :label="4">生成Service</el-checkbox>
|
||||||
|
<el-checkbox :label="5">生成Controller</el-checkbox>
|
||||||
|
<el-checkbox :label="6">生成Views和js</el-checkbox>
|
||||||
|
</el-checkbox-group>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="是否覆盖生成">
|
||||||
|
<el-radio v-model="coverd" :label="true">是</el-radio>
|
||||||
|
<el-radio v-model="coverd" :label="false">否</el-radio>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="生成查询的列">
|
||||||
|
<!-- <el-checkbox-group v-model="checkedQueryColumn">
|
||||||
|
<el-checkbox :label="item.dbColumnName" v-for="item in columnData" :key="item.dbColumnName">{{item.dbColumnName}}</el-checkbox>
|
||||||
|
</el-checkbox-group> -->
|
||||||
|
|
||||||
|
<el-table :data="columnData" height="300px">
|
||||||
|
<el-table-column type="selection" width="60" />
|
||||||
|
<el-table-column label="字段列名" prop="dbColumnName" />
|
||||||
|
<el-table-column label="字段描述" prop="columnDescription">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-input v-model="scope.row.columnDescription" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="表数据类型" prop="dataType" />
|
||||||
|
<el-table-column label="C#类型">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-select v-model="scope.row.dataType">
|
||||||
|
<el-option value="int">int</el-option>
|
||||||
|
<el-option value="bigint">bigint</el-option>
|
||||||
|
<el-option value="varchar">varchar</el-option>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<!-- <el-table-column label="显示类型">
|
||||||
|
<el-select v-model="selectType">
|
||||||
|
<el-option value="input">文本框</el-option>
|
||||||
|
<el-option value="textArea">文本域</el-option>
|
||||||
|
<el-option value="select">下拉框</el-option>
|
||||||
|
<el-option value="radio">单选框</el-option>
|
||||||
|
<el-option value="datetime">日期控件</el-option>
|
||||||
|
<el-option value="upload">图片上传</el-option>
|
||||||
|
<el-option value="fileUpload">文件上传</el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-table-column> -->
|
||||||
|
</el-table>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="handleGenerate">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -81,43 +109,28 @@ import {
|
|||||||
codeGetDBList,
|
codeGetDBList,
|
||||||
codeGetTableList,
|
codeGetTableList,
|
||||||
codeGenerator,
|
codeGenerator,
|
||||||
|
queryColumnInfo,
|
||||||
} from "@/api/tool/gen";
|
} from "@/api/tool/gen";
|
||||||
import { downloadFile } from "@/utils/index";
|
// import { downloadFile } from "@/utils/index";
|
||||||
import { Loading } from "element-ui";
|
import { Loading } from "element-ui";
|
||||||
|
|
||||||
import defaultSettings from "@/settings";
|
|
||||||
import template from "../../../document/template.vue";
|
import template from "../../../document/template.vue";
|
||||||
|
|
||||||
|
// import defaultSettings from "@/settings";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { template },
|
components: { template },
|
||||||
name: "CodeGenerator",
|
name: "CodeGenerator",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
searchDbform: {
|
codeform: {
|
||||||
DbName: "",
|
|
||||||
DbAddress: "",
|
|
||||||
DbPort: "1433",
|
|
||||||
DbUserName: "",
|
|
||||||
DbPassword: "",
|
|
||||||
DbType: "",
|
|
||||||
},
|
|
||||||
searchform: {
|
|
||||||
dbName: "",
|
dbName: "",
|
||||||
tableName: "",
|
tableName: "",
|
||||||
},
|
|
||||||
codeform: {
|
|
||||||
baseSpace: "",
|
baseSpace: "",
|
||||||
replaceTableNameStr: "",
|
replaceTableNameStr: "",
|
||||||
},
|
},
|
||||||
|
showGenerate: false,
|
||||||
|
checkedCodeGenerateForm: [1, 2, 3, 4, 5, 6],
|
||||||
rules: {
|
rules: {
|
||||||
// baseSpace: [
|
|
||||||
// { required: true, message: "请输入项目名称", trigger: "blur" },
|
|
||||||
// {
|
|
||||||
// min: 2,
|
|
||||||
// max: 50,
|
|
||||||
// message: "长度在 2 到 50 个字符",
|
|
||||||
// trigger: "blur",
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
dbName: [
|
dbName: [
|
||||||
{ required: true, message: "请选择数据库名称", trigger: "blur" },
|
{ required: true, message: "请选择数据库名称", trigger: "blur" },
|
||||||
],
|
],
|
||||||
@ -125,16 +138,6 @@ export default {
|
|||||||
{ min: 0, max: 50, message: "长度小于50个字符", trigger: "blur" },
|
{ min: 0, max: 50, message: "长度小于50个字符", trigger: "blur" },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
selectDbTypes: [
|
|
||||||
{
|
|
||||||
Id: "SqlServer",
|
|
||||||
Title: "SqlServer",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Id: "MySql",
|
|
||||||
Title: "MySql",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
tableData: [],
|
tableData: [],
|
||||||
tableloading: false,
|
tableloading: false,
|
||||||
pagination: {
|
pagination: {
|
||||||
@ -142,30 +145,35 @@ export default {
|
|||||||
pagesize: 20,
|
pagesize: 20,
|
||||||
pageTotal: 0,
|
pageTotal: 0,
|
||||||
},
|
},
|
||||||
sortableData: {
|
// 选中行的表
|
||||||
order: "",
|
currentSelected: {},
|
||||||
sort: "",
|
|
||||||
},
|
|
||||||
currentSelected: [],
|
|
||||||
selectedDataBase: [],
|
selectedDataBase: [],
|
||||||
|
// 列信息
|
||||||
|
columnData: [],
|
||||||
|
// 选中的列
|
||||||
|
checkedQueryColumn: [],
|
||||||
|
//是否覆盖原先代码
|
||||||
|
coverd: true,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.pagination.pageNum = 1;
|
this.pagination.pageNum = 1;
|
||||||
this.loadData();
|
this.loadData();
|
||||||
// this.loadTableData();
|
this.loadTableData();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadData: function () {
|
loadData() {
|
||||||
codeGetDBList().then((res) => {
|
codeGetDBList().then((res) => {
|
||||||
this.selectedDataBase = res.data;
|
const { dbList, defaultDb } = res.data;
|
||||||
|
this.codeform.dbName = defaultDb;
|
||||||
|
this.selectedDataBase = dbList;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 加载页面table数据
|
* 加载页面table数据
|
||||||
*/
|
*/
|
||||||
loadTableData: function () {
|
loadTableData() {
|
||||||
if (this.codeform.dataBaseName !== "") {
|
if (this.codeform.dbName !== "") {
|
||||||
this.tableloading = true;
|
this.tableloading = true;
|
||||||
var seachdata = {
|
var seachdata = {
|
||||||
pageNum: this.pagination.pageNum,
|
pageNum: this.pagination.pageNum,
|
||||||
@ -183,46 +191,53 @@ export default {
|
|||||||
/**
|
/**
|
||||||
* 点击查询
|
* 点击查询
|
||||||
*/
|
*/
|
||||||
handleSearch: function () {
|
handleSearch() {
|
||||||
this.$refs["codeform"].validate((valid) => {
|
this.$refs["codeform"].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.tableloading = true;
|
this.tableloading = true;
|
||||||
this.pagination.pageNum = 1;
|
this.pagination.pageNum = 1;
|
||||||
this.loadTableData();
|
this.loadTableData();
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleShowTable: function () {
|
handleShowTable() {
|
||||||
this.pagination.pageNum = 1;
|
|
||||||
// this.loadTableData();
|
|
||||||
},
|
|
||||||
handleDbConn: function () {
|
|
||||||
var dataInfo = {
|
|
||||||
DbAddress: this.searchDbform.DbAddress,
|
|
||||||
DbPort: this.searchDbform.DbPort,
|
|
||||||
DbName: this.searchDbform.DbName,
|
|
||||||
DbUserName: this.searchDbform.DbUserName,
|
|
||||||
DbPassword: this.searchDbform.DbPassword,
|
|
||||||
DbType: this.searchDbform.DbType,
|
|
||||||
};
|
|
||||||
createGetDBConn(dataInfo).then((res) => {
|
|
||||||
this.selectedDataBase = res.ResData;
|
|
||||||
this.searchform.DbName = this.searchDbform.DbName;
|
|
||||||
});
|
|
||||||
this.pagination.pageNum = 1;
|
this.pagination.pageNum = 1;
|
||||||
this.loadTableData();
|
this.loadTableData();
|
||||||
},
|
},
|
||||||
|
handlePreview() {
|
||||||
|
this.msgSuccess("敬请期待");
|
||||||
|
},
|
||||||
|
handleShowDialog(row) {
|
||||||
|
console.log(row);
|
||||||
|
this.showGenerate = true;
|
||||||
|
this.currentSelected = row.name;
|
||||||
|
|
||||||
|
queryColumnInfo({
|
||||||
|
dbName: this.codeform.dbName,
|
||||||
|
tableName: row.name,
|
||||||
|
}).then((res) => {
|
||||||
|
if (res.code === 200) {
|
||||||
|
const columnData = res.data;
|
||||||
|
|
||||||
|
// for (let i = 0; i < columnData.length; i++) {
|
||||||
|
// this.$set(columnData[i], "selectType", 1);
|
||||||
|
// }
|
||||||
|
this.columnData = columnData;
|
||||||
|
// this.checkedQueryColumn = res.data.map((r) => r.dbColumnName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 点击生成服务端代码
|
* 点击生成服务端代码
|
||||||
*/
|
*/
|
||||||
handleGenerate: async function (row) {
|
handleGenerate: async function () {
|
||||||
console.log(JSON.stringify(row));
|
console.log(JSON.stringify(this.checkedCodeGenerateForm));
|
||||||
// if (this.currentSelected.length === 0 || this.currentSelected.length > 3) {
|
if (!this.currentSelected) {
|
||||||
// this.msgError("请先选择要生成代码的数据表", "提示");
|
this.msgError("请先选择要生成代码的数据表");
|
||||||
// return false;
|
return false;
|
||||||
// } else {
|
}
|
||||||
this.$refs["codeform"].validate((valid) => {
|
this.$refs["codeform"].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
var loadop = {
|
var loadop = {
|
||||||
@ -235,10 +250,15 @@ export default {
|
|||||||
|
|
||||||
var seachdata = {
|
var seachdata = {
|
||||||
dbName: this.codeform.dbName,
|
dbName: this.codeform.dbName,
|
||||||
tables: row.name, // this.currentSelected.toString(),
|
tables: this.currentSelected.name,
|
||||||
baseSpace: this.codeform.baseSpace,
|
baseSpace: this.codeform.baseSpace,
|
||||||
replaceTableNameStr: this.codeform.replaceTableNameStr,
|
replaceTableNameStr: this.codeform.replaceTableNameStr,
|
||||||
|
genFiles: this.checkedCodeGenerateForm,
|
||||||
|
coverd: this.coverd,
|
||||||
|
queryColumn: this.checkedQueryColumn,
|
||||||
};
|
};
|
||||||
|
console.log(JSON.stringify(seachdata));
|
||||||
|
//return;
|
||||||
codeGenerator(seachdata)
|
codeGenerator(seachdata)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
@ -246,7 +266,7 @@ export default {
|
|||||||
// defaultSettings.fileUrl + res.ResData[0],
|
// defaultSettings.fileUrl + res.ResData[0],
|
||||||
// res.ResData[1]
|
// res.ResData[1]
|
||||||
// );
|
// );
|
||||||
|
this.showGenerate = false;
|
||||||
this.msgSuccess("恭喜你,代码生成完成!");
|
this.msgSuccess("恭喜你,代码生成完成!");
|
||||||
} else {
|
} else {
|
||||||
this.msgError(res.msg);
|
this.msgError(res.msg);
|
||||||
@ -260,14 +280,6 @@ export default {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// }
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* 当用户手动勾选checkbox数据行事件
|
|
||||||
*/
|
|
||||||
handleSelectChange: function (selection, row) {
|
|
||||||
console.log(JSON.stringify(selection));
|
|
||||||
this.currentSelected = selection.map((item) => item.name);
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 选择每页显示数量
|
* 选择每页显示数量
|
||||||
@ -284,6 +296,10 @@ export default {
|
|||||||
this.pagination.pageNum = val;
|
this.pagination.pageNum = val;
|
||||||
this.loadTableData();
|
this.loadTableData();
|
||||||
},
|
},
|
||||||
|
cancel() {
|
||||||
|
this.showGenerate = false;
|
||||||
|
this.currentSelected = {};
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
15
ZRAdmin.xml
15
ZRAdmin.xml
@ -47,14 +47,19 @@
|
|||||||
<param name="pager">分页信息</param>
|
<param name="pager">分页信息</param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.CodeGeneratorController.Generate(System.String,System.String,System.String,System.String)">
|
<member name="M:ZR.Admin.WebApi.Controllers.CodeGeneratorController.QueryColumnInfo(System.String,System.String)">
|
||||||
|
<summary>
|
||||||
|
获取表格列
|
||||||
|
</summary>
|
||||||
|
<param name="dbName"></param>
|
||||||
|
<param name="tableName"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:ZR.Admin.WebApi.Controllers.CodeGeneratorController.Generate(ZR.CodeGenerator.Model.GenerateDto)">
|
||||||
<summary>
|
<summary>
|
||||||
代码生成器
|
代码生成器
|
||||||
</summary>
|
</summary>
|
||||||
<param name="dbName"></param>
|
<param name="dto">数据传输对象</param>
|
||||||
<param name="tables">要生成代码的表</param>
|
|
||||||
<param name="baseSpace">项目命名空间</param>
|
|
||||||
<param name="replaceTableNameStr">要删除表名的字符串用英文逗号","隔开</param>
|
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:ZR.Admin.WebApi.Controllers.HomeController.Health">
|
<member name="M:ZR.Admin.WebApi.Controllers.HomeController.Health">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user