返回json格式

This commit is contained in:
Jimmy 2020-12-24 13:37:40 +08:00
parent bf7b2ab019
commit 1cc17bfac2
4 changed files with 39 additions and 6 deletions

View File

@ -0,0 +1,15 @@
using Abp.Application.Services.Dto;
using System;
using System.Collections.Generic;
using System.Text;
namespace MineTec.ProManager.Commd
{
public class OutputBase
{
public int code { get; set; }
public string msg { get; set; }
public int count { get; set; }
}
}

View File

@ -0,0 +1,12 @@
using MineTec.ProManager.Commd;
using System;
using System.Collections.Generic;
using System.Text;
namespace MineTec.ProManager.UserInfo.Dto
{
public class UserInfoOutput:OutputBase
{
public List<UserInfoDto> data { get; set; }
}
}

View File

@ -12,5 +12,7 @@ namespace MineTec.ProManager.UserInfo
CreateUpdateUserInfoDto, //用于创建用户
CreateUpdateUserInfoDto> //用于更新用户信息
{
}
}

View File

@ -2,6 +2,7 @@
using Abp.Application.Services.Dto;
using Abp.Collections.Extensions;
using Abp.Domain.Repositories;
using MineTec.ProManager.Commd;
using MineTec.ProManager.UserInfo.Dto;
using System;
using System.Collections.Generic;
@ -39,16 +40,19 @@ namespace MineTec.ProManager.UserInfo
}
public async Task<PagedResultDto<UserInfoDto>> GetAllUsers(GetAllUsers input)
public async Task<UserInfoOutput> GetAllUsers(GetAllUsers input)
{
var result = new UserInfoOutput();
var query = base.CreateFilteredQuery(input).WhereIf(!string.IsNullOrEmpty(input.Account), t => t.Account.Contains(input.Account)).WhereIf(!string.IsNullOrEmpty(input.UserName), t => t.UserName.Contains(input.UserName));
var usercount = query.Count();
var userlist = query.ToList();
return new PagedResultDto<UserInfoDto>()
{
TotalCount = usercount,
Items = ObjectMapper.Map<List<UserInfoDto>>(userlist)
};
var list = ObjectMapper.Map<List<UserInfoDto>>(userlist);
result.code = 0;
result.count = usercount;
result.data = list;
return new UserInfoOutput { code = 0, msg = "", count = usercount, data = list };
}
}
}