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 = "Candidate", Order = 1)] public class CandidateService : ICandidateService, IDynamicApiController, ITransient { private readonly SqlSugarRepository _rep; public CandidateService(SqlSugarRepository rep) { _rep = rep; } /// /// 新增合作 /// /// /// [HttpPost("/Candidate/AddOrUpdate")] public async Task AddOrUpdate(AddCandidateInput input) { var res = await this._rep.AsQueryable().Where(x => x.CanndidateID == input.CanndidateID && x.HeadID == input.HeadID).FirstAsync(); if (res.IsEmpty()) { var entity = input.Adapt(); await _rep.InsertAsync(entity); } else { res.Status = input.Status; await _rep.UpdateAsync(res); } } /// /// 分页查询猎头合作管理 /// /// /// [HttpGet("/Candidate/page")] public async Task Page([FromQuery] CandidateInput input) { var entities = await _rep.AsQueryable() .ToPagedListAsync(input.PageNo, input.PageSize); return entities.XnPagedResult(); } /// /// 删除猎头合作管理 /// /// /// [HttpPost("/Candidate/delete")] public async Task Delete(DeleteCandidateInput input) { var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); await _rep.DeleteAsync(entity); } /// /// 更新猎头合作管理 /// /// /// [HttpPost("/Candidate/edit")] public async Task Update(UpdateCandidateInput input) { var entity = input.Adapt(); await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns:true).ExecuteCommandAsync(); } /// /// 获取猎头合作管理 /// /// /// [HttpGet("/Candidate/detail")] public async Task Get([FromQuery] QueryeCandidateInput input) { return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); } /// /// 获取猎头合作管理列表 /// /// /// [HttpGet("/Candidate/list")] public async Task List([FromQuery] CandidateInput input) { return await _rep.ToListAsync(); } } }