121 lines
4.5 KiB
C#
121 lines
4.5 KiB
C#
using Admin.NET.Core;
|
|
using Furion.DatabaseAccessor;
|
|
using Furion.DependencyInjection;
|
|
using Furion.DynamicApiController;
|
|
using Furion.FriendlyException;
|
|
using Mapster;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Dynamic.Core;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Admin.NET.Application
|
|
{
|
|
/// <summary>
|
|
/// 用户做题进度服务
|
|
/// </summary>
|
|
[ApiDescriptionSettings("测评服务", Name = "BusCustomMapReport", Order = 100)]
|
|
|
|
public class BusCustomMapReportService : IDynamicApiController, ITransient
|
|
{
|
|
private readonly SqlSugarRepository<BusCustomMapReport> _busCustomMapReportRep;
|
|
|
|
public BusCustomMapReportService(
|
|
SqlSugarRepository<BusCustomMapReport> busCustomMapReportRep
|
|
)
|
|
{
|
|
_busCustomMapReportRep = busCustomMapReportRep;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页查询用户做题进度
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("page")]
|
|
public async Task<SqlSugarPagedList<BusCustomMapReportOutput>> Page([FromQuery] BusCustomMapReportInput input)
|
|
{
|
|
var busCustomMapReports = await _busCustomMapReportRep.AsQueryable()
|
|
.Where(u => u.CustomId == input.CustomId)
|
|
.Where(u => u.Status == input.Status)
|
|
.Where(u => u.Proccess == input.Proccess)
|
|
.Where(u => u.Sort == input.Sort)
|
|
.OrderBy(u => u.CreateTime, OrderByType.Desc)
|
|
.Select(s => new BusCustomMapReportOutput
|
|
{
|
|
CustomId = s.CustomId,
|
|
Id = s.Id,
|
|
Proccess = s.Proccess,
|
|
Sort = s.Sort,
|
|
Status = s.Status
|
|
})
|
|
.OrderBuilder(input).ToPagedListAsync(input.Page, input.PageSize);
|
|
|
|
return busCustomMapReports;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 增加用户做题进度
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("add")]
|
|
public async Task Add(AddBusCustomMapReportInput input)
|
|
{
|
|
var busCustomMapReport = input.Adapt<BusCustomMapReport>();
|
|
await _busCustomMapReportRep.InsertAsync(busCustomMapReport);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除用户做题进度
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("delete")]
|
|
public async Task Delete(DeleteBusCustomMapReportInput input)
|
|
{
|
|
var busCustomMapReport = await _busCustomMapReportRep.AsQueryable().FirstAsync(u => u.Id == input.Id);
|
|
await _busCustomMapReportRep.FakeDeleteAsync(busCustomMapReport);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新用户做题进度
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("edit")]
|
|
public async Task Update(UpdateBusCustomMapReportInput input)
|
|
{
|
|
var isExist = await _busCustomMapReportRep.AsQueryable().AnyAsync(u => u.Id == input.Id);
|
|
if (!isExist) throw Oops.Oh(ErrorCodeEnum.D3000);
|
|
|
|
var busCustomMapReport = input.Adapt<BusCustomMapReport>();
|
|
await _busCustomMapReportRep.UpdateAsync(busCustomMapReport);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取用户做题进度
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("detail")]
|
|
public async Task<BusCustomMapReportOutput> Get([FromQuery] QueryeBusCustomMapReportInput input)
|
|
{
|
|
return (await _busCustomMapReportRep.AsQueryable().FirstAsync(u => u.Id == input.Id)).Adapt<BusCustomMapReportOutput>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取用户做题进度列表
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("list")]
|
|
public async Task<List<BusCustomMapReportOutput>> List([FromQuery] BusCustomMapReportInput input)
|
|
{
|
|
return await _busCustomMapReportRep.AsQueryable().Select<BusCustomMapReportOutput>().ToListAsync();
|
|
}
|
|
|
|
}
|
|
}
|