refactor: 批量新增枚举类型并完成实体、DTO、服务层枚举替换
- 新增30+业务枚举类型覆盖用户、宠物、商城、社区、积分等模块 - 完成实体类、DTO、服务层的字符串枚举替换为强类型枚举 - 修复用户状态枚举名称变更,将Frozen改为Disabled - 新增批量发布社区消息接口与控制器实现 - 新增操作日志、积分管理、补偿任务相关服务与DTO
This commit is contained in:
@ -3,6 +3,7 @@ using Newtonsoft.Json;
|
||||
using QYZH.InteractiveMagazine.IService;
|
||||
using QYZH.InteractiveMagazine.Models.Dto.Compensation;
|
||||
using QYZH.InteractiveMagazine.Models.Entity;
|
||||
using QYZH.InteractiveMagazine.Models.Enum;
|
||||
using QYZH.InteractiveMagazine.Repository;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.Service;
|
||||
@ -28,7 +29,7 @@ public class CompensationTaskService(
|
||||
|
||||
var task = new CompensationTask
|
||||
{
|
||||
TaskType = input.TaskType,
|
||||
TaskType = (int)input.TaskType,
|
||||
BusinessSource = input.BusinessSource,
|
||||
BusinessId = input.BusinessId,
|
||||
UserId = input.UserId,
|
||||
@ -37,7 +38,7 @@ public class CompensationTaskService(
|
||||
ErrorSource = input.ErrorSource,
|
||||
RetryCount = 0,
|
||||
MaxRetries = input.MaxRetries > 0 ? input.MaxRetries : 3,
|
||||
Status = CompensationTaskStatus.Pending,
|
||||
Status = CompensationTaskStatusEnum.Pending,
|
||||
ScheduledAt = DateTime.Now,
|
||||
IsDeleted = false,
|
||||
CreatedBy = "System",
|
||||
@ -61,7 +62,7 @@ public class CompensationTaskService(
|
||||
var now = DateTime.Now;
|
||||
|
||||
var tasks = await taskRepository.Queryable()
|
||||
.Where(t => (t.Status == CompensationTaskStatus.Pending || t.Status == CompensationTaskStatus.Processing)
|
||||
.Where(t => (t.Status == CompensationTaskStatusEnum.Pending || t.Status == CompensationTaskStatusEnum.Processing)
|
||||
&& !t.IsDeleted
|
||||
&& (t.ScheduledAt == null || t.ScheduledAt <= now))
|
||||
.OrderBy(t => t.CreatedAt)
|
||||
@ -69,7 +70,7 @@ public class CompensationTaskService(
|
||||
.Select(t => new CompensationTaskOutput
|
||||
{
|
||||
Id = t.Id,
|
||||
TaskType = t.TaskType,
|
||||
TaskType = (CompensationTaskTypeEnum)t.TaskType,
|
||||
BusinessSource = t.BusinessSource,
|
||||
BusinessId = t.BusinessId,
|
||||
UserId = t.UserId,
|
||||
@ -97,11 +98,11 @@ public class CompensationTaskService(
|
||||
var query = taskRepository.Queryable()
|
||||
.Where(t => !t.IsDeleted);
|
||||
|
||||
if (!string.IsNullOrEmpty(input.Status))
|
||||
query = query.Where(t => t.Status == input.Status);
|
||||
if (input.Status.HasValue)
|
||||
query = query.Where(t => t.Status == input.Status.Value);
|
||||
|
||||
if (!string.IsNullOrEmpty(input.TaskType))
|
||||
query = query.Where(t => t.TaskType == input.TaskType);
|
||||
if (input.TaskType.HasValue)
|
||||
query = query.Where(t => t.TaskType == (int)input.TaskType.Value);
|
||||
|
||||
if (!string.IsNullOrEmpty(input.BusinessSource))
|
||||
query = query.Where(t => t.BusinessSource == input.BusinessSource);
|
||||
@ -112,7 +113,7 @@ public class CompensationTaskService(
|
||||
.Select(t => new CompensationTaskOutput
|
||||
{
|
||||
Id = t.Id,
|
||||
TaskType = t.TaskType,
|
||||
TaskType = (CompensationTaskTypeEnum)t.TaskType,
|
||||
BusinessSource = t.BusinessSource,
|
||||
BusinessId = t.BusinessId,
|
||||
UserId = t.UserId,
|
||||
@ -162,7 +163,7 @@ public class CompensationTaskService(
|
||||
public async Task CancelTaskAsync(long taskId, string reason)
|
||||
{
|
||||
await taskRepository.Context.Updateable<CompensationTask>()
|
||||
.SetColumns(t => t.Status == CompensationTaskStatus.Cancelled)
|
||||
.SetColumns(t => t.Status == CompensationTaskStatusEnum.Cancelled)
|
||||
.SetColumns(t => t.ResultMessage == reason)
|
||||
.SetColumns(t => t.UpdatedAt == DateTime.Now)
|
||||
.Where(t => t.Id == taskId && !t.IsDeleted)
|
||||
|
||||
Reference in New Issue
Block a user