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.

149 lines
4.3 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.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(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> AddOrUpdateAsync([FromBody] AFRMasterDto input)
{
await _afrService.SaveInfo(input);
return SuccessResp();
}
#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">主键集合</param>
/// <param name="sendType">1:发送 2原始重发 3修改发送 4删除发送</param>
/// <returns></returns>
[HttpGet("Send")]
public async Task<Response> Send(string ids, int sendType)
{
string message = await _afrService.Send(ids, 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="id">主键</param>
/// <returns>历史记录列表</returns>
[HttpGet("GetHistory")]
public async Task<Response<List<AFRMasterHistory>>> GetHistory(string id)
{
var data = await _afrService.GetHistory(id);
return SuccessResp(data);
}
/// <summary>
/// 获取服务器当前时间
/// </summary>
/// <returns></returns>
[AllowAnonymous]
[HttpGet("[action]")]
public Response GetTime()
{
return SuccessResp(DateTime.Now.ToString());
}
}
}