新增文件控制

development
温天培 2 years ago
parent fc8c4cab4b
commit 931238bff1

@ -2,42 +2,48 @@
using SqlSugar;
using System.ComponentModel;
using GDZZ.Core.Entity;
using System.Collections.Generic;
namespace GDZZ.Application.Entity
{
/// <summary>
/// 课程表
/// </summary>
[SugarTable("mini_course")]
[Description("课程表")]
public class Course : DEntityBase
{
/// <summary>
/// 文件ID字段
/// </summary>
public long FileID { get; set; }
/// <summary>
/// 文件描述
/// </summary>
public string Info { get; set; }
/// <summary>
/// 标价
/// </summary>
public decimal Price { get; set; }
/// <summary>
/// 标签
/// </summary>
public string Tags { get; set; }
/// <summary>
/// 缩略图
/// </summary>
public string Url { get; set; }
/// <summary>
/// 标题
/// </summary>
public string Title { get; set; }
/// <summary>
/// 是否免费
/// </summary>
public int IsFree { get; set; }
}
/// <summary>
/// 课程表
/// </summary>
[SugarTable("mini_course")]
[Description("课程表")]
public class Course : DEntityBase
{
/// <summary>
/// 文件描述
/// </summary>
public string Info { get; set; }
/// <summary>
/// 标价
/// </summary>
public decimal Price { get; set; }
/// <summary>
/// 标签
/// </summary>
public string Tags { get; set; }
/// <summary>
/// 缩略图
/// </summary>
public string Url { get; set; }
/// <summary>
/// 标题
/// </summary>
public string Title { get; set; }
/// <summary>
/// 是否免费
/// </summary>
public int IsFree { get; set; }
/// <summary>
/// 文件列表
/// </summary>
[Navigate(NavigateType.OneToMany, nameof(SysFile.CID))]
public List<SysFile> SysFiles { get; set; }
}
}

@ -149,11 +149,6 @@
课程表
</summary>
</member>
<member name="P:GDZZ.Application.Entity.Course.FileID">
<summary>
文件ID字段
</summary>
</member>
<member name="P:GDZZ.Application.Entity.Course.Info">
<summary>
文件描述
@ -184,6 +179,11 @@
是否免费
</summary>
</member>
<member name="P:GDZZ.Application.Entity.Course.SysFiles">
<summary>
文件列表
</summary>
</member>
<member name="T:GDZZ.Application.Entity.FeedBack">
<summary>
意见反馈
@ -1358,11 +1358,6 @@
主键Id
</summary>
</member>
<member name="P:GDZZ.Application.CourseDto.FileID">
<summary>
文件ID字段
</summary>
</member>
<member name="P:GDZZ.Application.CourseDto.Info">
<summary>
文件描述
@ -1393,11 +1388,6 @@
课程表输入参数
</summary>
</member>
<member name="P:GDZZ.Application.CourseInput.FileID">
<summary>
文件ID字段
</summary>
</member>
<member name="P:GDZZ.Application.CourseInput.Info">
<summary>
文件描述
@ -1448,11 +1438,6 @@
主键Id
</summary>
</member>
<member name="P:GDZZ.Application.CourseOutput.FileID">
<summary>
文件ID字段
</summary>
</member>
<member name="P:GDZZ.Application.CourseOutput.Info">
<summary>
文件描述
@ -1483,6 +1468,11 @@
视频路径
</summary>
</member>
<member name="P:GDZZ.Application.CourseOutput.sysFile">
<summary>
课程视频对象
</summary>
</member>
<member name="T:GDZZ.Application.FeedBackDto">
<summary>
意见反馈输出参数

@ -76,7 +76,7 @@ namespace GDZZ.Application.Service.Auth
/// 手机端登录
/// </summary>
/// <returns></returns>
[HttpPost("Mini/SignIn")]
[HttpPost("/Mini/SignIn")]
[AllowAnonymous]
public async Task<AuthUserOut> SignInAsync(PhoneModel phoneModel)
{
@ -233,7 +233,7 @@ namespace GDZZ.Application.Service.Auth
/// 获取当前登录用户信息
/// </summary>
/// <returns></returns>
[HttpGet("Mini/GetLoginUser")]
[HttpGet("/Mini/GetLoginUser")]
public async Task<AuthUserOut> GetLoginUserAsync()
{
return await this.cacheService.GetUserInfoAsync(UserManager.UserId);

@ -8,6 +8,7 @@ using System.Linq;
using System.Threading.Tasks;
using GDZZ.Application.Entity;
using GDZZ.Core.Entity;
using System.Collections.Generic;
namespace GDZZ.Application
{
@ -18,10 +19,12 @@ namespace GDZZ.Application
public class CourseService : ICourseService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository<Course> _rep;
private readonly SqlSugarRepository<SysFile> sysFileRep;
public CourseService(SqlSugarRepository<Course> rep)
public CourseService(SqlSugarRepository<Course> rep, SqlSugarRepository<SysFile> sysFileRep)
{
_rep = rep;
this.sysFileRep = sysFileRep;
}
/// <summary>
@ -33,21 +36,11 @@ namespace GDZZ.Application
public async Task<dynamic> Page([FromQuery] CourseInput input)
{
var entities = await _rep.AsQueryable()
.InnerJoin<SysFile>((n, u) => n.FileID == u.Id)
.Includes(x=>x.SysFiles)
.Where(x=>x.SysFiles.Any(z=>z.FileSuffix == "mp4"))
.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();
}
@ -57,7 +50,7 @@ namespace GDZZ.Application
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/Mini/Course/page")]
[HttpPost("/Mini/Course/add")]
public async Task Add(AddCourseInput input)
{
var entity = input.Adapt<Course>();

@ -13,10 +13,7 @@ namespace GDZZ.Application
/// </summary>
public long Id { get; set; }
/// <summary>
/// 文件ID字段
/// </summary>
public long FileID { get; set; }
/// <summary>
/// 文件描述

@ -9,10 +9,7 @@ namespace GDZZ.Application
/// </summary>
public class CourseInput : PageInputBase
{
/// <summary>
/// 文件ID字段
/// </summary>
public virtual long FileID { get; set; }
/// <summary>
/// 文件描述

@ -1,4 +1,6 @@
using System;
using GDZZ.Core.Entity;
using System;
using System.Collections.Generic;
namespace GDZZ.Application
{
@ -11,11 +13,8 @@ namespace GDZZ.Application
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 文件ID字段
/// </summary>
public long FileID { get; set; }
/// <summary>
/// 文件描述
@ -46,7 +45,12 @@ namespace GDZZ.Application
/// 视频路径
/// </summary>
public string VoiderUrl { get; set; }
/// <summary>
/// 课程视频对象
/// </summary>
public List<SysFile> sysFile { get; set; }
}
}

@ -6,13 +6,13 @@ using System.ComponentModel.DataAnnotations;
namespace GDZZ.Core.Entity
{
/// <summary>
/// 文件信息表
/// </summary>
[SugarTable("sys_file")]
[Description("文件信息表")]
public class SysFile : DEntityBase
{
/// <summary>
/// 文件信息表
/// </summary>
[SugarTable("sys_file")]
[Description("文件信息表")]
public class SysFile : DEntityBase
{
/// <summary>
/// 文件存储位置1:阿里云2:腾讯云3:minio4:本地)
/// </summary>
@ -74,5 +74,14 @@ namespace GDZZ.Core.Entity
[MaxLength(2000)]
[SugarColumn(ColumnDescription = "文件描述", IsNullable = true)]
public string Info { get; set; }
}
/// <summary>
/// 课件ID
/// </summary>
[SugarColumn(ColumnDescription = "课件ID", IsNullable = true)]
public long CID { get; set; }
}
}

@ -1100,6 +1100,11 @@
文件描述
</summary>
</member>
<member name="P:GDZZ.Core.Entity.SysFile.CID">
<summary>
课件ID
</summary>
</member>
<member name="T:GDZZ.Core.Entity.SysLogAudit">
<summary>
系统操作/审计日志表
@ -6037,11 +6042,21 @@
存储路径
</summary>
</member>
<member name="P:GDZZ.Core.Service.FileInput.FileType">
<summary>
文件类型
</summary>
</member>
<member name="P:GDZZ.Core.Service.DeleteFileInfoInput.Id">
<summary>
文件Id
</summary>
</member>
<member name="P:GDZZ.Core.Service.BinDingFileInfoInput.VideoIDs">
<summary>
视频列表
</summary>
</member>
<member name="T:GDZZ.Core.Service.FileOutput">
<summary>
上传文件参数
@ -6064,6 +6079,20 @@
<param name="input"></param>
<returns></returns>
</member>
<member name="M:GDZZ.Core.Service.SysFileService.QueryMP4FileInfoPageList(GDZZ.Core.Service.FileInput)">
<summary>
分页获取MP文件列表
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:GDZZ.Core.Service.SysFileService.BinDingFileInfo(GDZZ.Core.Service.BinDingFileInfoInput)">
<summary>
排课
</summary>
<param name="input"></param>
<returns></returns>
</member>
<member name="M:GDZZ.Core.Service.SysFileService.GetFileInfoList(GDZZ.Core.Service.FileOutput)">
<summary>
获取文件列表

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace GDZZ.Core.Service;
@ -47,6 +48,11 @@ public class FileInput : PageInputBase
/// 存储路径
/// </summary>
public string FilePath { get; set; }
/// <summary>
/// 文件类型
/// </summary>
public int FileType { get; set; }
}
public class DeleteFileInfoInput
@ -62,3 +68,13 @@ public class QueryFileInoInput : DeleteFileInfoInput
{
}
public class BinDingFileInfoInput: DeleteFileInfoInput
{
/// <summary>
/// 视频列表
/// </summary>
public List<long> VideoIDs { get; set; }
}

@ -55,6 +55,57 @@ public class SysFileService : ISysFileService, IDynamicApiController, ITransient
return files.XnPagedResult();
}
/// <summary>
/// 分页获取MP文件列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet("/sysFileInfo/mppage")]
public async Task<dynamic> QueryMP4FileInfoPageList([FromQuery] FileInput input)
{
var fileBucket = !string.IsNullOrEmpty(input.FileBucket?.Trim());
var fileOriginName = !string.IsNullOrEmpty(input.FileOriginName?.Trim());
//rmrf-
var files = await _sysFileInfoRep.AsQueryable()
.WhereIF(input.FileLocation > 0, u => u.FileLocation == input.FileLocation)
.Where(u=>u.FileSuffix =="MP4")
.WhereIF(input.FileType == 1,u=> u.CID == 0)
.WhereIF(input.FileType == 2, u => u.CID != 0)
.WhereIF(!UserManager.IsSuperAdmin, u => u.CreatedUserId == UserManager.UserId)
.WhereIF(!string.IsNullOrWhiteSpace(input.FileBucket), u => u.FileBucket.Contains(input.FileBucket.Trim()))
.WhereIF(!string.IsNullOrWhiteSpace(input.FileOriginName), u => u.FileOriginName.Contains(input.FileOriginName.Trim()))
.Select<FileOutput>()
.ToPagedListAsync(input.PageNo, input.PageSize);
return files.XnPagedResult();
}
/// <summary>
/// 排课
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("/sysFileInfo/binding")]
public async Task BinDingFileInfo(BinDingFileInfoInput input)
{
foreach (var item in input.VideoIDs)
{
var file = await _sysFileInfoRep.FirstOrDefaultAsync(u => u.Id == item);
if (file != null)
{
file.CID = input.Id;
await _sysFileInfoRep.UpdateAsync(file);
}
}
}
/// <summary>
/// 获取文件列表
/// </summary>

Loading…
Cancel
Save