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 = "JobhuntMessage", Order = 1)]
public class JobhuntMessageService : IJobhuntMessageService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository _rep;
public JobhuntMessageService(SqlSugarRepository rep)
{
_rep = rep;
}
///
/// 分页查询求职信息
///
///
///
[HttpGet("/JobhuntMessage/page")]
public async Task Page([FromQuery] JobhuntMessageInput input)
{
var entities = await _rep.AsQueryable()
.WhereIF(!string.IsNullOrWhiteSpace(input.PositionInfo), u => u.PositionInfo == input.PositionInfo)
.WhereIF(!string.IsNullOrWhiteSpace(input.Title), u => u.Title == input.Title)
.WhereIF(!string.IsNullOrWhiteSpace(input.Tag), u => u.Tag == input.Tag)
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities.XnPagedResult();
}
///
/// 增加求职信息
///
///
///
[HttpPost("/JobhuntMessage/add")]
public async Task Add(AddJobhuntMessageInput input)
{
var entity = input.Adapt();
await _rep.InsertAsync(entity);
}
///
/// 删除求职信息
///
///
///
[HttpPost("/JobhuntMessage/delete")]
public async Task Delete(DeleteJobhuntMessageInput input)
{
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
await _rep.DeleteAsync(entity);
}
///
/// 更新求职信息
///
///
///
[HttpPost("/JobhuntMessage/edit")]
public async Task Update(UpdateJobhuntMessageInput input)
{
var entity = input.Adapt();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns:true).ExecuteCommandAsync();
}
///
/// 获取求职信息
///
///
///
[HttpGet("/JobhuntMessage/detail")]
public async Task Get([FromQuery] QueryeJobhuntMessageInput input)
{
return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
}
///
/// 获取求职信息列表
///
///
///
[HttpGet("/JobhuntMessage/list")]
public async Task List([FromQuery] JobhuntMessageInput input)
{
return await _rep.ToListAsync();
}
}
}