namespace Tiobon.Core.Api.Controllers;

/// <summary>
/// 招聘模板(Controller)
/// </summary>
[Route("api/[controller]")]
[ApiController, GlobalActionFilter]
[Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_Ghrh)]
public class Ghrh_TemplateController : BaseController<IGhrh_TemplateServices, Ghrh_Template, Ghrh_TemplateDto, InsertGhrh_TemplateInput, EditGhrh_TemplateInput>
{
    public Ghrh_TemplateController(IGhrh_TemplateServices service) : base(service)
    {
    }

    #region 是否开启
    /// <summary>
    /// 是否开启
    /// </summary> 
    /// <param name="id"></param>
    /// <param name="isPublish"></param>
    /// <returns></returns>
    [HttpPost("SwitchPublish/{id}/{isPublish}")]
    public async Task<ServiceResult> SwitchPublish(long id, int? isPublish) => await _service.SwitchPublish(id, isPublish);
    #endregion

    #region 查询Offer支持的字段
    /// <summary>
    /// Offer支持的字段
    /// </summary>
    /// <returns></returns>
    [HttpPost("QueryOfferTags")]
    public async Task<ServiceResult<List<CustomFieldView>>> QueryOfferTags() => await _service.QueryOfferTags();
    #endregion

    #region 预览
    /// <summary>
    /// 预览Offer
    /// </summary>
    /// <param name="resumeId">简历Id</param>
    /// <param name="templateId">模板ID</param>
    /// <param name="extFields">扩展字段</param>
    /// <returns></returns>
    [HttpPost("Preview/{resumeId}/{templateId}")]
    public async Task<ServiceResult<string>> Preview(long resumeId, long templateId, Dictionary<string, string> extFields) => await _service.Preview(resumeId, templateId, extFields);
    #endregion
}