using System.Dynamic; using MES.Service.service; using MES.Service.util; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; namespace MESApplication.Controllers.Base; [Route("api/[controller]")] [ApiController] public class DemoController : ControllerBase { [HttpPost("sum")] public ResponseResult sum([FromBody] JObject data) { try { var x = Convert.ToInt32(data["x"].ToString()); var y = Convert.ToInt32(data["y"].ToString()); ; var sum = x + y; return new ResponseResult { status = 0, message = "OK", data = sum }; } catch (Exception ex) { return ResponseResult.ResponseError(ex); } } [HttpPost("getData")] public ResponseResult getData([FromBody] JObject data) { var name = data["deptNo"].ToString(); try { dynamic resultInfos = new ExpandoObject(); var tbBillList = new DemoService().getAll(name); resultInfos.tbBillList = tbBillList; return new ResponseResult { status = 0, message = "OK", data = resultInfos }; } catch (Exception ex) { return ResponseResult.ResponseError(ex); } } [HttpPost("getItemById")] public ResponseResult getItemById([FromBody] JObject data) { var id = data["id"].ToString(); try { dynamic resultInfos = new ExpandoObject(); var tbBillList = new DemoService().getItemById(id); resultInfos.tbBillList = tbBillList; return new ResponseResult { status = 0, message = "OK", data = resultInfos }; } catch (Exception ex) { return ResponseResult.ResponseError(ex); } } }