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.

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