using System.Dynamic;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using PadApplication.Entites.DbModels;
using PadApplication.Services;
using PadApplication.util;
namespace PadApplication.Controllers;
[ApiController]
[Route("api/[controller]")]
public class DevMachineController : ControllerBase
{
private readonly DevMachineManager m = new();
public class Root
{
public string version { get; set; }
public string apkUrl { get; set; }
}
///
/// 获取App最新版本信息
///
///
///
[HttpPost("getAppUpgradeInfo")]
public async Task getAppUpgradeInfo()
{
try
{
HttpClient client = new();
var requestUrl = $"http://192.168.0.94:9898/UpgradeInformation.json";
var response = await client.GetAsync(requestUrl);
response.EnsureSuccessStatusCode(); // 检查HTTP状态码
var responseContent = await response.Content.ReadAsStringAsync();
var a= JsonConvert.DeserializeObject(responseContent);
return new ResponseResult
{
status = 0,
message = "OK",
data = a
};
}
catch (Exception ex)
{
return new ResponseResult
{
status = 1,
message = "NG",
data = ex.Message
};
}
}
//UpdateDevMachine
///
/// 获取所有
///
///
[HttpPost("UpdateDevMachine")]
public ResponseResult UpdateDevMachine([FromBody] DevMacBycl data)
{
try
{
dynamic resultInfos = new ExpandoObject();
resultInfos.tbBillList = m.UpdateDevMachine(data);
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
//GetDevMachineByPdaMac
[HttpPost("GetDevMachineByPdaMac")]
public ResponseResult GetDevMachineByPdaMac([FromBody] DevMacBycl data)
{
try
{
dynamic resultInfos = new ExpandoObject();
resultInfos.tbBillList = m.GetDevMachineByPdaMac(data.PdaMac);
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 获取所有
///
///
[HttpPost("GetList")]
public ResponseResult GetList()
{
try
{
dynamic resultInfos = new ExpandoObject();
resultInfos.tbBillList = m.GetList();
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 根据主键获取
///
///
[HttpPost("GetById")]
public ResponseResult GetById(int id)
{
try
{
dynamic resultInfos = new ExpandoObject();
resultInfos.tbBillList = m.GetById(id);
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 根据主键删除
///
///
[HttpPost("DeleteByIds")]
public ResponseResult DeleteByIds([FromBody] object[] ids)
{
try
{
dynamic resultInfos = new ExpandoObject();
resultInfos.tbBillList = m.DeleteByIds(ids);
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 添加
///
///
[HttpPost("Insert")]
public ResponseResult Add([FromBody] DevMacBycl data)
{
try
{
dynamic resultInfos = new ExpandoObject();
resultInfos.tbBillList = m.Insert(data);
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 添加返回自增
///
///
[HttpPost("InsertReturnIdentity")]
public ResponseResult InsertReturnIdentity([FromBody] DevMacBycl data)
{
try
{
dynamic resultInfos = new ExpandoObject();
resultInfos.tbBillList = m.InsertReturnIdentity(data);
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 修改
///
///
[HttpPost("Update")]
public ResponseResult Update([FromBody] DevMacBycl data)
{
try
{
dynamic resultInfos = new ExpandoObject();
resultInfos.tbBillList = m.Update(data);
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
}