You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.3 KiB

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