62 lines
1.8 KiB
C#
62 lines
1.8 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
|
|
//using Syc.Basic.Web.Contracts;
|
|
using Syc.Basic.Web.WMS.Dtos.Token;
|
|
using Syc.Basic.Web.WMS.Entitys;
|
|
using Syc.Basic.Web.WMS.IServices;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Dynamic.Core;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.Domain.Repositories;
|
|
|
|
namespace Syc.Basic.Web.Service
|
|
{
|
|
public class TokenService : ApiService
|
|
{
|
|
private readonly IRepository<Token> token;
|
|
|
|
public TokenService(IRepository<Token> _token)
|
|
{
|
|
token = _token;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task Delete(TokenDeleteDto tokenDeleteDto)
|
|
{
|
|
if (tokenDeleteDto.ids.Any())
|
|
{
|
|
for (int i = 0; i < tokenDeleteDto.ids.Length; i++)
|
|
await token.DeleteAsync(x => x.Id == tokenDeleteDto.ids[i]);
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<PageOutput<Token>> GetAllTokenPage(TokenAllDto tokenAllDto)
|
|
{
|
|
var data = await token.GetQueryableAsync();
|
|
if (!string.IsNullOrWhiteSpace(tokenAllDto.username))
|
|
data = data.Where(x => x.Client.Contains(tokenAllDto.username));
|
|
|
|
PageOutput<Token> pageOutput = new PageOutput<Token>();
|
|
pageOutput.Total = await token.CountAsync();
|
|
pageOutput.Data = data.OrderByDescending(x => x.Createtime).Page(tokenAllDto.page, tokenAllDto.pageSize);
|
|
|
|
return pageOutput;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task Update(TokenUpdateDto tokenUpdateDto)
|
|
{
|
|
var _Token = await token.FirstOrDefaultAsync(x => x.Id == tokenUpdateDto.Id);
|
|
|
|
if (_Token is not null)
|
|
{
|
|
_Token.Status = tokenUpdateDto.Status;
|
|
await token.UpdateAsync(_Token);
|
|
}
|
|
}
|
|
}
|
|
} |