using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using WIDESEA_Core; using WIDESEA_Core.BaseController; using WIDESEA_DTO.Stock; using WIDESEA_ITaskInfoService; using WIDESEA_Model.Models; namespace WIDESEA_WMSServer.Controllers.TaskInfo { /// /// 任务历史 /// [Route("api/Task_Hty")] [ApiController] public class Task_HtyController : ApiBaseController { public Task_HtyController(ITask_HtyService service) : base(service) { } /// /// 删除旧的历史任务数据 /// /// 保留的月数,默认为3个月(本月+后两个月) /// 删除的记录数 [HttpGet, Route("DeleteOldHistory")] [AllowAnonymous] public IActionResult DeleteOldHistory(int keepMonths = 3) { try { int result = Service.DeleteOldTaskHistory(keepMonths); return Ok(new { Success = true, Message = "历史任务删除成功", DeletedCount = result }); } catch (Exception ex) { return Ok(new { Success = false, Message = "历史任务删除失败: " + ex.Message }); } } } }