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.

265 lines
11 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;
2 years ago
using GDZZ.Core.Entity;
using Furion.FriendlyException;
namespace GDZZ.Application
{
/// <summary>
/// 小程序招聘列表服务
/// </summary>
[ApiDescriptionSettings("Application",Name = "MiniResume", Order = 1)]
public class MiniResumeService : IMiniResumeService, IDynamicApiController, ITransient
{
2 years ago
private readonly SqlSugarRepository<MiniResume> _rep; //招聘列表仓储
private readonly SqlSugarRepository<BaseUser> baseUser; //基础用户仓储
private readonly SqlSugarRepository<Company> CompanyRep; //公司仓储
private readonly SqlSugarRepository<SysTenant> _sysTenantRep;// 租户表仓储
private readonly SqlSugarRepository<Consume> ComsumeRep; //消费记录仓储
private readonly SqlSugarRepository<Balance> balance; //余额仓储
public MiniResumeService(SqlSugarRepository<MiniResume> rep,
SqlSugarRepository<BaseUser> baseUser,
SqlSugarRepository<SysTenant> _sysTenantRep,
SqlSugarRepository<Consume> ComsumeRep,
SqlSugarRepository<Balance> balance,
SqlSugarRepository<Company> CompanyRep)
{
_rep = rep;
2 years ago
this.balance = balance;
this.ComsumeRep = ComsumeRep;
this._sysTenantRep = _sysTenantRep;
this.baseUser = baseUser;
this.CompanyRep= CompanyRep;
}
#region 求职端
/// <summary>
2 years ago
/// 招聘列表
/// </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()
2 years ago
.OrderByDescending(u => u.Time)
.ToPagedListAsync(input.PageNo, input.PageSize);
2 years ago
return entities.XnPagedResult();
}
2 years ago
/// <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()
.ToListAsync();
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 => u.CompanyName.Contains(input.SearchValue))
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchValue), u => u.Level.Contains(input.SearchValue))
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchValue), u => u.RegionName.Contains(input.SearchValue))
.WhereIF(!string.IsNullOrWhiteSpace(input.SearchValue), u => u.Sak.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);
2 years ago
return entities.XnPagedResult();
}
#endregion
#region 招聘端
/// <summary>
/// 发布招聘信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
2 years ago
[HttpPost("/Mini/Resume/add")]
public async Task Add(AddMiniResumeInput input)
{
var entity = input.Adapt<MiniResume>();
2 years ago
var user =await this.baseUser.AsQueryable().Filter("TenantId", true).SingleAsync(x=>x.CreatedUserId == UserManager.UserId);
entity.CompanyID = user.CompanyID;
entity.CompanyName ="";
//查询是否有余额
var banlan = await this.balance.FirstOrDefaultAsync(x => x.UserID == UserManager.UserId);
if(banlan.IsNullOrZero() | banlan.Amount <= 0)
throw Oops.Oh(ErrorCode.B1001);
//查询所属租户收费
var tenantID =await this._sysTenantRep.FirstOrDefaultAsync(s => s.Id ==long.Parse(UserManager.TenantID));
if (tenantID.IsNullOrZero())
throw Oops.Oh(ErrorCode.F1001);
if(tenantID.PushFee > banlan.Amount)
throw Oops.Oh(ErrorCode.B1001);
//在余额中减去
banlan.Amount = banlan.Amount - tenantID.PushFee;
await this.balance.UpdateAsync(banlan);
//新增消费记录
await this.ComsumeRep.InsertAsync(new Consume { CAmount= tenantID.PushFee, Surplus = banlan.Amount,UserID = UserManager.UserId,Sort =(int)ConsumeEnum.Push });
await _rep.InsertAsync(entity);
}
2 years ago
/// <summary>
/// 获取自己发布的招聘信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/Mini/GetSelfResumeList")]
public async Task<dynamic> GetSelfResumeList([FromQuery] MiniResumeInput input)
{
var entities = await _rep.AsQueryable()
.LeftJoin<Company>((u, y) => u.CompanyID == y.Id) //关联公司信息
.Where(u => u.CreatedUserId == UserManager.UserId)
.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,
RegionStrID = u.RegionStrID,
SalaryID = u.SalaryID
}).MergeTable()
.OrderByDescending(u => u.Time)
.ToPagedListAsync(input.PageNo, input.PageSize);
return entities;
}
/// <summary>
/// 删除招聘信息
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
2 years ago
[HttpPost("/Mini/Resume/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>
2 years ago
[HttpPost("/Mini/Resume/edit")]
public async Task Update(UpdateMiniResumeInput input)
{
var entity = input.Adapt<MiniResume>();
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
}
#endregion
}
}