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;
using Microsoft.AspNetCore.Authorization;
using StackExchange.Profiling.Internal;
using System;
using System.Collections.Generic;
namespace GDZZ.Application
{
///
/// 小程序招聘列表服务
///
[ApiDescriptionSettings("Application",Name = "MiniResume", Order = 1)]
public class MiniResumeService : IMiniResumeService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository _rep;
private readonly SqlSugarRepository CompanyRep;
public MiniResumeService(SqlSugarRepository rep, SqlSugarRepository CompanyRep)
{
_rep = rep;
this.CompanyRep= CompanyRep;
}
#region 求职端
///
/// 初始化
///
///
///
[HttpGet("/Mini/GetResumeList")]
[AllowAnonymous]
public async Task GetResumeList([FromQuery] MiniResumeInput input)
{
var entities =await _rep.AsQueryable()
.LeftJoin((u, y) => u.CompanyID == y.Id) //关联公司信息
.Select((u, y) => new MiniResumeOutput
{
CompanyID =y.Id,CompanyName = y.Name,
Logo = y.logo,Id = u.Id,
Info = u.Info,Sak = u.Sak,
Salary = u.Salary,Title = u.Title,
Time = u.CreatedTime.Value.ToString("yyyy/MM/dd"),RegionName = u.RegionName,
Record = u.Record,Level = u.Level,
}).MergeTable()
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities;
}
///
/// 初始化
///
///
///
[HttpGet("/Mini/GetCompanyResumeList")]
[AllowAnonymous]
public async Task GetCompanyResumeList([FromQuery] MiniResumeInput input)
{
var entities = await _rep.AsQueryable()
.LeftJoin((u, y) => u.CompanyID == y.Id) //关联公司信息
.Where(u => u.CompanyID == input.CompanyID)
.Select((u, y) => new MiniResumeOutput
{
CompanyID = y.Id,
CompanyName = y.Name,
Logo = y.logo,
Id = u.Id,
Info = u.Info,
Sak = u.Sak,
Salary = u.Salary,
Title = u.Title,
Time = u.CreatedTime.Value.ToString("yyyy/MM/dd"),
RegionName = u.RegionName,
Record = u.Record,
Level = u.Level,
}).MergeTable()
.ToListAsync();
return entities;
}
///
/// 搜索招聘信息
///
///
///
[AllowAnonymous]
[HttpPost("/Mini/SearchRetFun")]
public async Task SearchRetFun(MiniResumeInput input)
{
var entities = await _rep.AsQueryable()
.LeftJoin((u, y) => u.CompanyID == y.Id) //关联公司信息
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchValue), u => u.Title.Contains(input.SearchValue))
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchValue), (u, y) => y.Name.Contains(input.SearchValue))
.Select((u, y) => new MiniResumeOutput
{
CompanyID = y.Id,
CompanyName = y.Name,
Logo = y.logo,
Id = u.Id,
Info = u.Info,
Sak = u.Sak,
Salary = u.Salary,
Title = u.Title,
Time = u.CreatedTime.Value.ToString("yyyy/MM/dd"),
RegionName = u.RegionName,
Record = u.Record,
Level = u.Level,
}).MergeTable()
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities;
}
#endregion
#region 招聘端
///
/// 发布招聘信息
///
///
///
[HttpPost("/MiniResume/add")]
public async Task Add(AddMiniResumeInput input)
{
var entity = input.Adapt();
await _rep.InsertAsync(entity);
}
///
/// 删除招聘信息
///
///
///
[HttpPost("/MiniResume/delete")]
public async Task Delete(DeleteMiniResumeInput input)
{
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
await _rep.DeleteAsync(entity);
}
///
/// 更新招聘信息
///
///
///
[HttpPost("/MiniResume/edit")]
public async Task Update(UpdateMiniResumeInput input)
{
var entity = input.Adapt();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
#endregion
}
}