refactor: 批量新增枚举类型并完成实体、DTO、服务层枚举替换
- 新增30+业务枚举类型覆盖用户、宠物、商城、社区、积分等模块 - 完成实体类、DTO、服务层的字符串枚举替换为强类型枚举 - 修复用户状态枚举名称变更,将Frozen改为Disabled - 新增批量发布社区消息接口与控制器实现 - 新增操作日志、积分管理、补偿任务相关服务与DTO
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using QYZH.InteractiveMagazine.Common.Extensions;
|
||||
using QYZH.InteractiveMagazine.IService;
|
||||
using QYZH.InteractiveMagazine.Models.Common;
|
||||
using QYZH.InteractiveMagazine.Models.Dto;
|
||||
using QYZH.InteractiveMagazine.Models.Entity;
|
||||
using QYZH.InteractiveMagazine.Models.Enum;
|
||||
using QYZH.InteractiveMagazine.Repository;
|
||||
using SqlSugar;
|
||||
|
||||
@ -28,11 +30,11 @@ public class CommunityMessageService(BaseRepository<CommunityMessage> messageRep
|
||||
RefAsync<int> totalNumber = 0;
|
||||
var pageResult = await messageRepository.Queryable()
|
||||
.WhereIF(input.JournalId.HasValue, m => m.JournalId == input.JournalId.Value)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.Type), m => m.Type == input.Type)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.Type), m => m.Type.ToString() == input.Type)
|
||||
.WhereIF(input.Status.HasValue, m => m.Status == input.Status.Value)
|
||||
.WhereIF(input.IsFeatured.HasValue, m => m.IsFeatured == input.IsFeatured.Value)
|
||||
.WhereIF(input.IsActive.HasValue, m => m.IsActive == input.IsActive.Value)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.Keyword), m => m.Content.Contains(input.Keyword))
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.KeyWord), m => m.Content.Contains(input.KeyWord))
|
||||
.WhereIF(input.UserId.HasValue, m => m.UserId == input.UserId.Value)
|
||||
.OrderByDescending(m => m.IsFeatured)
|
||||
.OrderByDescending(m => m.CreatedAt)
|
||||
@ -48,7 +50,7 @@ public class CommunityMessageService(BaseRepository<CommunityMessage> messageRep
|
||||
ImageUrl = m.ImageUrl,
|
||||
SortOrder = m.SortOrder,
|
||||
IsActive = m.IsActive,
|
||||
Type = m.Type,
|
||||
Type = m.Type.ToString(),
|
||||
LikeCount = m.LikeCount,
|
||||
IsFeatured = m.IsFeatured,
|
||||
Status = m.Status,
|
||||
@ -88,7 +90,7 @@ public class CommunityMessageService(BaseRepository<CommunityMessage> messageRep
|
||||
ImageUrl = message.ImageUrl,
|
||||
SortOrder = message.SortOrder,
|
||||
IsActive = message.IsActive,
|
||||
Type = message.Type,
|
||||
Type = message.Type.ToString(),
|
||||
LikeCount = message.LikeCount,
|
||||
IsFeatured = message.IsFeatured,
|
||||
Status = message.Status,
|
||||
@ -216,4 +218,24 @@ public class CommunityMessageService(BaseRepository<CommunityMessage> messageRep
|
||||
|
||||
logger.LogInformation("社区消息排序权重设置成功,ID: {Id}, SortOrder: {SortOrder}", id, sortOrder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量发布消息
|
||||
/// </summary>
|
||||
public async Task BatchPublishAsync(List<long> ids)
|
||||
{
|
||||
logger.LogInformation("正在批量发布社区消息,数量: {Count}", ids.Count);
|
||||
|
||||
if (ids == null || ids.Count == 0)
|
||||
{
|
||||
throw new BusinessException("消息ID列表不能为空", 400);
|
||||
}
|
||||
|
||||
var result = await Context.Updateable<CommunityMessage>()
|
||||
.SetColumns(m => m.IsActive == true)
|
||||
.Where(m => ids.Contains(m.Id))
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
logger.LogInformation("批量发布社区消息完成,影响行数: {Result}", result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user