增加称号跟徽章接口
This commit is contained in:
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