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; using Microsoft.AspNetCore.Authorization; namespace Magic.Application { /// /// 求职列表服务 /// [ApiDescriptionSettings("Application",Name = "JobHunt", Order = 1)] public class JobHuntService : IJobHuntService, IDynamicApiController, ITransient { private readonly SqlSugarRepository _rep; public JobHuntService(SqlSugarRepository rep) { _rep = rep; } /// /// 分页查询求职列表 /// /// /// [HttpGet("/JobHunt/page")] [AllowAnonymous] public async Task Page([FromQuery] JobHuntInput input) { var entities = await _rep.AsQueryable() .WhereIF(!string.IsNullOrWhiteSpace(input.Career), u => u.Career == input.Career) .WhereIF(!string.IsNullOrWhiteSpace(input.Info), u => u.Info == input.Info) .WhereIF(!string.IsNullOrWhiteSpace(input.Address), u => u.Address == input.Address) .WhereIF(!string.IsNullOrWhiteSpace(input.Tags), u => u.Tags == input.Tags) .WhereIF(!string.IsNullOrWhiteSpace(input.phone), u => u.phone == input.phone) .WhereIF(!string.IsNullOrWhiteSpace(input.Logo), u => u.Logo == input.Logo) .ToPagedListAsync(input.PageNo, input.PageSize); return entities.XnPagedResult(); } /// /// 增加求职列表 /// /// /// [HttpPost("/JobHunt/add")] public async Task Add(AddJobHuntInput input) { var entity = input.Adapt(); await _rep.InsertAsync(entity); } /// /// 删除求职列表 /// /// /// [HttpPost("/JobHunt/delete")] public async Task Delete(DeleteJobHuntInput input) { var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); await _rep.DeleteAsync(entity); } /// /// 更新求职列表 /// /// /// [HttpPost("/JobHunt/edit")] public async Task Update(UpdateJobHuntInput input) { var entity = input.Adapt(); await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns:true).ExecuteCommandAsync(); } /// /// 获取求职列表 /// /// /// [HttpGet("/JobHunt/detail")] public async Task Get([FromQuery] QueryeJobHuntInput input) { return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); } /// /// 获取求职列表列表 /// /// /// [HttpGet("/JobHunt/list")] public async Task List([FromQuery] JobHuntInput input) { return await _rep.ToListAsync(); } } }