|
|
|
|
using System.Text;
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
|
using DS.WMS.Core.Code.Dtos;
|
|
|
|
|
using DS.WMS.Core.Code.Interface;
|
|
|
|
|
using DS.WMS.Core.Info.Dtos;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using MiniExcelLibs;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.MainApi.Controllers;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 用户邮箱设置 模块
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class UserEmailController : ApiController
|
|
|
|
|
{
|
|
|
|
|
private readonly IUserEmailService _invokeService;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构造函数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="invokeService"></param>
|
|
|
|
|
public UserEmailController(IUserEmailService invokeService)
|
|
|
|
|
{
|
|
|
|
|
_invokeService = invokeService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 导入
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="file"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost, Route("Import")]
|
|
|
|
|
public async Task<DataResult> ImportAsync(IFormFile file)
|
|
|
|
|
{
|
|
|
|
|
if (file == null)
|
|
|
|
|
return DataResult.Failed("请求未包含文件流");
|
|
|
|
|
|
|
|
|
|
var stream = file.OpenReadStream();
|
|
|
|
|
var rows = (await MiniExcel.QueryAsync(stream, excelType: ExcelType.XLSX, startCell: "A2")).ToList();
|
|
|
|
|
|
|
|
|
|
List<CodeUserEmailReq> list = [];
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
foreach (IDictionary<string, object> item in rows)
|
|
|
|
|
{
|
|
|
|
|
var model = new CodeUserEmailReq
|
|
|
|
|
{
|
|
|
|
|
ShowName = item["B"]?.ToString(),
|
|
|
|
|
MailAccount = item["D"]?.ToString(),
|
|
|
|
|
ReceiveServer = "imap.exmail.qq.com",
|
|
|
|
|
ReceivePort = 993,
|
|
|
|
|
ReceiveSSL = true,
|
|
|
|
|
SmtpServer = "smtp.exmail.qq.com",
|
|
|
|
|
SmtpPort = 465,
|
|
|
|
|
SmtpSSL = true,
|
|
|
|
|
IsCompany = false
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
list.Add(model);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed("读取文件失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return await _invokeService.ImportAsync(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="request"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[Route("GetUserEmailList")]
|
|
|
|
|
public DataResult<List<CodeUserEmailRes>> GetUserEmailList([FromBody] PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
var res = _invokeService.GetListByPage(request);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 编辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[Route("EditUserEmail")]
|
|
|
|
|
public DataResult EditUserEmail([FromBody] CodeUserEmailReq req)
|
|
|
|
|
{
|
|
|
|
|
var res = _invokeService.EditUserEmail(req);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 详情
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">Id</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("GetUserEmailInfo")]
|
|
|
|
|
public DataResult<CodeUserEmailRes> GetUserEmailInfo([FromQuery] string id)
|
|
|
|
|
{
|
|
|
|
|
var res = _invokeService.GetUserEmailInfo(id);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量删除
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req">req</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
[Route("BatchDelUserEmail")]
|
|
|
|
|
public DataResult BatchDelUserEmail([FromBody] IdModel req)
|
|
|
|
|
{
|
|
|
|
|
var res = _invokeService.BatchDelUserEmail(req);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取用户邮箱配置
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpGet]
|
|
|
|
|
[Route("GetUserEmailSetInfo")]
|
|
|
|
|
public async Task<DataResult<CodeUserEmailRes>> GetUserEmailSetInfo()
|
|
|
|
|
{
|
|
|
|
|
var res = await _invokeService.GetUserEmailSetInfo();
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
}
|