91 lines
3.0 KiB
C#
91 lines
3.0 KiB
C#
using System.Linq;
|
|
using AdminDomain.BeautifulNumber;
|
|
using AdminDomain.Entity;
|
|
using Common;
|
|
using Common.CommonModel;
|
|
using CommonInfrastructure;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using UserDomain.Entity;
|
|
using UserService.BeautifulNumber;
|
|
|
|
namespace UserApi.BeautifulNumber
|
|
{
|
|
[ApiController, Route("api/[controller]")]
|
|
[Authorize]
|
|
|
|
public class BeautifulNumberController : BaseController
|
|
{
|
|
private readonly IBeautifulNumberService _beautifulNumberService;
|
|
|
|
public BeautifulNumberController(IBeautifulNumberService beautifulNumberService)
|
|
{
|
|
_beautifulNumberService = beautifulNumberService;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取可购买的靓号列表
|
|
/// </summary>
|
|
[HttpGet("available")]
|
|
public async Task<PageResponse<BeautifulNumberDto>> GetAvailableList([FromQuery] BeautifulNumberListParam param)
|
|
{
|
|
param.page = param.page > 0 ? param.page : 1;
|
|
param.size = param.size > 0 ? param.size : 20;
|
|
param.status = (int)BeautifulNumberStatus.Available;
|
|
var result = await _beautifulNumberService.GetList(param);
|
|
var dtos = result.Data.Select(MapToDto).ToList();
|
|
return this.ToPageResult(dtos, result.Count);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询靓号信息
|
|
/// </summary>
|
|
[HttpGet("check/{number}")]
|
|
public async Task<BaseResponse<BeautifulNumberDto>> CheckNumber(string number)
|
|
{
|
|
var result = await _beautifulNumberService.CheckNumber(number);
|
|
return this.ToResult(MapToDto(result));
|
|
}
|
|
|
|
private static BeautifulNumberDto MapToDto(BeautifulNumberConfig entity)
|
|
{
|
|
if (entity == null) return new BeautifulNumberDto();
|
|
return new BeautifulNumberDto
|
|
{
|
|
Id = entity.Id ?? "",
|
|
Number = entity.Number ?? "",
|
|
RuleName = entity.RuleName ?? "",
|
|
Level = entity.Level ?? "",
|
|
Price = entity.Price,
|
|
Status = (int)entity.Status,
|
|
SaleTime = entity.SaleTime,
|
|
BuyerUserId = entity.BuyerUserId ?? "",
|
|
UserId = entity.UserId ?? "",
|
|
Remark = entity.Remark ?? "",
|
|
CreateTime = entity.CreateTime
|
|
};
|
|
}
|
|
}
|
|
|
|
public class BeautifulNumberDto
|
|
{
|
|
public string Id { get; set; }
|
|
public string Number { get; set; }
|
|
public string RuleName { get; set; }
|
|
public string Level { get; set; }
|
|
public long Price { get; set; }
|
|
public int Status { get; set; }
|
|
public long SaleTime { get; set; }
|
|
public string BuyerUserId { get; set; }
|
|
public string UserId { get; set; }
|
|
public string Remark { get; set; }
|
|
public long CreateTime { get; set; }
|
|
}
|
|
|
|
public class PurchaseBeautifulNumberParam
|
|
{
|
|
public string Number { get; set; }
|
|
}
|
|
}
|