/***********************************************************************
|
* Project: baifenBinfa
|
* ProjectName: 百分兵法管理系统
|
* Web: http://chuanyin.com
|
* Author:
|
* Email:
|
* CreateTime: 2024/5/15 14:19:19
|
* Description: 暂无
|
***********************************************************************/
|
|
using System;
|
using System.Collections.Generic;
|
using System.Linq.Expressions;
|
using System.Threading.Tasks;
|
using CoreCms.Net.Caching.Manual;
|
using CoreCms.Net.Configuration;
|
using CoreCms.Net.Model.Entities;
|
using CoreCms.Net.Model.ViewModels.Basics;
|
using CoreCms.Net.IRepository;
|
using CoreCms.Net.IRepository.UnitOfWork;
|
using CoreCms.Net.Model.ViewModels.UI;
|
using SqlSugar;
|
using CoreCms.Net.Model.Entities.baifenbingfa.jon;
|
using Org.BouncyCastle.Crypto;
|
|
namespace CoreCms.Net.Repository
|
{
|
/// <summary>
|
/// 个人简历 接口实现
|
/// </summary>
|
public class Job_ApplicantProfileRepository : BaseRepository<Job_ApplicantProfile>, IJob_ApplicantProfileRepository
|
{
|
private readonly IUnitOfWork _unitOfWork;
|
public Job_ApplicantProfileRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
{
|
_unitOfWork = unitOfWork;
|
}
|
|
#region 实现重写增删改查操作==========================================================
|
|
/// <summary>
|
/// 重写异步插入方法
|
/// </summary>
|
/// <param name="entity">实体数据</param>
|
/// <returns></returns>
|
public async Task<AdminUiCallBack> InsertAsync(Job_ApplicantProfile entity)
|
{
|
var jm = new AdminUiCallBack();
|
|
var bl = await DbClient.Insertable(entity).ExecuteReturnIdentityAsync() > 0;
|
jm.code = bl ? 0 : 1;
|
jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure;
|
|
return jm;
|
}
|
|
/// <summary>
|
/// 重写异步更新方法
|
/// </summary>
|
/// <param name="entity"></param>
|
/// <returns></returns>
|
public async Task<AdminUiCallBack> UpdateAsync(Job_ApplicantProfile entity)
|
{
|
var jm = new AdminUiCallBack();
|
|
var oldModel = await DbClient.Queryable<Job_ApplicantProfile>().In(entity.id).SingleAsync();
|
if (oldModel == null)
|
{
|
jm.msg = "不存在此信息";
|
return jm;
|
}
|
//事物处理过程开始
|
oldModel.id = entity.id;
|
oldModel.jobId = entity.jobId;
|
oldModel.minSalaryRequirement = entity.minSalaryRequirement;
|
oldModel.name = entity.name;
|
oldModel.gender = entity.gender;
|
oldModel.height = entity.height;
|
oldModel.weight = entity.weight;
|
oldModel.dateOfBirth = entity.dateOfBirth;
|
oldModel.graduatingSchool = entity.graduatingSchool;
|
oldModel.educationLevel = entity.educationLevel;
|
oldModel.major = entity.major;
|
oldModel.smokes = entity.smokes;
|
oldModel.drivingSkill = entity.drivingSkill;
|
oldModel.phoneNumber = entity.phoneNumber;
|
oldModel.whiteWineCapacity = entity.whiteWineCapacity;
|
oldModel.politicalAffiliation = entity.politicalAffiliation;
|
oldModel.maritalStatus = entity.maritalStatus;
|
oldModel.specialAbilities = entity.specialAbilities;
|
oldModel.email = entity.email;
|
oldModel.parentalStatus = entity.parentalStatus;
|
oldModel.residentialAddress = entity.residentialAddress;
|
oldModel.createTime = entity.createTime;
|
oldModel.upDataTime = entity.upDataTime;
|
oldModel.createBy = entity.createBy;
|
oldModel.upDataBy = entity.upDataBy;
|
oldModel.isdelete = entity.isdelete;
|
oldModel.AuditStatu = entity.AuditStatu;
|
|
//事物处理过程结束
|
var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
|
jm.code = bl ? 0 : 1;
|
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
|
return jm;
|
}
|
|
/// <summary>
|
/// 重写异步更新方法
|
/// </summary>
|
/// <param name="entity"></param>
|
/// <returns></returns>
|
public async Task<AdminUiCallBack> UpdateAsync(List<Job_ApplicantProfile> entity)
|
{
|
var jm = new AdminUiCallBack();
|
|
var bl = await DbClient.Updateable(entity).ExecuteCommandHasChangeAsync();
|
jm.code = bl ? 0 : 1;
|
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
|
return jm;
|
}
|
|
/// <summary>
|
/// 重写删除指定ID的数据
|
/// </summary>
|
/// <param name="id"></param>
|
/// <returns></returns>
|
public async Task<AdminUiCallBack> DeleteByIdAsync(object id)
|
{
|
var jm = new AdminUiCallBack();
|
|
var bl = await DbClient.Deleteable<Job_ApplicantProfile>(id).ExecuteCommandHasChangeAsync();
|
jm.code = bl ? 0 : 1;
|
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
|
return jm;
|
}
|
|
/// <summary>
|
/// 重写删除指定ID集合的数据(批量删除)
|
/// </summary>
|
/// <param name="ids"></param>
|
/// <returns></returns>
|
public async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
|
{
|
var jm = new AdminUiCallBack();
|
|
var bl = await DbClient.Deleteable<Job_ApplicantProfile>().In(ids).ExecuteCommandHasChangeAsync();
|
jm.code = bl ? 0 : 1;
|
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
|
return jm;
|
}
|
|
#endregion
|
|
#region 获取缓存的所有数据==========================================================
|
|
/// <summary>
|
/// 获取缓存的所有数据
|
/// </summary>
|
/// <returns></returns>
|
public async Task<List<Job_ApplicantProfile>> GetCaChe()
|
{
|
var list = await DbClient.Queryable<Job_ApplicantProfile>().With(SqlWith.NoLock).WithCache().ToListAsync();
|
return list;
|
}
|
|
#endregion
|
|
|
#region 重写根据条件查询分页数据
|
/// <summary>
|
/// 重写根据条件查询分页数据
|
/// </summary>
|
/// <param name="predicate">判断集合</param>
|
/// <param name="orderByType">排序方式</param>
|
/// <param name="pageIndex">当前页面索引</param>
|
/// <param name="pageSize">分布大小</param>
|
/// <param name="orderByExpression"></param>
|
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
|
/// <returns></returns>
|
public async Task<IPageList<Job_ApplicantProfile>> QueryPageAsync(Expression<Func<Job_ApplicantProfile, bool>> predicate,
|
Expression<Func<Job_ApplicantProfile, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
|
int pageSize = 20, bool blUseNoLock = false)
|
{
|
RefAsync<int> totalCount = 0;
|
List<Job_ApplicantProfile> page;
|
if (blUseNoLock)
|
{
|
page = await DbClient.Queryable<Job_ApplicantProfile>()
|
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
.WhereIF(predicate != null, predicate).Select(p => new Job_ApplicantProfile
|
{
|
id = p.id,
|
jobId = p.jobId,
|
minSalaryRequirement = p.minSalaryRequirement,
|
name = p.name,
|
gender = p.gender,
|
height = p.height,
|
weight = p.weight,
|
dateOfBirth = p.dateOfBirth,
|
graduatingSchool = p.graduatingSchool,
|
educationLevel = p.educationLevel,
|
major = p.major,
|
smokes = p.smokes,
|
drivingSkill = p.drivingSkill,
|
phoneNumber = p.phoneNumber,
|
whiteWineCapacity = p.whiteWineCapacity,
|
politicalAffiliation = p.politicalAffiliation,
|
maritalStatus = p.maritalStatus,
|
specialAbilities = p.specialAbilities,
|
email = p.email,
|
parentalStatus = p.parentalStatus,
|
residentialAddress = p.residentialAddress,
|
createTime = p.createTime,
|
upDataTime = p.upDataTime,
|
createBy = p.createBy,
|
upDataBy = p.upDataBy,
|
isdelete = p.isdelete,
|
AuditStatu = p.AuditStatu,
|
|
}).With(SqlWith.NoLock).ToPageListAsync(pageIndex, pageSize, totalCount);
|
}
|
else
|
{
|
page = await DbClient.Queryable<Job_ApplicantProfile>()
|
.OrderByIF(orderByExpression != null, orderByExpression, orderByType)
|
.WhereIF(predicate != null, predicate).Select(p => new Job_ApplicantProfile
|
{
|
id = p.id,
|
jobId = p.jobId,
|
minSalaryRequirement = p.minSalaryRequirement,
|
name = p.name,
|
gender = p.gender,
|
height = p.height,
|
weight = p.weight,
|
dateOfBirth = p.dateOfBirth,
|
graduatingSchool = p.graduatingSchool,
|
educationLevel = p.educationLevel,
|
major = p.major,
|
smokes = p.smokes,
|
drivingSkill = p.drivingSkill,
|
phoneNumber = p.phoneNumber,
|
whiteWineCapacity = p.whiteWineCapacity,
|
politicalAffiliation = p.politicalAffiliation,
|
maritalStatus = p.maritalStatus,
|
specialAbilities = p.specialAbilities,
|
email = p.email,
|
parentalStatus = p.parentalStatus,
|
residentialAddress = p.residentialAddress,
|
createTime = p.createTime,
|
upDataTime = p.upDataTime,
|
createBy = p.createBy,
|
upDataBy = p.upDataBy,
|
isdelete = p.isdelete,
|
AuditStatu = p.AuditStatu,
|
|
}).ToPageListAsync(pageIndex, pageSize, totalCount);
|
}
|
var list = new PageList<Job_ApplicantProfile>(page, pageIndex, pageSize, totalCount);
|
return list;
|
}
|
|
public async Task<AdminUiCallBack> NvInsertAsync(Job_ApplicantProfile entity)
|
{
|
var jm = new AdminUiCallBack();
|
|
var bl = await DbClient.InsertNav<Job_ApplicantProfile>(entity).Include(x=>x.FamilyMembers).Include(x=>x.employmentRecords).ExecuteCommandAsync();
|
jm.code = bl ? 0 : 1;
|
jm.msg = bl ? GlobalConstVars.InsertSuccess : GlobalConstVars.InsertFailure;
|
|
return jm;
|
}
|
|
#endregion
|
|
}
|
}
|