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 = "Company", Order = 1)] public class CompanyService : ICompanyService, IDynamicApiController, ITransient { private readonly SqlSugarRepository _rep; public CompanyService(SqlSugarRepository rep) { _rep = rep; } /// /// 分页查询招聘公司 /// /// /// [HttpGet("/Company/page")] public async Task Page([FromQuery] CompanyInput input) { var entities = await _rep.AsQueryable() .ToPagedListAsync(input.PageNo, input.PageSize); return entities.XnPagedResult(); } /// /// 增加招聘公司 /// /// /// [HttpPost("/Company/add")] public async Task Add(AddCompanyInput input) { var entity = input.Adapt(); await _rep.InsertAsync(entity); } /// /// 删除招聘公司 /// /// /// [HttpPost("/Company/delete")] public async Task Delete(DeleteCompanyInput input) { var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); await _rep.DeleteAsync(entity); } /// /// 更新招聘公司 /// /// /// [HttpPost("/Company/edit")] public async Task Update(UpdateCompanyInput input) { var entity = input.Adapt(); await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns:true).ExecuteCommandAsync(); } /// /// 获取招聘公司 /// /// /// [HttpGet("/Company/detail")] public async Task Get([FromQuery] QueryeCompanyInput input) { return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); } /// /// 获取招聘公司列表 /// /// /// [HttpGet("/Company/list")] public async Task List([FromQuery] CompanyInput input) { return await _rep.ToListAsync(); } } }