91 lines
3.1 KiB
C#
91 lines
3.1 KiB
C#
namespace SimpleAdmin.Web.Core;
|
|
|
|
/// <summary>
|
|
/// 提供员工端入职任务访问相关 HTTP 接口。
|
|
/// </summary>
|
|
[ApiDescriptionSettings("Application", Tag = "员工入职填写")]
|
|
[Route("open/onboarding")]
|
|
[AllowAnonymous]
|
|
public class OnboardingPublicTaskController
|
|
{
|
|
private readonly IOnboardingPublicTaskService _service;
|
|
private readonly IFileService _fileService;
|
|
|
|
public OnboardingPublicTaskController(IOnboardingPublicTaskService service, IFileService fileService)
|
|
{
|
|
_service = service;
|
|
_fileService = fileService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 通过 Token 获取员工端入职任务详情。
|
|
/// </summary>
|
|
[HttpPost("detail")]
|
|
public async Task<dynamic> Detail([FromBody] OnboardingTaskPublicAccessInput input)
|
|
{
|
|
return await _service.Detail(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存候选人固定基础信息。
|
|
/// </summary>
|
|
[HttpPost("save-employee-info")]
|
|
public async Task SaveEmployeeInfo([FromBody] OnboardingTaskPublicSaveInput input)
|
|
{
|
|
await _service.SaveEmployeeInfo(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 校验合同变量并提前生成候选人的合同文件。
|
|
/// </summary>
|
|
[HttpPost("prepare-contract")]
|
|
public async Task<OnboardingPublicContractPrepareOutput> PrepareContract(
|
|
[FromBody] OnboardingPublicContractSourceInput input)
|
|
{
|
|
return await _service.PrepareContract(input);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 下载已经准备完成并替换变量的合同文件。
|
|
/// </summary>
|
|
[HttpGet("contract-source")]
|
|
[ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)]
|
|
public async Task<FileStreamResult> ContractSource([FromQuery] OnboardingPublicContractSourceInput input)
|
|
{
|
|
var fileId = await _service.GetContractSourceFileId(input);
|
|
return await _fileService.Download(new BaseIdInput { Id = fileId })
|
|
?? throw Oops.Bah("合同文件不存在,请重新准备合同");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 通过任务 Token 内联输出候选人已上传的图片材料,供手机端预览。
|
|
/// </summary>
|
|
[HttpGet("material-source")]
|
|
public async Task<FileStreamResult> MaterialSource(
|
|
[FromQuery] OnboardingPublicMaterialSourceInput input)
|
|
{
|
|
var material = await _service.GetMaterialSource(input);
|
|
var source = await _fileService.Download(new BaseIdInput { Id = material.FileId })
|
|
?? throw Oops.Bah("上传文件不存在");
|
|
return new FileStreamResult(
|
|
source.FileStream,
|
|
GetImageContentType(material.FileSuffix));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据图片扩展名设置浏览器可内联展示的响应类型。
|
|
/// </summary>
|
|
private static string GetImageContentType(string suffix)
|
|
{
|
|
return suffix?.TrimStart('.').ToLowerInvariant() switch
|
|
{
|
|
"png" => "image/png",
|
|
"jpg" or "jpeg" => "image/jpeg",
|
|
"gif" => "image/gif",
|
|
"bmp" => "image/bmp",
|
|
"webp" => "image/webp",
|
|
_ => "application/octet-stream"
|
|
};
|
|
}
|
|
}
|