NewGaoKaoApi/New_College.Api/Controllers/Back/VipCardController.cs

151 lines
4.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using New_College.IServices;
using New_College.Model;
using New_College.Model.Models;
using New_College.Model.ViewModels;
using New_College.Model.ViewModels.Query;
namespace New_College.Api.Controllers.Back
{
[Route("api/back/[controller]/[action]")]
[ApiController]
public class VipCardController : ControllerBase
{
private readonly IV_VipCardInfoServices iV_VipCardInfoServices;
private readonly IV_VipCardTypeServices iV_VipCardTypeServices;
private readonly IV_OrderInfoServices iV_OrderInfoServices;
private readonly IV_CustomerInfoServices _CustomerInfoServices;
public VipCardController(IV_VipCardInfoServices IV_VipCardInfoServices, IV_VipCardTypeServices IV_VipCardTypeServices, IV_OrderInfoServices IV_OrderInfoServices, IV_CustomerInfoServices customerInfoServices)
{
iV_VipCardInfoServices = IV_VipCardInfoServices;
iV_VipCardTypeServices = IV_VipCardTypeServices;
iV_OrderInfoServices = IV_OrderInfoServices;
_CustomerInfoServices = customerInfoServices;
}
/// <summary>
/// 生成卡信息
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<List<string>>> AutoVipCardInfo([FromBody] AutoVipInfoQuery query)
{
return await iV_VipCardInfoServices.AutoVipCardInfo(query);
}
/// <summary>
/// 获取分页
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<PageModel<VipCardInfoResult>>> GetVipCardInfoByPage([FromQuery] VipCardInfoSearchQuery query)
{
return await iV_VipCardInfoServices.GetVipCardInfoByPage(query);
}
/// <summary>
/// 获取单个
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<MessageModel<VipCardInfoResultOne>> GetVipCardInfoOne([FromQuery] IdQuery query)
{
return await iV_VipCardInfoServices.GetVipCardInfoOne(query);
}
/// <summary>
/// 添加
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<bool>> AddVipCardInfo([FromBody] VipCardInfoQuery query)
{
return await iV_VipCardInfoServices.AddVipCardInfo(query);
}
/// <summary>
/// 修改
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPut]
public async Task<MessageModel<bool>> UpdateVipCardInfo(VipCardInfoQuery query)
{
return await iV_VipCardInfoServices.UpdateVipCardInfo(query);
}
/// <summary>
/// 删除
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpPost]
public async Task<MessageModel<bool>> DeleteVipCardInfo([FromBody] IdQuery query)
{
return await iV_VipCardInfoServices.DeleteVipCardInfo(query);
}
/// <summary>
/// 获取vipcardTypeList
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<List<VipCardTypeQuery>> GetVipCardType()
{
return await iV_VipCardTypeServices.GetVipCardType();
}
/// <summary>
/// 根据用户是否为Vip获取相应权限
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
[HttpGet]
public async Task<VipPowerRolesViewsDTO> CheckRoles([FromQuery] IdQuery query)
{
var response = new VipPowerRolesViewsDTO();
var custom = await _CustomerInfoServices.Query(c => c.Id == query.CustomerId);
if (custom.Any())
{
response.IsVip = custom.FirstOrDefault().IsVIP;
response.pcRole = new PCRole()
{
ScoreCount = 10,
SearchCount = 99999
};
response.minProRole = new MinProRole()
{
ScoreCount = 10,
SearchCount = 99999
};
}
else
{
response.IsVip = false;
response.pcRole = new PCRole()
{
ScoreCount = 1,
SearchCount = 10
};
response.minProRole = new MinProRole()
{
ScoreCount = 1,
SearchCount = 10
};
}
return response;
}
}
}