namespace Tiobon.Core.Api.Controllers { /// /// Ghra_Grade /// [Route("api/[controller]")] [ApiController, GlobalActionFilter] [Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_Ghra)] public class Ghra_GradeController : ControllerBase { #region 初始化 /// /// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下 /// private readonly IGhra_GradeServices _ghra_GradeServices; public Ghra_GradeController(IGhra_GradeServices Ghra_GradeServices) { _ghra_GradeServices = Ghra_GradeServices; } #endregion #region 基础接口 #region 查询 /// /// Ghra_Grade -- 根据条件查询数据 /// /// 条件 /// [HttpGet] public async Task>> Get([FromFilter] QueryFilter filter) { var response = await _ghra_GradeServices.QueryFilterPage(filter); return new MessageModel>() { msg = "获取成功", success = true, response = response }; } /// /// Ghra_Grade -- 根据Id查询数据 /// /// 主键ID /// [HttpGet("{Id}")] public async Task> Get(string Id) { var entity = await _ghra_GradeServices.QueryById(Id); if (entity == null) return MessageModel.Fail("获取失败"); else return new MessageModel() { msg = "获取成功", success = true, response = entity }; } #endregion #region 新增 /// /// Ghra_Grade -- 新增数据 /// /// /// [HttpPost] public async Task> Post([FromBody] InsertGhra_GradeInput insertModel) { var data = MessageModel.Success("获取成功", null); var id = await _ghra_GradeServices.Add(insertModel); data.success = id > 0; if (data.success) data.response = id.ObjToString(); return data; } #endregion #region 更新 /// /// Ghra_Grade -- 更新数据 /// /// /// /// [HttpPut("{Id}")] public async Task Put(long Id, [FromBody] EditGhra_GradeInput editModel) { var data = MessageModel.Success("更新成功"); data.success = await _ghra_GradeServices.Update(Id, editModel); if (!data.success) data.msg = "更新失败"; return data; } #endregion #region 删除 /// /// Ghra_Grade -- 删除数据 /// /// /// [HttpDelete("{Id}")] public async Task Delete(long Id) { var data = MessageModel.Success("删除成功"); var entity = await _ghra_GradeServices.QueryById(Id); if (entity == null) return MessageModel.Fail("删除失败"); entity.IsEnable = 0; data.success = await _ghra_GradeServices.Update(entity); if (!data.success) data.msg = "删除失败"; return data; } #endregion #endregion } }