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 = "RecruitMessage", Order = 1)] public class RecruitMessageService : IRecruitMessageService, IDynamicApiController, ITransient { private readonly SqlSugarRepository _rep; public RecruitMessageService(SqlSugarRepository rep) { _rep = rep; } /// /// 分页查询招聘消息 /// /// /// [HttpGet("/RecruitMessage/page")] public async Task Page([FromQuery] RecruitMessageInput 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.Phone), u => u.Phone == input.Phone) .WhereIF(!string.IsNullOrWhiteSpace(input.Tag), u => u.Tag == input.Tag) .ToPagedListAsync(input.PageNo, input.PageSize); return entities.XnPagedResult(); } /// /// 增加招聘消息 /// /// /// [HttpPost("/RecruitMessage/add")] public async Task Add(AddRecruitMessageInput input) { var entity = input.Adapt(); await _rep.InsertAsync(entity); } /// /// 删除招聘消息 /// /// /// [HttpPost("/RecruitMessage/delete")] public async Task Delete(DeleteRecruitMessageInput input) { var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); await _rep.DeleteAsync(entity); } /// /// 更新招聘消息 /// /// /// [HttpPost("/RecruitMessage/edit")] public async Task Update(UpdateRecruitMessageInput input) { var entity = input.Adapt(); await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns:true).ExecuteCommandAsync(); } /// /// 获取招聘消息 /// /// /// [HttpGet("/RecruitMessage/detail")] public async Task Get([FromQuery] QueryeRecruitMessageInput input) { return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); } /// /// 获取招聘消息列表 /// /// /// [HttpGet("/RecruitMessage/list")] public async Task List([FromQuery] RecruitMessageInput input) { return await _rep.ToListAsync(); } } }