using JiepeiWMS.IServices; using JiepeiWMS.Model; using JiepeiWMS.Model.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using SqlSugar; using System; using System.Linq.Expressions; using System.Threading.Tasks; namespace JiepeiWMS.Api.Controllers { [Route("api/[controller]/[action]")] [ApiController] [Authorize(Permissions.Name)] public class WMQuoteInfoLogController : ControllerBase { /// /// 服务器接口,因为是模板生成,所以首字母是大写的,自己可以重构下 /// private readonly IWMQuoteInfoLogServices _wMQuoteInfoLogServices; public WMQuoteInfoLogController(IWMQuoteInfoLogServices WMQuoteInfoLogServices) { _wMQuoteInfoLogServices = WMQuoteInfoLogServices; } [HttpGet] public async Task>> Get(int OrderId = 0, int PageIndex = 1, int PageSize = 10) { Expression> whereExpression = (pg, u) => pg.OrderId == OrderId; var page = await _wMQuoteInfoLogServices.QueryPage( (pg, u) => new object[] { JoinType.Left, pg.AdminId == u.uID }, (pg, u) => new WMQuoteInfoLog { AdminId = pg.AdminId, Content = pg.Content, CreateTime = pg.CreateTime, Id = pg.Id, OrderId = pg.OrderId, AdminName = u.uRealName } , whereExpression, PageIndex, PageSize,"Id desc"); return new MessageModel>() { msg = "获取成功", success = true, response = page }; } [HttpGet("{id}")] public async Task> Get(int id = 0) { return new MessageModel() { msg = "获取成功", success = true, response = await _wMQuoteInfoLogServices.QueryById(id) }; } [HttpPost] public async Task> Post([FromBody] WMQuoteInfoLog request) { var data = new MessageModel(); var id = await _wMQuoteInfoLogServices.Add(request); data.success = id > 0; if (data.success) { data.response = id.ObjToString(); data.msg = "添加成功"; } return data; } [HttpPut] public async Task> Put([FromBody] WMQuoteInfoLog request) { var data = new MessageModel(); if (request.Id > 0) { data.success = await _wMQuoteInfoLogServices.Update(request); if (data.success) { data.msg = "更新成功"; data.response = request?.Id.ObjToString(); } } return data; } [HttpDelete("{id}")] public async Task> Delete(int id = 0) { var data = new MessageModel(); if (id > 0) { var detail = await _wMQuoteInfoLogServices.QueryById(id); //detail.IsDeleted = true; if (detail != null) { data.success = await _wMQuoteInfoLogServices.Update(detail); if (data.success) { data.msg = "删除成功"; data.response = detail?.Id.ObjToString(); } } } return data; } } }