refactor: 批量新增枚举类型并完成实体、DTO、服务层枚举替换
- 新增30+业务枚举类型覆盖用户、宠物、商城、社区、积分等模块 - 完成实体类、DTO、服务层的字符串枚举替换为强类型枚举 - 修复用户状态枚举名称变更,将Frozen改为Disabled - 新增批量发布社区消息接口与控制器实现 - 新增操作日志、积分管理、补偿任务相关服务与DTO
This commit is contained in:
@ -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