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.
114 lines
3.8 KiB
114 lines
3.8 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 System.Collections.Generic;
|
|
using System;
|
|
|
|
namespace GDZZ.Application
|
|
{
|
|
/// <summary>
|
|
/// 职位管理服务
|
|
/// </summary>
|
|
[ApiDescriptionSettings("Application", Name = "Position", Order = 1)]
|
|
public class PositionService : IPositionService, IDynamicApiController, ITransient
|
|
{
|
|
private readonly SqlSugarRepository<Position> _rep;
|
|
|
|
public PositionService(SqlSugarRepository<Position> rep)
|
|
{
|
|
_rep = rep;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页查询职位管理
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("/Position/page")]
|
|
public async Task<dynamic> Page([FromQuery] PositionInput input)
|
|
{
|
|
var entities = await _rep.AsQueryable()
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.PositionName), u => u.PositionName == input.PositionName)
|
|
.ToPagedListAsync(input.PageNo, input.PageSize);
|
|
return entities.XnPagedResult();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 增加职位管理
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("/Position/add")]
|
|
public async Task Add(AddPositionInput input)
|
|
{
|
|
var entity = input.Adapt<Position>();
|
|
await _rep.InsertAsync(entity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除职位管理
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("/Position/delete")]
|
|
public async Task Delete(DeletePositionInput input)
|
|
{
|
|
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
|
|
await _rep.DeleteAsync(entity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新职位管理
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("/Position/edit")]
|
|
public async Task Update(UpdatePositionInput input)
|
|
{
|
|
var entity = input.Adapt<Position>();
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取职位管理
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("/Position/detail")]
|
|
public async Task<Position> Get([FromQuery] QueryePositionInput input)
|
|
{
|
|
return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取职位管理列表
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("/Position/list")]
|
|
public async Task<List<PositionOutput>> List([FromQuery] PositionInput input)
|
|
{;
|
|
|
|
var allProvinces = await _rep.AsQueryable().ToListAsync();
|
|
//先查询 省级别
|
|
var JobList = allProvinces.Where(x => x.PositionLevel == PositionEnum.JobList).ToList().Adapt<List<PositionOutput>>();
|
|
|
|
foreach (var province in JobList)
|
|
{
|
|
province.Children = allProvinces.Where(r => r.PositionLevel == PositionEnum.Subitem && r.ParentID == province.ID).ToList().Adapt<List<PositionOutput>>();
|
|
foreach (var city in province.Children)
|
|
{
|
|
city.Children = allProvinces.Where(r => r.PositionLevel == PositionEnum.Grandson && r.ParentID == city.ID).ToList().Adapt<List<PositionOutput>>()??null;
|
|
}
|
|
}
|
|
return JobList;
|
|
}
|
|
}
|
|
}
|