refactor: 批量新增枚举类型并完成实体、DTO、服务层枚举替换
- 新增30+业务枚举类型覆盖用户、宠物、商城、社区、积分等模块 - 完成实体类、DTO、服务层的字符串枚举替换为强类型枚举 - 修复用户状态枚举名称变更,将Frozen改为Disabled - 新增批量发布社区消息接口与控制器实现 - 新增操作日志、积分管理、补偿任务相关服务与DTO
This commit is contained in:
@ -4,6 +4,7 @@ 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;
|
||||
|
||||
@ -38,7 +39,7 @@ public class MedalService(BaseRepository<Medal> medalRepository, ILogger<MedalSe
|
||||
Description = input.Description,
|
||||
ImageUrl = input.ImageUrl,
|
||||
SortOrder = input.SortOrder,
|
||||
Type = input.Type,
|
||||
Type = Enum.Parse<MedalTypeEnum>(input.Type, true),
|
||||
JournalId = input.JournalId,
|
||||
CreatedBy = "System",
|
||||
UpdatedBy = "System",
|
||||
@ -107,7 +108,7 @@ public class MedalService(BaseRepository<Medal> medalRepository, ILogger<MedalSe
|
||||
medal.Description = input.Description;
|
||||
medal.ImageUrl = input.ImageUrl;
|
||||
medal.SortOrder = input.SortOrder;
|
||||
medal.Type = input.Type;
|
||||
medal.Type = Enum.Parse<MedalTypeEnum>(input.Type, true);
|
||||
medal.JournalId = input.JournalId;
|
||||
medal.UpdatedBy = "System";
|
||||
medal.UpdatedAt = DateTime.Now;
|
||||
@ -232,7 +233,7 @@ public class MedalService(BaseRepository<Medal> medalRepository, ILogger<MedalSe
|
||||
RefAsync<int> totalNumber = 0;
|
||||
var medals = await medalRepository.Queryable()
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.Name), m => m.Name.Contains(input.Name))
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.Type), m => m.Type == input.Type)
|
||||
.WhereIF(!string.IsNullOrWhiteSpace(input.Type), m => m.Type.ToString() == input.Type)
|
||||
.OrderBy(m => m.SortOrder)
|
||||
.OrderByDescending(m => m.CreatedAt)
|
||||
.ToPageListAsync(input.PageIndex, input.PageSize, totalNumber);
|
||||
@ -313,7 +314,7 @@ public class MedalService(BaseRepository<Medal> medalRepository, ILogger<MedalSe
|
||||
.ToListAsync();
|
||||
|
||||
var userMedals = await Context.Queryable<UserMedal>()
|
||||
.Where(um => um.UserId == userId && um.Status == "Awarded")
|
||||
.Where(um => um.UserId == userId && um.Status == UserMedalStatusEnum.Awarded)
|
||||
.ToListAsync();
|
||||
|
||||
var userMedalDict = userMedals.ToDictionary(um => um.MedalId, um => um.AwardedAt);
|
||||
@ -325,7 +326,7 @@ public class MedalService(BaseRepository<Medal> medalRepository, ILogger<MedalSe
|
||||
Description = m.Description,
|
||||
ImageUrl = m.ImageUrl,
|
||||
SortOrder = m.SortOrder,
|
||||
Type = m.Type,
|
||||
Type = m.Type.ToString(),
|
||||
IsOwned = userMedalDict.ContainsKey((int)m.Id),
|
||||
AwardedAt = userMedalDict.TryGetValue((int)m.Id, out var awardedAt) ? awardedAt : null
|
||||
}).ToList();
|
||||
@ -340,7 +341,7 @@ public class MedalService(BaseRepository<Medal> medalRepository, ILogger<MedalSe
|
||||
|
||||
var result = await Context.Queryable<UserMedal>()
|
||||
.InnerJoin<Medal>((um, m) => um.MedalId == m.Id)
|
||||
.Where((um, m) => um.UserId == userId && um.Status == "Awarded")
|
||||
.Where((um, m) => um.UserId == userId && um.Status == UserMedalStatusEnum.Awarded)
|
||||
.OrderByDescending((um, m) => um.AwardedAt)
|
||||
.Select((um, m) => new WxUserMedalOutput
|
||||
{
|
||||
@ -348,9 +349,9 @@ public class MedalService(BaseRepository<Medal> medalRepository, ILogger<MedalSe
|
||||
Name = m.Name,
|
||||
Description = m.Description,
|
||||
ImageUrl = m.ImageUrl,
|
||||
Type = m.Type,
|
||||
Type = m.Type.ToString(),
|
||||
AwardedAt = um.AwardedAt,
|
||||
Status = um.Status
|
||||
Status = um.Status.ToString()
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
@ -390,7 +391,7 @@ public class MedalService(BaseRepository<Medal> medalRepository, ILogger<MedalSe
|
||||
}
|
||||
|
||||
var existingUserMedal = await Context.Queryable<UserMedal>()
|
||||
.Where(um => um.UserId == userId && um.MedalId == (int)input.MedalId && um.Status == "Awarded")
|
||||
.Where(um => um.UserId == userId && um.MedalId == (int)input.MedalId && um.Status == UserMedalStatusEnum.Awarded)
|
||||
.FirstAsync();
|
||||
|
||||
if (existingUserMedal != null)
|
||||
@ -403,8 +404,8 @@ public class MedalService(BaseRepository<Medal> medalRepository, ILogger<MedalSe
|
||||
UserId = userId,
|
||||
MedalId = (int)input.MedalId,
|
||||
AwardedAt = DateTime.Now,
|
||||
Type = medal.Type,
|
||||
Status = "Awarded",
|
||||
Type = (UserMedalTypeEnum)medal.Type,
|
||||
Status = UserMedalStatusEnum.Awarded,
|
||||
CreatedBy = "System",
|
||||
UpdatedBy = "System",
|
||||
CreatedAt = DateTime.Now,
|
||||
@ -472,7 +473,7 @@ public class MedalService(BaseRepository<Medal> medalRepository, ILogger<MedalSe
|
||||
Description = medal.Description,
|
||||
ImageUrl = medal.ImageUrl,
|
||||
SortOrder = medal.SortOrder,
|
||||
Type = medal.Type,
|
||||
Type = medal.Type.ToString(),
|
||||
JournalId = medal.JournalId,
|
||||
Rules = rules,
|
||||
CreatedBy = medal.CreatedBy,
|
||||
|
||||
Reference in New Issue
Block a user