using System.Dynamic;
|
using Microsoft.AspNetCore.Mvc;
|
using NewPdaSqlServer.entity;
|
using NewPdaSqlServer.service.@base;
|
using NewPdaSqlServer.util;
|
using Newtonsoft.Json.Linq;
|
|
namespace NewPdaSqlServer.Controllers.@base;
|
|
[ApiController]
|
[Route("api/[controller]")]
|
public class MessageCenterController : ControllerBase
|
{
|
private readonly GetErpParametersServer ErpParametersServer = new();
|
private readonly MessageCenterManager m = new();
|
|
|
//ResetUpdate
|
[HttpPost("ResetUpdate")]
|
public ResponseResult ResetUpdate([FromBody] MessageCenter data)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = m.ResetUpdate(data);
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
//getBadge
|
[HttpPost("getBadge")]
|
public ResponseResult getBadge()
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = m.getBadge();
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
//Resend
|
[HttpPost("Resend")]
|
public ResponseResult Resend(MessageCenter data)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = ErpParametersServer.Resend(data);
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
//saveError
|
[HttpPost("SetError")]
|
public ResponseResult SetError([FromBody] MessageCenter data)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = m.SetError(data);
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("GetByPid")]
|
public ResponseResult ResetUpdate([FromBody] JObject data)
|
{
|
var pid = data["pid"].ToString();
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
|
var parsedGuid = Guid.Empty;
|
if (string.IsNullOrEmpty(pid))
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
|
var isValid = Guid.TryParse(pid, out parsedGuid);
|
if (!isValid)
|
throw new ApplicationException("GUID转换错误");
|
|
var messageCenter = m.GetById(pid);
|
var messageCenters = m.GetList(it => it.Pid == parsedGuid);
|
messageCenters.Add(messageCenter);
|
resultInfos.tbBillList = messageCenters;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
[HttpPost("getPushFailed")]
|
public ResponseResult getPushFailed(MessageCenter query)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var (item, totalCount) = m.GetPushFailedPage(query);
|
resultInfos.tbBillList = item;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos,
|
TotalCount = totalCount
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
//IsShow
|
[HttpPost("IsShow")]
|
public ResponseResult IsShow(MessageCenter query)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = m.IsShow(query);
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
//UpdateRead
|
[HttpPost("UpdateRead")]
|
public ResponseResult UpdateRead(MessageCenter query)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = m.UpdateRead(query);
|
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([FromBody] JObject data)
|
{
|
var id = Convert.ToDecimal(data["id"].ToString());
|
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] MessageCenter data)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = m.save(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] MessageCenter 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] MessageCenter 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);
|
}
|
}
|
}
|