代码生成新增加查询功能一键生成
This commit is contained in:
parent
1375a1f61a
commit
250a9a9847
@ -15,6 +15,7 @@ using {ApiControllerNamespace}.Extensions;
|
|||||||
using {ApiControllerNamespace}.Filters;
|
using {ApiControllerNamespace}.Filters;
|
||||||
using ZR.Common;
|
using ZR.Common;
|
||||||
using Infrastructure.Extensions;
|
using Infrastructure.Extensions;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace {ApiControllerNamespace}.Controllers
|
namespace {ApiControllerNamespace}.Controllers
|
||||||
{
|
{
|
||||||
@ -51,7 +52,7 @@ namespace {ApiControllerNamespace}.Controllers
|
|||||||
|
|
||||||
//TODO 自己实现搜索条件查询语法参考Sqlsugar,默认查询所有
|
//TODO 自己实现搜索条件查询语法参考Sqlsugar,默认查询所有
|
||||||
//predicate = predicate.And(m => m.Name.Contains(parm.Name));
|
//predicate = predicate.And(m => m.Name.Contains(parm.Name));
|
||||||
|
{QueryCondition}
|
||||||
var response = _{ModelName}Service.GetPages(predicate.ToExpression(), parm);
|
var response = _{ModelName}Service.GetPages(predicate.ToExpression(), parm);
|
||||||
|
|
||||||
return SUCCESS(response);
|
return SUCCESS(response);
|
||||||
@ -66,7 +67,7 @@ namespace {ApiControllerNamespace}.Controllers
|
|||||||
[ActionPermissionFilter(Permission = "{Permission}:query")]
|
[ActionPermissionFilter(Permission = "{Permission}:query")]
|
||||||
public IActionResult Get{ModelName}({PKCsharpType} {PrimaryKey})
|
public IActionResult Get{ModelName}({PKCsharpType} {PrimaryKey})
|
||||||
{
|
{
|
||||||
var response = _{ModelName}Service.GetId({PrimaryKey});
|
var response = _{ModelName}Service.GetFirst(x => x.{PrimaryKey} == {PrimaryKey});
|
||||||
|
|
||||||
return SUCCESS(response);
|
return SUCCESS(response);
|
||||||
}
|
}
|
||||||
@ -134,5 +135,20 @@ namespace {ApiControllerNamespace}.Controllers
|
|||||||
|
|
||||||
return SUCCESS(response);
|
return SUCCESS(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// {FunctionName}导出
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[Log(BusinessType = BusinessType.EXPORT, IsSaveResponseData = false, Title = "{FunctionName}")]
|
||||||
|
[HttpGet("export")]
|
||||||
|
[ActionPermissionFilter(Permission = "{Permission}:export")]
|
||||||
|
public IActionResult Export()
|
||||||
|
{
|
||||||
|
var list = _{ModelName}Service.GetAll();
|
||||||
|
|
||||||
|
string sFileName = ExportExcel(list, "{ModelName}", "{FunctionName}");
|
||||||
|
return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
namespace {ModelsNamespace}.Models
|
namespace {ModelsNamespace}.Models
|
||||||
{
|
{
|
||||||
@ -9,7 +10,7 @@ namespace {ModelsNamespace}.Models
|
|||||||
/// @author {Author}
|
/// @author {Author}
|
||||||
/// @date {DateTime}
|
/// @date {DateTime}
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SqlSugar.SugarTable("{TableName}")]
|
[SugarTable("{TableName}")]
|
||||||
public class {ModelTypeName}
|
public class {ModelTypeName}
|
||||||
{
|
{
|
||||||
{PropertyName}
|
{PropertyName}
|
||||||
|
|||||||
@ -12,10 +12,10 @@ namespace {ServicesNamespace}.Business
|
|||||||
/// @date {DateTime}
|
/// @date {DateTime}
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AppService(ServiceType = typeof(I{ModelTypeName}Service), ServiceLifetime = LifeTime.Transient)]
|
[AppService(ServiceType = typeof(I{ModelTypeName}Service), ServiceLifetime = LifeTime.Transient)]
|
||||||
public class {ModelTypeName}Service: BaseService<{ModelTypeName}>, I{ModelTypeName}Service
|
public class {ModelTypeName}Service : BaseService<{ModelTypeName}>, I{ModelTypeName}Service
|
||||||
{
|
{
|
||||||
private readonly {ModelTypeName}Repository _{ModelTypeName}repository;
|
private readonly {ModelTypeName}Repository _{ModelTypeName}repository;
|
||||||
public {ModelTypeName}Service({ModelTypeName}Repository repository)
|
public {ModelTypeName}Service({ModelTypeName}Repository repository) : base(repository)
|
||||||
{
|
{
|
||||||
_{ModelTypeName}repository = repository;
|
_{ModelTypeName}repository = repository;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,5 +18,5 @@ VALUES ('{FunctionName}删除', @menuId, 2, '#', NULL, 0, 0, 'F', '0', '0', '{Pe
|
|||||||
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time, update_by, update_time, remark)
|
INSERT INTO sys_menu(menuName, parentId, orderNum, path, component, isFrame, isCache, menuType, visible, status, perms, icon, create_by,create_time, update_by, update_time, remark)
|
||||||
VALUES ('{FunctionName}修改', @menuId, 3, '#', NULL, 0, 0, 'F', '0', '0', '{Permission}:update', '', '', GETDATE(), '', NULL, NULL);
|
VALUES ('{FunctionName}修改', @menuId, 3, '#', NULL, 0, 0, 'F', '0', '0', '{Permission}:update', '', '', GETDATE(), '', NULL, NULL);
|
||||||
|
|
||||||
SELECT * FROM sys_menu WHERE parentId = {ParentId};
|
SELECT * FROM sys_menu WHERE parentId = @menuId;
|
||||||
SELECT * FROM sys_menu WHERE menuId = @menuId;
|
SELECT * FROM sys_menu WHERE menuId = @menuId;
|
||||||
@ -1,9 +1,9 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {FunctionName}分页查询
|
* {FunctionName}分页查询
|
||||||
* @param {查询条件} data
|
* @param {查询条件} data
|
||||||
*/
|
*/
|
||||||
export function list{ModelTypeName}(query) {
|
export function list{ModelTypeName}(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '{ModuleName}/{ModelTypeName}/list',
|
url: '{ModuleName}/{ModelTypeName}/list',
|
||||||
@ -13,9 +13,9 @@ export function list{ModelTypeName}(query) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增{FunctionName}
|
* 新增{FunctionName}
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export function add{ModelTypeName}(data) {
|
export function add{ModelTypeName}(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '{ModuleName}/{ModelTypeName}',
|
url: '{ModuleName}/{ModelTypeName}',
|
||||||
@ -25,9 +25,9 @@ export function add{ModelTypeName}(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改{FunctionName}
|
* 修改{FunctionName}
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export function update{ModelTypeName}(data) {
|
export function update{ModelTypeName}(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '{ModuleName}/{ModelTypeName}',
|
url: '{ModuleName}/{ModelTypeName}',
|
||||||
@ -37,9 +37,9 @@ export function update{ModelTypeName}(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取{FunctionName}详情
|
* 获取{FunctionName}详情
|
||||||
* @param {Id} {FunctionName}Id
|
* @param {Id} {FunctionName}Id
|
||||||
*/
|
*/
|
||||||
export function get{ModelTypeName}(id) {
|
export function get{ModelTypeName}(id) {
|
||||||
return request({
|
return request({
|
||||||
url: '{ModuleName}/{ModelTypeName}/' + id,
|
url: '{ModuleName}/{ModelTypeName}/' + id,
|
||||||
@ -48,12 +48,20 @@ export function get{ModelTypeName}(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
* @param {主键} pid
|
* @param {主键} pid
|
||||||
*/
|
*/
|
||||||
export function del{ModelTypeName}(pid) {
|
export function del{ModelTypeName}(pid) {
|
||||||
return request({
|
return request({
|
||||||
url: '{ModuleName}/{ModelTypeName}/' + pid,
|
url: '{ModuleName}/{ModelTypeName}/' + pid,
|
||||||
method: 'delete'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 导出
|
||||||
|
export function export{ModelTypeName}(query) {
|
||||||
|
return request({
|
||||||
|
url: '{ModuleName}/{ModelTypeName}/export',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using ZR.CodeGenerator.Model;
|
||||||
using ZR.Model.System.Generate;
|
using ZR.Model.System.Generate;
|
||||||
|
|
||||||
namespace ZR.CodeGenerator
|
namespace ZR.CodeGenerator
|
||||||
@ -10,6 +11,78 @@ namespace ZR.CodeGenerator
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class CodeGenerateTemplate
|
public class CodeGenerateTemplate
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 表Model属性
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tbColumn"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetModelTemplate(GenTableColumn tbColumn)
|
||||||
|
{
|
||||||
|
StringBuilder sbModel = new StringBuilder();
|
||||||
|
sbModel.AppendLine(" /// <summary>");
|
||||||
|
sbModel.AppendLine($" /// 描述 :{tbColumn.ColumnComment}");
|
||||||
|
sbModel.AppendLine($" /// 空值 :{!tbColumn.IsRequired}");
|
||||||
|
sbModel.AppendLine(" /// </summary>");
|
||||||
|
if (tbColumn.IsPk || tbColumn.IsIncrement)
|
||||||
|
{
|
||||||
|
sbModel.AppendLine($" [SqlSugar.SugarColumn(IsPrimaryKey = {tbColumn.IsPk.ToString().ToLower()}, IsIdentity = {tbColumn.IsIncrement.ToString().ToLower()})]");
|
||||||
|
}
|
||||||
|
sbModel.AppendLine($" public {tbColumn.CsharpType}{(CodeGeneratorTool.GetModelRequired(tbColumn))} {tbColumn.CsharpField} {{ get; set; }}");
|
||||||
|
return sbModel.ToString();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 增改Dto
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tbColumn"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetDtoProperty(GenTableColumn tbColumn)
|
||||||
|
{
|
||||||
|
string InputDtoContent = "";
|
||||||
|
if (GenConstants.inputDtoNoField.Any(f => f.ToLower().Contains(tbColumn.CsharpField.ToLower())))
|
||||||
|
{
|
||||||
|
return InputDtoContent;
|
||||||
|
}
|
||||||
|
else if (tbColumn.IsInsert || tbColumn.IsEdit || tbColumn.IsPk || tbColumn.IsIncrement)
|
||||||
|
{
|
||||||
|
InputDtoContent += $" public {tbColumn.CsharpType}{CodeGeneratorTool.GetModelRequired(tbColumn)} {tbColumn.CsharpField} {{ get; set; }}\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return InputDtoContent;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 查询Dto属性
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tbColumn"></param>
|
||||||
|
/// <param name="replaceDto">替换字符对象</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static void GetQueryDtoProperty(GenTableColumn tbColumn, ReplaceDto replaceDto)
|
||||||
|
{
|
||||||
|
string QueryDtoContent = "";
|
||||||
|
if (tbColumn.IsQuery)
|
||||||
|
{
|
||||||
|
QueryDtoContent += $" public {tbColumn.CsharpType} {tbColumn.CsharpField} {{ get; set; }}\r\n";
|
||||||
|
//字符串类型表达式
|
||||||
|
if (tbColumn.CsharpType == GenConstants.TYPE_STRING)
|
||||||
|
{
|
||||||
|
replaceDto.QueryCondition += $" predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.{tbColumn.CsharpField}), {QueryExp(tbColumn.CsharpField, tbColumn.QueryType)};\n";
|
||||||
|
}
|
||||||
|
//int类型表达式
|
||||||
|
if (CodeGeneratorTool.IsNumber(tbColumn.CsharpType))
|
||||||
|
{
|
||||||
|
replaceDto.QueryCondition += $" predicate = predicate.AndIF(parm.{tbColumn.CsharpField} > 0, {QueryExp(tbColumn.CsharpField, tbColumn.QueryType)};\n";
|
||||||
|
}
|
||||||
|
//时间类型
|
||||||
|
if (tbColumn.CsharpType == GenConstants.TYPE_DATE)
|
||||||
|
{
|
||||||
|
replaceDto.QueryCondition += $" predicate = predicate.AndIF(parm.BeginTime != null, it => it.{tbColumn.CsharpField} >= parm.BeginTime);\n";
|
||||||
|
replaceDto.QueryCondition += $" predicate = predicate.AndIF(parm.EndTime != null, it => it.{tbColumn.CsharpField} <= parm.EndTime);\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
replaceDto.QueryProperty += QueryDtoContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region vue 模板
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成vuejs模板,目前只有上传文件方法
|
/// 生成vuejs模板,目前只有上传文件方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -39,7 +112,11 @@ namespace ZR.CodeGenerator
|
|||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
//rules
|
/// <summary>
|
||||||
|
/// Vue rules
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dbFieldInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static string GetFormRules(GenTableColumn dbFieldInfo)
|
public static string GetFormRules(GenTableColumn dbFieldInfo)
|
||||||
{
|
{
|
||||||
StringBuilder sbRule = new StringBuilder();
|
StringBuilder sbRule = new StringBuilder();
|
||||||
@ -55,67 +132,11 @@ namespace ZR.CodeGenerator
|
|||||||
return sbRule.ToString();
|
return sbRule.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
//model 属性
|
|
||||||
public static string GetModelTemplate(GenTableColumn dbFieldInfo)
|
|
||||||
{
|
|
||||||
StringBuilder sbModel = new StringBuilder();
|
|
||||||
sbModel.AppendLine(" /// <summary>");
|
|
||||||
sbModel.AppendLine($" /// 描述 :{dbFieldInfo.ColumnComment}");
|
|
||||||
sbModel.AppendLine($" /// 空值 :{!dbFieldInfo.IsRequired}");
|
|
||||||
sbModel.AppendLine(" /// </summary>");
|
|
||||||
if (dbFieldInfo.IsPk || dbFieldInfo.IsIncrement)
|
|
||||||
{
|
|
||||||
sbModel.AppendLine($" [SqlSugar.SugarColumn(IsPrimaryKey = {dbFieldInfo.IsPk.ToString().ToLower()}, IsIdentity = {dbFieldInfo.IsIncrement.ToString().ToLower()})]");
|
|
||||||
}
|
|
||||||
sbModel.AppendLine($" public {dbFieldInfo.CsharpType}{(GetModelRequired(dbFieldInfo))} {dbFieldInfo.CsharpField} {{ get; set; }}");
|
|
||||||
return sbModel.ToString();
|
|
||||||
}
|
|
||||||
public static string GetModelRequired(GenTableColumn dbFieldInfo)
|
|
||||||
{
|
|
||||||
string str = "";
|
|
||||||
if (!dbFieldInfo.IsRequired && (CodeGeneratorTool.IsNumber(dbFieldInfo.ColumnType) || dbFieldInfo.CsharpType == "DateTime"))
|
|
||||||
{
|
|
||||||
str = "?";
|
|
||||||
}
|
|
||||||
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
//DTO model
|
|
||||||
public static string GetDtoProperty(GenTableColumn dbFieldInfo)
|
|
||||||
{
|
|
||||||
string InputDtoContent = "";
|
|
||||||
if (GenConstants.inputDtoNoField.Any(f => f.Replace("_", "").ToLower().Contains(dbFieldInfo.CsharpField.ToLower().Replace("_", ""))))
|
|
||||||
{
|
|
||||||
return InputDtoContent;
|
|
||||||
}
|
|
||||||
//else if (dbFieldInfo.HtmlType == GenConstants.HTML_DATETIME)
|
|
||||||
//{
|
|
||||||
// return InputDtoContent;
|
|
||||||
//}
|
|
||||||
else if (dbFieldInfo.IsInsert || dbFieldInfo.IsEdit || dbFieldInfo.IsPk || dbFieldInfo.IsIncrement)
|
|
||||||
{
|
|
||||||
InputDtoContent += $" public {dbFieldInfo.CsharpType}{GetModelRequired(dbFieldInfo)} {dbFieldInfo.CsharpField} {{ get; set; }}\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return InputDtoContent;
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询Dto属性
|
/// Vue 添加修改表单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dbFieldInfo"></param>
|
/// <param name="dbFieldInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string GetQueryDtoProperty(GenTableColumn dbFieldInfo)
|
|
||||||
{
|
|
||||||
string QueryDtoContent = "";
|
|
||||||
if (dbFieldInfo.IsQuery && !GenConstants.inputDtoNoField.Any(f => f.ToLower().Contains(dbFieldInfo.CsharpField.ToLower())))
|
|
||||||
{
|
|
||||||
QueryDtoContent += $" public {dbFieldInfo.CsharpType} {dbFieldInfo.CsharpField} {{ get; set; }}\r\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return QueryDtoContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
//form-item
|
|
||||||
public static string GetVueViewFormContent(GenTableColumn dbFieldInfo)
|
public static string GetVueViewFormContent(GenTableColumn dbFieldInfo)
|
||||||
{
|
{
|
||||||
string columnName = dbFieldInfo.ColumnName;
|
string columnName = dbFieldInfo.ColumnName;
|
||||||
@ -131,6 +152,8 @@ namespace ZR.CodeGenerator
|
|||||||
{
|
{
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
sb.AppendLine("<el-row>");
|
||||||
|
sb.AppendLine("<el-col :span=\"24\">");
|
||||||
if (dbFieldInfo.HtmlType == GenConstants.HTML_INPUT_NUMBER)
|
if (dbFieldInfo.HtmlType == GenConstants.HTML_INPUT_NUMBER)
|
||||||
{
|
{
|
||||||
sb.AppendLine($" <el-form-item label=\"{labelName}\" :label-width=\"labelWidth\" prop=\"{CodeGeneratorTool.FirstLowerCase(columnName)}\">");
|
sb.AppendLine($" <el-form-item label=\"{labelName}\" :label-width=\"labelWidth\" prop=\"{CodeGeneratorTool.FirstLowerCase(columnName)}\">");
|
||||||
@ -200,12 +223,13 @@ namespace ZR.CodeGenerator
|
|||||||
sb.AppendLine($" <el-input v-model{inputNumTxt}=\"form.{CodeGeneratorTool.FirstLowerCase(columnName)}\" placeholder=\"{placeHolder}\" {labelDisabled}/>");
|
sb.AppendLine($" <el-input v-model{inputNumTxt}=\"form.{CodeGeneratorTool.FirstLowerCase(columnName)}\" placeholder=\"{placeHolder}\" {labelDisabled}/>");
|
||||||
sb.AppendLine(" </el-form-item>");
|
sb.AppendLine(" </el-form-item>");
|
||||||
}
|
}
|
||||||
|
sb.AppendLine("</el-col>");
|
||||||
|
sb.AppendLine("</el-row>");
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询表单
|
/// Vue 查询表单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dbFieldInfo"></param>
|
/// <param name="dbFieldInfo"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
@ -231,7 +255,11 @@ namespace ZR.CodeGenerator
|
|||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
//table-column
|
/// <summary>
|
||||||
|
/// Vue 查询列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dbFieldInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static string GetTableColumn(GenTableColumn dbFieldInfo)
|
public static string GetTableColumn(GenTableColumn dbFieldInfo)
|
||||||
{
|
{
|
||||||
string columnName = dbFieldInfo.ColumnName;
|
string columnName = dbFieldInfo.ColumnName;
|
||||||
@ -262,5 +290,40 @@ namespace ZR.CodeGenerator
|
|||||||
}
|
}
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public static string QueryExp(string propertyName, string queryType)
|
||||||
|
{
|
||||||
|
if (queryType.Equals("EQ"))
|
||||||
|
{
|
||||||
|
return $"m => m.{ propertyName} == parm.{propertyName})";
|
||||||
|
}
|
||||||
|
if (queryType.Equals("GTE"))
|
||||||
|
{
|
||||||
|
return $"m => m.{ propertyName} >= parm.{propertyName})";
|
||||||
|
}
|
||||||
|
if (queryType.Equals("GT"))
|
||||||
|
{
|
||||||
|
return $"m => m.{ propertyName} > parm.{propertyName})";
|
||||||
|
}
|
||||||
|
if (queryType.Equals("LT"))
|
||||||
|
{
|
||||||
|
return $"m => m.{ propertyName} < parm.{propertyName})";
|
||||||
|
}
|
||||||
|
if (queryType.Equals("LTE"))
|
||||||
|
{
|
||||||
|
return $"m => m.{ propertyName} <= parm.{propertyName})";
|
||||||
|
}
|
||||||
|
if (queryType.Equals("NE"))
|
||||||
|
{
|
||||||
|
return $"m => m.{ propertyName} != parm.{propertyName})";
|
||||||
|
}
|
||||||
|
if (queryType.Equals("LIKE"))
|
||||||
|
{
|
||||||
|
return $"m => m.{ propertyName}.Contains(parm.{propertyName}))";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -107,7 +107,7 @@ namespace ZR.CodeGenerator
|
|||||||
replaceDto.VueComponentImport += "import Editor from '@/components/Editor';\n";
|
replaceDto.VueComponentImport += "import Editor from '@/components/Editor';\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceDto.QueryProperty += CodeGenerateTemplate.GetQueryDtoProperty(dbFieldInfo);
|
CodeGenerateTemplate.GetQueryDtoProperty(dbFieldInfo, replaceDto);
|
||||||
replaceDto.ModelProperty += CodeGenerateTemplate.GetModelTemplate(dbFieldInfo);
|
replaceDto.ModelProperty += CodeGenerateTemplate.GetModelTemplate(dbFieldInfo);
|
||||||
replaceDto.VueViewFormHtml += CodeGenerateTemplate.GetVueViewFormContent(dbFieldInfo);
|
replaceDto.VueViewFormHtml += CodeGenerateTemplate.GetVueViewFormContent(dbFieldInfo);
|
||||||
replaceDto.VueJsMethod += CodeGenerateTemplate.GetVueJsMethod(dbFieldInfo);
|
replaceDto.VueJsMethod += CodeGenerateTemplate.GetVueJsMethod(dbFieldInfo);
|
||||||
@ -329,6 +329,10 @@ namespace ZR.CodeGenerator
|
|||||||
{
|
{
|
||||||
content = content.Replace("{InsertColumn}", replaceDto.InsertColumn.TrimEnd('\n'));
|
content = content.Replace("{InsertColumn}", replaceDto.InsertColumn.TrimEnd('\n'));
|
||||||
}
|
}
|
||||||
|
if (replaceDto.QueryCondition != null)
|
||||||
|
{
|
||||||
|
content = content.Replace("{QueryCondition}", replaceDto.QueryCondition);
|
||||||
|
}
|
||||||
generateDto.GenCodes.Add(new GenCode(5, "控制器", fullPath, content));
|
generateDto.GenCodes.Add(new GenCode(5, "控制器", fullPath, content));
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -464,6 +468,16 @@ namespace ZR.CodeGenerator
|
|||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(columnDescription) ? columnName : columnDescription;
|
return string.IsNullOrEmpty(columnDescription) ? columnName : columnDescription;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 判断是否给属性添加?
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dbFieldInfo"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetModelRequired(GenTableColumn dbFieldInfo)
|
||||||
|
{
|
||||||
|
return (!dbFieldInfo.IsRequired && (IsNumber(dbFieldInfo.ColumnType) || dbFieldInfo.CsharpType == "DateTime")) ? "?" : "";
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -127,7 +127,7 @@ namespace ZR.CodeGenerator
|
|||||||
public static string TYPE_DOUBLE = "Double";
|
public static string TYPE_DOUBLE = "Double";
|
||||||
|
|
||||||
/** 时间类型 */
|
/** 时间类型 */
|
||||||
public static string TYPE_DATE = "Date";
|
public static string TYPE_DATE = "DateTime";
|
||||||
|
|
||||||
/** 模糊查询 */
|
/** 模糊查询 */
|
||||||
public static string QUERY_LIKE = "LIKE";
|
public static string QUERY_LIKE = "LIKE";
|
||||||
|
|||||||
@ -51,14 +51,16 @@
|
|||||||
<el-checkbox v-model="scope.row.isList"></el-checkbox>
|
<el-checkbox v-model="scope.row.isList"></el-checkbox>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<!-- <el-table-column label="查询" min-width="5%">
|
<el-table-column label="查询" min-width="5%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-checkbox v-model="scope.row.isQuery"></el-checkbox>
|
<el-checkbox v-model="scope.row.isQuery"
|
||||||
|
:disabled="scope.row.htmlType == 'imageUpload' || scope.row.htmlType == 'fileUpload'">
|
||||||
|
</el-checkbox>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="查询方式" min-width="10%">
|
<el-table-column label="查询方式" min-width="10%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-select v-model="scope.row.queryType">
|
<el-select v-model="scope.row.queryType" :disabled="scope.row.htmlType == 'datetime'">
|
||||||
<el-option label="=" value="EQ" />
|
<el-option label="=" value="EQ" />
|
||||||
<el-option label="!=" value="NE" />
|
<el-option label="!=" value="NE" />
|
||||||
<el-option label=">" value="GT" />
|
<el-option label=">" value="GT" />
|
||||||
@ -69,8 +71,8 @@
|
|||||||
<el-option label="BETWEEN" value="BETWEEN" />
|
<el-option label="BETWEEN" value="BETWEEN" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column> -->
|
</el-table-column>
|
||||||
<el-table-column label="显示类型" min-width="12%">
|
<el-table-column label="表单显示类型" min-width="12%">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-select v-model="scope.row.htmlType">
|
<el-select v-model="scope.row.htmlType">
|
||||||
<el-option label="文本框" value="input" />
|
<el-option label="文本框" value="input" />
|
||||||
@ -182,7 +184,7 @@ export default {
|
|||||||
// treeParentCode: genTable.treeParentCode,
|
// treeParentCode: genTable.treeParentCode,
|
||||||
// parentMenuId: genTable.parentMenuId,
|
// parentMenuId: genTable.parentMenuId,
|
||||||
// };
|
// };
|
||||||
console.log(JSON.stringify(genTable))
|
console.log(JSON.stringify(genTable));
|
||||||
updateGenTable(genTable).then((res) => {
|
updateGenTable(genTable).then((res) => {
|
||||||
this.msgSuccess(res.msg);
|
this.msgSuccess(res.msg);
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user