using GDZZ.Core;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using System.Linq;
using System.Threading.Tasks;
using GDZZ.Application.Entity;
namespace GDZZ.Application
{
///
/// 求职者服务
///
[ApiDescriptionSettings("Application",Name = "JobHunter", Order = 1)]
public class JobHunterService : IJobHunterService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository _rep;
public JobHunterService(SqlSugarRepository rep)
{
_rep = rep;
}
///
/// 分页查询求职者
///
///
///
[HttpGet("/JobHunter/page")]
public async Task Page([FromQuery] JobHunterInput input)
{
var entities = await _rep.AsQueryable()
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities.XnPagedResult();
}
///
/// 增加求职者
///
///
///
[HttpPost("/JobHunter/add")]
public async Task Add(AddJobHunterInput input)
{
var entity = input.Adapt();
await _rep.InsertAsync(entity);
}
///
/// 删除求职者
///
///
///
[HttpPost("/JobHunter/delete")]
public async Task Delete(DeleteJobHunterInput input)
{
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
await _rep.DeleteAsync(entity);
}
///
/// 更新求职者
///
///
///
[HttpPost("/JobHunter/edit")]
public async Task Update(UpdateJobHunterInput input)
{
var entity = input.Adapt();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns:true).ExecuteCommandAsync();
}
///
/// 获取求职者
///
///
///
[HttpGet("/JobHunter/detail")]
public async Task Get([FromQuery] QueryeJobHunterInput input)
{
return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
}
///
/// 获取求职者列表
///
///
///
[HttpGet("/JobHunter/list")]
public async Task List([FromQuery] JobHunterInput input)
{
return await _rep.ToListAsync();
}
}
}