更新考试状态接口

master
xiaochanghai 1 year ago
parent bf4fe5d7ad
commit a6e9c5c179
  1. 6
      Tiobon.Core.Api/Controllers/FileController.cs
  2. 15
      Tiobon.Core.Api/Controllers/Ghre/Ghre_ExamController.cs
  3. 2
      Tiobon.Core.IServices/Ghre/IGhre_AttachmentServices.cs
  4. 2
      Tiobon.Core.IServices/Ghre/IGhre_ExamServices.cs
  5. 2
      Tiobon.Core.Services/Ghre/Ghre_AttachmentServices.cs
  6. 40
      Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs

@ -150,15 +150,15 @@ public class FileController : BaseApiController
/// 分片上传
/// </summary>
/// <param name="file"></param>
/// <param name="videoName"></param>
/// <param name="fileName"></param>
/// <param name="chunkIndex"></param>
/// <param name="totalChunks"></param>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost("UploadLarge")]
public async Task<IActionResult> UploadLargeAsync(IFormFile file, string videoName, int chunkIndex, int totalChunks, string id)
public async Task<IActionResult> UploadLargeAsync(IFormFile file, string fileName, int chunkIndex, int totalChunks, string id)
{
dynamic obj = await _ghre_AttachmentServices.UploadVideoAsync(file, videoName, chunkIndex, totalChunks, id);
dynamic obj = await _ghre_AttachmentServices.UploadVideoAsync(file, fileName, chunkIndex, totalChunks, id);
return Ok(obj);
}
#endregion

@ -85,4 +85,19 @@ public class Ghre_ExamController : BaseController<IGhre_ExamServices, Ghre_Exam,
}
#endregion
#region 更新考试状态接口
/// <summary>
/// 更新考试状态接口
/// </summary>
/// <param name="ids"></param>
/// <param name="status"></param>
/// <returns></returns>
[HttpPost("UpdateStatus/{status}")]
public async Task<ServiceResult> UpdateStatus([FromBody] long[] ids, string status)
{
return await _service.UpdateStatus(ids, status);
}
#endregion
}

@ -9,7 +9,7 @@ namespace Tiobon.Core.IServices
/// </summary>
public interface IGhre_AttachmentServices :IBaseServices<Ghre_Attachment, Ghre_AttachmentDto, InsertGhre_AttachmentInput, EditGhre_AttachmentInput>
{
Task<dynamic> UploadVideoAsync(IFormFile file, string videoName, int chunkIndex, int totalChunks, string id);
Task<dynamic> UploadVideoAsync(IFormFile file, string fileName, int chunkIndex, int totalChunks, string id);
}
}

@ -18,5 +18,7 @@ namespace Tiobon.Core.IServices
Task<ServiceResult<List<StaffTableData>>> QueryStaff(List<int> Ids, string type);
Task<ServiceResult<long>> Insert1(long id, DefaultGhre_ExamPageData pageData);
Task<ServiceResult> UpdateStatus(long[] ids, string status);
}
}

@ -21,7 +21,7 @@ namespace Tiobon.Core.Services
base.BaseDal = dal;
}
public async Task<dynamic> UploadVideoAsync(IFormFile file, string videoName, int chunkIndex, int totalChunks, string id)
public async Task<dynamic> UploadVideoAsync(IFormFile file, string fileName, int chunkIndex, int totalChunks, string id)
{
dynamic obj = new ExpandoObject();
string status = "error";

@ -12,6 +12,8 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Tiobon.Core.Common.Helper;
using Microsoft.AspNetCore.Http;
using Tiobon.Core.Common.UserManager;
namespace Tiobon.Core.Services;
@ -528,7 +530,7 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
else sql += "AND 1!=1 ";
//var list = await _ghra_StaffSceneServices.Query(x => Ids.Contains(x.StaffID));
var data = Db.Ado.SqlQuery<StaffTableData>(sql);
var data = await Db.Ado.SqlQueryAsync<StaffTableData>(sql);
//var data = list.Select(x => new StaffTableData()
//{
// StaffID = x.StaffID,
@ -585,4 +587,40 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
}
}
public async Task<ServiceResult> UpdateStatus(long[] ids, string status)
{
if (status != "Released" && status != "Disabled" && status != "Draft")
throw new Exception("无效的状态");
HttpRequest request = UserContext.Context.Request;
var api = request.Path.ObjToString().TrimEnd('/').ToLower();
var ip = GetUserIp(UserContext.Context);
var entities = new List<Ghre_Exam>();
foreach (var id in ids)
{
if (id == null || !BaseDal.Any(id))
continue;
var entity = await BaseDal.QueryById(id);
BasePoco ent = entity;
ent.UpdateIP = ip;
ent.UpdateProg = api;
if (status == "Released" || status == "Disabled" || status == "Draft")
{
entity.Status = status;
entities.Add(entity);
}
}
var result = await BaseDal.Update(entities);
if (status == "Released")
return ServiceResult.OprateSuccess("发布成功!");
else if (status == "Draft")
return ServiceResult.OprateSuccess("取消发布成功!");
else
return ServiceResult.OprateSuccess("停用成功!");
}
}
Loading…
Cancel
Save