增加称号跟徽章接口
This commit is contained in:
101
Service/Application.Web/Controllers/Pub/BadgeController.cs
Normal file
101
Service/Application.Web/Controllers/Pub/BadgeController.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using Application.Domain.Services;
|
||||
using Application.Web.Model.RequestParms.Maxname;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Application.Web.Controllers.Pub
|
||||
{
|
||||
/// <summary>
|
||||
/// 徽章接口
|
||||
/// </summary>
|
||||
[Route("[controller]/[action]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class BadgeController : ControllerBase
|
||||
{
|
||||
private readonly IGameBadgeService badgeService;
|
||||
public BadgeController(IGameBadgeService _badgeService)
|
||||
{
|
||||
badgeService = _badgeService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户徽章列表
|
||||
/// </summary>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserBadgeList(int page)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
string userId = StateHelper.userId;
|
||||
var list = await badgeService.GetUserBadgeList(userId, page, 10, total);
|
||||
return PoAction.Ok(new { list, total });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取徽章详情
|
||||
/// </summary>
|
||||
/// <param name="ubId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserBadgeInfo(string ubId)
|
||||
{
|
||||
var data = await badgeService.GetUserBadegInfo(ubId);
|
||||
if (data == null)
|
||||
{
|
||||
return PoAction.Message("徽章信息不存在!");
|
||||
}
|
||||
string userId = StateHelper.userId;
|
||||
if (data.userId != userId)
|
||||
{
|
||||
return PoAction.Message("徽章信息不存在!");
|
||||
}
|
||||
return PoAction.Ok(new { data });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改徽章展示不展示
|
||||
/// </summary>
|
||||
/// <param name="par"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IPoAction> UpdateBadgeShow([FromBody] UpdateBadgeParms par)
|
||||
{
|
||||
var data = await badgeService.GetUserBadegInfo(par.ubId);
|
||||
if (data == null)
|
||||
{
|
||||
return PoAction.Message("徽章信息不存在!");
|
||||
}
|
||||
string userId = StateHelper.userId;
|
||||
if (data.userId != userId)
|
||||
{
|
||||
return PoAction.Message("徽章信息不存在!");
|
||||
}
|
||||
//int onCount = await badgeService.GetUserShowBadgeOnCount(userId);
|
||||
//int showCount = await badgeService.GetUserShowBadgeCount(userId);
|
||||
//if (onCount == 0)
|
||||
//{
|
||||
// if (showCount >= 1)
|
||||
// {
|
||||
// return PoAction.Message("您最多可以同时展示1个徽章!");
|
||||
// }
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// if (showCount >= onCount)
|
||||
// {
|
||||
// return PoAction.Message(string.Format("您最多可以同时展示{0}个徽章!", onCount));
|
||||
// }
|
||||
//}
|
||||
int show = data.show == 1 ? 0 : 1;
|
||||
if (await badgeService.UpdateUserBadgeShow(par.ubId, show))
|
||||
{
|
||||
return PoAction.Ok("操作成功!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("操作失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
84
Service/Application.Web/Controllers/Pub/MaxnameController.cs
Normal file
84
Service/Application.Web/Controllers/Pub/MaxnameController.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using Application.Web.Model.RequestParms.Maxname;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Application.Web.Controllers.Pub
|
||||
{
|
||||
/// <summary>
|
||||
/// 称号接口
|
||||
/// </summary>
|
||||
[Route("[controller]/[action]")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class MaxnameController : ControllerBase
|
||||
{
|
||||
private readonly IGameMaxNameService maxnameService;
|
||||
public MaxnameController(IGameMaxNameService _maxnameService)
|
||||
{
|
||||
maxnameService = _maxnameService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户称号列表
|
||||
/// </summary>
|
||||
/// <param name="page"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserMaxnameList(int page)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
string userId = StateHelper.userId;
|
||||
var list = await maxnameService.GetUserMaxnameList(userId, page, 10, total);
|
||||
return PoAction.Ok(new { list, total });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取称号详情
|
||||
/// </summary>
|
||||
/// <param name="umnId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<IPoAction> GetUserMaxnameInfo(string umnId)
|
||||
{
|
||||
var data = await maxnameService.GetUserMaxnameInfo(umnId);
|
||||
if (data == null)
|
||||
{
|
||||
return PoAction.Message("称号信息不存在!");
|
||||
}
|
||||
string userId = StateHelper.userId;
|
||||
if (data.userId != userId)
|
||||
{
|
||||
return PoAction.Message("称号信息不存在!");
|
||||
}
|
||||
return PoAction.Ok(new { data });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改称号展示不展示
|
||||
/// </summary>
|
||||
/// <param name="par"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IPoAction> UpdateMaxnameShow([FromBody] UpdateMaxnameParms par)
|
||||
{
|
||||
var data = await maxnameService.GetUserMaxnameInfo(par.umnId);
|
||||
if (data == null)
|
||||
{
|
||||
return PoAction.Message("称号信息不存在!");
|
||||
}
|
||||
string userId = StateHelper.userId;
|
||||
if (data.userId != userId)
|
||||
{
|
||||
return PoAction.Message("称号信息不存在!");
|
||||
}
|
||||
data.show = data.show == 1 ? 0 : 1;
|
||||
if (await maxnameService.UpdateUserMaxname(data))
|
||||
{
|
||||
return PoAction.Ok("操作成功!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return PoAction.Message("操作失败!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user