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.

107 lines
3.4 KiB

using GDZZ.Core;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using GDZZ.Application.Entity;
using Microsoft.AspNetCore.Authorization;
1 year ago
namespace GDZZ.Application
{
/// <summary>
/// 求职列表服务
/// </summary>
[ApiDescriptionSettings("Application",Name = "JobHunt", Order = 1)]
public class JobHuntService : IJobHuntService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<JobHunt> _rep;
public JobHuntService(SqlSugarRepository<JobHunt> rep)
{
_rep = rep;
}
/// <summary>
/// 分页查询求职列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/JobHunt/page")]
[AllowAnonymous]
public async Task<dynamic> Page([FromQuery] JobHuntInput input)
{
var entities = await _rep.AsQueryable()
.WhereIF(!string.IsNullOrWhiteSpace(input.Tags), u => u.Tags == input.Tags)
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities.XnPagedResult();
}
/// <summary>
/// 增加求职列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/JobHunt/add")]
1 year ago
[AllowAnonymous]
public async Task Add(AddJobHuntInput input)
{
var entity = input.Adapt<JobHunt>();
await _rep.InsertAsync(entity);
}
/// <summary>
/// 删除求职列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/JobHunt/delete")]
1 year ago
[AllowAnonymous]
public async Task Delete(DeleteJobHuntInput input)
{
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
await _rep.DeleteAsync(entity);
}
/// <summary>
/// 更新求职列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/JobHunt/edit")]
1 year ago
[AllowAnonymous]
public async Task Update(UpdateJobHuntInput input)
{
var entity = input.Adapt<JobHunt>();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns:true).ExecuteCommandAsync();
}
/// <summary>
/// 获取求职列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/JobHunt/Detail")]
1 year ago
[AllowAnonymous]
public async Task<JobHunt> Get([FromQuery] QueryeJobHuntInput input)
{
return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
}
/// <summary>
/// 获取求职列表列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/JobHunt/list")]
1 year ago
[AllowAnonymous]
public async Task<dynamic> List([FromQuery] JobHuntInput input)
{
1 year ago
return await _rep.AsQueryable()
.Where(x=>x.CreatedUserId == UserManager.UserId)
.OrderByDescending(x=>x.Tags)
.ToListAsync();
}
}
}