You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
3.8 KiB
124 lines
3.8 KiB
namespace Tiobon.Core.Api.Controllers
|
|
{
|
|
/// <summary>
|
|
/// Ghra_Grade
|
|
/// </summary>
|
|
[Route("api/[controller]")]
|
|
[ApiController, GlobalActionFilter]
|
|
[Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_Ghra)]
|
|
public class Ghra_GradeController : ControllerBase
|
|
{
|
|
#region 初始化
|
|
/// <summary>
|
|
/// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下
|
|
/// </summary>
|
|
private readonly IGhra_GradeServices _ghra_GradeServices;
|
|
|
|
public Ghra_GradeController(IGhra_GradeServices Ghra_GradeServices)
|
|
{
|
|
_ghra_GradeServices = Ghra_GradeServices;
|
|
}
|
|
#endregion
|
|
|
|
#region 基础接口
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// Ghra_Grade -- 根据条件查询数据
|
|
/// </summary>
|
|
/// <param name="filter">条件</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<MessageModel<PageModel<Ghra_Grade>>> Get([FromFilter] QueryFilter filter)
|
|
{
|
|
var response = await _ghra_GradeServices.QueryFilterPage(filter);
|
|
return new MessageModel<PageModel<Ghra_Grade>>() { msg = "获取成功", success = true, response = response };
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ghra_Grade -- 根据Id查询数据
|
|
/// </summary>
|
|
/// <param name="id">主键ID</param>
|
|
/// <returns></returns>
|
|
[HttpGet("{id}")]
|
|
public async Task<MessageModel<Ghra_Grade>> Get(string id)
|
|
{
|
|
return new MessageModel<Ghra_Grade>()
|
|
{
|
|
msg = "获取成功",
|
|
success = true,
|
|
response = await _ghra_GradeServices.QueryById(id)
|
|
};
|
|
}
|
|
#endregion
|
|
|
|
#region 新增
|
|
/// <summary>
|
|
/// Ghra_Grade -- 新增数据
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<MessageModel<string>> Post([FromBody] Ghra_Grade request)
|
|
{
|
|
var data = new MessageModel<string>();
|
|
|
|
var id = await _ghra_GradeServices.Add(request);
|
|
data.success = id > 0;
|
|
if (data.success)
|
|
{
|
|
data.response = id.ObjToString();
|
|
data.msg = "添加成功";
|
|
}
|
|
|
|
return data;
|
|
}
|
|
#endregion
|
|
|
|
#region 更新
|
|
/// <summary>
|
|
/// Ghra_Grade -- 更新数据
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
[HttpPut]
|
|
public async Task<MessageModel<string>> Put([FromBody] Ghra_Grade request)
|
|
{
|
|
var data = new MessageModel<string>();
|
|
data.success = await _ghra_GradeServices.Update(request);
|
|
if (data.success)
|
|
{
|
|
data.msg = "更新成功";
|
|
data.response = request?.Id.ObjToString();
|
|
}
|
|
|
|
return data;
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// Ghra_Grade -- 删除数据
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpDelete]
|
|
public async Task<MessageModel<string>> Delete(int id)
|
|
{
|
|
var data = new MessageModel<string>();
|
|
var model = await _ghra_GradeServices.QueryById(id);
|
|
model.IsEnable = 1;
|
|
// data.success = await _departmentServices.Update(model);
|
|
if (data.success)
|
|
{
|
|
data.msg = "删除成功";
|
|
data.response = model?.Id.ObjToString();
|
|
}
|
|
|
|
return data;
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
} |