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.

195 lines
7.0 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;
using Microsoft.AspNetCore.Authorization;
using StackExchange.Profiling.Internal;
using System;
using System.Collections.Generic;
namespace GDZZ.Application
{
/// <summary>
/// 小程序招聘列表服务
/// </summary>
[ApiDescriptionSettings("Application",Name = "MiniResume", Order = 1)]
public class MiniResumeService : IMiniResumeService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<MiniResume> _rep;
private readonly SqlSugarRepository<Company> CompanyRep;
public MiniResumeService(SqlSugarRepository<MiniResume> rep, SqlSugarRepository<Company> CompanyRep)
{
_rep = rep;
this.CompanyRep= CompanyRep;
}
#region 求职端
/// <summary>
/// 初始化
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/Mini/GetResumeList")]
[AllowAnonymous]
public async Task<dynamic> GetResumeList([FromQuery] MiniResumeInput input)
{
var entities =await _rep.AsQueryable()
.LeftJoin<Company>((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;
}
/// <summary>
/// 初始化
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/Mini/GetCompanyResumeList")]
[AllowAnonymous]
public async Task<dynamic> GetCompanyResumeList([FromQuery] MiniResumeInput input)
{
var entities = await _rep.AsQueryable()
.LeftJoin<Company>((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()
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities;
}
/// <summary>
/// 搜索招聘信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[AllowAnonymous]
[HttpPost("/Mini/SearchRetFun")]
public async Task<dynamic> SearchRetFun(MiniResumeInput input)
{
var entities = await _rep.AsQueryable()
.LeftJoin<Company>((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 招聘端
/// <summary>
/// 发布招聘信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/MiniResume/add")]
public async Task Add(AddMiniResumeInput input)
{
var entity = input.Adapt<MiniResume>();
await _rep.InsertAsync(entity);
}
/// <summary>
/// 删除招聘信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/MiniResume/delete")]
public async Task Delete(DeleteMiniResumeInput input)
{
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
await _rep.DeleteAsync(entity);
}
/// <summary>
/// 更新招聘信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/MiniResume/edit")]
public async Task Update(UpdateMiniResumeInput input)
{
var entity = input.Adapt<MiniResume>();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
#endregion
}
}