提交 901733a9 编写于 作者: P pangmingjun-tw

使用统一异常提示信息

上级 aad7cf33
......@@ -1395,6 +1395,16 @@
数据库未支持异常提示信息
</summary>
</member>
<member name="F:RuYiAdmin.Net.CommonInfrastructure.Constants.System.ExceptionMessage.InvalidCronExpressionExceptionMessage">
<summary>
无效Cron表达式异常提示信息
</summary>
</member>
<member name="F:RuYiAdmin.Net.CommonInfrastructure.Constants.System.ExceptionMessage.StopJobExceptionMessage">
<summary>
停止作业异常提示信息
</summary>
</member>
<member name="T:RuYiAdmin.Net.CommonInfrastructure.Constants.System.WarnningMessage">
<summary>
系统警告提示信息
......
......@@ -10,6 +10,7 @@ using Newtonsoft.Json;
using Quartz;
using RuYiAdmin.Net.CommonInfrastructure.Configurations;
using RuYiAdmin.Net.CommonInfrastructure.Constants.Business;
using RuYiAdmin.Net.CommonInfrastructure.Constants.System;
using RuYiAdmin.Net.CommonInfrastructure.Enums.Business;
using RuYiAdmin.Net.CommonInfrastructure.Exceptions.Framework;
using RuYiAdmin.Net.CommonInfrastructure.Extensions.Business;
......@@ -90,12 +91,10 @@ namespace RuYiAdmin.Net.WebApi.RuYiAdminController.SystemController
scheduleJobs = scheduleJobs.Sort(searchCondition.Sort);
}
var actionResponseResult = new QueryResponseResult<SysScheduleJob>();
actionResponseResult.HttpStatusCode = HttpStatusCode.OK;
actionResponseResult.Message = new string("OK");
actionResponseResult.TotalCount = scheduleJobs.Count;
actionResponseResult.List = scheduleJobs.Skip(searchCondition.PageIndex * searchCondition.PageSize).Take(searchCondition.PageSize).ToList();
int count = scheduleJobs.Count;
scheduleJobs = scheduleJobs.Skip(searchCondition.PageIndex * searchCondition.PageSize).Take(searchCondition.PageSize).ToList();
var actionResponseResult = QueryResponseResult<SysScheduleJob>.OK(count, scheduleJobs);
return Ok(actionResponseResult);
}
......@@ -113,13 +112,8 @@ namespace RuYiAdmin.Net.WebApi.RuYiAdminController.SystemController
[Permission("job:query:list")]
public async Task<IActionResult> GetById(Guid jobId)
{
var actionResponseResult = new ActionResponseResult();
actionResponseResult.HttpStatusCode = HttpStatusCode.OK;
actionResponseResult.Message = new string("OK");
var scheduleJobs = await redisService.GetAsync<List<SysScheduleJob>>(RuYiGlobalConfig.SystemCacheConfig.ScheduleJobCacheName);
actionResponseResult.Object = scheduleJobs.Where(t => t.Id == jobId).FirstOrDefault();
var actionResponseResult = ActionResponseResult.OK(scheduleJobs.Where(t => t.Id == jobId).FirstOrDefault());
return Ok(actionResponseResult);
}
......@@ -188,7 +182,7 @@ namespace RuYiAdmin.Net.WebApi.RuYiAdminController.SystemController
bool expression = CronExpression.IsValidExpression(scheduleJob.CronExpression);
if (!expression)
{
throw new RuYiAdminCustomException("invalid cron expression");
throw new RuYiAdminCustomException(ExceptionMessage.InvalidCronExpressionExceptionMessage);
}
var scheduleJobs = await redisService.GetAsync<List<SysScheduleJob>>(RuYiGlobalConfig.SystemCacheConfig.ScheduleJobCacheName);
......@@ -196,7 +190,7 @@ namespace RuYiAdmin.Net.WebApi.RuYiAdminController.SystemController
if (job.JobStatus == JobStatus.Running)
{
throw new RuYiAdminCustomException("job is running,please stop it first");
throw new RuYiAdminCustomException(ExceptionMessage.StopJobExceptionMessage);
}
var actionResponseResult = await scheduleJobService.UpdateAsync(scheduleJob);
......@@ -250,11 +244,7 @@ namespace RuYiAdmin.Net.WebApi.RuYiAdminController.SystemController
#endregion
var actionResponseResult = new ActionResponseResult();
actionResponseResult.HttpStatusCode = HttpStatusCode.OK;
actionResponseResult.Message = "OK";
return Ok(actionResponseResult);
return Ok(ActionResponseResult.OK());
}
else if (RuYiGlobalConfig.QuartzConfig.SupportGroup && job.GroupId != null && job.GroupId == RuYiGlobalConfig.QuartzConfig.GroupId)
{
......@@ -271,11 +261,7 @@ namespace RuYiAdmin.Net.WebApi.RuYiAdminController.SystemController
#endregion
var actionResponseResult = new ActionResponseResult();
actionResponseResult.HttpStatusCode = HttpStatusCode.OK;
actionResponseResult.Message = "OK";
return Ok(actionResponseResult);
return Ok(ActionResponseResult.OK());
}
else
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册