refactor: 批量新增枚举类型并完成实体、DTO、服务层枚举替换
- 新增30+业务枚举类型覆盖用户、宠物、商城、社区、积分等模块 - 完成实体类、DTO、服务层的字符串枚举替换为强类型枚举 - 修复用户状态枚举名称变更,将Frozen改为Disabled - 新增批量发布社区消息接口与控制器实现 - 新增操作日志、积分管理、补偿任务相关服务与DTO
This commit is contained in:
@ -101,7 +101,7 @@ public class CommunityMessageController : BaseController
|
||||
try
|
||||
{
|
||||
await _communityMessageService.FreezeAsync(id, input.Status);
|
||||
return Success(new object(), input.Status == 2 ? "冻结消息成功" : "解冻消息成功");
|
||||
return Success(new object(), input.Status == (int)MessageStatusEnum.Frozen ? "冻结消息成功" : "解冻消息成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
@ -160,4 +160,27 @@ public class CommunityMessageController : BaseController
|
||||
return BaseResponse<object>.Fail("操作失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量发布消息
|
||||
/// </summary>
|
||||
[HttpPost("batch-publish")]
|
||||
public async Task<BaseResponse<object>> BatchPublishAsync([FromBody] AdminBatchPublishInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _communityMessageService.BatchPublishAsync(input.Ids);
|
||||
return Success(new object(), "批量发布消息成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "批量发布社区消息业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<object>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "批量发布社区消息系统异常,IDs:{Ids}", input.Ids);
|
||||
return BaseResponse<object>.Fail("批量发布消息失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,124 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using QYZH.InteractiveMagazine.IService;
|
||||
using QYZH.InteractiveMagazine.Models.Common;
|
||||
using QYZH.InteractiveMagazine.Models.Dto;
|
||||
using QYZH.InteractiveMagazine.Models.Dto.Compensation;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.WebApi.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 补偿任务管理控制器
|
||||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class CompensationManageController : BaseController
|
||||
{
|
||||
private readonly ICompensationManageService _compensationManageService;
|
||||
private readonly ILogger<CompensationManageController> _logger;
|
||||
|
||||
public CompensationManageController(ICompensationManageService compensationManageService, ILogger<CompensationManageController> logger)
|
||||
{
|
||||
_compensationManageService = compensationManageService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询补偿任务列表
|
||||
/// </summary>
|
||||
[HttpPost("list")]
|
||||
public async Task<BaseResponse<PageListModel<CompensationManageOutput>>> GetList([FromBody] CompensationTaskQueryInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _compensationManageService.GetListAsync(input);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "查询补偿任务列表业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PageListModel<CompensationManageOutput>>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "查询补偿任务列表系统异常");
|
||||
return BaseResponse<PageListModel<CompensationManageOutput>>.Fail("查询补偿任务列表失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取补偿任务详情
|
||||
/// </summary>
|
||||
[HttpGet("{id}/detail")]
|
||||
public async Task<BaseResponse<CompensationManageDetailOutput>> GetDetail(long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _compensationManageService.GetDetailAsync(id);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "获取补偿任务详情业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<CompensationManageDetailOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "获取补偿任务详情系统异常,TaskId: {TaskId}", id);
|
||||
return BaseResponse<CompensationManageDetailOutput>.Fail("获取补偿任务详情失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手动重试补偿任务
|
||||
/// </summary>
|
||||
[HttpPost("{id}/retry")]
|
||||
public async Task<BaseResponse<object>> Retry(long id, [FromBody] CompensationRetryInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var operatorId = GetCurrentUserId() ?? 0;
|
||||
var operatorName = GetCurrentUserName() ?? "Unknown";
|
||||
var ipAddress = HttpContext.Connection.RemoteIpAddress?.ToString();
|
||||
|
||||
await _compensationManageService.RetryAsync(id, operatorId, operatorName, input, ipAddress);
|
||||
return Success(new object(), "补偿任务已重置为待处理状态");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "手动重试补偿任务业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<object>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "手动重试补偿任务系统异常,TaskId: {TaskId}", id);
|
||||
return BaseResponse<object>.Fail("手动重试失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 标记补偿任务为已解决
|
||||
/// </summary>
|
||||
[HttpPost("{id}/resolve")]
|
||||
public async Task<BaseResponse<object>> Resolve(long id, [FromBody] CompensationResolveInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var operatorId = GetCurrentUserId() ?? 0;
|
||||
var operatorName = GetCurrentUserName() ?? "Unknown";
|
||||
var ipAddress = HttpContext.Connection.RemoteIpAddress?.ToString();
|
||||
|
||||
await _compensationManageService.ResolveAsync(id, operatorId, operatorName, input, ipAddress);
|
||||
return Success(new object(), "补偿任务已标记为已解决");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "标记补偿任务已解决业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<object>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "标记补偿任务已解决系统异常,TaskId: {TaskId}", id);
|
||||
return BaseResponse<object>.Fail("标记已解决失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using QYZH.InteractiveMagazine.IService;
|
||||
using QYZH.InteractiveMagazine.Models.Common;
|
||||
using QYZH.InteractiveMagazine.Models.Dto;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.WebApi.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 操作日志控制器
|
||||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class OperationLogController : BaseController
|
||||
{
|
||||
private readonly IOperationLogService _operationLogService;
|
||||
private readonly ILogger<OperationLogController> _logger;
|
||||
|
||||
public OperationLogController(IOperationLogService operationLogService, ILogger<OperationLogController> logger)
|
||||
{
|
||||
_operationLogService = operationLogService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询操作日志
|
||||
/// </summary>
|
||||
[HttpPost("list")]
|
||||
public async Task<BaseResponse<PageListModel<OperationLogOutput>>> GetList([FromBody] OperationLogQueryInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _operationLogService.GetListAsync(input);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "查询操作日志业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PageListModel<OperationLogOutput>>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "查询操作日志系统异常");
|
||||
return BaseResponse<PageListModel<OperationLogOutput>>.Fail("查询操作日志失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取操作日志详情
|
||||
/// </summary>
|
||||
[HttpGet("{id}")]
|
||||
public async Task<BaseResponse<OperationLogDetailOutput>> GetDetail(long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _operationLogService.GetDetailAsync(id);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "查询操作日志详情业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<OperationLogDetailOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "查询操作日志详情系统异常");
|
||||
return BaseResponse<OperationLogDetailOutput>.Fail("查询操作日志详情失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,494 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using QYZH.InteractiveMagazine.IService;
|
||||
using QYZH.InteractiveMagazine.Models.Common;
|
||||
using QYZH.InteractiveMagazine.Models.Dto;
|
||||
using QYZH.InteractiveMagazine.Models.Dto.Pet;
|
||||
using QYZH.InteractiveMagazine.Models.Enum;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.WebApi.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 宠物管理控制器(后台)
|
||||
/// </summary>
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
[ApiExplorerSettings(GroupName = nameof(ApiVersionEnum.Platform))]
|
||||
public class PetManageController : BaseController
|
||||
{
|
||||
private readonly IPetService _petService;
|
||||
private readonly ILogger<PetManageController> _logger;
|
||||
|
||||
public PetManageController(IPetService petService, ILogger<PetManageController> logger)
|
||||
{
|
||||
_petService = petService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
// ==================== 宠物模板管理 ====================
|
||||
|
||||
/// <summary>
|
||||
/// 创建宠物模板
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<BaseResponse<PetTemplateOutput>> CreateTemplateAsync([FromBody] PetTemplateInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.CreateTemplateAsync(input);
|
||||
return Success(result, "创建宠物模板成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "创建宠物模板业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PetTemplateOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "创建宠物模板系统异常");
|
||||
return BaseResponse<PetTemplateOutput>.Fail("创建宠物模板失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新宠物模板
|
||||
/// </summary>
|
||||
[HttpPut("{id}")]
|
||||
public async Task<BaseResponse<PetTemplateOutput>> UpdateTemplateAsync(long id, [FromBody] PetTemplateInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.UpdateTemplateAsync(id, input);
|
||||
return Success(result, "更新宠物模板成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "更新宠物模板业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PetTemplateOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "更新宠物模板系统异常,ID:{Id}", id);
|
||||
return BaseResponse<PetTemplateOutput>.Fail("更新宠物模板失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除宠物模板
|
||||
/// </summary>
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<BaseResponse<object>> DeleteTemplateAsync(long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _petService.DeleteTemplateAsync(id);
|
||||
return Success(new object(), "删除宠物模板成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "删除宠物模板业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<object>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "删除宠物模板系统异常,ID:{Id}", id);
|
||||
return BaseResponse<object>.Fail("删除宠物模板失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个宠物模板
|
||||
/// </summary>
|
||||
[HttpGet("{id}")]
|
||||
public async Task<BaseResponse<PetTemplateOutput>> GetTemplateByIdAsync(long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.GetTemplateByIdAsync(id);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "获取宠物模板业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PetTemplateOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "获取宠物模板系统异常,ID:{Id}", id);
|
||||
return BaseResponse<PetTemplateOutput>.Fail("获取宠物模板失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询宠物模板列表
|
||||
/// </summary>
|
||||
[HttpPost("list")]
|
||||
public async Task<BaseResponse<PageListModel<PetTemplateOutput>>> GetTemplatesAsync([FromBody] PetTemplateQueryInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.GetTemplatesAsync(input);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "查询宠物模板列表业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PageListModel<PetTemplateOutput>>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "查询宠物模板列表系统异常");
|
||||
return BaseResponse<PageListModel<PetTemplateOutput>>.Fail("查询宠物模板列表失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新宠物模板状态(启用/禁用)
|
||||
/// </summary>
|
||||
[HttpPut("{id}/status")]
|
||||
public async Task<BaseResponse<object>> UpdateTemplateStatusAsync(long id, [FromBody] string status)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _petService.UpdateTemplateStatusAsync(id, status);
|
||||
return Success(new object(), "更新状态成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "更新模板状态业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<object>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "更新模板状态系统异常,ID:{Id}", id);
|
||||
return BaseResponse<object>.Fail("更新模板状态失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 进化链管理 ====================
|
||||
|
||||
/// <summary>
|
||||
/// 创建进化阶段
|
||||
/// </summary>
|
||||
[HttpPost("evolution")]
|
||||
public async Task<BaseResponse<PetEvolutionOutput>> CreateEvolutionAsync([FromBody] PetEvolutionInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.CreateEvolutionAsync(input);
|
||||
return Success(result, "创建进化阶段成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "创建进化阶段业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PetEvolutionOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "创建进化阶段系统异常");
|
||||
return BaseResponse<PetEvolutionOutput>.Fail("创建进化阶段失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新进化阶段
|
||||
/// </summary>
|
||||
[HttpPut("evolution/{id}")]
|
||||
public async Task<BaseResponse<PetEvolutionOutput>> UpdateEvolutionAsync(long id, [FromBody] PetEvolutionInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.UpdateEvolutionAsync(id, input);
|
||||
return Success(result, "更新进化阶段成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "更新进化阶段业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PetEvolutionOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "更新进化阶段系统异常,ID:{Id}", id);
|
||||
return BaseResponse<PetEvolutionOutput>.Fail("更新进化阶段失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除进化阶段
|
||||
/// </summary>
|
||||
[HttpDelete("evolution/{id}")]
|
||||
public async Task<BaseResponse<object>> DeleteEvolutionAsync(long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _petService.DeleteEvolutionAsync(id);
|
||||
return Success(new object(), "删除进化阶段成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "删除进化阶段业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<object>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "删除进化阶段系统异常,ID:{Id}", id);
|
||||
return BaseResponse<object>.Fail("删除进化阶段失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个进化阶段
|
||||
/// </summary>
|
||||
[HttpGet("evolution/{id}")]
|
||||
public async Task<BaseResponse<PetEvolutionOutput>> GetEvolutionByIdAsync(long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.GetEvolutionByIdAsync(id);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "获取进化阶段业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PetEvolutionOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "获取进化阶段系统异常,ID:{Id}", id);
|
||||
return BaseResponse<PetEvolutionOutput>.Fail("获取进化阶段失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询进化阶段列表
|
||||
/// </summary>
|
||||
[HttpPost("evolution/list")]
|
||||
public async Task<BaseResponse<PageListModel<PetEvolutionOutput>>> GetEvolutionsAsync([FromBody] PetEvolutionQueryInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.GetEvolutionsAsync(input);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "查询进化阶段列表业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PageListModel<PetEvolutionOutput>>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "查询进化阶段列表系统异常");
|
||||
return BaseResponse<PageListModel<PetEvolutionOutput>>.Fail("查询进化阶段列表失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 皮肤管理 ====================
|
||||
|
||||
/// <summary>
|
||||
/// 创建皮肤
|
||||
/// </summary>
|
||||
[HttpPost("skin")]
|
||||
public async Task<BaseResponse<PetSkinOutput>> CreateSkinAsync([FromBody] PetSkinInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.CreateSkinAsync(input);
|
||||
return Success(result, "创建皮肤成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "创建皮肤业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PetSkinOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "创建皮肤系统异常");
|
||||
return BaseResponse<PetSkinOutput>.Fail("创建皮肤失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新皮肤
|
||||
/// </summary>
|
||||
[HttpPut("skin/{id}")]
|
||||
public async Task<BaseResponse<PetSkinOutput>> UpdateSkinAsync(long id, [FromBody] PetSkinInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.UpdateSkinAsync(id, input);
|
||||
return Success(result, "更新皮肤成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "更新皮肤业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PetSkinOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "更新皮肤系统异常,ID:{Id}", id);
|
||||
return BaseResponse<PetSkinOutput>.Fail("更新皮肤失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除皮肤
|
||||
/// </summary>
|
||||
[HttpDelete("skin/{id}")]
|
||||
public async Task<BaseResponse<object>> DeleteSkinAsync(long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _petService.DeleteSkinAsync(id);
|
||||
return Success(new object(), "删除皮肤成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "删除皮肤业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<object>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "删除皮肤系统异常,ID:{Id}", id);
|
||||
return BaseResponse<object>.Fail("删除皮肤失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个皮肤(含图片列表)
|
||||
/// </summary>
|
||||
[HttpGet("skin/{id}")]
|
||||
public async Task<BaseResponse<PetSkinOutput>> GetSkinByIdAsync(long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.GetSkinByIdAsync(id);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "获取皮肤业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PetSkinOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "获取皮肤系统异常,ID:{Id}", id);
|
||||
return BaseResponse<PetSkinOutput>.Fail("获取皮肤失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页查询皮肤列表
|
||||
/// </summary>
|
||||
[HttpPost("skin/list")]
|
||||
public async Task<BaseResponse<PageListModel<PetSkinOutput>>> GetSkinsAsync([FromBody] PetSkinQueryInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.GetSkinsAsync(input);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "查询皮肤列表业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PageListModel<PetSkinOutput>>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "查询皮肤列表系统异常");
|
||||
return BaseResponse<PageListModel<PetSkinOutput>>.Fail("查询皮肤列表失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 皮肤图片管理 ====================
|
||||
|
||||
/// <summary>
|
||||
/// 创建皮肤图片
|
||||
/// </summary>
|
||||
[HttpPost("skin-image")]
|
||||
public async Task<BaseResponse<PetSkinImageOutput>> CreateSkinImageAsync([FromBody] PetSkinImageInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.CreateSkinImageAsync(input);
|
||||
return Success(result, "创建皮肤图片成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "创建皮肤图片业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PetSkinImageOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "创建皮肤图片系统异常");
|
||||
return BaseResponse<PetSkinImageOutput>.Fail("创建皮肤图片失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新皮肤图片
|
||||
/// </summary>
|
||||
[HttpPut("skin-image/{id}")]
|
||||
public async Task<BaseResponse<PetSkinImageOutput>> UpdateSkinImageAsync(long id, [FromBody] PetSkinImageInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.UpdateSkinImageAsync(id, input);
|
||||
return Success(result, "更新皮肤图片成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "更新皮肤图片业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<PetSkinImageOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "更新皮肤图片系统异常,ID:{Id}", id);
|
||||
return BaseResponse<PetSkinImageOutput>.Fail("更新皮肤图片失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除皮肤图片
|
||||
/// </summary>
|
||||
[HttpDelete("skin-image/{id}")]
|
||||
public async Task<BaseResponse<object>> DeleteSkinImageAsync(long id)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _petService.DeleteSkinImageAsync(id);
|
||||
return Success(new object(), "删除皮肤图片成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "删除皮肤图片业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<object>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "删除皮肤图片系统异常,ID:{Id}", id);
|
||||
return BaseResponse<object>.Fail("删除皮肤图片失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定皮肤的所有图片
|
||||
/// </summary>
|
||||
[HttpGet("skin-images/{skinId}")]
|
||||
public async Task<BaseResponse<List<PetSkinImageOutput>>> GetSkinImagesAsync(long skinId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _petService.GetSkinImagesBySkinIdAsync(skinId);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "获取皮肤图片列表业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<List<PetSkinImageOutput>>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "获取皮肤图片列表系统异常,SkinId:{SkinId}", skinId);
|
||||
return BaseResponse<List<PetSkinImageOutput>>.Fail("获取皮肤图片列表失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ using QYZH.InteractiveMagazine.IService;
|
||||
|
||||
using QYZH.InteractiveMagazine.Models.Common;
|
||||
using QYZH.InteractiveMagazine.Models.Dto;
|
||||
using QYZH.InteractiveMagazine.Models.Dto.Points;
|
||||
|
||||
namespace QYZH.InteractiveMagazine.WebApi.Controllers;
|
||||
|
||||
@ -32,10 +33,10 @@ public class UsersController : BaseController
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户详情
|
||||
/// 获取用户详情(包含积分记录、签到记录、补偿任务、期刊列表)
|
||||
/// </summary>
|
||||
[HttpGet("{id}")]
|
||||
public async Task<BaseResponse<UsersOutput>> GetDetail(long id)
|
||||
public async Task<BaseResponse<UserDetailOutput>> GetDetail(long id)
|
||||
{
|
||||
return await _usersService.GetDetailAsync(id);
|
||||
}
|
||||
@ -48,4 +49,58 @@ public class UsersController : BaseController
|
||||
{
|
||||
return await _usersService.UpdateStatusAsync(id, input);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手动增加用户积分
|
||||
/// </summary>
|
||||
[HttpPost("{userId}/points/add")]
|
||||
public async Task<BaseResponse<ManualPointsOutput>> ManualAddPoints(long userId, [FromBody] ManualAddPointsInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var operatorId = GetCurrentUserId() ?? 0;
|
||||
var operatorName = GetCurrentUserName() ?? "Unknown";
|
||||
var ipAddress = HttpContext.Connection.RemoteIpAddress?.ToString();
|
||||
|
||||
var result = await _usersService.ManualAddPointsAsync(userId, input, operatorId, operatorName, ipAddress);
|
||||
return Success(result, "手动增加积分成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "手动增加积分业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<ManualPointsOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "手动增加积分系统异常,UserId: {UserId}", userId);
|
||||
return BaseResponse<ManualPointsOutput>.Fail("手动增加积分失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手动扣除用户积分
|
||||
/// </summary>
|
||||
[HttpPost("{userId}/points/deduct")]
|
||||
public async Task<BaseResponse<ManualPointsOutput>> ManualDeductPoints(long userId, [FromBody] ManualDeductPointsInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var operatorId = GetCurrentUserId() ?? 0;
|
||||
var operatorName = GetCurrentUserName() ?? "Unknown";
|
||||
var ipAddress = HttpContext.Connection.RemoteIpAddress?.ToString();
|
||||
|
||||
var result = await _usersService.ManualDeductPointsAsync(userId, input, operatorId, operatorName, ipAddress);
|
||||
return Success(result, "手动扣除积分成功");
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "手动扣除积分业务异常: {Message}", ex.Message);
|
||||
return BaseResponse<ManualPointsOutput>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "手动扣除积分系统异常,UserId: {UserId}", userId);
|
||||
return BaseResponse<ManualPointsOutput>.Fail("手动扣除积分失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user