using CoreCms.Net.IRepository;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.Entities.baifenbingfa.jon;
using CoreCms.Net.Model.FromBody;
using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.Services;
using CoreCms.Net.Utility.Helper;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using System;
using System.Threading.Tasks;
namespace CoreCms.Net.Web.WebApi.Controllers.baifenbingfa
{
///
/// 招聘相关
///
[Route("api/[controller]")]
[ApiController]
public class JobController : ControllerBase
{
IJob_jobSetingRepository _job_JobSetingRepository;
IJob_jobSetingServices _job_JobSetingServices;
IJob_ApplicantProfileServices _job_ApplicantProfileServices;
public JobController(IJob_jobSetingRepository job_JobSeting ,IJob_jobSetingServices job_JobSetingServices,IJob_ApplicantProfileServices job_ApplicantProfileServices)
{
_job_JobSetingRepository=job_JobSeting;
_job_JobSetingServices=job_JobSetingServices;
_job_ApplicantProfileServices=job_ApplicantProfileServices;
}
///
/// 获取招聘信息
///
///
[HttpPost("jobSet")]
[SwaggerResponse(200, "返回数据", typeof(WebApiCallBack))]
[SwaggerResponse(201, "Data类型", typeof(Job_jobSeting))]
public async Task GetjobSeting()
{
var jm = new WebApiCallBack();
jm.data = await _job_JobSetingRepository.QueryAsyncALL();
jm.status = true;
return jm;
}
///
/// 创建简历
///
///
///
[HttpPost("CreatCV")]
public async Task CreatCVFile([FromBody] Job_ApplicantProfile Param)
{
var jm = new WebApiCallBack();
var CreatTime=DateTime.Now;
Param.createTime = CreatTime;
Param.createBy = "PC";
if (Param.employmentRecords!=null)
foreach(var record in Param.employmentRecords)
{
if(record.StartEndDateTimes==null||record.StartEndDateTimes.Count<2)
{
jm.status = false;
jm.msg = "工作经历必须填起止时间";
jm.code = 1;
return jm;
}
record.startDate= record.StartEndDateTimes[0];
record.endDate = record.StartEndDateTimes[1];
}
jm.data = await _job_ApplicantProfileServices.InsertAsync(Param);
jm.status = true;
return jm;
}
}
}