2025-03-27 15:05:14 +08:00

157 lines
5.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Web.Http;
using System.Web.Http.Description;
using ESCG = GSYWApi.GeneralMethod;
using ESCM = GSYWApi.Model;
using HZQR.Common;
namespace GSYWApi.Controllers
{
/// <summary>
/// 相关接口
/// </summary>
public class ENDACCOUNTController : BaseController
{
#region
/// <summary>
/// 获取列表
/// </summary>
/// <param name="searchModel">查询条件对象</param>
/// <returns></returns>
[Route("Analysis/GetENDACCOUNTList")]
[AcceptVerbs("POST")]
[ResponseType(typeof(Models.JsonMsg<Models.JsonList<ESCM.ENDACCOUNTModel>>))]
public IHttpActionResult GetENDACCOUNTList(ESCM.SearchModel<ESCM.ENDACCOUNTModel> searchModel)
{
string Parameter = "入参信息:查询方式【" + searchModel.QueryType + "】,查询页码【" + searchModel.PageIndex + "】," +
"每页显示数量【" + searchModel.PageSize + "】,排序条件【" + searchModel.SortStr + "】";
try
{
int TotalCount = 0;
//获取列表
List<ESCM.ENDACCOUNTModel> ENDACCOUNTList = ESCG.ENDACCOUNTHelper.GetENDACCOUNTList(
transaction, ref TotalCount, searchModel);
//转化json形式
Models.JsonList<ESCM.ENDACCOUNTModel> jsonList = Models.JsonList<ESCM.ENDACCOUNTModel>.Success(
ENDACCOUNTList, TotalCount, searchModel.PageIndex, searchModel.PageSize);
return Ok(Models.JsonMsg<Models.JsonList<ESCM.ENDACCOUNTModel>>.Success(jsonList, 100, "查询成功"));
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_GetENDACCOUNTList");
return Ok(Method.Common.ReturnJson(999, "查询失败" + ex.Message));
}
}
#endregion
#region
/// <summary>
/// 获取明细
/// </summary>
/// <param name="ENDACCOUNTId">内码</param>
/// <returns></returns>
[Route("Analysis/GetENDACCOUNTDetail")]
[AcceptVerbs("GET")]
[ResponseType(typeof(Models.JsonMsg<ESCM.ENDACCOUNTModel>))]
public IHttpActionResult GetENDACCOUNTDetail(int ENDACCOUNTId)
{
string Parameter = "入参信息:内码【" + ENDACCOUNTId + "】";
try
{
//获取明细
ESCM.ENDACCOUNTModel endaccountModel = ESCG.ENDACCOUNTHelper.GetENDACCOUNTDetail(transaction, ENDACCOUNTId);
return Ok(Models.JsonMsg<ESCM.ENDACCOUNTModel>.Success(endaccountModel, 100, "查询成功"));
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_GetENDACCOUNTDetail");
return Ok(Method.Common.ReturnJson(999, "查询失败" + ex.Message));
}
}
#endregion
#region
/// <summary>
/// 同步
/// </summary>
/// <param name="endaccountModel"></param>
/// <returns></returns>
[Route("Analysis/SynchroENDACCOUNT")]
[AcceptVerbs("POST")]
[ResponseType(typeof(Models.JsonMsg<string>))]
public IHttpActionResult SynchroENDACCOUNT(ESCM.ENDACCOUNTModel endaccountModel)
{
try
{
//新增
bool SynchroFlag = ESCG.ENDACCOUNTHelper.SynchroENDACCOUNT(transaction, endaccountModel);
if (SynchroFlag)
{
return Ok(Method.Common.ReturnJson(100, "同步成功"));
}
else
{
return Ok(Method.Common.ReturnJson(200, "更新失败,数据不存在!"));
}
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
LogUtil.WriteLog(null, "同步失败!失败原因:" + ex.Message,
DateTime.Now.ToString("yyyyMMdd") + "_SynchroENDACCOUNT");
return Ok(Method.Common.ReturnJson(999, "同步失败" + ex.Message));
}
}
#endregion
#region
/// <summary>
/// 删除
/// </summary>
/// <param name="ENDACCOUNTId">内码</param>
/// <returns></returns>
[Route("Analysis/DeleteENDACCOUNT")]
[AcceptVerbs("GET", "POST")]
[ResponseType(typeof(Models.JsonMsg<string>))]
public IHttpActionResult DeleteENDACCOUNT(int ENDACCOUNTId)
{
string Parameter = "入参信息:内码【" + ENDACCOUNTId + "】";
try
{
//删除
bool DeleteFlag = ESCG.ENDACCOUNTHelper.DeleteENDACCOUNT(transaction, ENDACCOUNTId);
if (DeleteFlag)
{
return Ok(Method.Common.ReturnJson(100, "删除成功"));
}
else
{
return Ok(Method.Common.ReturnJson(200, "删除失败,数据不存在!"));
}
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
LogUtil.WriteLog(null, "删除失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_DeleteENDACCOUNT");
return Ok(Method.Common.ReturnJson(999, "删除失败" + ex.Message));
}
}
#endregion
}
}