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#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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