|
|
|
@ -19,7 +19,7 @@ namespace Tiobon.Core.Common.Seed |
|
|
|
|
/// <returns></returns> |
|
|
|
|
public static bool CreateControllers(SqlSugarScope sqlSugarClient, string ConnId = null, bool isMuti = false, string[] tableNames = null) |
|
|
|
|
{ |
|
|
|
|
Create_Controller_ClassFileByDBTalbe(sqlSugarClient, ConnId, $@"C:\my-file\Tiobon.Core.Api.Controllers", "Tiobon.Core.Api.Controllers", tableNames, "", isMuti); |
|
|
|
|
Create_Controller_ClassFileByDBTalbe(sqlSugarClient, ConnId, $@"C:\my-file\Tiobon.Core.Api\Controllers", "Tiobon.Core.Api.Controllers", tableNames, "", isMuti); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -132,22 +132,14 @@ namespace Tiobon.Core.Common.Seed |
|
|
|
|
var ls = IDbFirst.IsCreateDefaultValue().IsCreateAttribute() |
|
|
|
|
|
|
|
|
|
.SettingClassTemplate(p => p = |
|
|
|
|
@"using Tiobon.Core.IServices;
|
|
|
|
|
using Tiobon.Core.Model; |
|
|
|
|
using Tiobon.Core.Model.Models; |
|
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
|
using System; |
|
|
|
|
using System.Linq.Expressions; |
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
|
namespace " + strNameSpace + @"
|
|
|
|
|
@"namespace " + strNameSpace + @"
|
|
|
|
|
{ |
|
|
|
|
[Route(""api/[controller]/[action]"")] |
|
|
|
|
[ApiController] |
|
|
|
|
[Authorize(Permissions.Name)] |
|
|
|
|
public class {ClassName}Controller : ControllerBase |
|
|
|
|
{ |
|
|
|
|
#region 初始化 |
|
|
|
|
/// <summary> |
|
|
|
|
/// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下 |
|
|
|
|
/// </summary> |
|
|
|
@ -157,14 +149,16 @@ namespace " + strNameSpace + @" |
|
|
|
|
{ |
|
|
|
|
_{ClassName}Services = {ClassName}Services; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 基础接口 |
|
|
|
|
|
|
|
|
|
#region 查询 |
|
|
|
|
[HttpGet] |
|
|
|
|
public async Task<MessageModel<PageModel<{ClassName}>>> Get(int page = 1, string key = """",int intPageSize = 50) |
|
|
|
|
{ |
|
|
|
|
if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key)) |
|
|
|
|
{ |
|
|
|
|
key = """"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Expression<Func<{ClassName}, bool>> whereExpression = a => true; |
|
|
|
|
|
|
|
|
@ -174,7 +168,6 @@ namespace " + strNameSpace + @" |
|
|
|
|
success = true, |
|
|
|
|
response = await _{ClassName}Services.QueryPage(whereExpression, page, intPageSize) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[HttpGet(""{id}"")] |
|
|
|
@ -187,7 +180,9 @@ namespace " + strNameSpace + @" |
|
|
|
|
response = await _{ClassName}Services.QueryById(id) |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 新增 |
|
|
|
|
[HttpPost] |
|
|
|
|
public async Task<MessageModel<string>> Post([FromBody] {ClassName} request) |
|
|
|
|
{ |
|
|
|
@ -203,7 +198,9 @@ namespace " + strNameSpace + @" |
|
|
|
|
|
|
|
|
|
return data; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 新增 |
|
|
|
|
[HttpPut] |
|
|
|
|
public async Task<MessageModel<string>> Put([FromBody] {ClassName} request) |
|
|
|
|
{ |
|
|
|
@ -212,19 +209,21 @@ namespace " + strNameSpace + @" |
|
|
|
|
if (data.success) |
|
|
|
|
{ |
|
|
|
|
data.msg = ""更新成功""; |
|
|
|
|
data.response = request?.id.ObjToString(); |
|
|
|
|
data.response = request?.Id.ObjToString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return data; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 删除 |
|
|
|
|
[HttpDelete] |
|
|
|
|
public async Task<MessageModel<string>> Delete(int id) |
|
|
|
|
{ |
|
|
|
|
var data = new MessageModel<string>(); |
|
|
|
|
var model = await _{ClassName}Services.QueryById(id); |
|
|
|
|
model.IsDeleted = true; |
|
|
|
|
data.success = await _departmentServices.Update(model); |
|
|
|
|
model.IsEnable = 1; |
|
|
|
|
// data.success = await _departmentServices.Update(model); |
|
|
|
|
if (data.success) |
|
|
|
|
{ |
|
|
|
|
data.msg = ""删除成功""; |
|
|
|
@ -233,6 +232,9 @@ namespace " + strNameSpace + @" |
|
|
|
|
|
|
|
|
|
return data; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
} |
|
|
|
|
}")
|
|
|
|
|
|
|
|
|
|