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 PERSONSELLController : BaseController
{
#region
/// <summary>
/// 获取列表
/// </summary>
/// <param name="searchModel">查询条件对象</param>
/// <returns></returns>
[Route("Analysis/GetPERSONSELLList")]
[AcceptVerbs("POST")]
[ResponseType(typeof(Models.JsonMsg<Models.JsonList<ESCM.PERSONSELLModel>>))]
public IHttpActionResult GetPERSONSELLList(ESCM.SearchModel<ESCM.PERSONSELLModel> searchModel)
{
string Parameter = "入参信息:查询方式【" + searchModel.QueryType + "】,查询页码【" + searchModel.PageIndex + "】," +
"每页显示数量【" + searchModel.PageSize + "】,排序条件【" + searchModel.SortStr + "】";
try
{
int TotalCount = 0;
//获取列表
List<ESCM.PERSONSELLModel> PERSONSELLList = ESCG.PERSONSELLHelper.GetPERSONSELLList(
transaction, ref TotalCount, searchModel);
//转化json形式
Models.JsonList<ESCM.PERSONSELLModel> jsonList = Models.JsonList<ESCM.PERSONSELLModel>.Success(
PERSONSELLList, TotalCount, searchModel.PageIndex, searchModel.PageSize);
return Ok(Models.JsonMsg<Models.JsonList<ESCM.PERSONSELLModel>>.Success(jsonList, 100, "查询成功"));
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_GetPERSONSELLList");
return Ok(Method.Common.ReturnJson(999, "查询失败" + ex.Message));
}
}
#endregion
#region
/// <summary>
/// 获取明细
/// </summary>
/// <param name="PERSONSELLId">内码</param>
/// <returns></returns>
[Route("Analysis/GetPERSONSELLDetail")]
[AcceptVerbs("GET")]
[ResponseType(typeof(Models.JsonMsg<ESCM.PERSONSELLModel>))]
public IHttpActionResult GetPERSONSELLDetail(int PERSONSELLId)
{
string Parameter = "入参信息:内码【" + PERSONSELLId + "】";
try
{
//获取明细
ESCM.PERSONSELLModel personsellModel = ESCG.PERSONSELLHelper.GetPERSONSELLDetail(transaction, PERSONSELLId);
return Ok(Models.JsonMsg<ESCM.PERSONSELLModel>.Success(personsellModel, 100, "查询成功"));
}
catch (Exception ex)
{
//事务回滚
transaction.Rollback();
LogUtil.WriteLog(null, "查询失败!失败原因:" + ex.Message + "\r\n" + Parameter,
DateTime.Now.ToString("yyyyMMdd") + "_GetPERSONSELLDetail");
return Ok(Method.Common.ReturnJson(999, "查询失败" + ex.Message));
}
}
#endregion
#region
/// <summary>
/// 同步
/// </summary>
/// <param name="personsellModel"></param>
/// <returns></returns>
[Route("Analysis/SynchroPERSONSELL")]
[AcceptVerbs("POST")]
[ResponseType(typeof(Models.JsonMsg<string>))]
public IHttpActionResult SynchroPERSONSELL(ESCM.PERSONSELLModel personsellModel)
{
try
{
//新增
bool SynchroFlag = ESCG.PERSONSELLHelper.SynchroPERSONSELL(transaction, personsellModel);
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") + "_SynchroPERSONSELL");
return Ok(Method.Common.ReturnJson(999, "同步失败" + ex.Message));
}
}
#endregion
#region
/// <summary>
/// 删除
/// </summary>
/// <param name="PERSONSELLId">内码</param>
/// <returns></returns>
[Route("Analysis/DeletePERSONSELL")]
[AcceptVerbs("GET", "POST")]
[ResponseType(typeof(Models.JsonMsg<string>))]
public IHttpActionResult DeletePERSONSELL(int PERSONSELLId)
{
string Parameter = "入参信息:内码【" + PERSONSELLId + "】";
try
{
//删除
bool DeleteFlag = ESCG.PERSONSELLHelper.DeletePERSONSELL(transaction, PERSONSELLId);
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") + "_DeletePERSONSELL");
return Ok(Method.Common.ReturnJson(999, "删除失败" + ex.Message));
}
}
#endregion
}
}