refactor: 重构用户与勋章体系,统一状态管理与数据结构

1.  新增通用默认状态枚举 DefaultStatusEnum,替换原有分散的状态枚举
2.  重构用户体系:拆分 WxUser 独立表存储微信身份,Users 表改为角色子用户表并关联 WxUser
3.  重构勋章模块:新增系统/期刊勋章类型,调整 JournalId 为可空,新增勋章状态字段
4.  重构微信认证流程:基于 WxUser 生成 Token,支持多子用户管理
5.  清理冗余枚举文件,重构多处业务逻辑适配新的数据结构
6.  修复用户手机号关联逻辑,迁移手机号字段至 WxUser 表
This commit is contained in:
glz
2026-06-10 13:47:13 +08:00
parent 296d87b245
commit 028e3dfb34
29 changed files with 477 additions and 515 deletions

View File

@ -112,7 +112,7 @@ public class PetService(
// 查询默认宠物模板取排序权重最低且状态为Active的模板
var defaultTemplate = await petTemplateRepository.Queryable()
.Where(t => t.Status == (int)PetTemplateStatusEnum.Active && !t.IsDeleted)
.Where(t => t.Status == (int)DefaultStatusEnum.Active && !t.IsDeleted)
.OrderBy(t => t.SortOrder)
.FirstAsync();
@ -137,7 +137,7 @@ public class PetService(
initialEvolution = await petEvolutionRepository.Queryable()
.Where(e => e.TemplateId == defaultTemplate.Id
&& e.PreviousEvolutionId == null
&& e.Status == (int)PetEvolutionStatusEnum.Active)
&& e.Status == (int)DefaultStatusEnum.Active)
.OrderBy(e => e.StageLevel)
.FirstAsync();
}
@ -279,7 +279,7 @@ public class PetService(
var nextEvolution = await petEvolutionRepository.Queryable()
.Where(e => e.PreviousEvolutionId == pet.CurrentEvolutionId
&& e.RequiredGrowth <= growthAfter
&& e.Status == (int)PetEvolutionStatusEnum.Active)
&& e.Status == (int)DefaultStatusEnum.Active)
.OrderBy(e => e.RequiredGrowth, OrderByType.Desc)
.FirstAsync();
@ -396,7 +396,7 @@ public class PetService(
IconUrl = input.IconUrl,
SortOrder = input.SortOrder,
Type = Enum.Parse<PetTemplateTypeEnum>(input.Type, true),
Status = (int)PetTemplateStatusEnum.Active,
Status = (int)DefaultStatusEnum.Active,
CreatedBy = "System",
CreatedAt = DateTime.Now,
UpdatedBy = "System",
@ -424,7 +424,7 @@ public class PetService(
RequiredGrowth = evoInput.RequiredGrowth,
PreviousEvolutionId = previousEvolution?.Id, // 第一个为 null
Type = Enum.Parse<PetEvolutionTypeEnum>(evoInput.Type, true),
Status = (int)PetEvolutionStatusEnum.Active,
Status = (int)DefaultStatusEnum.Active,
CreatedBy = "System",
CreatedAt = DateTime.Now,
UpdatedBy = "System",
@ -636,9 +636,9 @@ public class PetService(
if (template == null || template.IsDeleted)
throw new BusinessException("宠物模板不存在", 404);
template.Status = template.Status == (int)PetTemplateStatusEnum.Active
? (int)PetTemplateStatusEnum.Inactive
: (int)PetTemplateStatusEnum.Active;
template.Status = template.Status == (int)DefaultStatusEnum.Active
? (int)DefaultStatusEnum.Inactive
: (int)DefaultStatusEnum.Active;
template.UpdatedBy = "System";
template.UpdatedAt = DateTime.Now;
await petTemplateRepository.UpdateAsync(template);
@ -693,7 +693,7 @@ public class PetService(
RequiredGrowth = input.RequiredGrowth,
PreviousEvolutionId = input.PreviousEvolutionId,
Type = Enum.Parse<PetEvolutionTypeEnum>(input.Type, true),
Status = (int)PetEvolutionStatusEnum.Active,
Status = (int)DefaultStatusEnum.Active,
CreatedBy = "System",
CreatedAt = DateTime.Now,
UpdatedBy = "System",