feat: webfrist基本流程已完成
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
using System.Text;
|
||||
using EasyTool;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using Furion.DependencyInjection;
|
||||
using Yi.Framework.Module.WebFirstManager.Enums;
|
||||
|
||||
namespace Yi.Framework.Module.WebFirstManager.Handler
|
||||
{
|
||||
public class FieldTemplateHandler : TemplateHandlerBase, ITemplateHandler, ISingleton
|
||||
{
|
||||
public string Invoker(string str)
|
||||
public HandledTemplate Invoker(string str,string path)
|
||||
{
|
||||
return str.Replace("@field", BuildFields());
|
||||
var output= new HandledTemplate();
|
||||
output.TemplateStr = str.Replace("@field", BuildFields());
|
||||
output.BuildPath = path;
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,15 +29,20 @@ namespace Yi.Framework.Module.WebFirstManager.Handler
|
||||
|
||||
foreach (var field in Table.Fields)
|
||||
{
|
||||
var typeStr = EnumUtil.GetDescriptionByValue(field.FieldType);
|
||||
var typeStr = typeof(FieldTypeEnum).GetFields().Where(x=> x.Name== field.FieldType.ToString())?.FirstOrDefault().GetCustomAttribute<DisplayAttribute>().Name;
|
||||
|
||||
if (typeStr is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var nameStr = field.Name;
|
||||
|
||||
//添加备注
|
||||
if (string.IsNullOrEmpty(field.Description))
|
||||
if (!string.IsNullOrEmpty(field.Description))
|
||||
{
|
||||
var desStr = "/// <summary>" +
|
||||
@$"///{field.Description}" +
|
||||
"/// </summary>";
|
||||
var desStr = "/// <summary>\n" +
|
||||
$"///{field.Description}\n" +
|
||||
"/// </summary>\n";
|
||||
fieldStrs.AppendLine(desStr);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Yi.Framework.Module.WebFirstManager.Handler
|
||||
{
|
||||
public class HandledTemplate
|
||||
{
|
||||
public string TemplateStr { get; set; }
|
||||
|
||||
public string BuildPath { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,6 @@ namespace Yi.Framework.Module.WebFirstManager.Handler
|
||||
public interface ITemplateHandler
|
||||
{
|
||||
void SetTable(TableAggregateRoot table);
|
||||
string Invoker(string str);
|
||||
HandledTemplate Invoker(string str, string path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,12 @@ namespace Yi.Framework.Module.WebFirstManager.Handler
|
||||
{
|
||||
public class ModelTemplateHandler : TemplateHandlerBase, ITemplateHandler, ISingleton
|
||||
{
|
||||
public string Invoker(string str)
|
||||
public HandledTemplate Invoker(string str, string path)
|
||||
{
|
||||
return str.Replace("@model", StrUtil.ToFirstLetterLowerCase(Table.Name)).Replace("@Model", StrUtil.ToFirstLetterUpperCase(Table.Name));
|
||||
var output = new HandledTemplate();
|
||||
output.TemplateStr= str.Replace("@model", StrUtil.ToFirstLetterLowerCase(Table.Name)).Replace("@Model", StrUtil.ToFirstLetterUpperCase(Table.Name));
|
||||
output.BuildPath = path.Replace("@model", StrUtil.ToFirstLetterLowerCase(Table.Name)).Replace("@Model", StrUtil.ToFirstLetterUpperCase(Table.Name));
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,12 @@ namespace Yi.Framework.Module.WebFirstManager.Handler
|
||||
{
|
||||
public class NameSpaceTemplateHandler : TemplateHandlerBase, ITemplateHandler, ISingleton
|
||||
{
|
||||
public string Invoker(string str)
|
||||
public HandledTemplate Invoker(string str, string path)
|
||||
{
|
||||
return str.Replace("@namespace", "");
|
||||
var output = new HandledTemplate();
|
||||
output.TemplateStr = str.Replace("@namespace", "");
|
||||
output.BuildPath = path;
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user