using System.Collections.Generic; using System.Threading.Tasks; using GxPress.Auth; using GxPress.Repository.Interface; using GxPress.Request.App.Middle; using GxPress.Request.Notice; using GxPress.Request.NoticeFolder; using GxPress.Result.App.Middle; using GxPress.Service.Interface.Middle; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace GxPress.Api.AppControllers { /// /// 中间件 /// [Route("api/app/middle")] [ApiController] [Authorize] public class MiddleController : ControllerBase { public readonly IMiddleService _middleService; public readonly ILoginContext _loginContext; private readonly IFolderUserRepository _folderUserRepository; public MiddleController(IMiddleService middleService, ILoginContext loginContext, IFolderUserRepository folderUserRepository) { _middleService = middleService; _loginContext = loginContext; _folderUserRepository = folderUserRepository; } /// /// 排序 /// /// /// [HttpPost("sort")] public async Task MiddleSort(MiddleSortRequest request) { return await _middleService.MiddleSortAsync(request); } /// /// 创建文件夹 /// /// /// [HttpPut("add-folder")] public async Task Insert(NoticeFolderInRequest request) { request.UserId = _loginContext.AccountId; var middleInsertRequest = new MiddleInsertRequest { FolderName = request.FolderName, FolderType = request.TypeId, ParentId = request.ParentId, UserId = request.UserId, RoleId = request.RoleId, UserIds = request.UserIds, UserMiddles = request.UserMiddles }; return await _middleService.InsertAsync(middleInsertRequest) > 0; } /// /// 设置置顶 /// /// /// [HttpPut("{id}")] public async Task SetTop(int id) { return await _middleService.SetTopAsync(id); } /// /// 删除记录 /// /// /// [HttpPost("delete")] public async Task Delete(NoticeDeRequest request) { var userId = _loginContext.AccountId; request.UserId = userId; return await _middleService.DeleteAsync(request); } /// /// 恢复删除 /// /// /// [HttpPost("recover-delete")] public async Task RecoverDelete(NoticeDeRequest request) { return await _middleService.RecoverDeleteAsync(request); } /// /// 恢复全部 /// /// 文件夹类型 1 通知 2话题 3 收藏 4笔记 5 普通站内信 6匿名站内信 7小组 /// [HttpPut("recover-all/{folderType}")] public async Task RecoverAllAsync(int folderType) { return await _middleService.RecoverAllAsync(folderType, _loginContext.AccountId); } /// /// 删除全部 /// /// 文件夹类型 1 通知 2话题 3 收藏 4笔记 5 普通站内信 6匿名站内信 7小组 /// [HttpDelete("delete-all/{folderType}")] public async Task DeleteAllAsync(int folderType) { return await _middleService.DeleteAllAsync(folderType, _loginContext.AccountId); } /// /// 移动 /// /// /// [HttpPost("move")] public async Task SetMove(MiddleMoveRequest request) { return await _middleService.SetMove(request); } /// /// 修改文件夹名称 /// /// /// [HttpPost("update")] public async Task UpdateFolderName(MiddleFolderNameRequest request) { return await _middleService.UpdateFolderNameAsync(request); } /// /// 查询文件夹 /// /// /// [HttpPost("search-folder")] public async Task> SearchFolderAsync(MiddleSearchFolderRequest request) { request.UserId = _loginContext.AccountId; return await _middleService.SearchFolderAsync(request); } /// /// 获取话题 笔记共享范围文件夹 /// /// /// [HttpPost("search-note-folder")] public async Task> SearchNoteFolderAsync(MiddleSearchFolderRequest request) { request.UserId = _loginContext.AccountId; return await _middleService.SearchNoteFolderAsync(request); } /// /// 修改文件夹名称或权限 /// /// /// [HttpPut("update-role")] public async Task UpdateFolderRole(MiddleUpdateFolderRoleRequest request) { return await _middleService.UpdateFolderRoleAsync(request); } /// /// 根据文件夹ID查询文件夹信息 /// /// /// [HttpGet("find-folder-info/{middleId}")] public async Task GetFolderUser(int middleId) { return await _middleService.GetFolderInfo(middleId); } /// /// 获取默认的共享文件夹范围 /// /// [HttpGet("enjoy-default/{folderType}")] public async Task GetEnjoyDefault(int folderType) { return await _middleService.GetEnjoyDefaultAsync(_loginContext.AccountId,folderType); } } }