You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
4.7 KiB
C#

11 months ago
using Common.DJYModel;
using Common.Utilities;
11 months ago
using djy.IService.Afr;
using djy.Model.Afr;
using djy.Model.AFRDto;
11 months ago
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
11 months ago
using System;
11 months ago
using System.Collections.Generic;
11 months ago
using System.ComponentModel.DataAnnotations;
11 months ago
using System.Threading.Tasks;
namespace djy_AfrApi.Controllers
{
11 months ago
/// <summary>
/// AFR对接接口
/// </summary>
11 months ago
[Route("api/[controller]")]
[ApiController]
[Authorize]
11 months ago
public class AfrController : ApiBase
{
private readonly ILogger logger;
11 months ago
private readonly IAfrService _afrService;
11 months ago
11 months ago
//private readonly ILogger bigLogger;
public AfrController(ILogger<AfrController> logger,
IAfrService afrService)
11 months ago
{
this.logger = logger;
11 months ago
this._afrService = afrService;
11 months ago
// 获取ILogger对象
11 months ago
//ILoggerFactory loggerFactory,
//bigLogger = loggerFactory.CreateLogger("BigDataLogger"); // 通过指定名称获取ILogger对象
11 months ago
}
#region 查询接口
11 months ago
/// <summary>
/// 分页查询草稿箱或已发送列表的数据
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
11 months ago
[HttpGet("PageData")]
11 months ago
public async Task<ResponsePage<AFRMaster>> PageData([FromQuery] AFRMasterInputDto input)
11 months ago
{
11 months ago
UserAuthorityDto aut = GetUserAuthorityToFormDto("modIsfList");
11 months ago
11 months ago
input.CompanyId = aut.CompayId?.ToString();
input.UserId = aut.UserId?.ToString();
11 months ago
11 months ago
var pageData = await _afrService.Load(input);
return SuccessPage(pageData);
11 months ago
}
11 months ago
/// <summary>
/// 获取详情
/// </summary>
/// <param name="gid"></param>
/// <returns></returns>
11 months ago
[HttpGet("Detail")]
public async Task<Response<AFRMaster>> Detail(string gid)
11 months ago
{
var model = await _afrService.Get(gid);
return SuccessResp(model);
}
11 months ago
#endregion
#region 新增/编辑
11 months ago
/// <summary>
/// 新增或修改
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
11 months ago
[HttpPost("AddOrUpdate")]
11 months ago
public async Task<Response<AFRMaster>> AddOrUpdateAsync([FromBody] AFRMaster input)
11 months ago
{
11 months ago
var result = await _afrService.SaveInfo(input);
return SuccessResp(result);
11 months ago
}
11 months ago
#endregion
#region 删除
11 months ago
/// <summary>
/// 删除
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
11 months ago
[HttpPost("Del")]
public async Task<Response> Delete(string ids)
{
await _afrService.Delete(ids);
return SuccessResp();
}
11 months ago
#endregion
#region 第三方接口
11 months ago
/// <summary>
/// 发送接口
/// </summary>
11 months ago
/// <param name="ids">主单主键的集合,使用,连接当sendType==1时必填</param>
/// <param name="hids">分单主键集合,使用,连接当sendType==2、3、4时必填</param>
11 months ago
/// <param name="sendType">1:发送 2原始重发 3修改发送 4删除发送</param>
11 months ago
[HttpGet("Send")]
11 months ago
public async Task<Response> Send(string ids, string hids, [Required] int sendType)
11 months ago
{
11 months ago
string message = await _afrService.Send(ids, hids, sendType);
11 months ago
return SuccessResp(message);
11 months ago
}
11 months ago
11 months ago
/// <summary>
/// 接收回执
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
11 months ago
[AllowAnonymous]
[HttpPost("Receipt")]
public async Task<Response> SaveReceiptAsync(AFRReceiptDto input)
{
await _afrService.SaveReceipt(input);
return SuccessResp("接收成功");
}
11 months ago
#endregion
11 months ago
/// <summary>
/// 获取历史记录
/// </summary>
11 months ago
/// <param name="mid">主单主键</param>
/// <param name="hid">分单主键</param>
11 months ago
/// <returns>历史记录列表</returns>
[HttpGet("GetHistory")]
11 months ago
public async Task<Response<List<AFRMasterHistory>>> GetHistory([Required] string mid, string hid)
11 months ago
{
11 months ago
var data = await _afrService.GetHistory(mid, hid);
11 months ago
return SuccessResp(data);
}
11 months ago
/// <summary>
/// 获取服务器当前时间
/// </summary>
/// <returns></returns>
11 months ago
[AllowAnonymous]
[HttpGet("[action]")]
public Response GetTime()
{
return SuccessResp(DateTime.Now.ToString());
}
11 months ago
}
}