From b9461aefdc9eceeee18470d6b821dd8413a8412f Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Tue, 16 Apr 2024 15:33:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=A1=A8=E5=A2=9E=E5=88=A0?= =?UTF-8?q?=E6=9F=A5=E6=94=B9=EF=BC=8CDBFirst=E7=94=9F=E6=88=90=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tiobon.Core.Common/Seed/FrameSeed.cs | 249 ++++++++++++++------------- 1 file changed, 134 insertions(+), 115 deletions(-) diff --git a/Tiobon.Core.Common/Seed/FrameSeed.cs b/Tiobon.Core.Common/Seed/FrameSeed.cs index 3795a87e..045fb691 100644 --- a/Tiobon.Core.Common/Seed/FrameSeed.cs +++ b/Tiobon.Core.Common/Seed/FrameSeed.cs @@ -129,128 +129,147 @@ namespace Tiobon.Core.Common.Seed var tableName = lstTableNames[0]; var groupName = tableName.Split('_')[0]; + // var ls = IDbFirst.IsCreateDefaultValue().IsCreateAttribute() + + // .SettingClassTemplate(p => p = + //@"namespace " + strNameSpace + @" + //{ + // /// + // /// {ClassName} + // /// + // [Route(""api/[controller]"")] + // [ApiController, GlobalActionFilter] + // [Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_" + groupName + @")] + // public class {ClassName}Controller : ControllerBase + // { + // #region 初始化 + // /// + // /// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下 + // /// + // private readonly I{ClassName}Services _{ClassName}Services; + + // public {ClassName}Controller(I{ClassName}Services {ClassName}Services) + // { + // _{ClassName}Services = {ClassName}Services; + // } + // #endregion + + // #region 基础接口 + + // #region 查询 + // /// + // /// {ClassName} -- 根据条件查询数据 + // /// + // /// 条件 + // /// + // [HttpGet] + // public async Task>> Get([FromFilter] QueryFilter filter) + // { + // var response = await _{ClassName}Services.QueryFilterPage(filter); + // return new ServiceResult>() { msg = ""获取成功"", success = true, response = response }; + // } + + // /// + // /// {ClassName} -- 根据Id查询数据 + // /// + // /// 主键ID + // /// + // [HttpGet(""{Id}"")] + // public async Task> Get(string Id) + // { + // var entity = await _{ClassName}Services.QueryById(Id); + // if (entity == null) + // return ServiceResult<{ClassName}Dto>.Fail(""获取失败""); + // else + // return new ServiceResult<{ClassName}Dto>() { msg = ""获取成功"", success = true, response = entity }; + // } + // #endregion + + // #region 新增 + // /// + // /// {ClassName} -- 新增数据 + // /// + // /// + // /// + // [HttpPost] + // public async Task> Post([FromBody] Insert{ClassName}Input insertModel) + // { + // var data = ServiceResult.Success(""获取成功"", null); + + // var id = await _{ClassName}Services.Add(insertModel); + // data.success = id > 0; + // if (data.success) + // data.response = id.ObjToString(); + + // return data; + // } + // #endregion + + // #region 更新 + // /// + // /// {ClassName} -- 更新数据 + // /// + // /// + // /// + // /// + // [HttpPut(""{Id}"")] + // public async Task Put(long Id, [FromBody] Edit{ClassName}Input editModel) + // { + // var data = MessageModel.Success(""更新成功""); + // data.success = await _{ClassName}Services.Update(Id, editModel); + // if (!data.success) + // data.msg = ""更新失败""; + + // return data; + // } + // #endregion + + // #region 删除 + // /// + // /// {ClassName} -- 删除数据 + // /// + // /// + // /// + // [HttpDelete(""{Id}"")] + // public async Task Delete(long Id) + // { + // var data = MessageModel.Success(""删除成功""); + // var entity = await _{ClassName}Services.QueryById(Id); + // if (entity == null) + // return MessageModel.Fail(""删除失败""); + + // entity.IsEnable = 0; + // data.success = await _{ClassName}Services.Update(entity); + // if (!data.success) + // data.msg = ""删除失败""; + // return data; + // } + // #endregion + + // #endregion + // } + //}") + + // .ToClassStringList(strNameSpace); var ls = IDbFirst.IsCreateDefaultValue().IsCreateAttribute() - .SettingClassTemplate(p => p = -@"namespace " + strNameSpace + @" + .SettingClassTemplate(p => p = + @"namespace " + strNameSpace + @"; + +/// +/// {ClassName} +/// +[Route(""api/[controller]"")] +[ApiController, GlobalActionFilter] +[Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_" + groupName + @")] +public class {ClassName}Controller : BaseController { - /// - /// {ClassName} - /// - [Route(""api/[controller]"")] - [ApiController, GlobalActionFilter] - [Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_" + groupName + @")] - public class {ClassName}Controller : ControllerBase + public {ClassName}Controller(I{ClassName}Services service) : base(service) { - #region 初始化 - /// - /// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下 - /// - private readonly I{ClassName}Services _{ClassName}Services; - - public {ClassName}Controller(I{ClassName}Services {ClassName}Services) - { - _{ClassName}Services = {ClassName}Services; - } - #endregion - - #region 基础接口 - - #region 查询 - /// - /// {ClassName} -- 根据条件查询数据 - /// - /// 条件 - /// - [HttpGet] - public async Task>> Get([FromFilter] QueryFilter filter) - { - var response = await _{ClassName}Services.QueryFilterPage(filter); - return new ServiceResult>() { msg = ""获取成功"", success = true, response = response }; - } - - /// - /// {ClassName} -- 根据Id查询数据 - /// - /// 主键ID - /// - [HttpGet(""{Id}"")] - public async Task> Get(string Id) - { - var entity = await _{ClassName}Services.QueryById(Id); - if (entity == null) - return ServiceResult<{ClassName}Dto>.Fail(""获取失败""); - else - return new ServiceResult<{ClassName}Dto>() { msg = ""获取成功"", success = true, response = entity }; - } - #endregion - - #region 新增 - /// - /// {ClassName} -- 新增数据 - /// - /// - /// - [HttpPost] - public async Task> Post([FromBody] Insert{ClassName}Input insertModel) - { - var data = ServiceResult.Success(""获取成功"", null); - - var id = await _{ClassName}Services.Add(insertModel); - data.success = id > 0; - if (data.success) - data.response = id.ObjToString(); - - return data; - } - #endregion - - #region 更新 - /// - /// {ClassName} -- 更新数据 - /// - /// - /// - /// - [HttpPut(""{Id}"")] - public async Task Put(long Id, [FromBody] Edit{ClassName}Input editModel) - { - var data = MessageModel.Success(""更新成功""); - data.success = await _{ClassName}Services.Update(Id, editModel); - if (!data.success) - data.msg = ""更新失败""; - - return data; - } - #endregion - - #region 删除 - /// - /// {ClassName} -- 删除数据 - /// - /// - /// - [HttpDelete(""{Id}"")] - public async Task Delete(long Id) - { - var data = MessageModel.Success(""删除成功""); - var entity = await _{ClassName}Services.QueryById(Id); - if (entity == null) - return MessageModel.Fail(""删除失败""); - - entity.IsEnable = 0; - data.success = await _{ClassName}Services.Update(entity); - if (!data.success) - data.msg = ""删除失败""; - return data; - } - #endregion - - #endregion } }") - .ToClassStringList(strNameSpace); + .ToClassStringList(strNameSpace); Dictionary newdic = new Dictionary(); //循环处理 首字母小写 并插入新的 Dictionary