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.9 KiB
114 lines
3.9 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 GDZZ.Core.Entity;
|
|
|
|
namespace GDZZ.Application
|
|
{
|
|
/// <summary>
|
|
/// 课程表服务
|
|
/// </summary>
|
|
[ApiDescriptionSettings("Application", Name = "Course", Order = 1)]
|
|
public class CourseService : ICourseService, IDynamicApiController, ITransient
|
|
{
|
|
private readonly SqlSugarRepository<Course> _rep;
|
|
|
|
public CourseService(SqlSugarRepository<Course> rep)
|
|
{
|
|
_rep = rep;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页查询课程表
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("/Mini/Course/page")]
|
|
public async Task<dynamic> Page([FromQuery] CourseInput input)
|
|
{
|
|
var entities = await _rep.AsQueryable()
|
|
.InnerJoin<SysFile>((n, u) => n.FileID == u.Id)
|
|
.WhereIF(!UserManager.IsTenantAdmin, n => n.CreatedUserId == UserManager.UserId)
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Tags), n => n.Tags == input.Tags)
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.Title), n => n.Title == input.Title)
|
|
.Select((n, u) => new CourseOutput
|
|
{
|
|
FileID = u.Id,
|
|
Id = n.Id,
|
|
Info = n.Info,
|
|
Price = n.Price,
|
|
Tags = n.Tags,
|
|
Title = n.Title,
|
|
Url = n.Url,
|
|
VoiderUrl = "/"+u.FilePath+"/"+u.FileObjectName
|
|
})
|
|
.ToPagedListAsync(input.PageNo, input.PageSize);
|
|
return entities.XnPagedResult();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 增加课程表
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("/Mini/Course/page")]
|
|
public async Task Add(AddCourseInput input)
|
|
{
|
|
var entity = input.Adapt<Course>();
|
|
await _rep.InsertAsync(entity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除课程表
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("/Course/delete")]
|
|
public async Task Delete(DeleteCourseInput input)
|
|
{
|
|
var entity = await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
|
|
await _rep.DeleteAsync(entity);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新课程表
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("/Course/edit")]
|
|
public async Task Update(UpdateCourseInput input)
|
|
{
|
|
var entity = input.Adapt<Course>();
|
|
await _rep.AsUpdateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取课程表
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("/Course/detail")]
|
|
public async Task<Course> Get([FromQuery] QueryeCourseInput input)
|
|
{
|
|
return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取课程表列表
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("/Course/list")]
|
|
public async Task<dynamic> List([FromQuery] CourseInput input)
|
|
{
|
|
return await _rep.ToListAsync();
|
|
}
|
|
}
|
|
}
|