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; }
|
}
|
|
/// <summary>
|
/// 获取App最新版本信息
|
/// </summary>
|
/// <param name="data"></param>
|
/// <returns></returns>
|
[HttpPost("getAppUpgradeInfo")]
|
public async Task<ResponseResult> 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<Root>(responseContent);
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = a
|
};
|
|
}
|
catch (Exception ex)
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = "NG",
|
data = ex.Message
|
};
|
}
|
}
|
|
//UpdateDevMachine
|
/// <summary>
|
/// 获取所有
|
/// </summary>
|
/// <returns></returns>
|
[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);
|
}
|
}
|
|
/// <summary>
|
/// 获取所有
|
/// </summary>
|
/// <returns></returns>
|
[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);
|
}
|
}
|
|
|
/// <summary>
|
/// 根据主键获取
|
/// </summary>
|
/// <returns></returns>
|
[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);
|
}
|
}
|
|
/// <summary>
|
/// 根据主键删除
|
/// </summary>
|
/// <returns></returns>
|
[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);
|
}
|
}
|
|
/// <summary>
|
/// 添加
|
/// </summary>
|
/// <returns></returns>
|
[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);
|
}
|
}
|
|
/// <summary>
|
/// 添加返回自增
|
/// </summary>
|
/// <returns></returns>
|
[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);
|
}
|
}
|
|
/// <summary>
|
/// 修改
|
/// </summary>
|
/// <returns></returns>
|
[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);
|
}
|
}
|
}
|