Merge branch 'master' of http://8.137.159.94:3000/glz/QYZH.InteractiveMagazine
This commit is contained in:
@ -262,100 +262,4 @@ public class UserAnswerTaskController : WeChatBaseController
|
||||
return BaseResponse<BatchClaimPointsOutput>.Fail("批量领取积分失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取杂志列表
|
||||
/// </summary>
|
||||
/// <param name="queryType">查询类型:bound=已绑定,unbound=未绑定(添加杂志用列表),默认是:bound</param>
|
||||
/// <returns>杂志列表</returns>
|
||||
[HttpGet("journal-list")]
|
||||
public async Task<BaseResponse<List<JournalListOutput>>> GetJournalListAsync(string? queryType = "bound")
|
||||
{
|
||||
try
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
if (userId == 0)
|
||||
{
|
||||
return BaseResponse<List<JournalListOutput>>.Fail(ResultCode.DENY, "未获取到用户信息");
|
||||
}
|
||||
|
||||
var result = await _userAnswerTaskService.GetJournalListAsync(userId, queryType);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "查询杂志列表业务异常,UserId: {UserId}", GetCurrentUserId());
|
||||
return BaseResponse<List<JournalListOutput>>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "查询杂志列表失败,UserId: {UserId}", GetCurrentUserId());
|
||||
return BaseResponse<List<JournalListOutput>>.Fail("查询杂志列表失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定杂志(添加用户与杂志关联)
|
||||
/// </summary>
|
||||
/// <param name="journalId">杂志ID</param>
|
||||
/// <returns>是否绑定成功(已绑定过返回false)</returns>
|
||||
[HttpPost("add-user-journal/{journalId:long}")]
|
||||
public async Task<BaseResponse<bool>> AddUserJournalAsync([Required(ErrorMessage = "参数错误")] long journalId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
if (userId == 0)
|
||||
{
|
||||
return BaseResponse<bool>.Fail(ResultCode.DENY, "未获取到用户信息");
|
||||
}
|
||||
|
||||
var result = await _userAnswerTaskService.AddUserJournalAsync(journalId, userId);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "绑定杂志业务异常,UserId: {UserId}, JournalId: {JournalId}", GetCurrentUserId(), journalId);
|
||||
return BaseResponse<bool>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "绑定杂志失败,UserId: {UserId}, JournalId: {JournalId}", GetCurrentUserId(), journalId);
|
||||
return BaseResponse<bool>.Fail("绑定杂志失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增学生
|
||||
/// </summary>
|
||||
/// <param name="input">新增学生参数</param>
|
||||
/// <returns>新增学生结果</returns>
|
||||
[HttpPost("add-student")]
|
||||
public async Task<BaseResponse<bool>> AddStudentAsync([FromBody] AddStudentInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
var userId = GetCurrentUserId();
|
||||
if (userId == 0)
|
||||
{
|
||||
return BaseResponse<bool>.Fail(ResultCode.DENY, "未获取到用户信息");
|
||||
}
|
||||
if (GetCurrentWxUserId() == null)
|
||||
{
|
||||
return BaseResponse<bool>.Fail(ResultCode.DENY, "未获取到微信信息");
|
||||
}
|
||||
var result = await _userAnswerTaskService.AddStudentAsync(input, GetCurrentWxUserId()!.Value);
|
||||
return Success(result);
|
||||
}
|
||||
catch (BusinessException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "新增学生业务异常,UserId: {UserId}", GetCurrentUserId());
|
||||
return BaseResponse<bool>.Fail(ex.Message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "新增学生失败,UserId: {UserId}", GetCurrentUserId());
|
||||
return BaseResponse<bool>.Fail("新增学生失败,请稍后重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user