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.
109 lines
3.6 KiB
109 lines
3.6 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 : BaseController<IGhra_GradeServices, Ghra_Grade, Ghra_GradeDto, InsertGhra_GradeInput, EditGhra_GradeInput>
|
|
{
|
|
public Ghra_GradeController(IGhra_GradeServices service) : base(service)
|
|
{
|
|
}
|
|
|
|
#region 基础接口
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// Ghra_Grade -- 根据条件查询数据
|
|
/// </summary>
|
|
/// <param name="filter">条件</param>
|
|
/// <returns></returns>
|
|
[HttpGet]
|
|
public async Task<ServiceResult<PageModel<Ghra_GradeDto>>> Get([FromFilter] QueryFilter filter)
|
|
{
|
|
var response = await _service.QueryFilterPage(filter);
|
|
return new ServiceResult<PageModel<Ghra_GradeDto>>() { msg = "获取成功", success = true, response = response };
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ghra_Grade -- 根据Id查询数据
|
|
/// </summary>
|
|
/// <param name="Id">主键ID</param>
|
|
/// <returns></returns>
|
|
[HttpGet("{Id}")]
|
|
public async Task<ServiceResult<Ghra_GradeDto>> Get(string Id)
|
|
{
|
|
var entity = await _service.QueryById(Id);
|
|
if (entity == null)
|
|
return ServiceResult<Ghra_GradeDto>.OprateFailed("获取失败");
|
|
else
|
|
return new ServiceResult<Ghra_GradeDto>() { msg = "获取成功", success = true, response = entity };
|
|
}
|
|
#endregion
|
|
|
|
#region 新增
|
|
/// <summary>
|
|
/// Ghra_Grade -- 新增数据
|
|
/// </summary>
|
|
/// <param name="insertModel"></param>
|
|
/// <returns></returns>
|
|
[HttpPost]
|
|
public async Task<ServiceResult<string>> Post([FromBody] InsertGhra_GradeInput insertModel)
|
|
{
|
|
var data = ServiceResult<string>.OprateSuccess("获取成功", null);
|
|
|
|
var id = await _service.Add(insertModel);
|
|
data.success = id > 0;
|
|
if (data.success)
|
|
data.response = id.ObjToString();
|
|
|
|
return data;
|
|
}
|
|
#endregion
|
|
|
|
#region 更新
|
|
/// <summary>
|
|
/// Ghra_Grade -- 更新数据
|
|
/// </summary>
|
|
/// <param name="Id"></param>
|
|
/// <param name="editModel"></param>
|
|
/// <returns></returns>
|
|
[HttpPut("{Id}")]
|
|
public async Task<ServiceResult> Put(long Id, [FromBody] EditGhra_GradeInput editModel)
|
|
{
|
|
var data = ServiceResult.OprateSuccess("更新成功");
|
|
data.success = await _service.Update(Id, editModel);
|
|
if (!data.success)
|
|
data.msg = "更新失败";
|
|
|
|
return data;
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// Ghra_Grade -- 删除数据
|
|
/// </summary>
|
|
/// <param name="Id"></param>
|
|
/// <returns></returns>
|
|
[HttpDelete("{Id}")]
|
|
public async Task<ServiceResult> Delete(long Id)
|
|
{
|
|
var data = ServiceResult.OprateSuccess("删除成功");
|
|
var entity = await _service.QueryById(Id);
|
|
if (entity == null)
|
|
return ServiceResult.OprateFailed("删除失败");
|
|
|
|
entity.IsEnable = 0;
|
|
data.success = await _service.Update(entity);
|
|
if (!data.success)
|
|
data.msg = "删除失败";
|
|
return data;
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
}
|
|
} |