namespace Tiobon.Core.Services; /// /// 招聘模板 (服务) /// public class Ghrh_TemplateServices : BaseServices, IGhrh_TemplateServices { private readonly IBaseRepository _dal; public Ghrh_TemplateServices(ICaching caching, IBaseRepository dal) { this._dal = dal; base.BaseDal = dal; base._caching = caching; } #region 是否开启 public async Task SwitchPublish(long id, int? isPublish) { if (isPublish == 0) return ServiceResult.OprateFailed("当前已开启状态 不可以取消!"); await Db.Updateable() .SetColumns(it => new Ghrh_Template() { IsPublish = 0, UpdateBy = App.User.ID, UpdateTime = DateTime.Now }) .Where(it => it.IsPublish == 1) .ExecuteCommandAsync(); await Db.Updateable() .SetColumns(it => new Ghrh_Template() { IsPublish = isPublish, UpdateBy = App.User.ID, UpdateTime = DateTime.Now }) .Where(it => it.Id == id) .ExecuteCommandAsync(); return ServiceResult.OprateSuccess(); } #endregion #region 获取Offer模板字段 public async Task>> QueryOfferTags() { var list = new List() { new CustomFieldView { GroupName = "中文", Fields = StringHelper.GetFieldDesc().Select(o => new ModelTagView2Item { Name=o.Key,Code=o.Key}).ToList() }, new CustomFieldView { GroupName = "英文", Fields = StringHelper.GetFieldDesc().Select(o => new ModelTagView2Item { Name=o.Value+"_EN",Code=o.Value+"_EN"}).ToList() }, }; return await Task.FromResult(ServiceResult>.OprateSuccess("查询成功!", list)); } #endregion #region 预览Offer简历 public async Task> Preview(long resumeId) { var resume = await Db.Queryable().Where(x => x.Id == resumeId).SingleAsync(); var result = string.Empty; var template = await base.QuerySingle(x => x.IsPublish == 1); if (template != null) { result = template.TemplateContent; if (result.IsNullOrEmpty()) return await Task.FromResult(ServiceResult.OprateSuccess("查询成功!", result)); result = result.Replace("[姓名]", resume.StaffName); result = result.Replace("[电话]", resume.Mobile); result = result.Replace("[邮箱]", resume.Email); result = result.Replace("[身份证号码]", resume.IdCardNo); result = result.Replace("[StaffName_EN]", resume.StaffEname); result = result.Replace("[Mobile_EN]", resume.Mobile); result = result.Replace("[Email_EN]", resume.Email); result = result.Replace("[IdCardNo_EN]", resume.IdCardNo); var offerApplyOrder = await Db.Queryable().Where(x => x.ResumeId == resumeId).OrderByDescending(x => x.ApplyTime).SingleAsync(); if (offerApplyOrder != null) { #region 岗位 if (offerApplyOrder.TitleId.IsNotEmptyOrNull()) { var title = await Db.Queryable().Where(x => x.TitleID == offerApplyOrder.TitleId).SingleAsync(); if (title.MKey.IsNotEmptyOrNull()) { var lang = await Db.Queryable().Where(x => x.LangKey == title.MKey).SingleAsync(); if (lang != null) { result = result.Replace("[TitleName_EN]", lang.Value03); result = result.Replace("[岗位]", lang.LangValue); } } } #endregion #region 汇报对象 if (offerApplyOrder.ReportId.IsNotEmptyOrNull()) { var staff = await Db.Queryable().Where(x => x.StaffID == offerApplyOrder.ReportId).SingleAsync(); if (staff != null) { result = result.Replace("[ReportName_EN]", staff.StaffEname ?? staff.StaffName); result = result.Replace("[汇报对象]", staff.StaffName); } } #endregion #region 薪资 if (offerApplyOrder.ProbationSalary.IsNotEmptyOrNull()) { result = result.Replace("[Salary_EN]", offerApplyOrder.ProbationSalary.ObjToString()); result = result.Replace("[薪资]", offerApplyOrder.ProbationSalary.ObjToString()); } #endregion #region 入职日期 if (offerApplyOrder.InDate.IsNotEmptyOrNull()) { result = result.Replace("[InDate_EN]", DateTimeHelper.ConvertToDayString(offerApplyOrder.InDate)); result = result.Replace("[入职日期]", $" {offerApplyOrder.InDate.Value.Year}年 {offerApplyOrder.InDate.Value.Month} 月 {offerApplyOrder.InDate.Value.Day} 日"); } #endregion } } return await Task.FromResult(ServiceResult.OprateSuccess("查询成功!", result)); } #endregion }